Page 1 of 1

Newbie fwrite text file question

Posted: Sat Sep 11, 2004 5:32 pm
by mrpants
Sorry if this has been answered before somewhere... but it's a pain to actually search for it because of the character output.

Whenever I write to a text file using fwrite... instead of writing a single quotation mark... I get a backslash before every one. thusly:

<a href="http://www.targetwebsite" target="_blank">

Looks like

<a href=\"http://www.targetwebsite\" target=\"_blank\">

Huh?

I am using nl2br since I want people not to have to use html... but have it as an option. Am I doing something wrong... or do I need to find an replace all of these characters with a script?

It's a pain in the ass trying to search for \" as a problem in any search engine.

Any help would be much obliged.

pants

strip

Posted: Sat Sep 11, 2004 5:42 pm
by neophyte
Did you try?

Code: Select all

<?php
stripslashes($string);

?>

Posted: Sat Sep 11, 2004 6:26 pm
by mrpants
ACH! Thank you! Is there a way to have those slashes not even be written?

but yes... thank you.

pants

Maybe

Posted: Sat Sep 11, 2004 6:34 pm
by neophyte
The slashes are created by "magic slashes" a feature that is on by default and defined in your php.ini file. It adds slashes and removes slashes when pulling to and from databases. I just leave mine on and deal with it. If you're on a shared server you are probably stuck with it. There is a lot more you can read about it on the forum. Do a search for "magic slashes." I think the general opnion in this forum is that it's best to addslashes() and stripslashes() in your code rather than allowing "magic slashes" to do it for you.

Posted: Sat Sep 11, 2004 7:49 pm
by feyd
[devnet]magicquotes[/devnet]