Re: Randomly unable to read set variable from class

From: Date: Tue, 13 Mar 2012 23:42:12 +0000
Subject: Re: Randomly unable to read set variable from class
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-317011@lists.php.net to get a copy of this message
Sorry wasn't able to reproduce it on my test machine. Do you have any external modules loaded such as APC, memcached, xDebug maybe or other that can affect the output on that machine? Greetings On 13 Mar 2012, at 17:02, Adrian Basalic wrote: > I have an issue that occurs randomly on a machine. After a number of reloads > of the page i can't read $this->_foo although it is set (var_dump shows it > but the script cannot read it). The code works locally and on other machines > i tested. Apache restart seems to fix it but only temporary. > > Environment: > > . PHP Version 5.3.3 > > . Linux 2.6.32-220.2.1.el6.x86_64 #1 SMP Fri Dec 23 02:21:33 CST > 2011 x86_64 > > . Apache 2.0 > > > > class FooBar > > { > > protected $_foo; > > public function setFoo($bar) > > { > > if (!$bar) { > > print_r("Cannot find bar"); > > } > > $this->_foo = $bar; > > if (!$this->_foo) { > > print_r("Cannot read {$this->_foo} set with $bar"); > > var_dump($this); > > } > > var_dump($this); > > return $this; > > } > > } > > > > $foobar = new FooBar; > > $foobar->setFoo('bar'); > > > > The output when this happens would be: > > > > Cannot read set with barobject(FooBar)#1 (1) { ["_foo":protected]=> > string(3) "bar" } object(FooBar)#1 (1) { ["_foo":protected]=> string(3) > "bar" } > > > > I'm going nuts here, and nobody seems to be able to reproduce this. Where > should I start looking? > _______________________ Mi blog CHW Mi Twitter

« previous php.general (#317011) next »