note 92883 added to function.strlen
| From: | pifta at csoma dot elte dot hu | Date: | Thu, 13 Aug 2009 02:05:42 +0000 |
| Subject: | note 92883 added to function.strlen | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-159423@lists.php.net to get a copy of this message | ||
I have ran into a strange situation, when i wanted to process some strings, and i noticed the
following:
<?php
echo (strlen("\\"));
?>
will return 1 instead of 2, so watch out if you want mass processing strings, and the length has to
be known for them, and they can contain such a substring.
That is the case even if you read the string from a file or stream, and try to get its length.
The use of the addslashes() function can solve the problem.
----
Server IP: 92.43.200.200
Probable Submitter: 157.181.119.145 (proxied: 157.181.193.191)
----
Manual Page -- http://www.php.net/manual/en/function.strlen.php
Edit -- https://master.php.net/note/edit/92883
Del: integrated -- https://master.php.net/note/delete/92883/integrated
Del: useless -- https://master.php.net/note/delete/92883/useless
Del: bad code -- https://master.php.net/note/delete/92883/bad+code
Del: spam -- https://master.php.net/note/delete/92883/spam
Del: non-english -- https://master.php.net/note/delete/92883/non-english
Del: in docs -- https://master.php.net/note/delete/92883/in+docs
Del: other reasons-- https://master.php.net/note/delete/92883
Reject -- https://master.php.net/note/reject/92883
Search -- https://master.php.net/manage/user-notes.php