|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-11-10 22:19 UTC] webjedi at hudzilla dot eclipse dot co dot uk
Description:
------------
Would it be possible to write a function, named something like smart_addslashes(), that only adds slashes to a string if magic_quotes_gpc is disabled?
Yes, this is only three lines of userland code:
if (!get_magic_quotes_gpc()) {
$input_string = addslashes($input_string);
}
But adding slashes to strings is a common task, and checking whether the string has already been auto-slashed is crucial for portability reasons - trimming three lines down to one would help ease the job a little.
Thanks!
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 23:00:01 2025 UTC |
Here it is: <? function smart_addslashes($str) { if (!get_magic_quotes_gpc()) { return addslashes($str); } return $str; } ?> Is that what you want?