Odd problem with ereg_replace and addslashes
| From: | Ian Truelsen | Date: | Wed, 03 Dec 2003 20:28:07 +0000 |
| Subject: | Odd problem with ereg_replace and addslashes | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-171720@lists.php.net to get a copy of this message | ||
Here is what I am doing:
I am reading in the contents of a text file that contains variables
whose properties I want to output. So, as was suggested on the list I
used the following:
eval("\$rest = \"".addslashes($pre_rest)."\";");
This works quite well, with one problem: if I use a contraction, like
won't, it will output as won\'t. So, I tried changing it to a backtic
(
Attachment: [application/pgp-signature]
) in the text file and after the eval statement, the output was wont.
So, I thought I had it. I added:
ereg_replace("'", "`", $pre_rest);
before the eval statement. However, the output then became won\`t.
I don't understand why it is that changing quote to backtic in the text
file will give me the proper output, but the ereg_replace, which should
provide the same input to the eval statement, gets the slash added.
Does anyone have any ideas on why this is happening, and what I can do
to avoid the quote being slashed?
--
Ian Truelsen
Email: ian@ihtruelsen.dyndns.org
AIM: ihtruelsen
Homepage: http://www.ihtruelsen.dyndns.org
Signature key (742B740D) available at pgp.mit.edu
Attachment: [application/pgp-signature]