聲明功能isbnFromText()
,isbn2Image()
和imagePix()
外getImg()
。
我不確切知道PHP如何處理在另一個函數中聲明的函數,但顯然它將它們放入同一個作用域,如果你運行兩次外部函數,它們會再次聲明。
實施例:
function a() {
function b() {
print 'foo';
}
b();
}
a();
a();
打印
foo
Fatal error: Cannot redeclare b() (previously declared in /t.php:4) on line 3
更新:
Learn more about functions,特別是實施例3還表示有:
All functions and classes in PHP have the global scope - they can be called outside a function even if they were defined inside and vice versa.
PHP does not support function overloading, nor is it possible to undefine or redefine previously-declared functions.
什麼是錯誤? – 2010-10-08 19:11:51
是什麼錯誤信息? – Sarfraz 2010-10-08 19:12:30
你爲什麼要嵌套功能? – halfdan 2010-10-08 19:15:16