String Functions II


#1

help please,
I keep getting this error message; Oops, try again. You should print out a useful error message for the failed strpos() call.

dont know what is wrong with my code



<html>
    <p>
    <?php
    // Print out the position of a letter that is in
    // your own name
    $josh = "programmer";
     echo strpos($josh, "g");
        ?>
        
        <?php
        
        if (strpos($josh,"h") === false) {
  print "Sorry, no 'h' in 'programmer'";
}
    ?>
    </p>
</html>
 



#2

You could try using echo instead of print


#3

I tried that too, still not working


#4

Whoopsie, you’re missing the original p tags between the 2 blocks of code:

<html>
    <p>
    <?php
    // Print out the position of a letter that is in
    // your own name
    $josh = "programmer";
     echo strpos($josh, "g");
        ?>
    </p>
    <p>        
        <?php
        
        if (strpos($josh,"h") === false) {
  print "Sorry, no 'h' in 'programmer'";
}
    ?>
    </p>
</html>

The exercise wants to see 2 different paragraphs rendered out to their browser interface.


#5

you can make it like this:

<html>
    <p>
    <?php
    // Print out the position of a letter that is in
    // your own name
   echo strpos("programmer","g");
        ?>
      </p>
      <p>
        <?php
        
        if (strpos("programmer","h") === false) {
  print "Sorry, no 'h' in 'programmer'";
}
    ?>
    </p>
</html>

#6

Thanks guys
I have it now
it was the p tags
Thanks again


#7

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