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

Functions, Part I Forum

View Course » View Exercise

1263 points
52e482278c1ccca6a900608f_815284360
Submitted by
Henry
over 3 years ago

Why 3/8 Doesn't work???

Here is my code:

<html>
    <p>
    <?php
    // Print out the position of a letter that is in
    // your own name
    print(strpos('henry','y'))
    ?>

    <?php
    // Check for a false value of a letter that is not
    // in your own name and print out an error message

if (strpos("henry","p") === false) {
  print "Sorry, no 'p' in 'henry'";
}


    ?>
    </p>
</html>

3 votes

permalink

Try this in the first section

$pos=strpos("Henry", "y");
print $pos

I had issues this one too

348 points
Cfa8c3ddd973a2d13b427b8fdb35ed40?s=140&d=retro
Submitted by
Paul Hernandez
over 3 years ago

4 Comments

52e482278c1ccca6a900608f_815284360 Henry over 3 years ago

Doesn't work- error message says "Oops, try again. You should print out a useful error message for the failed strpos() call"

Cfa8c3ddd973a2d13b427b8fdb35ed40?s=140&d=retro Paul Hernandez over 3 years ago

That's strange, I used the following and this worked for me.

if (strpos("Paul","x") === false) {
print "Sorry there is no x in Paul";
}

52e482278c1ccca6a900608f_815284360 Henry over 3 years ago

nope- didn't work. might be a bug

2a6151f824affc97a768f5ecacaad522?s=140&d=retro Arpitcoder over 3 years ago

Yes . may bugs in PHP course. same error for me. Also I have an error in an exercise where u just have to declare a variable! strange.


0 votes

permalink

Your code works. Try pressing Reset Code, Ctrl + F5, or F5 and complete the exercise again.

2570 points
56ec11ba1ec4b00bc400069e_656519138
Submitted by
Gaurang Tandon
over 3 years ago


0 votes

permalink

Hello, I had a lot of trouble with that one as well, I finally find the code that worked for me:


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


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

545 points
54098716631fe9d1b2002a33_548009098
Submitted by
krishova
almost 3 years ago


0 votes

permalink

Ok, I figured it out, I didn't do anything, one day it just worked :/ :)

1263 points
52e482278c1ccca6a900608f_815284360
Submitted by
Henry
almost 3 years ago