funguse Posted July 17, 2007 Share Posted July 17, 2007 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 Quote Link to comment Share on other sites More sharing options...
dooper3 Posted July 17, 2007 Share Posted July 17, 2007 Don't use require then, use include: include file.php; Quote Link to comment Share on other sites More sharing options...
grimmier Posted July 17, 2007 Share Posted July 17, 2007 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. Quote Link to comment Share on other sites More sharing options...
Glyde Posted July 17, 2007 Share Posted July 17, 2007 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. Quote Link to comment Share on other sites More sharing options...
dooper3 Posted July 17, 2007 Share Posted July 17, 2007 I stand corrected! My amateurness is showing through! Quote Link to comment Share on other sites More sharing options...
funguse Posted July 18, 2007 Author Share Posted July 18, 2007 ok thx i'll use require_once instead of require where needed Quote Link to comment 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.