Posted By

Sverri on 07/29/10


Tagged

backwards compatibility first lowercase lcfirst


Versions (?)

Function "lcfirst" for PHP


 / Published in: PHP
 

Adds the function "lcfirst" if it does not exist (it was first added in PHP 5.3.0) while its counterpart, "ucfirst" was added in PHP 4.

  1. if ( ! function_exists('lcfirst'))
  2. {
  3. function lcfirst($str)
  4. {
  5. if ( ! is_string($str))
  6. {
  7. throw new Exception("Subject must be of type string");
  8. }
  9. $str[0] = strtolower($str[0]);
  10.  
  11. return $str;
  12. }
  13. }

Report this snippet  

You need to login to post a comment.