Re: Class Auto-Assigning to Variable
| From: | Ashley Sheridan | Date: | Wed, 07 Aug 2013 19:31:28 +0000 |
| Subject: | Re: Class Auto-Assigning to Variable | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-321808@lists.php.net to get a copy of this message | ||
On Wed, 2013-08-07 at 13:11 -0600, Brian Smither wrote:
> Second go around:
>
> I have a situation where, for some unknown reason, where each class that finishes its
> __contruct{} function, that class gets automatically assigned to a variable - other than the
> variable I specify.
>
> Conceptually (a little bit better on the conceptualizing):
>
> class Hello {
> private $_world = 'World';
> function __construct(){}
> }
>
> $clsHello = new Hello();
>
> echo 'The variable $hello is '.gettype($hello)."\n".print_r($hello,true);
>
> Output:
> The variable $hello is object
> Hello Object
> (
> [_world:Hello:private] => World
> )
>
> There is no statement in my application that assigns an instance of the class to another
> variable, the name being a lowercase variant of the class name.
>
> Would there be a PHP function that would do this as a side-effect?
>
> I am more interested in learning what is happening as opposed to rolling back to a previous
> version. (A backup copy functions fine. A file compare does not reveal any likely suspects.)
>
> PHP5.4.17-NTS-VC9 (Windows XP-SP3)
>
>
>
>
I cannot replicate this. That code you supplied correctly gives a notice
warning about an undefined variable '$hello'. Are you sure that that
simple code excerpt is giving you the problem you describe and there's
not more to the whole thing, more code, etc?
Thanks,
Ash
http://www.ashleysheridan.co.uk