Function \"lcfirst\" for PHP


/ Published in: PHP
Save to your folder(s)

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.


Copy this code and paste it in your HTML
  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


Comments


You need to login to view comments.