所以,如果你嘗試做一個嵌套類是這樣的:PHP嵌套類工作...排序?
//nestedtest.php
class nestedTest{
function test(){
class E extends Exception{}
throw new E;
}
}
你會得到一個錯誤Fatal error: Class declarations may not be nested in [...]
,但如果你有一個類在一個單獨的文件,像這樣:
//nestedtest2.php
class nestedTest2{
function test(){
include('e.php');
throw new E;
}
}
//e.php
class E Extends Exception{}
那麼,爲什麼做這件事的第二種方法很有效,但這種做法並不行之有效?
+1不知道那 – soulmerge 2010-04-09 15:01:54
因此,他們有一個全球範圍,我可以打電話給所有的私人和受保護的職能,該類擁有... – SeanJA 2010-04-09 15:09:59
@ SeanJA:因爲他們有全球範圍,你將不能夠調用那些包含include() – 2010-04-09 15:53:47