note 38552 deleted from function.substr by nlopess
| From: | nlopess@php.net | Date: | Sat, 03 Jul 2004 12:10:02 +0000 |
| Subject: | note 38552 deleted from function.substr by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-72412@lists.php.net to get a copy of this message | ||
Note Submitter: icewolf@excite.co.jp
----
As per the post below, posted 12-dec-2003,
The examples given are incorrect,
>>If string length is exactly equal to startpos, then false is returned (not a zero-length
>>string). Example:
>>substr("filename.txt",9,1)==='.txt'
substr ("filename.txt", 9, 1) === 'txt'
the substr function is 0 based, not 1, thus as stated in the description the first character is 0,
the second is 1.
>>but
>>substr("filename.",9,1)!=='.' (it equals false)
substr("filename.",9,1) should equal false, as there is no 10th character is the given
string -- as per the documentation.
>>People familiar with the "c" function of the same name, would have expected a
>>zero-length string.
PHP strings are not implictly null-terminated, thus the length of the string ("filename.")
is 9. and the max start position would be 8 (the ninth character). There is no terminating null
character at position #9, and thus the difference between this and the "c" version.