lcfirst 


string apg

CONVERTS the first character of a string to lowercase.





This function returns a string with the first character converted to lowercase if that character is alphabetic.

May experience conversion issues even with LOCALE information.



<?php

str lcfirst 
str $str )


where,

$str The string to transform the first character in lowercase

?>
 

$str


The input STRING.



  1 EXERCISE   

<?php

$str0010 
'Quandoque bonus dormitat Homerus';

$str0011 lcfirst ($str0010);

echo 
'Original STRING:<br>' $str0010 
        
'<br><br>After lcfirst:<br>' $str0011 '<br>';

?>

 RESULT   

Original STRING

Quandoque bonus dormitat Homerus


After lcfirst

quandoque bonus dormitat Homerus

  2 EXERCISE   

<?php

$str0020 
'Âmbito nacional';

$str0021 lcfirst ($str0020);

echo 
'Original STRING:<br>' $str0020 
              
'<br><br>After lcfirst:<br>' $str0021 '<br>';

?>

 RESULT   

Original STRING

Âmbito nacional


After lcfirst

�mbito nacional

This exercise presents - as expected - a conversion problem.

  3 EXERCISE   

<?php

$str0030 
'1,2,3,4,5,6,7,8,9 for 12 missing 3';

$str0031 lcfirst ($str0030);

echo 
'Original STRING:<br>' $str0030 
          
'<br><br>After ucfirst:<br>' $str0031 '<br>';

?>

  4 EXERCISE   

<?php

/* Make a string's first character lowercase */

echo "Basic and Various operations:<br><br>";
$str_array = array(
"TesTing lcfirst.",
"1.testing lcfirst",
"HELLO wORLD",
'HELLO wORLD',
"\0",        
// Null
"\x00",        
// Hex Null
"\x000",
"abcd",        
// double quoted string
'xyz',        
// single quoted string
"-3",
-
3,
'-3.344',
-
3.344,
NULL,
"NULL",
"0",
0,
TRUE,        
// bool type
"TRUE",
"1",
1,
1.234444,
FALSE,
"FALSE",
" ",
"     ",
'b',        
// single char
'\t',        
// escape sequences
"\t",
"12",
"12twelve",        
// int + string
);
/* loop to test working of lcfirst 
   with different values */
foreach ($str_array as $string) {
    echo 
$string '<br>' lcfirst($string) . '<br><br>';
}

?>