This forum is now read-only. Please use our new forums! Go to forums
Why doesn't this work - code seems to be correct
Answer 5328e87c7c82ca0e2f0002bf
5 votes
<?php
$name = "Gavin";
$age = 57;
function aboutMe($name, $age){
echo "Hello! My name is " . $name . " and I am " . $age . "years old.";
}
return aboutMe($name,$age);
?>
change the second “function” to “return” to call aboutMe
Answer 5415d872631fe96fa7001a8f
1 vote
this is my code and it worked perfectly ::
<html>
<head>
<title></title>
</head>
<body>
<p>
<?php
function aboutMe($name, $age){
echo "Hello! My name is $name, and I am $age years old.";
}
aboutMe("ziana",26);
?>
</p>
</body>
</html>
Answer 532a08e77c82ca0782003c51
Answer 54f5387f937676cfb50008d4
0 votes
Just remove the “function” when you call the function.
function aboutMe($name, $age) { echo “Hello! my name is” . $name . “, and I am” . $age . “years old.”; }
$name = “Gavin”; $age = “57”;
function (remove function. It’s hard to explain codes in writing :D)aboutMe($name,$age);
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
3 comments
That looks good :)
But I think you have to put the parameters in the exact same location. Like you have to put “ziana” exactly in the first, 26 exactly in the second, etc. If the number of paraeters get too many, you’d get into serious problems :D I was impressed at first. But I don’t think this is going to be an efficient way. Just my thoughts :)
Or maybe not :D