したがって、次のようなネストされたクラスを実行しようとすると、次のようになります。
//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{}
では、なぜ2番目のハッキーな方法は機能するのに、ハッキーではない方法は機能しないのでしょうか。