String functions part II - what on earth is a "useful error message" in this context?


#1


https://www.codecademy.com/courses/web-beginner-en-7I7Xm/0/3?curriculum_id=5124ef4c78d510dd89003eb8

My code appears to function fine, but I keep getting "Oops try again! You should print out a useful error message for the failed strpos() call." I've tried several different error messages and can't seem to get it to work, can't see what's wrong with the output my code gives, either.

Edit: Actually, I'm a muppet and misread the instructions, sorry. Can't find a way to delete thread, but should anybody else have same problem, issue is that should be carrying out two different checks.


<html>
    <p>
    <?php
    // Print out the position of a letter that is in
    // your own name
    $haystack = "Sean";
    $needle = "a";
    $position = strpos($haystack, $needle);
    echo $position
    ?>
    </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 ($position === false) {
        echo "Sorry, no " . $needle . " in " . $haystack;
    }
    ?>
    </p>
</html>


#2

@jhaaglund
If you look at your Post
You will see a couple of buttons
pencil ( to edit your Post )
trash-can ( to delete your Post )


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.