note 116184 added to functions.user-defined
| From: | jose dot antonio dot bayona dot medina at gmail dot com | Date: | Wed, 19 Nov 2014 17:06:07 +0000 |
| Subject: | note 116184 added to functions.user-defined | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-200954@lists.php.net to get a copy of this message | ||
To response to Ben Tiessen note:
The answer is incorrect. If you execute the code:
function myFunc(){
echo "Hello World";
}
$myFunc = myFunc();
$myFunc();
You will have the next output:
Hello World
Fatal error: Function name must be a string in...
The function is executed when you declare the variable $myFunc to the function. The last line is not
executed. This is because there is the incorrect way to use functions variables.
For a correct way, you need to declare the variable $myFunc to the name string of the function:
function myFunc(){
echo "Hello World";
}
$myFunc = 'myFunc';
$myFunc();
Now you will have the correct output:
Hello World.
----
Server IP: 72.52.91.14
Probable Submitter: 190.239.252.174
----
Manual Page -- http://php.net/manual/en/functions.user-defined.php
Edit -- https://master.php.net/note/edit/116184
Del: integrated -- https://master.php.net/note/delete/116184/integrated
Del: useless -- https://master.php.net/note/delete/116184/useless
Del: bad code -- https://master.php.net/note/delete/116184/bad+code
Del: spam -- https://master.php.net/note/delete/116184/spam
Del: non-english -- https://master.php.net/note/delete/116184/non-english
Del: in docs -- https://master.php.net/note/delete/116184/in+docs
Del: other reasons-- https://master.php.net/note/delete/116184
Reject -- https://master.php.net/note/reject/116184
Search -- https://master.php.net/manage/user-notes.php