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

0 points
Submitted by arrayRockstar62988
almost 11 years

Error in validation in the exercise 7 of Defining Functions in PHP

The validation in the exercise 7 of Defining Functions in PHP, does not work properly.

        function aboutMe($name, $age) {
            print "Hello! My name is $name, and I am $age years old.";
        }

        aboutMe("John Doe", 25);

I tried with the comma value after $name, but nothing.

Answer 517c7a40fbe7c6c52e0018b3

3 votes

Permalink

THE ANSWER: Don’t pass the comma value after the parameter $name and don’t pass more than one name (with a single name, it works): Example (corrected):

        function aboutMe($name, $age) {
            print "Hello! My name is $name and I am $age years old";
        }

        aboutMe("John", 25);
points
Submitted by arrayRockstar62988
almost 11 years

1 comments

3DMW almost 11 years

Alright, this helped. Though I burned 10 minutes thinking there was something small I missed that’s wronging my code. Will check Q&A sooner next time.

Answer 51f7280c7c82caed11000fdb

0 votes

Permalink

Hi guys,

Here is answer: htmlentities function, search about it.

points
Submitted by André Vieira
over 10 years

Answer 5230c04e80ff334ae800673b

0 votes

Permalink

The window doesn’t include the PHP tags in it, but the emulator renders the PHP code anyway. That’s what screwed me up. Once I added the PHP tags, it worked.

points
Submitted by Michael Stabosz
over 10 years