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
Instead of echoing inside your function you should consider returning a string with it. Also prefer passing a parameter instead of using global scope :
$greeting = 'Hello';
function frank ($funcGreetings)
{
$name = 'frank';
$second = 'robson';
//Concat variable together an return them
return $funcGreetings.' '.$name.' '.$second;
}
echo frank($greeting);
Finally a variable name start with a letter or an underscore so $2nd
is not a valid name.
See this this link for more info on naming variable