Page 1 of 1

calling a function from another file

Posted: Fri Mar 11, 2011 9:29 pm
by stevestark5000
lets say i have 3 functions in file b. In file a i would like to call the first function from file b. can this be done. if so can i have an example please.

Re: calling a function from another file

Posted: Fri Mar 11, 2011 10:51 pm
by jim.barrett
This is done by including the file that contains the functions on the page where you want to call the functions.

Code: Select all

<?php
   include("fileB.php");
?>
...add a line like this to fileA.php and you can call any function from the other file. Of course, your include has to happen before the function can be called (closer to the top of the page).

Is this what you were looking for?

Re: calling a function from another file

Posted: Fri Mar 11, 2011 10:55 pm
by stevestark5000
yes just what i was looking for. php seems easy to learn. thank you.