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

0 points
Submitted by gavin barker
about 10 years

Why doesn't this work - code seems to be correct

Answer 5328e87c7c82ca0e2f0002bf

5 votes

Permalink

 <?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

points
Submitted by ralphwongyu
about 10 years

Answer 5415d872631fe96fa7001a8f

1 vote

Permalink

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>
points
over 9 years

3 comments

sunoy14 about 9 years

That looks good :)

sunoy14 about 9 years

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 :)

sunoy14 about 9 years

Or maybe not :D

Answer 543d01b77c82ca0022001bf7

1 vote

Permalink

try that one:

points
Submitted by 123123
over 9 years

Answer 532a08e77c82ca0782003c51

0 votes

Permalink

Ah! ok thanks

points
Submitted by gavin barker
about 10 years

Answer 54f5387f937676cfb50008d4

0 votes

Permalink

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);

points
Submitted by sunoy14
about 9 years