note 104204 added to function.stripslashes
| From: | Kent at osu1 dot php dot net | Date: | Tue, 31 May 2011 21:52:52 +0000 |
| Subject: | note 104204 added to function.stripslashes | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-180146@lists.php.net to get a copy of this message | ||
Haha.. I love the example here.
$s = "Let\'s post a plug for O\'Rielly";
Why anyone would use stripslashes to read this string is beyond me!
In this case, the backslashes are useless since they are escaping single quotes in a double quoted
string.
But even if converting it to:
$s = 'Let\'s post a plug for O\'rielly';
It would only act as a signal to the php interpreter that ' is not the end of the string... the
string in memory WOULD NOT HAVE THE SLASHES.
* You actually need the slashes in the string being stripped... it's stripping the slashes...
no slashes, no stripping (er.. uh whatever)
Try:
$a = "\\\"This needs strip slashes\\\"";
print $a . '<br />' . stripslashes($a);
But watch out: You want to have a reasonable amount of certainty that the string was escaped (adding
slashes) or you can corrupt your data.
----
Server IP: 69.147.83.197
Probable Submitter: 24.87.87.181
----
Manual Page -- http://www.php.net/manual/en/function.stripslashes.php
Edit -- https://master.php.net/note/edit/104204
Del: integrated -- https://master.php.net/note/delete/104204/integrated
Del: useless -- https://master.php.net/note/delete/104204/useless
Del: bad code -- https://master.php.net/note/delete/104204/bad+code
Del: spam -- https://master.php.net/note/delete/104204/spam
Del: non-english -- https://master.php.net/note/delete/104204/non-english
Del: in docs -- https://master.php.net/note/delete/104204/in+docs
Del: other reasons-- https://master.php.net/note/delete/104204
Reject -- https://master.php.net/note/reject/104204
Search -- https://master.php.net/manage/user-notes.php