This forum is now read-only. Please use our new forums! Go to forums
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
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>
Answer 52465b6b548c35fa08001ece
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);
Answer 52539ab8f10c600463001f5e
Its work.. just use your first or last name
Answer 52408904abf8218965004235
1 comments
I find a alternative solution in other similar problem, after the echo, write htmlentities.
Answer 52434026abf8212ebc000b19
Popular free courses
- Free Course
Learn SQL
In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.Beginner friendly,4 LessonsLanguage Fluency - Free Course
Learn JavaScript
Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.Beginner friendly,11 LessonsLanguage Fluency - Free Course
Learn HTML
Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.Beginner friendly,6 LessonsLanguage Fluency
1 comments
Thanks was having some issues