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

Functions, Part I Forum

View Course » View Exercise

995 points
55e41ec39113cbb2000002b9_930161079
Submitted by
Chiem Janssen
over 2 years ago

Functions, Part I 3/8 (PHP)

This code is not working:

<?php
// Print out the position of a letter that is in
// your own name
print strpos("chiem", "m");
print strpos("chiem", "e");
print strpos("chiem", "h");
?>

<?php
// Check for a false value of a letter that is not
// in your own name and print out an error message
if (strpos("chiem","o") === false) {
print "Sorry, no 'o' in 'chiem'";
}
?>

Error: Your first strpos() call should output a number.

Output: 431 Sorry, no 'o' in 'chiem'


6 votes

permalink

Nevermind, i fixed it already, resetted the code, i forgot that we had <p> and the <html> tags

Here is the working code:

<html>
    <p>
    <?php
// Print out the position of a letter that is in
// your own name
print strpos("chiem", "m");
print strpos("chiem", "e");
print strpos("chiem", "h");
?>
</p>
<p>
<?php
// Check for a false value of a letter that is not
// in your own name and print out an error message
if (strpos("chiem","o") === false) {
print "Sorry, no 'o' in 'chiem'";
}
?>
    </p>
</html>

995 points
55e41ec39113cbb2000002b9_930161079
Submitted by
Chiem Janssen
over 2 years ago

4 Comments

524c87d8f10c605230003ebf_192064290 Silvio Fontevivo over 2 years ago

Thx!

56d7f54d8541388c7b00065c_686543546 Jesse over 2 years ago

thx based Choem

55e41ec39113cbb2000002b9_930161079 Chiem Janssen over 2 years ago

np

54511d989c4e9d76dd000498_706122142 Serrara over 2 years ago

Thx! :D


1 vote

permalink

<html>
<p>
<?php
// Print out the position of a letter that is in
// your own name
print strpos("AbuBakar", "C");

?>
</p>
<p>
<?php
// Check for a false value of a letter that is not
// in your own name and print out an error message
if(strpos("AbuBakar", "C") === false) {
    print "error";
}
?>
</p>

error:Your first strpos() call should output a number.

please tell the problem...

550 points
93dfecbd78367ac7c01174e47feb3cc5?s=140&d=retro
Submitted by
abuakarsial
over 2 years ago

2 Comments

53bb968c282ae37b37000265_794966998 Stanislav Mikhailenko over 2 years ago

Same here

55e41ec39113cbb2000002b9_930161079 Chiem Janssen over 2 years ago

print strpos("AbuBakar", "C"); The letter C isn't in your name, take for example the letter A, maybe that'll work!


0 votes

permalink

401 points
549537a19113cbb621002eab_431055238
Submitted by
hfdlfd
over 2 years ago