This forum is now read-only. Please use our new forums! Go to forums

0 points
Submitted by Zach Perkins
over 8 years

I've spent a couple hours on this, tried different browsers, still can't figure out what's wrong.

I’m given the error “Oops, try again. You should print out a useful error message for the failed strpos() call.” when running the code. I can’t tell what is wrong. Help?

<?php
// Print out the position of a letter that is in
//your name
$name = "Zach";
$letter = "a";
$pos = strpos($name, $letter);
print $pos;
?>


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

Answer 55ac14a276b8fe29110003a3

2 votes

Permalink

// Try this approach // It worked for me

points
Submitted by RikShep
over 8 years

5 comments

Zach Perkins over 8 years

I just tried it with your code in both Safari and Chrome and it still didn’t work for me

RikShep over 8 years

don’t know what to say then. I tried that exact code with the exception of my name instead of yours and it worked fine for me

SamaAs over 8 years

Thank you very much! For me worked fine.

zhulan over 8 years

I guess it works differently on different browsers or different type of computers.

zhulan over 8 years

because it didn’t work for me and I have an apple computer.

Answer 55bf5ea39376766040000148

0 votes

Permalink

I tried RikSheps code and it doesn´t work, then i removed the: print “hay”; and it worked.

points
Submitted by xMichi1996x
over 8 years