You are here: Re: include problem « PHP Programming Language « IT news, forums, messages
Re: include problem

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация