__autocreate() function for non-existing variables
| From: | Vesselin Atanasov | Date: | Wed, 20 Aug 2003 03:10:13 +0000 |
| Subject: | __autocreate() function for non-existing variables | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-4100@lists.php.net to get a copy of this message | ||
Hello.
I think that it would be useful to allow an __autocreate() function create
non-existing
variables just like __autoload is called for non-existing classes. The
function will be
called when an attempt is made to read a non-existent variable. It will
return a reference
to the new variable it creates. This could be very useful in some cases. For
example it
could be used in a php library that creates a database object. When some
function tries to
use the database object, the __autocreate function will check if a global
database object
exists. If it does not exist the function will create the database object as
global and
in either case return a reference to the object.
I am willing to implement this functionality, but I'd like to hear the
opinion of the PHP
developers first and especially of the Zend2 team because this functionality
will modify
the Zend2 engine.
vesselin