/
proc
/
self
/
root
/
usr
/
local
/
lsws
/
phpbuild
/
php-8.0.7
/
ext
/
standard
/
tests
/
strings
/
File Upload :
llllll
Current File: //proc/self/root/usr/local/lsws/phpbuild/php-8.0.7/ext/standard/tests/strings/ucfirst.phpt
--TEST-- "ucfirst()" function --INI-- precision=14 --FILE-- <?php /* Make a string's first character uppercase */ echo "#### Basic and Various operations ####\n"; $str_array = array( "testing ucfirst.", "1.testing ucfirst", "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) { var_dump( ucfirst($string) ); } echo "\n#### Testing miscellaneous inputs ####\n"; echo "\n--- Testing objects ---\n"; /* we get "Recoverable fatal error: saying Object of class could not be converted to string" by default when an object is passed instead of string: The error can be avoided by choosing the __toString magix method as follows: */ class StringCapable { function __toString() { return "hello, world"; } } $obj_string = new StringCapable; var_dump(ucfirst("$obj_string")); echo "\n--- Testing a longer and heredoc string ---\n"; $string = <<<EOD abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789 abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789 abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789 abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789 abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789 abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789 abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789 @#$%^&**&^%$#@!~:())))((((&&&**%$###@@@!!!~~~~@###$%^&* abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789 EOD; var_dump(ucfirst($string)); echo "\n--- Testing a heredoc null string ---\n"; $str = <<<EOD EOD; var_dump(ucfirst($str)); echo "\n--- Testing simple and complex syntax strings ---\n"; $str = 'world'; /* Simple syntax */ var_dump(ucfirst("$str")); var_dump(ucfirst("$str'S")); var_dump(ucfirst("$strS")); /* String with curly braces, complex syntax */ var_dump(ucfirst("${str}S")); var_dump(ucfirst("{$str}S")); echo "\n--- Nested ucfirst() ---\n"; var_dump(ucfirst(ucfirst("hello"))); echo "Done\n"; ?> --EXPECTF-- #### Basic and Various operations #### string(16) "Testing ucfirst." string(17) "1.testing ucfirst" string(11) "HELLO wORLD" string(11) "HELLO wORLD" string(1) "