note 95046 deleted from function.substr by danbrown
| From: | danbrown@php.net | Date: | Thu, 10 Dec 2009 19:12:59 +0000 |
| Subject: | note 95046 deleted from function.substr by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-163829@lists.php.net to get a copy of this message | ||
Note Submitter: wphampton at gmail dot com
----
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.