There is nothing of me. I just cut and pasted the example from manual.
Anyway Iam including here.
Thanks for Reply,
<?php
class OO
{
var $a = 111;
var $elem = array('b' => 9, 'c' => 42);
function __get($prop_name, &$prop_value)
{
if (isset($this->elem[$prop_name])) {
$prop_value = $this->elem[$prop_name];
return true;
} else {
return false;
}
}
// Callback method for setting a property
function __set($prop_name, $prop_value)
{
$this->elem[$prop_name] = $prop_value;
return true;
}
}
overload('OO');
$o = new OO;
print "\$o->a: $o->a\n"; // print: $o->a:
print "\$o->b: $o->b\n"; // print: $o->b: 9
print "\$o->c: $o->c\n"; // print: $o->c: 42
print "\$o->d: $o->d\n"; // print: $o->d:
// add a new item to the $elem array in OO
$o->x = 56;
$val = new stdclass;
$val->prop = 555;
$o->a = array($val);
var_dump($o->a[0]->prop);
?>
On Wed, 6 Mar 2002, Martin Towell wrote:
> can you provide a code snippet so we can see what you're doing?
>
> -----Original Message-----
> From: S.Murali Krishna [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, March 06, 2002 4:38 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] OOP .. overload not working
>
>
>
> Hi PHPzers
>
> Is php have to compile with anything to get 'overload' function to work,
> bcoz its not working on mine, by saying 'undefined function'. In manual
> ,there is no restriction in using this.
>
>
> <[EMAIL PROTECTED]>
> -------------------------------------------------------------------
> We must use time wisely and forever realize that the time is
> always ripe to do right."
>
> -- Nelson Mandela
> -------------------------------------------------------------------
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
<[EMAIL PROTECTED]>
-------------------------------------------------------------------
We must use time wisely and forever realize that the time is
always ripe to do right."
-- Nelson Mandela
-------------------------------------------------------------------
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php