Could anyone explain in layman terms how I can use the PHP function command.
I have got a script which I want to use several times for different scenarios. For each one of these only 1 variable in the script needs to change - therefore creating a function out of the script makes sense.
I've got a little way to understanding it, but can anyone help me along, and correct me where I'm wrong.
To create a function I do this:
<?php
function my_reusable_function($my_one_changing_variable)
{
//Insert the full script here
}
?>
To run the script with my changing variable I put:
<?php
my_reusable_function(the_variable_that_will_change);
?>
If I want to save my functions in a different directory to the scripts that reference them, how do I get the script to know where the function I want to use is?????
eg If I store my functions in mysite.com/php/functions
and my script that references it is in
mysite.com/scripts/myfirstscript.php
What do I need to insert within the script to find the function?????





Bookmarks