note 76176 added to language.types.string
| From: | php at craigbuchek dot com | Date: | Tue, 03 Jul 2007 21:32:32 +0000 |
| Subject: | note 76176 added to language.types.string | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-128206@lists.php.net to get a copy of this message | ||
Function calls within double-quote variable interpolation work in PHP 5, but not quite as you'd
expect. Basically the function has to be a variable function. I.e. a variable that holds the name of
a function. So if you've got a function named 'x' that you want to call, you'll
have to assign the function name to a variable. It's easiest to just assign it to a variable
with the same name:
function x () { return 4; }
$x = 'x';
echo "x = {$x()}";
I'm not sure what the point of that is though, since it would be easier to do it this way:
function x () { return 4; }
$x = x();
echo "x = $x";
----
Server IP: 64.71.164.2
Probable Submitter: 24.207.253.154
----
Manual Page -- http://www.php.net/manual/en/language.types.string.php
Edit -- https://master.php.net/note/edit/76176
Del: integrated -- https://master.php.net/note/delete/76176/integrated
Del: useless -- https://master.php.net/note/delete/76176/useless
Del: bad code -- https://master.php.net/note/delete/76176/bad+code
Del: spam -- https://master.php.net/note/delete/76176/spam
Del: non-english -- https://master.php.net/note/delete/76176/non-english
Del: in docs -- https://master.php.net/note/delete/76176/in+docs
Del: other reasons-- https://master.php.net/note/delete/76176
Reject -- https://master.php.net/note/reject/76176
Search -- https://master.php.net/manage/user-notes.php