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


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.

    // Print out the position of a letter that is in
    // your own name
    $haystack = "Sean";
    $needle = "a";
    $position = strpos($haystack, $needle);
    echo $position
    // 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;


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


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