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

banner
Close banner
0 points
Submitted by Kiana Ward
over 9 years

Code won't work but looks ok

Here is my code;

<html>
<head>
    <title></title>
</head>
<body>
<?php 
function displayName() {
    echo "James";
}
displayName();
?>
</body>
</html>

what i don’t understand is, why doesn’t it work? according to the sample, the format and wording is correct and the code looks fine and it prints out James but its not passing.

i keep getting this error: Oops, try again. It looks like your function doesn't echo or print anything!

Answer 54d5f42093767682280046b4

1 vote

Permalink

it is not working.. same problem… i did refreshing the page but didnt work

points
about 9 years

Answer 54da803286f55269fe0001e4

1 vote

Permalink

ok, figured it out. You don’t have the < p> </ p> elements in your php.

<html>
    <head>
        <title></title>
    </head>
    <body>
      <p> <!-- <p> -->
        <?php
            $myname = "Spyros";
           $length = strlen("Spyros");
          echo $length;
        ?>
      </p> <!-- </p> -->
    </body>
</html>
points
Submitted by Spiridon Konofaos
about 9 years

Answer 54b9b066e39efedcac000a9f

0 votes

Permalink

It should work and echo your name. Try refreshing your page.

points
Submitted by Spiridon Konofaos
over 9 years

Answer 54c49bbd9113cbde55002bb3

0 votes

Permalink

try

return displayName();

points
Submitted by Francis Bawasanta
about 9 years

1 comments

Kiana Ward about 9 years

It doesn’t work. i keep getting the error “Oops, try again. It looks like your function doesn’t echo or print anything!”

Answer 553913cae39efed945000086

-1 votes

Permalink

function returnName() { echo “James”; } returnName();

this works

points
Submitted by Kim Rikardsen
almost 9 years