Category: PHP5

Added: 7th of October 2020

Viewed: 62 times

Convert all characters to Upper or Lower case in PHP5

There might be occasions when you need to ensure all characters submitted through a form field are either in upper or lower case.

One example could be a form field where you ask your users to enter their website address. Some users might accidentally enter the address in upper case. In this case we can use PHP to take the user input, and convert the text to lower case, using the strtolower() function.

Please look at the examples below

To convert all characters to upper case in PHP5 use the strtoupper() function

<?php
echo strtoupper('www.mycomputertips.co.uk');
?>


Output
WWW.MYCOMPUTERTIPS.CO.UK

To convert all characters to lower case in PHP5 use the strtolower() function
<?php
echo strtolower('WWW.MYCOMPUTERTIPS.CO.UK');
?>


Output
www.mycomputertips.co.uk

Other Tips & Tutorials

PHP5

Convert all characters to Upper or Lower case in PHP5

Posted: 7th of October 2020

Views: 62

PHP5

Get the day of the week for a specified date using PHP5

Posted: 17th of January 2016

Views: 1718

PHP5

How to upload files larger than 2MB using PHP5

Posted: 14th of January 2016

Views: 1890

PHP5

Preserve line breaks in PHP. nl2br function

Posted: 21st of December 2015

Views: 3361

PHP5

Convert a Unix timestamp to date and time using PHP

Posted: 18th of December 2015

Views: 1983

PHP5

How to validate a form using PHP5

Posted: 15th of December 2015

Views: 1005

PHP5

Count the number of elements in a PHP array using the count() function

Posted: 15th of December 2015

Views: 841

PHP5

Pass ampersand through query strings in URL using PHP5

Posted: 27th of November 2015

Views: 2076