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 Link to comment https://forums.phpfreaks.com/topic/60371-solved-require-filephp-calls-function/ 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; Link to comment https://forums.phpfreaks.com/topic/60371-solved-require-filephp-calls-function/#findComment-300343 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. Link to comment https://forums.phpfreaks.com/topic/60371-solved-require-filephp-calls-function/#findComment-300346 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. Link to comment https://forums.phpfreaks.com/topic/60371-solved-require-filephp-calls-function/#findComment-300348 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! Link to comment https://forums.phpfreaks.com/topic/60371-solved-require-filephp-calls-function/#findComment-300349 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 Link to comment https://forums.phpfreaks.com/topic/60371-solved-require-filephp-calls-function/#findComment-301100 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.