add a note add a note

User Contributed Notes 2 notes

up
-26
josh at PraxisStudios dot com
19 years ago
As with echo, you can define a variable like this:

<?php

$text
= <<<END

<table>
    <tr>
        <td>
            
$outputdata
        </td>
     </tr>
</table>

END;

?>

The closing END; must be on a line by itself (no whitespace).

[EDIT by danbrown AT php DOT net: This note illustrates HEREDOC syntax.  For more information on this and similar features, please read the "Strings" section of the manual here: http://www.php.net/manual/en/language.types.string.php ]
up
-31
Mike at ImmortalSoFar dot com
18 years ago
References and "return" can be flakey:

<?php
//  This only returns a copy, despite the dereferencing in the function definition
function &GetLogin ()
{
    return
$_SESSION['Login'];
}

//  This gives a syntax error
function &GetLogin ()
{
    return &
$_SESSION['Login'];
}

//  This works
function &GetLogin ()
{
   
$ret = &$_SESSION['Login'];
    return
$ret;
}
?>
To Top