Re: [PHP] strange stuff in a class
class test { function test() { $globals['test2'] = $this; } } $test1 = new test(); The problem hier is that $globals['test2'] is a copy of $globals['test1'] not a references. Use $GLOBALS rather than $globals I think he's building his own pool of objects for object-management in $globals, rather than trying to set the value of $test2... And mucking directly with $GLOBALS is morally wrong :-) global $test2; $test2 = $this; if that's what you wanted to do, which I don't think it is. Of course, you *will* need: global $globals; if you expect this code to do anything useful. -- Like Music? http://l-i-e.com/artists.htm Off-Topic: What is the moral equivalent of 'cat' in Windows? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strange stuff in a class
ðÒÉ×ÅÔ! ?php class test { function test() { $globals['test2'] = $this; } } $test1 = new test(); ? The problem hier is that $globals['test2'] is a copy of $globals['test1'] not a references. It is, but you are looking in the wrong direction. the copy is in test1, test2 holds the reference. This should work: ?php class test { function test() { $globals['test2'] = $this; } } $test1 = new test(); ? To output a reference instead of a copy a function *must* be declared with an . Not sure whether you might also need it here: $test1 = new test(); check it out ÐÏËÁ áÌØÂÅÒÔÏ ëÉÅ× -_=}{=_-@-_=}{=_--_=}{=_-@-_=}{=_--_=}{=_-@-_=}{=_--_=}{=_- LoRd, CaN yOu HeAr Me, LiKe I'm HeArInG yOu? lOrD i'M sHiNiNg... YoU kNoW I AlMoSt LoSt My MiNd, BuT nOw I'm HoMe AnD fReE tHe TeSt, YeS iT iS ThE tEsT, yEs It Is tHe TeSt, YeS iT iS ThE tEsT, yEs It Is... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strange stuff in a class
On Wed, Jul 10, 2002 at 09:50:27AM -, Alex Elderson wrote: class test { function test() { $globals['test2'] = $this; } } $test1 = new test(); The problem hier is that $globals['test2'] is a copy of $globals['test1'] not a references. Use $GLOBALS rather than $globals --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php