Microsoft Word - Core PHP Programming Using PHP to Build Dynamic Web Sites

(singke) #1

string strtolower(string text)


The strtolower function returns the text argument with all letters changed to
lowercase. Other characters are unaffected. Locale affects which characters are
considered letters, and you may find that letters with accents and umlauts are being
ignored. You may overcome this by using setlocale, discussed in Chapter 11,


"Time, Date, and Configuration Functions."


<?


print(strtolower("Hello World"));
?>


string strtoupper(string text)


The strtoupper function returns the text argument with all letters changed to
uppercase. Other characters are unaffected. Locale affects which characters are
considered letters, and you may find that letters with accents and umlauts are being
ignored. You may overcome this by using setlocale, discussed in Chapter 11.


<?


print(strtoupper("Hello World"));
?>


string strtr(string text, string original, string translated)


When passed three arguments, the strtr function returns the text argument with
characters matching the second argument changed to those in the third argument. If
original and translated aren't the same length, the extra characters are ignored.


At the time of writing a second prototype for strtr was being planned that allows you
to pass two arguments. The second argument must be an associative array. The indices
specify strings to be replaced, and the values specify replacement text. If a substring
matches more than one index, the longer substring will be used. The process is not
iterative. That is, once substrings are replaced, they are not further matched.


This function is safe to use with binary strings.


<?


$text = "Wow! This is neat.";
$original = "!.";

Free download pdf