Parameters and Arguments - Fucntions (Bug)


There is something wrong.
Someone can help?
There is my code:

$name= "Iris";
function greetings($name) {
echo "Greetings," . $name ."!".


Then when I try to go on the site says:

"Ops, . It looks like nothing was printed! Did you remember to call your function? (Check the Hint if you need help.)"

What should I do?


Should be,




The parameter is shadowing the global variable. The names may be the same, but they are two different variables.

echo "Greetings, " . $name ."!";

Note two changes... space after comma in string expression. Semi-colon at end of statement instead of full stop (period).


Wow thanks man! it works <3


As an aside, PHP permits string interpolation when we use double quotes.

How it must be written when single quotes are used (concatenation).

echo 'Greetings, ' . $name . '!';

How it may be written when double quotes are used (interpolation):

echo "Greetings, $name!";


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.