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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.