note 13841 modified in function.create-function by vrana

From: Date: Tue, 17 Aug 2004 14:55:57 +0000
Subject: note 13841 modified in function.create-function by vrana
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-79873@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: <?php 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. --was-- 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://php.net/manual/en/function.create-function.php

« previous php.notes (#79873) next »