PHP Tutorial Example
Example
PHP Mail
PHP Libxml
PHP HTTP
PHP Filter
PHP Zip
PHP Directory
PHP Error
PHP SimpleXML
PHP Calendar
PHP Date
PHP Misc
PHP XML
PHP FTP
PHP Math
PHP MySQL
PHP Filesystem
PHP Array
PHP String
PHP Tutorial
PHP Introduction
PHP Installation
PHP Syntax
PHP Variables
PHP Echo
PHP Strings
PHP Operators
PHP Comments
PHP Include File
PHP Require
PHP If Statement
PHP If Else
PHP Elseif
PHP Switch
PHP Forms
PHP Functions
PHP Array
PHP While Loop
PHP For Loop
PHP For Each
PHP Do While
PHP POST and GET
PHP Magic Quotes
PHP htmlentities
PHP Files
PHP File
PHP File Create
PHP File Open
PHP File Close
PHP File Write
PHP File Read
PHP File Delete
PHP File Append
PHP File Truncate
PHP File Upload
PHP Strings
PHP strpos
PHP str replace
PHP substrreplace
PHP Capitalization
PHP explode
PHP implode
PHP Advanced
PHP Date
PHP Session
PHP Cookies
PHP Include
PHP Email
PHP Secure Email
PHP Error
PHP Exception
PHP Filter
PHP and AJAX
AJAX Intro
AJAX PHP
AJAX Database
AJAX XML
AJAX Live Search
AJAX RSS Reader
AJAX Poll
PHP XML
XML Expat Parser
XML DOM
XML SimpleXML
PHP Database
MySQL Introduction
MySQL Connect
MySQL Create
MySQL Insert
MySQL Select
MySQL Where
MySQL Order By
MySQL Update
MySQL Delete
PHP ODBC
PHP Misc
PHP connection aborted Function
If you've ever wanted to manipulate the capitalization of your PHP strings, then this lesson will be quite helpful to you. PHP has three primary capitalization related functions: strtoupper, strtolower and ucwords. The function names are pretty self-explanatory, but why they are useful in programming might be new to you.
The strtoupper function takes one argument, the string you want converted to upper case and returns the converted string. Only letters of the alphabet are changed, numbers will remain the same.
$originalString = "String Capitalization 1234";
$upperCase = strtoupper($originalString);
echo "Old string - $originalString <br />";
echo "New String - $upperCase";
One might use this function to increase emphasis of a important point or in a title. Another time it might be used with a font that looks very nice with all caps to fit the style of the web page design.
A more technical reason would be to convert two strings you are comparing to see if they are equal. By converting them to the same capitalization you remove the possibility that they won't match simply because of different capitalizations.
The strtolower function also has one argument: the string that will be converted to lower case.
$originalString = "String Capitalization 1234";
$lowerCase = strtolower($originalString);
echo "Old string - $originalString <br />";
echo "New String - $lowerCase";
Titles of various media types often capitalize the first letter of each word and PHP has a time-saving function that will do just this.
$titleString = "a title that could use some hELP";
$ucTitleString = ucwords($titleString);
echo "Old title - $titleString <br />";
echo "New title - $ucTitleString";
Notice that the last word "hELP" did not have the capitalization changed on the letters that weren't first, they remained capitalized. If you want to ensure that only the first letter is capitalized in each word of your title, first use the strtolower function and then the ucwords function.

