On Wed, 2013-08-07 at 19:02 -0600, Brian Smither wrote:

> >Your example does _not_ show this, it works
> >as expected and throws a notice, from which can be inferred there is other
> >code doing this
> Or relevant code having a side-effect not currently realized.

No, you just didn't post relevant code.

> >Is your class maybe inheriting from another one and that contains the code
> >causing this issue?
> No.
> >>May I infer that the declaration of $GLOBALS['hello'] will, at the same
> >>time, also create $hello (without a statement declaring such)?
> >
> >The $GLOBALS array is what's known as a super global. Elements within the
> >array are reflected as global variables and vice-versa.
> Let's refine the conceptual example:
> class Hello {
> private $_world = 'World';
> function __construct(){}
> }
> $GLOBALS['hello'] = new Hello();
> echo 'The variable $hello is '.gettype($hello)."\n".print_r($hello,true);
> Can we then postulate that the value of $GLOBALS['hello'] will also be 
> revealed in $hello, even though $hello was never formally declared?
> I know that $GLOBALS['hello'] has a universal scope, and $hello (wherever it 
> comes from) needs to be global-ized inside functions.

$GLOBALS['hello'] is essentially a synonym for $hello in this context.
$GLOBALS is just an array of all variables that have global scope, so
adding to this causes variables to be added at the global scope level.
But, like I've said a few times, this might not be your specific
problem, and without seeing the actual code that causes this problem,
it's very difficult for anyone to help. Your code examples don't exhibit
the issue you describe, so they're not useful in the context of
pin-pointing the problem. If you can post code that *does* give that
problem, then someone on the list may be able to help.


Reply via email to