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

0 points
Submitted by jmgillett
over 10 years

Function Error

Can anybody help me with this? I’ve been staring at this for a while and don’t see an error:

Answer 5237962780ff334d0d0005fd

3 votes

Permalink

Hi.

You don’t need to define name before the function. You can just put it as an argument to your function. Like this.

<?php
    function greetings($name) {
        echo "Greetings, " . $name . "!";
    }
        greetings("JMG");
?>
points
Submitted by Fabián
over 10 years

Answer 5306881752f8636523000e2b

1 vote

Permalink

This worked for me:

$name = "Tim";
$age = "29";
    
aboutMe($name, $age);
points
Submitted by Tim
about 10 years

Answer 52316d0880ff33bfc4005e6e

-2 votes

Permalink

points
Submitted by potheadpewe
over 10 years

2 comments

jmgillett over 10 years

Thanks! Not sure why $name has to go in the parentheses, but that must be it.

potheadpewe over 10 years

its because $name is the variable that is being used in the function, or that at least that is what I can tell.