note 87176 added to function.lcfirst

From: Date: Sun, 23 Nov 2008 05:48:49 +0000
Subject: note 87176 added to function.lcfirst
Groups: php.notes 
Request: Send a blank email to php-notes+get-146833@lists.php.net to get a copy of this message
As of PHP release 6 direct reference modification is not permitted any more. Reference modification is the process of manipulating characters within a string by means of the instruction such as: $str[0] in the code line: $str[0] = strtolower($str[0]); For this reason I have recoded the lcfirst function (on function_exists('lcfirst') === false) as follows: if ( false === function_exists('lcfirst') ): function lcfirst( $str ) { return (string)(strtolower(substr($str,0,1)).substr($str,1));} endif; Remarks: Also notice that I have used the more modern scope delimeters (if:-endif;) and I have also removed the unnecessary intermediate result. That is, the manipulation is returned directly. ---- Server IP: 89.248.170.61 Probable Submitter: 77.248.255.252 ---- Manual Page -- http://www.php.net/manual/en/function.lcfirst.php Edit -- https://master.php.net/note/edit/87176 Del: integrated -- https://master.php.net/note/delete/87176/integrated Del: useless -- https://master.php.net/note/delete/87176/useless Del: bad code -- https://master.php.net/note/delete/87176/bad+code Del: spam -- https://master.php.net/note/delete/87176/spam Del: non-english -- https://master.php.net/note/delete/87176/non-english Del: in docs -- https://master.php.net/note/delete/87176/in+docs Del: other reasons-- https://master.php.net/note/delete/87176 Reject -- https://master.php.net/note/reject/87176 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#146833) next »