This forum is now read-only. Please use our new forums at discuss.codecademy.com.

Functions, Part II Forum

View Course » View Exercise

1562 points
52605615f10c605228002abc_770166181
Submitted by
Rich Girou
over 3 years ago

Whats wrong? Passes but does not print my name.

<?php
// Write your function below!
$name = "Rich";
function displayName(){
echo $name;
}
displayName();

    ?>
  </p>
</body>

0 votes

permalink

I think because your variable $name is not global, so the function can not see it. You should rewrite like this:

$name = "Rich";
function displayName($text){
echo $text;
}
displayName($name);

Or you should declare $name as global variable/

834 points
5285a97b548c35c327002249_741279610
Submitted by
Jhon Villarreal
over 3 years ago


0 votes

permalink

reset code and just press save and submit code.

840 points
63041ca1164990c0559e4e99730e1824?s=140&d=retro
Submitted by
Fireblaze1313
over 3 years ago