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

0 points
Submitted by Juan Diego
over 10 years

Problem with the exercise

Hi:

I was doing the exercise, here is my code:

<?php
    function aboutMe($name, $age) {
        echo "Hello! My name is " . $name . " and I am " . $age . " years old.";
    } 
    
    aboutMe("Juan Diego", 18);
?>

But when I try to run the code I get the following error message:

Oops, try again! It looks like your code printed ‘Hello! My name is Juan Diego and I am 18 years old.’ instead of ‘Hello! My name is [your name here] and I am [your age here] years old.’

I don’t see any error, I wrote the echo exactlly as in the Hint. Might be a bug in the exercise?

Thanks for the help.

Answer 52447d0e548c35c6e300550d

5 votes

Permalink

SOLUTION! I was struggling with this for a while but then I found a solution. Instead of calling the function with a string and an int, I defined two variables $name and $age and it worked. See code:

<html>
<head>
    <title></title>
</head>
<body>
  <p>
    <?php
    $name = "Ingrid";
    $age = 17;
    function aboutMe($name, $age){
        echo "Hello! My name is " . $name . " and I am " . $age . " years old.";
        }
    aboutMe($name, $age);
    ?>
  </p>
</body>
points
Submitted by Ingrid Stevens
over 10 years

1 comments

Adrian Demo over 10 years

Thanks was having some issues

Answer 52465b6b548c35fa08001ece

4 votes

Permalink

Hello fellas!!

I encountered the same problem there and I thought it was the spaces in the string but when I copied the exact string from the hint it still didn’t work.

I figured out that it was the value of my name which is “Rein Sano”, there’s a space between it and it wasn’t allowed by the compiler.

**Solution : ** Just use a single word as your name, e.g. “Juan” only

In my case I only use ‘Rein’

function aboutMe($name, $age)
    {
        echo "Hello! My name is " . $name . " and I am " . $age . " years old.";
    }
    
    aboutMe("Rein", 19);
    
points
Submitted by Rein Sano
over 10 years

2 comments

张鑫 over 10 years

omg…you’re right thanks:)

Rein Sano over 10 years

=)

Answer 52539ab8f10c600463001f5e

1 vote

Permalink

Its work.. just use your first or last name

points
Submitted by Muhajir Knight
over 10 years

Answer 52408904abf8218965004235

0 votes

Permalink

Same problem here.

points
Submitted by Renan Bartalo
over 10 years

1 comments

Renan Bartalo over 10 years

I find a alternative solution in other similar problem, after the echo, write htmlentities.

Answer 52434026abf8212ebc000b19

0 votes

Permalink

Same thing :(

points
Submitted by annemarieny
over 10 years