__autoload and Zend

Environment: PHP 5.3.6, Zend Framework 1.11.6

This problem occurred when I needed to build a mixed environment where the existing code was "pure PHP" and new code was based on Zend Framework.

The "pure PHP" code's __autoload function stopped working as soon as Zend application ran.

Apparently, when there is a call to spl_autoload_register, __autoload is ignored.

The solution was to rename __autoload to OldAutoLoad and call:

Note: after that, the OldAutoload was called first and then Zend's autoload. In order to let OldAutoload ignore Zend classes, I replaced require_once calls with @include_once.

1 comment:

  1. I had exactly the same problem today with symfony 1.0. At first I taught that it was just a change in PHP 5.3.6 which broke __autoload, but couldn't find such information neither in the changelog or other places.

    So this is how I got here. Cheers for lightening the situation for me.