note 95046 added to function.substr
| From: | wphampton at gmail dot com | Date: | Thu, 10 Dec 2009 18:28:42 +0000 |
| Subject: | note 95046 added to function.substr | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-163820@lists.php.net to get a copy of this message | ||
For anyone moving code between Windows and Linux I thought this would be worth highlighting. As
mentioned in the documentation above:
If
start parameter is negative, the returned string will start at the start 'th
character from the end of string .
However, there is different behavior between Windows and Linux in my experience. Take this code as
an example:
<?php
echo substr('abcdef', -7);
?>
Windows will print: abcdef
Linux will print nothing
It seems ridiculous that this scenario would ever happen, but I ran into this problem when working
with the mcrypt() functions and variable length key sizes and such. Better written code on my part
solved my problem but I thought I should at least contribute my experience.
----
Server IP: 69.147.83.197
Probable Submitter: 64.128.124.130
----
Manual Page -- http://www.php.net/manual/en/function.substr.php
Edit -- https://master.php.net/note/edit/95046
Del: integrated -- https://master.php.net/note/delete/95046/integrated
Del: useless -- https://master.php.net/note/delete/95046/useless
Del: bad code -- https://master.php.net/note/delete/95046/bad+code
Del: spam -- https://master.php.net/note/delete/95046/spam
Del: non-english -- https://master.php.net/note/delete/95046/non-english
Del: in docs -- https://master.php.net/note/delete/95046/in+docs
Del: other reasons-- https://master.php.net/note/delete/95046
Reject -- https://master.php.net/note/reject/95046
Search -- https://master.php.net/manage/user-notes.php