What is a string in PHP?
PHP strings are sequences of characters, where each character is represented by one byte. A byte can only contain 256 characters, so Unicode strings are not natively supported in PHP. In PHP, you can create strings using single quotes ('...'), double quotes ("..."), and Heredoc syntax (<<<). PHP provides a rich set of built-in functions for replacing, concatenating, comparing, interpolating, and splitting strings. You can also find the length of a string, convert the string to int, and convert the string to array.
How to make PHP string lowercase?
To convert the PHP string to lowercase, you can use the strtolower() function. The following is the syntax of the strtolower() function:
Where:
- string: specifies the string to be converted to lowercase
PHP String to Lowercase Examples
The following are examples of converting string to lowercase in PHP:
Converting string to lowercase
The following is an example of converting a PHP string to lowercase using strtolower():
Converting non-English characters to lowercase
To convert non-English characters to lowercase in PHP, you can use the mb_strtolower() function:
Converting special characters to lowercase
To convert special characters to lowercase in PHP, you can use the mb_strtolower() function:
Converting the first character of a string to lowercase
To convert the first character of a string to lowercase in PHP, you can use the lcfirst() function:
Converting multibyte non-ASCII characters to lowercase
To convert multibyte non-ASCII characters to lowercase, you can use the mb_strtolower() function. The bytes in the range "A" (0x41) to "Z" (0x5a) will be converted to lowercase letters by adding 32 to each value. This can be used to convert ASCII characters to UTF-8 encoded strings, as UTF-8 multibyte characters will be ignored.
How to convert string to uppercase in PHP?
To convert a PHP string to uppercase, you can use the strtoupper() function: