String Function:it shows Your first strpos() call should output a number


#1

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

whats wrong with my code.if i have followed all the instructions that appear on the left
Oops, try again. Your first strpos() call should output a number.


<html>
    <p>
    <?php
    // Print out the position of a letter that is in
    // your own name
    strpos("payal","p");
    ?>
    </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("payal", "g") === false)
    {
        print "Sorry,no 'g'in 'payal'";
        }
    ?>
    </p>
</html>


#2

Hey Payal, here is your problem. write the word print in front of your strpos, like this:

print strpos("payal", "p");

Also in your custom error message, put a space between the comma after 'sorry' and the word 'no'. This program is very picky about syntax. Put a space before the word 'in'. Like so:

if(strpos("payal", "g") === false)
{
print "Sorry, no 'g' in 'payal'";
}
?>



#3

**Where is the problem ?


#4

You only need two strpos lines. Delete lines 8 and 9, and that should work.


#5

i have solution:


<?php
// Print out the position of a letter that is in
// your own name
$ime="stefan";
echo strpos($ime,"e");
echo strpos($ime,"f");
echo strpos($ime,"g");
?>



<?php
// Check for a false value of a letter that is not
// in your own name and print out an error message
if(strpos($ime,"g")!=$ime){
print "greska";
}
?>



#6

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