我想知道为什么当一个函数被声明在类的函数内部时,PHP处理已声明函数的作用域与普通函数不同。
例如:
function test() // global function
{
function myTest() // global function. Why?
{
print( "Hello world" );
}
}
class CMyTestClass
{
public function test() // method of CMyTestClass
{
function myTest() // This declaration will be global! Why?
{
print( "Hello world" );
}
}
}
}
有人能解释一下为什么会发生这种情况吗? 谢谢你的回答。
问候。