无法从类'有时'读取变量

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 set {$this->_foo} with $bar");
          var_dump($this);
        }
        var_dump($this);
        return $this;
      }
    }

    $foobar = new FooBar;
    $foobar->setFoo('bar');

The output when this happens would be:

Cannot set with barobject(FooBar)#1 (1) { ["_foo":protected]=> string(3) "bar" } object(FooBar)#1 (1) { ["_foo":protected]=> string(3) "bar" }

:|

ideas?