Jump to content

Cannot Redeclare Previously Declared Function


objnoob

Recommended Posts

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?

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.

Well error solved!  :facewall:

 

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.