What is ucfirst, ucwords, lcfirst, strtolower, strtoupper function in php?
What is ucfirst, ucwords, lcfirst, strtolower, strtoupper function in php?
ucfirst : Make a string’s first character uppercase
<?php
$var = ‘anwar hossain!’;
$var = ucfirst($var); // Anwar hossain!$bar = ‘HELLO WORLD!’;
$bar = ucfirst($bar); // HELLO WORLD!
$bar = ucfirst(strtolower($bar)); // Hello world!
?>
ucwords : Uppercase the first character of each word in a string.
<?php
$var = ‘anwar hossain!’;
$var = ucwords($var); // Anwar Hossain!$bar = ‘HELLO WORLD!’;
$bar = ucwords($bar); // HELLO WORLD!
$bar = ucwords(strtolower($bar)); // Hello World!
?>
lcfirst : Make a string’s first character lowercase.
<?php
$var = ‘AnwarHossain!’;
$var = lcfirst($var); // anwarHossain!$bar = ‘HELLO WORLD!’;
$bar = lcfirst($bar); // hELLO WORLD!
$bar = lcfirst(strtoupper($bar)); // hELLO WORLD!
?>
strtoupper : Make a string uppercase.
<?php
$string = “Anwar is a good boy”;
$string = strtoupper($string);
echo $string; // Output : ANWAR IS A GOOD BOY
?>
strtolower : Make a string lowercase.
<?php
$string = “ANWAR IS A GOOD BOY”;
$string = strtolower($string);
echo $string; // Output : anwar is a good boy
?>