note 116184 deleted from functions.user-defined by salathe
| From: | salathe@php.net | Date: | Fri, 21 Nov 2014 14:57:08 +0000 |
| Subject: | note 116184 deleted from functions.user-defined by salathe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-200987@lists.php.net to get a copy of this message | ||
Note Submitter: jose dot antonio dot bayona dot medina at gmail dot com
----
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.