Re: ZE2 , static variables and friends

From: Date: Wed, 08 Jan 2003 01:11:03 +0000
Subject: Re: ZE2 , static variables and friends
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-93247@lists.php.net to get a copy of this message
Check your syntax!!!! I don't know how many times people have asked a question like this and they mess up the $'s class test { static $foo = ''; } class test2 { var $how = 3; } $bar = new test2; test::$foo = $bar; echo "How ? ".test::$foo->how; where you had echo "How ? ".test::$foo->$how; now what php is trying to do here, is derefrence the local variable $how which has no value and then get the property of $foo with the value of nothing if you said $how = 'how'; then did echo "How ? ".test::$foo->$how; then you would get the correct output. Get it? - Brad --- Mickael BAILLY <mickael.bailly@trader.com> wrote: > > Why can't I do this: > -- > class test { > static $foo = ''; > } > class test2 { > var $how = 3; > } > > $bar = new test2; > test::$foo = $bar; > > echo "How ? ".test::$foo->$bar; > -- > output gives me 'How ? ' > > Is it a PHP/ZE2 bug? If not, how to do that right ? > > -- > NetClub'ment votre > Mickael BAILLY > http://www.netclub.fr/ > > > -- > PHP Development Mailing List <http://www.php.net/> > To unsubscribe, visit: http://www.php.net/unsub.php > __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com

« previous php.dev (#93247) next »