note 13841 added to function.create-function.php
| From: | x-empt at php2 dot chek dot com | Date: | Thu, 05 Jul 2001 15:41:22 +0000 |
| Subject: | note 13841 added to function.create-function.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-15013@lists.php.net to get a copy of this message | ||
Create_function enables the ability to change the scope of functions. You might have a class where
it needs to define a GLOBAL function. This is possible, like:
class blah {
function blah() {
$z=create_function('$arg1string','return
"function-z-".$arg1string;');
$GLOBALS['z']=$z;
}
}
$blah_object=new blah;
$result=$GLOBALS['z']('Argument 1 String');
echo $result;
Making a function escape it's defined scope can be useful in many situations.
http://www.php.net/manual/en/function.create-function.php