我试图想象 javascript 和 php 如何处理嵌套函数。
重点是:
php :
b(); //CANNOT call b at this point because isn't defined yet
a(); //CAN call a at this point because the interpreter see the declar
b(); //ok now i can call b, because the interpreter see the declaration after a execution
function a(){
function b(){
echo "inner";
}
}
同时在javascript 中:
b(); //CANNOT call b isn't defined yet
a(); //CAN call a at this point because the interpreter see the declar
function a(){
function b(){
console.log("inner");
}
}
a(); //ok now i can call a because is defined
b(); // **CANNOT** call b yet !!
为什么在 javascript 中即使 a 被执行我也不能调用 b() ?PHP 在哪些方面表现不同?
相关分类