autoloading methods
| From: | Atif Ghaffar | Date: | Mon, 29 May 2000 23:30:33 +0000 |
| Subject: | autoloading methods | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-15923@lists.php.net to get a copy of this message | ||
Just a little php question.
I know its not the place to ask but I will be thankful if you can help
me.
How does method autoloading works in php.
for example if I call
$lang->hello;
if the method hello does not exists then some other function can take
this argument and return a value according to that. For example make a
lookup in the data base etc.
Thanks
in perl I would do something like this.
package Dictionary;
sub new {my $self=shift; return bless {}, $self;};
sub AUTOLOAD{
my $self=shift;
my $name=$AUTOLOAD;
$name=~s/.*://;
return "You tried to access $name";
}
package main;
my $obj=Dictionary->new();
print $obj->test;
#this will print
You tried to access test
--
Atif Ghaffar
I*Net/Unix Consultant
--------------------------------------
Internet : http://aghaffar.developer.ch
WAP : http://www.wapdrive.net/aghaffar
Email : atif@developer.ch