String Functions I Codeacademy PHP Example

String Functions I Codeacademy PHP Example

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<html>
  <p>
    <?php
    // Get a partial string from within your own name
    // and print it to the screen!
    $name = "Cristi";
$extract = substr($name, 0, 3);
print $extract;
    ?>
  </p>
  <p>
    <?php
    // Make your name upper case and print it to the screen:
    $name = "Cristi";
    $upper = strtoupper($name);
    print $upper;
    ?>
  </p>
  <p>
    <?php
    // Make your name lower case and print it to the screen:
    $name = "Cristi";
    $lower = strtolower($name);
    print $lower;
    ?>
  </p>
</html>

Add a comment: