I am trying to work out how to write php functions, so that I don\'t have to keep writing a block of code over and over again, I am having a play around and tried writing th
I see, you that you want to function which will return something string.
You can pass variable as an argument.
Things after return statement will be what you get by calling frank()
$greeting = 'Hello';
function frank ( $greeting) {
$name = 'frank';
$second = 'robson';
return $greeting." ".$name." ".$second;
}
echo frank ( $greeting );
Or if you want to use global variable in the function you must declared this by a global statement
$greeting = 'Hello';
function frank ( $greeting) {
global $greeting;
$name = 'frank';
$second = 'robson';
return $greeting." ".$name." ".$second; //
}
echo frank ( $greeting );