note 23487 added to function.ereg-replace

From: Date: Fri, 19 Jul 2002 12:58:01 +0000
Subject: note 23487 added to function.ereg-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-33302@lists.php.net to get a copy of this message
If You work with HTML INPUT's users are able to write a " or ' into the string, and that can cause bugs. A possible solution is the following: $name = ereg_replace( "'", "", $name ); $name = ereg_replace( "\"", "", $name ); $name = ereg_replace( "[\]", "", $name ); The reason why the third line is recommended is that ereg_replace() will change every "" to one backslash. The problem is just with the double quote, single quote is repaired in the first line. Don't replace "[\]" with "\\" in the last line it also cause bugs! So with this 3-lines script You get a string without any quotes. Enigma -- http://www.php.net/manual/en/function.ereg-replace.php http://master.php.net/manage/user-notes.php?action=edit+23487 http://master.php.net/manage/user-notes.php?action=delete+23487 http://master.php.net/manage/user-notes.php?action=reject+23487

« previous php.notes (#33302) next »