This forum is now read-only. Please use our new forums at discuss.codecademy.com.

Functions, Part I Forum

View Course » View Exercise

1099 points
Picture
Submitted by
Cholent MT
over 4 years ago

I know I'm doing this right but the code won't work????

This is my code

<?php
// Get the length of your own name
// and print it to the screen!
$length - strlen("Avraham");
print $length;
?>

These are the errors I get:

Undefined variable: length (line 6)Undefined variable: length (line 7)

Oops, try again! Your output should be a number!

Please help???


4 votes

permalink

Instead of
$length - strlen("Avraham");
You should have
$length = strlen("Avraham");

Subtle, but important :)

624 points
Picture
Submitted by
Rick Gale
over 4 years ago

3 Comments

Picture Cholent MT over 4 years ago

Thank you! I guess I should have been sleeping instead of trying ti program. lol

543fc82f631fe988640020d7_382532424 Tobias Páez about 3 years ago

try to sleep more dear

798a6357de8f900134218609cde0b1a5?s=140&d=retro AnchyMorgan12 over 2 years ago

Sleep is for the weak!


1 vote

permalink

I tried using this way and it still said it didn't pass. Did anyone get it to pass or not?

559 points
5322f9e3631fe9523e000295_73092818
Submitted by
Sara Rae
over 3 years ago

4 Comments

Picture Rick Gale over 3 years ago

Sara, would you mind posting the code you have so far? That should make it easier to help :)

5322f9e3631fe9523e000295_73092818 Sara Rae over 3 years ago

<?php
// Get the length of your own name
// and print it to the screen!
$length = strlen("Sara")
print $length;
?>

Cbf6e314b0bdba199d93c3100fc2bd6b?s=140&d=retro mprevuznak over 3 years ago

Sara, use echo instead of print

543fc82f631fe988640020d7_382532424 Tobias Páez about 3 years ago

Sara you forgot to add semi-colon ;, at the end of strlen("Sara"), i will write beneath how it must be :


0 votes

permalink

$length = strlen("Sara");
echo $length;

365 points
543fc82f631fe988640020d7_382532424
Submitted by
Tobias Páez
about 3 years ago