3. String Functions II | infinite loop / not working


#1

Hello,

I've a problem with: 3. String Functions II.
I've made an infinite loop / I'm doing something wrong / the webbrowser isn't working correctly.

Error code: Oops, try again. Your first strpos() call should output a number.

This is my code:

<html>
    <p>
    <?php
        strpos("Jelle", "e");
    ?>
    </p>
    <p>
    <?php
        if (strpos("Jelle","h") === false) {
          print "Sorry, no 'h' in 'Jelle'";
        }
    ?>
    </p>
</html>

,Thank you


#2



<?php
// Print out the position of a letter that is in
// your own name
strpos("Rahul", "h");
echo strlen ("Rahul");
?>



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



#3

This code does not work aswell I asume it's a bugg or someting. :cry:


#4

you have to print this out


#5

like this
print strpos("Jelle","e")


#6

Agreed. The code generated - You should print out a useful error message for the failed strpos() call - but it works onscreen



<?php
// Print out the position of a letter that is in
// your own name
$str = strpos("rick", "i");

print $str;
?>

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

print "Sorry there is no 't' in 'rick'";
}
?>


Output is : 1 Sorry there is no 't' in 'rick'


#7

Put the code in 2 separate p-Tags

<p>
<?php
// Print out the position of a letter that is in
// your own name
$str = strpos("rick", "i");

print $str;
?>
</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("rick", "t") === false) {

print "Sorry there is no 't' in 'rick'";
}
?>
</p>