Jump to content

[SOLVED] Require (file.php) calls function


funguse

Recommended Posts

Hello,

I've got a question regarding the require statement.

 

When i have a function in the phpfile i want to require, first function is automatically called without me telling it to. is that on purpose and if so how can i find a way around this. i have a file where most of my functions are stored and then called upon when ever i need them.

 

Thanks

 

Mark

Link to comment
Share on other sites

By using a require() statement, you are telling the server to always read that file.

 

I would recommend using a require_once() statement for functions and class files though, as this way you don't get errors about trying to redeclare your functions.

Link to comment
Share on other sites

The require versus include is not the problem.  Require and include are identical with the exception that require will throw a fatal error if the file is not found, while include shows a warning or a notice.  The more likely chance is that your function in the required file has invalid formatting.  I require files with functions all the time and have never seen one of them act up like you say yours is.

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.