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
https://forums.phpfreaks.com/topic/60371-solved-require-filephp-calls-function/
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.

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.

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.