objnoob Posted November 14, 2010 Share Posted November 14, 2010 I'm receiving a cannot redeclare function error. I have a functions.php pack that I only require_once once. require_once 'functions.php'; require_once 'classes.php'; A little further into the code I conditionally require another php file. require_once 'dataentry.php'; It appears that when the require_once 'dataentry.php' line is hit, I receive this redeclare error. I do not call any include or require in dataentry.php. The first function in my function pack throws this error, and when I comment it out, the next function throws the error. Im appalled as to the reasoning for this error. Any Thoughts? Quote Link to comment https://forums.phpfreaks.com/topic/218652-cannot-redeclare-previously-declared-function/ Share on other sites More sharing options...
PFMaBiSmAd Posted November 14, 2010 Share Posted November 14, 2010 Either your code is including/requiring the function definitions more than once OR you have the function definitions inside of a loop. You might also have multiple files with the same function definitions in different folders. Php has also had a lot of problems getting the _once versions of the require/include to actually detect that when it is including the same file. I recommend posting the error message and enough of the relevant complete code that produces the problem so that someone can help. Quote Link to comment https://forums.phpfreaks.com/topic/218652-cannot-redeclare-previously-declared-function/#findComment-1134099 Share on other sites More sharing options...
objnoob Posted November 14, 2010 Author Share Posted November 14, 2010 Well error solved! Dealing with so many files, instead of individualy selecting all of them for export, I just selected the directory in my IDE. Well a new directory was created on the server, so I was accessing old files and not the new exports in the new directory. A quick modification to the export location will allow me to upload the directory without actually mkdir. The script that calls dataentry.php as well as the old dataentry.php required_once 'functions.php' thus error alley. Derrr... Thanks for making me look into dir-tree on the server. Quote Link to comment https://forums.phpfreaks.com/topic/218652-cannot-redeclare-previously-declared-function/#findComment-1134116 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.