PHP Functions strpos number,letter ,and false


#1


Replace this line with your code. 

2
e is the 2nd string position
Sorry,string position zxc is false 
Sorry, no z in greg 


My output is correct, I could add any more if possible for a simple lesson
I keep a ridiculous response
  Oops, try again. You should print out a useful error message for the failed strpos() call.


#2

For help please post here your code


#3



<?php
// Print out the position of a letter that is in
// your own name
strpos("greg", "g"); // 0
strpos("greg", "e"); // 2
strpos("greg", "reg"); // 2
strpos("greg", "zxc"); // false;

print (strpos("greg","e"));
print "<br>";
print ("e is the 2nd string position" );
print "<br>";
if(strpos("greg","zxc") == false)
print("Sorry,string position zxc is false "); 
print "<br>";
if (strpos("greg","z") == false)
print ("Sorry, no z in greg") 
?>
</p>
<p>
<?php
// Check for a false value of a letter that is not
// in your own name and print out an error message

?>
</p>


#4

Error Message

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

So look at your first strpos() do you print here?
No you doesnt. Change that.

Do only what the instructions say.
In front of your first <?php is a

<p>

Missing. Change that too.
Your code should look more like this:

<html>
    <p>
    <?php
    // Print out the position of a letter that is in
    // your own name
    print ...; 
    ?>
    </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 () 
    {
        print "";
    }
    ?>
</html>

#5

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