ucfirst 


string apg

CONVERTS the first character of a string to UPPERCASE.





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

May experience conversion issues even with LOCALE information.



<?php

str ucfirst 
str $str )


where,

$str The string to transform the first character in UPPERCASE

?>
 

$str


The input STRING.



  1 EXERCISE   

<?php

$str0010 
'quandoque bonus dormitat Homerus';

$str0011 ucfirst ($str0010);

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

?>

 RESULT   

Original STRING

quandoque bonus dormitat Homerus


After ucfirst

Quandoque bonus dormitat Homerus

  2 EXERCISE   

<?php

$str0020 
'âmbito nacional';

$str0021 ucfirst ($str0020);

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

?>

  3 EXERCISE   

<?php

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

$str0031 ucfirst ($str0030);

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

?>

  4 EXERCISE   

<?php

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

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 ucfirst 
                     with different values */
foreach ($str_array as $string) {
    echo 
$string '<br>' ucfirst($string) . '<br><br>';
}

?>