Posted by Rik on 02/07/07 14:31
Gunnar G <debian@comhem.se> wrote:
> Now I've tried working with classes, but I still get an error of
> redeclaration.
>
> Fatal error: Cannot redeclare bar() (previously declared
> in /var/www/localhost/htdocs/bar.php:3)
> in /var/www/localhost/htdocs/bar.php on line 3
>
> Is there any way to fix this without changing bar.php or main.php ?
Simplest way would be changing bar.php to
if(!function_exists('bar')){
function bar()
{return 4;}
}
But as this seems not to be an option:
> Hereis the code
> ---------------- main.php --------------
> <?php
> ?>
> ------------ foo2.php --------------
> <?php
> class foo2
> {
> static function foo2X()
> { include 'bar.php';
> return bar()+1;}
{
if(!function_exists('bar')) include 'bar.php';
return bar() +1;
}
> }
> ?>
> -------------- foo.php ----------
> <?php
> class foo
> {
> static function fooX()
> {include 'bar.php';
> return bar()+1;}
{
if(!function_exists('bar')) include 'bar.php';
return bar() +1;
}
--
Rik Wasmus
Navigation:
[Reply to this message]
|