views:

548

answers:

2

Fatal error: Call to undefined function lcfirst() in C:\xampp\htdocs\allsides\others\basecontroller.php on line 9

How come it didn't find a Text Proccessing function mentioned in the official php manual (http://www.php.net/manual/en/function.lcfirst.php)?

+6  A: 

Check the version: (PHP 5 >= 5.3.0)

You obviously have a version lower than that. :)

Use phpversion() to quickly check what version you have.

As pointed out by the comments, however, this function is trivially easy to replicate:

if(function_exists('lcfirst') === false) {
    function lcfirst($str) {
        $str[0] = strtolower($str[0]);
        return $str;
    }
}

You can throw the above code somewhere in your project's library/utilities file and it won't break when/if you upgrade to 5.3.0 down the road.

Paolo Bergantino
Beaten by 1 second!
tj111
Minor nitpick, but use of curly braces for character access (e.g. $str{0}) is being phased out: http://www.php.net/manual/en/language.types.string.php#language.types.string.substr
Frank Farmer
Learn something new everyday. Fixed.
Paolo Bergantino
+4  A: 

From the PHP manual page you linked:

(PHP 5 >= 5.3.0)

This function only exists if you are using PHP version 5.3 or newer.

tj111