[Solved] Problem regarding Redeclaration of a function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
waqas_punjabian
Forum Commoner
Posts: 67
Joined: Wed Aug 10, 2005 9:53 am

[Solved] Problem regarding Redeclaration of a function

Post by waqas_punjabian »

Hi ,

how's everybody, hope f9 .... But i m not well, cause of this <span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span> problem....

Kindly solve it :

i got an error in "lib.php" basically in this file i've defined common functionality of my

website in functions now i 've include it in header of my website because header is include

at each page now i got the following error ...

Fatal error: Cannot redeclare convertforstorage() (previously declared in

/home/content/s/u/m/sumitdua/html/test/includes/lib.php:2) in

/home/content/s/u/m/sumitdua/html/test/includes/lib.php on line 2


i m fed up because in "lib.php" the method "convertforstorage()" is declared just for one

time. And one thing more i 've tried to comment out this function in "lib.php" after that i

've found error on next defined method.i.e) "convertfordisplay()" and if i comment it too,

then found on next method and so on..........

Is there any technical reason for that ... kindly help me i m really worried about this

problem.

Thanks in Advance

regards
Waqas
Last edited by waqas_punjabian on Fri Aug 12, 2005 2:11 am, edited 1 time in total.
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

the only reason is if you are creating the function twice. im sure if you look hard enough you will find it
User avatar
nielsene
DevNet Resident
Posts: 1834
Joined: Fri Aug 16, 2002 8:57 am
Location: Watertown, MA

Post by nielsene »

How are you including your files? are you using include/require or include_once/require_once? Is it possible that you're including the file twice?
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Re: Problem regarding Redeclaration of a function

Post by neophyte »

waqas@balianti.com wrote:Hi ,

i got an error in "lib.php" basically in this file i've defined common functionality of my

website in functions now i 've include it in header of my website because header is include
Are using include_once() or require_once() as opposed to include(); requrie();. That might solve your problem as well.
waqas_punjabian
Forum Commoner
Posts: 67
Joined: Wed Aug 10, 2005 9:53 am

Thanks U all of gr88888 buddiesssss

Post by waqas_punjabian »

Hurraaahhhhhhhh !!!!


Error have been solved, Yeah, i 've used "require_once()" instead of "include()" ....... and this <span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span> 've been solved....


Once again thanxxxx a lot

Ba Bye :lol:
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

watch your language waqas@balianti.com...
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

From a maintenance stand point if you design your code well, you should not need to use include_once/require_once. If you have the same function in multiple places maintaining them can become a nightmare as changes to one should be updated in all the others.
Post Reply