Re: [PHP] Object Overloading in PHP5

2004-08-29 Thread FrzzMan
Daniel Schierbeck wrote:
Stefan wrote:
It's a bug.
 * Siehe http://bugs.php.net/bug.php?id=28444 ... und ...
 *   http://news.php.net/php.bugs/63652
A workaround is possible using __call( $name, $args) { return( 
$this-__get( $name)); }. But it sucks, since constructs using array 
indices are impossible as $obj-not_existing_attr()[0]

regards
Daniel Schierbeck wrote:
Do you guys have any idea why this code:
?php
class Foo
{
private $elem = array();
public function __get ($prop)
{
if (isset($this-elem[$prop])) {
return $this-elem[$prop];
} else {
trigger_error(Property '$prop' not defined, 
E_USER_ERROR);
}
}
public function __set ($prop, $val)
{
$this-elem[$prop] = $val;
}
}

$obj = new Foo;
$obj-a = new Foo;
$obj-a-b = Foobar;
?
returns this:
Fatal error: Cannot access undefined property for object with 
overloaded property access in ... on line 24

Where line 24 is:
$obj-a-b = Foobar;
?
%!#%%(/)((%%!#%%#!%#!
Calm down, calm down... it's not good for your health :D
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Object Overloading in PHP5

2004-08-29 Thread Daniel Schierbeck
Frzzman wrote:
Daniel Schierbeck wrote:
Stefan wrote:
It's a bug.
 * Siehe http://bugs.php.net/bug.php?id=28444 ... und ...
 *   http://news.php.net/php.bugs/63652
A workaround is possible using __call( $name, $args) { return( 
$this-__get( $name)); }. But it sucks, since constructs using array 
indices are impossible as $obj-not_existing_attr()[0]

regards
Daniel Schierbeck wrote:
Do you guys have any idea why this code:
?php
class Foo
{
private $elem = array();
public function __get ($prop)
{
if (isset($this-elem[$prop])) {
return $this-elem[$prop];
} else {
trigger_error(Property '$prop' not defined, 
E_USER_ERROR);
}
}
public function __set ($prop, $val)
{
$this-elem[$prop] = $val;
}
}

$obj = new Foo;
$obj-a = new Foo;
$obj-a-b = Foobar;
?
returns this:
Fatal error: Cannot access undefined property for object with 
overloaded property access in ... on line 24

Where line 24 is:
$obj-a-b = Foobar;
?
%!#%%(/)((%%!#%%#!%#!
Calm down, calm down... it's not good for your health :D
Hehe, I'm allright now, I just needed a cold shower...
--
Daniel Schierbeck
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Object Overloading in PHP5

2004-08-28 Thread Daniel Schierbeck
Do you guys have any idea why this code:
?php
class Foo
{
private $elem = array();

public function __get ($prop)
{
if (isset($this-elem[$prop])) {
return $this-elem[$prop];
} else {
trigger_error(Property '$prop' not defined, 
E_USER_ERROR);
}
}

public function __set ($prop, $val)
{
$this-elem[$prop] = $val;
}
}
$obj= new Foo;
$obj-a  = new Foo;
$obj-a-b= Foobar;
?
returns this:
	Fatal error: Cannot access undefined property for object with 
overloaded property access in ... on line 24

Where line 24 is:
$obj-a-b= Foobar;
?
--
Daniel Schierbeck
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Object Overloading in PHP5

2004-08-28 Thread Stefan
It's a bug.
 * Siehe http://bugs.php.net/bug.php?id=28444 ... und ...
 *   http://news.php.net/php.bugs/63652
A workaround is possible using __call( $name, $args) { return( 
$this-__get( $name)); }. But it sucks, since constructs using array 
indices are impossible as $obj-not_existing_attr()[0]

regards
Daniel Schierbeck wrote:
Do you guys have any idea why this code:
?php
class Foo
{
private $elem = array();

public function __get ($prop)
{
if (isset($this-elem[$prop])) {
return $this-elem[$prop];
} else {
trigger_error(Property '$prop' not defined, 
E_USER_ERROR);
}
}

public function __set ($prop, $val)
{
$this-elem[$prop] = $val;
}
}

$obj = new Foo;
$obj-a = new Foo;
$obj-a-b = Foobar;
?
returns this:
Fatal error: Cannot access undefined property for object with 
overloaded property access in ... on line 24

Where line 24 is:
$obj-a-b = Foobar;
?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Object Overloading in PHP5

2004-08-28 Thread Daniel Schierbeck
Stefan wrote:
It's a bug.
 * Siehe http://bugs.php.net/bug.php?id=28444 ... und ...
 *   http://news.php.net/php.bugs/63652
A workaround is possible using __call( $name, $args) { return( 
$this-__get( $name)); }. But it sucks, since constructs using array 
indices are impossible as $obj-not_existing_attr()[0]

regards
Daniel Schierbeck wrote:
Do you guys have any idea why this code:
?php
class Foo
{
private $elem = array();
public function __get ($prop)
{
if (isset($this-elem[$prop])) {
return $this-elem[$prop];
} else {
trigger_error(Property '$prop' not defined, 
E_USER_ERROR);
}
}
public function __set ($prop, $val)
{
$this-elem[$prop] = $val;
}
}

$obj = new Foo;
$obj-a = new Foo;
$obj-a-b = Foobar;
?
returns this:
Fatal error: Cannot access undefined property for object with 
overloaded property access in ... on line 24

Where line 24 is:
$obj-a-b = Foobar;
?
%!#¤%¤%(/)((%¤%!#¤%%#!%#!¤
--
Daniel Schierbeck
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php