This forum is now read-only. Please use our new forums! Go to forums

0 points
Submitted by Tim R
almost 11 years

Error: Oops try again. What's up?

Can anyone help me spot what’s wrong with my function for exercise 3, “Your First Function”?

I’m getting the error:

“Oops, try again! Did you remember to use echo or print, followed by your name?”

   function displayName() {
        echo("Tim");
    }

Complete code for my page:

<html>
    <head>
        <title></title>
    </head>
    <body>
      <p>
        <?php
        // Write your function below!
        function displayName() {
            echo("Tim");
        }
        ?>
      </p>
    </body>
</html>

Answer 517991844be8a3c1c9000c22

3 votes

Permalink

Got it.

Removing the parentheses around the name string allowed it to pass:

Instead of:

  function displayName() {
        echo("Tim");
    }

… I did:

function displayName() {
        echo "Tim";
    }
points
Submitted by Tim R
almost 11 years

2 comments

Sarah B almost 11 years

Yeah, i don’t understand why would you put parenthesis when in the past lesson, and even the Hint state clear that do not use them.

Sarah B almost 11 years

But, the doubt I have is: when you have write this code and submit it, It appears to name on the fake screen? or not?

Answer 51796a0a1e6652726f0002e9

0 votes

Permalink

I should add that when I call the function in the subsequent exercise, “Calling Your Function”, it works fine.

points
Submitted by Tim R
almost 11 years