note 41128 deleted from function.ereg-replace by tularis

From: Date: Sun, 29 Aug 2004 12:12:33 +0000
Subject: note 41128 deleted from function.ereg-replace by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-75552@lists.php.net to get a copy of this message
Note Submitter: aizam d' aim ---- <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.

« previous php.notes (#75552) next »