2

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 version-dependent.

Thanks!

Neil
  • 135
  • 1
  • 11

1 Answers1

2

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 :)

OZ_
  • 12,492
  • 7
  • 50
  • 68
  • Interesting, I'll have to look at this, I wasn't aware of this autoload functionality! I see some comments about difficulties when working with APC, something we'll have to test. – Neil May 27 '11 at 20:04