问题
(I'm using Joomla v1.5.15 and PHP 5.3.4)
I have tested the solutions found in this and others developer forums, but I still having the same error.
Requiring file => contratolocal.php
...
if ( !class_exists('MTIHelperEstadosLocal') )
JLoader::import('helpers.estados.estadoslocal', JPATH_COMPONENT, false);
class MTIControllerContratoLocal extends MTIController
{
...
Required file => estadoslocal.php
...
class MTIHelperEstadosLocal extends MTIHelperEstados
{
...
"JLoader::import" is used normally in Joomla to import files to the actual script. Anyway, I tried "include/require_once" php methods also without success.
I got the same error with every solution that I tried:
"Fatal error: Cannot redeclare class MTIHelperEstadosLocal"
The class is not declarated previously becouse I can't use the class without the import and if I print the returned array of the "get_declared_classes()" php method, this class isn't there.
What going on?
Thanks
回答1:
Solved.
There were 2 problems:
- In my project there are some helpers that include other files, and one of them has a require_once previously done.
The require_once doesn't avoid the second include, and I had to code every require_once in a condition:
if ( !class_exists('MTIHelperEstadosLocal') )
来源:https://stackoverflow.com/questions/8668630/fatal-error-cannot-redeclare-class-but-the-class-was-not-declared