note 41128 added to function.ereg-replace

From: Date: Wed, 31 Mar 2004 07:38:36 +0000
Subject: note 41128 added to function.ereg-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-67402@lists.php.net to get a copy of this message
<form action="string5.php" method="post"> Enter Name: <input name="variable_name" value="Mc' Donald's"></input> <input type="submit"></input> <!-- Entering Mc' Donald's --> </form> <?php //replacing the ' (apostrophe) to // (double backslash) $variable_name = ereg_replace("'", "'//",$variable_name); //Input using the textbox automatically adding \ (slash) behind ' (apostrophe) //Ouput should be : Mc\'// Donald\'//s print("Output generated by textbox : $variable_name<br><br>"); //removing \ (slash) behind ' (apostrophe) $striped_slash = stripslashes($variable_name); //Ouput should be : Mc'// Donald'//s print("Output using stripslashes : $striped_slash<br><br>"); //remove // (double backslash) after ' (apostrophe) $remove_dbslash = ereg_replace("'//", "'",$striped_slash); //Ouput should be : Mc' Donald's print("Output without double backslash : $remove_dbslash"); ?> You can replace double backslash with others. Maybe this trick is good while apostrophe might caused failure in some databases and yet it's quite annoying when displaying the name with apostrophe and the slash behind them. ---- Manual Page -- http://www.php.net/manual/en/function.ereg-replace.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+41128 Delete -- http://master.php.net/manage/user-notes.php?action=delete+41128&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+41128&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#67402) next »