PHP » PYTHON |
login |
register |
about
|
There is no direct equivalent. However,
result = myStr.capitalize() is similar. It turns the first letter to uppercase and it turns all the rest of the letters to lowercase. So the above code is actually equivalent to: <?php $result = ucfirst(strtolower($myStr)); ?> However, for most purposes, it should not make that much of a difference. If you wanted an exact equivalent, you would use: result = myStr[0].upper() + myStr[1:] ucfirst(PHP 4, PHP 5) ucfirst — Make a string's first character uppercase Description
string ucfirst
( string $str
)
Returns a string with the first character of str capitalized, if that character is alphabetic. Note that 'alphabetic' is determined by the current locale. For instance, in the default "C" locale characters such as umlaut-a (ä) will not be converted. Parameters
Return ValuesReturns the resulting string. Examples
Example #1 ucfirst() example
<?php
See Also
|
more
Recently updated
more
Most requested
more
Last requests
|