note 49205 added to function.addcslashes
| From: | phpcoder at cyberpimp dot pimpdomain dot com | Date: | Thu, 20 Jan 2005 07:02:18 +0000 |
| Subject: | note 49205 added to function.addcslashes | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-83651@lists.php.net to get a copy of this message | ||
If you are using addcslashes() to encode text which is to later be decoded back to it's
original form, you MUST specify the backslash (\) character in charlist!
Example:
<?php
$originaltext = 'This text does NOT contain \\n a new-line!';
$encoded = addcslashes($originaltext, '\\');
$decoded = stripcslashes($encoded);
//$decoded now contains a copy of $originaltext with perfect integrity
echo $decoded; //Display the sentence with it's literal \n intact
?>
If the '\\' was not specified in addcslashes(), any literal \n (or other C-style special
character) sequences in $originaltext would pass through un-encoded, but then be decoded into
control characters by stripcslashes() and the data would lose it's integrity through the
encode-decode transaction.
----
Manual Page -- http://www.php.net/manual/en/function.addcslashes.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+49205
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49205&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49205&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49205&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49205&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49205&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+49205&report=yes
Search -- http://master.php.net/manage/user-notes.php