|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-05-09 15:43 UTC] webmaster at drk dot com dot ar
Description: ------------ stripslashes() removes slashes not added by addslashes() I expect a function to do what is described in the first line of its documentation. As published in this site "un-quotes strings quoted with addslashes()" It is water clear this functions isn't working as expected. As it shouldn't remove any slash that addslashes() wouldn't add. In example, a slash before a space won't be added by addslashes() and mustn't be removed by stripslashes() You can refuse to correct the code. In that case, which I consider most useless, you ought to correct the documentation. I ask myself won't be useful a function which undoes what addslashes() does? Reproduce code: --------------- <? $str = "the first \ should stay. it\'s the \"right\" case"; $str = stripslashes($str); var_dump($str); ?> Expected result: ---------------- "the first \ should stay. it's the "right" case" Actual result: -------------- "the first should stay. it's the "right" case" PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 15 07:00:02 2025 UTC |
I agree. The documentation makes you think it's the exact opposite of addslashes(), both in the function description and its return values (which happen to be explicitly listed, and there's no mention of removing single slashes that are not escaping anything). There's no string that produces "this \ that" after a call to addslashes(). addslashes("this that") would never output "this \ that"... The doc says clearly "Un-quotes a quoted string", it's clear its purpose is to run it on strings to be inserted in a DB, why would it remove single slashes?