February 2008
Intermediate to advanced
216 pages
4h 33m
English
One occasional problem with PHP is that MySQL supports case-insensitive character fields, but strings in PHP are case sensitive. In a query, MySQL makes no distinction between the words Ferrett, FERRETT, and FerReTt, but as strings in PHP, they have nothing in common. So in PHP you may need to change the case of characters in a string before you compare or print them.
PHP has three essential functions that convert string case: strtolower(), strtoupper(), and ucwords(). Here is a sample of them in action:
<? $string = "heY hOw arE yoU doinG?"; echo strtoupper($string); // Displays "HEY HOW ARE YOU DOING?" echo strtolower($string); // Displays "hey how are you doing?" echo ucwords(strtolower($string)); ...
Read now
Unlock full access