Search code examples
phpdebuggingstack-tracerequire-once

How to debug a class redefinition in PHP?


I'm getting a PHP Fatal error: Cannot redeclare class Foo in /directory/ on line 20 error, but I have no idea where it's coming from. I'm always using require_once for this class file, and I'm not sure how to debug it. Can I get some kind of inclusion stack trace somehow? I'm running PHP 5, so case sensitivity such as descriped here should not be a problem: http://www.php.net/manual/en/function.include-once.php.


Solution

  • Use debug_backtrace in file where is class declared, but before it's declaration