note 78899 deleted from function.echo by tularis
| From: | tularis@php.net | Date: | Thu, 01 Nov 2007 09:13:55 +0000 |
| Subject: | note 78899 deleted from function.echo by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-131904@lists.php.net to get a copy of this message | ||
Note Submitter: nikolaas dot mennega at links dot com dot au
----
hemanman at gmail dot com, the problem is that func() doesn't actually return a value (string
or otherwise), so the result of echoing func() is null.
With the comma version, each argument is evaluated and echoed in turn: first the literal string
(simple), then func(). Evaluating a function call obviously calls the function (and in this case
executes its own internal echo), and the result (null) is then echoed accordingly. So we end up with
"outside func() within func()" as we would expect.
Thus:
<?
echo "outside func ()\n", func ();
?>
effectively becomes:
<?
echo "outside func ()\n";
//func ()
{
echo "within func ()\n";
}
echo '';
?>
The dot version is different: there's only one argument here, and it has to be fully evaluated
before it can be echoed as requested. So we start at the beginning again: a literal string, no
problem, then a concatenator, then a function call. Obviously the function call has to be evaluated
before the result can be concatenated with the literal string, and THAT has to happen BEFORE we can
complete the echo command. But evaluating func() produces its own call to echo, which promptly gets
executed.
Thus:
<?
echo "outside func ()\n" . func ();
?>
effectively becomes:
<?
//func ()
{
echo "within func ()\n";
}
echo "outside func ()\n" . '';
?>