开发者

Problems with circular includes in PHP 5.3

We're testing out a migration to php 5.3, and are seeing some odd issues. Trying to track down exactly what happens. Here's a simplified scenario.

File a.php

include_once(b.php);
class A {....

File b.php

include_once(a.php);
class B extends A {....

In reality, the circular references happen through a much more convoluted path, with various other includes. But, the main idea is, when it gets to the definition of class B, it throws a Fatal error, because it didn't have a definition for class A.

Thoughts? We're trying to clean up our includes to hopefully prevent these circular references, but I'm curious as to why this fails, particularly seeing that it may be ver开发者_如何学Csion-dependent.

Thanks!


Use spl_autoload instead of include.
Example of autoload-class and standards of using you can find here: http://groups.google.com/group/php-standards/web/psr-0-final-proposal?pli=1

It will clean up your code, be sure :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜