String Functions II Codeacademy PHP Example

String Functions II Codeacademy PHP Example

Here is a correct example for “String Functions II” from the PHP course.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<html>
    <p>
    <?php
    // Print out the position of a letter that is in
    // your own name
    print strpos("Cristi", "r");
    ?>
    </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("Cristi", "x") === false)
        {
            print "Sorry, there is no 'x' in 'Cristi' ";   
        }
    ?>
    </p>
</html>

Add a comment: