prudens Posted June 6, 2008 Share Posted June 6, 2008 Hi, I basically want to put all my functions in functions.php; How do I call the function setUpSQL() from functions.php??? Quote Link to comment https://forums.phpfreaks.com/topic/108942-solved-calling-functions-from-another-file/ Share on other sites More sharing options...
haku Posted June 6, 2008 Share Posted June 6, 2008 <?php include("functions.php"); setUpSQL(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/108942-solved-calling-functions-from-another-file/#findComment-558925 Share on other sites More sharing options...
GingerRobot Posted June 6, 2008 Share Posted June 6, 2008 When you include functions.php you are effectively taking everything in functions.php and putting it into the file that included it. From a results point of view, it would be no different to copying and pasting functions.php into the other file. Of course, using an include is much easier. So, calling a function from functions.php is just like calling any other function. This obviously works both ways too. If you defined a variable or function in the page doing the including, then it would be avaliable to the included code. Quote Link to comment https://forums.phpfreaks.com/topic/108942-solved-calling-functions-from-another-file/#findComment-558968 Share on other sites More sharing options...
runnerjp Posted June 6, 2008 Share Posted June 6, 2008 think of it like stroing your db name password in a file then includeing it via ..include 'mydb.php; all works in the same way Quote Link to comment https://forums.phpfreaks.com/topic/108942-solved-calling-functions-from-another-file/#findComment-558972 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.