Re: Class/function scope general question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Edward Vermillion wrote:
But my thought is that since the include was from inside the member function that the included function would be in the scope of the member function, and not global. (?)

So if I have:

class foo {

    function bar()
    {
        function baz(){}
    }
}

Would baz() be out of class scope here? Or are includes automatically global no matter where they are called? Or is it the convoluted manner in which I'm getting to baz() that's causing this?

Scope is your issue here. Functions and classes defined in included files are registered at the global level. Therefore within your include file you do not have a $this because your function is actually defined outside the class.

The example you give above I'm not so sure about. I believe baz() wouldn't have a $this variable, but stick some code in it to check.

-Stut

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux