PHP string functions – strtolower and strtoupper

This tutorial explains how to convert strings to uppercase and lowercase using the strtolower and strtoupper functions. These functions each take one argument – the string that needs to be converted to lowercase or uppercase.


$uppercaseString = strtoupper($lowercaseString);

Watch the video below and then scroll down for the sample code.

PHP sample code:

  $mystring = "Hello world";
  // convert to uppercase
  $mystring_upper = strtoupper($mystring);

  // convert to lowercase
  $mystring_lower = strtolower($mystring);

  echo $mystring , "</br>";
  echo $mystring_upper , "</br>";
  echo $mystring_lower;