darkfreaks Posted December 29, 2008 Share Posted December 29, 2008 okay so i notice if i include a file that has a function on it then i include it again in another file. it throws a "cannot redeclare function" error, how do i avoid this ??? Quote Link to comment https://forums.phpfreaks.com/topic/138755-solved-function-include-help/ Share on other sites More sharing options...
Mark Baker Posted December 29, 2008 Share Posted December 29, 2008 okay so i notice if i include a file that has a function on it then i include it again in another file. it throws a "cannot redeclare function" error, how do i avoid this By using include_once Quote Link to comment https://forums.phpfreaks.com/topic/138755-solved-function-include-help/#findComment-725465 Share on other sites More sharing options...
trochia Posted December 29, 2008 Share Posted December 29, 2008 The code you furnished us, to look at...really helped !! So?? http://us3.php.net/results.php?q=cannot+redeclare+function&l=en&p=all Here's your answer !! :-) Quote Link to comment https://forums.phpfreaks.com/topic/138755-solved-function-include-help/#findComment-725466 Share on other sites More sharing options...
darkfreaks Posted December 29, 2008 Author Share Posted December 29, 2008 i will try include_once dunno if it will work but the include is being called before any looping occurs. Quote Link to comment https://forums.phpfreaks.com/topic/138755-solved-function-include-help/#findComment-725473 Share on other sites More sharing options...
CroNiX Posted December 29, 2008 Share Posted December 29, 2008 if(!function_exists(my_function)){ function my_function(){ .... } } Quote Link to comment https://forums.phpfreaks.com/topic/138755-solved-function-include-help/#findComment-725475 Share on other sites More sharing options...
darkfreaks Posted December 29, 2008 Author Share Posted December 29, 2008 include_once worked thanks Quote Link to comment https://forums.phpfreaks.com/topic/138755-solved-function-include-help/#findComment-725476 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.