This forum is now read-only. Please use our new forums! Go to forums
Finding it difficult on this one.
Why is the following code returning : `Parse error: syntax error, unexpected ‘;’, expecting ‘{‘ on line 9?``
The code is:
<html>
<head>
<title></title>
</head>
<body>
<p>
<?php
// Write your function below!
function displayName();
{
echo "Zane is the one."
}
?>
</p>
</body>
</html>
Please lets hear from you. Thanks.
Alex J edited this post to fix code formatting
Answer 51d54e10631fe98c43006855
read the error message:
unexpected ';', expecting '{' on line 9
Go to line 9. Look at it. Think about it. Then you should be able to figure out what to do.
(Hint: if I were you, the first thing I’d try is removing the thing that the error says is unexpected).
Answer 51d5cfb19c4e9d8df600f42d
My apologies, Alex. I was hasty in writing my response this morning. The above code only printed to the editor but did not pass when clicked. Now, after some siesta, the following code worked.
<html>
<head>
<title></title>
</head>
<body>
<p>
<?php
// Write your function below!
function displayName(){
echo "zane is the one";
}
?>
</p>
</body>
</html>
Many thanks.
Answer 51d5831952f863d922009bff
Thanks Alex. Note, however, that I’ve carried out the instructions as many times as possible without success. Now, check out what works below:
<html>
<head>
<title></title>
</head>
<body>
<p>
<?php
// Write your function below!
function displayName()
{}echo "Zane is the one."
?>
</p>
</body>
</html>
From my understanding of codes, the above is not a standard code, yet it works. Maybe the editor at fault.
Alex J edited this post to fix code formatting
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