On Wed, 2013-08-07 at 21:02 +0100, Stuart Dallas wrote:

> On 7 Aug 2013, at 20:45, "Brian Smither" <bhsmit...@gmail.com> wrote:
> 
> >> I cannot replicate this.
> > 
> > I don't expect anyone to be able to replicate this behavior. The example 
> > shows an extraordinarily stripped-down sequence of statements that informs 
> > what should work, but do to some unknown agent, which, therefore, cannot be 
> > included in the example, produces unexpected output.
> > 
> > This conceptual example is not a 'sample' or 'excerpt' of the actual 
> > application. There is much, much more code. None of it is an apparent 
> > likely suspect in causing this behavior.
> > 
> > I am hoping for a, "Oh, yeah! I've seen that happen before. It's caused 
> > by..."
> > 
> > Let us focus on the central question:
> > 
> > Would there be a PHP function that would do [what the example describes] as 
> > a side-effect?
> 
> Yes:
> 
> $hello = $clsHello;
> 
> There are only a few variables that get assigned as side effects of 
> functions, but they have very specific names, and none of them are $hello 
> (but I'm guessing that's not the actual variable name) and none of them will 
> assign a userland object. Somewhere in your code there is something that is 
> assigning to $hello. Find everything that's doing that and look at each 
> instance in detail.
> 
> -Stuart
> 
> -- 
> Stuart Dallas
> 3ft9 Ltd
> http://3ft9.com/
> 


As you've said that your excerpt doesn't replicate the problem, it's not
that useful really to accurately illustrate it. I would say for definite
that it's some of the surrounding code, probably something similar to
this:

class Hello
{
        private $_world = 'World';
        function __construct(){}
        
        function test()
        {
                $GLOBALS[strtolower(get_class($this))] = $this;
        }
}

$clsHello = new Hello();
$clsHello->test();

echo 'The variable $hello is
'.gettype($hello)."\n".print_r($hello,true);


There are probably many ways to achieve this, I can't think of a sane
reason for any of them though!

Thanks,
Ash
http://www.ashleysheridan.co.uk


Reply via email to