Jump to content

String Question


bgeorgeus

Recommended Posts

First of all i am a beginner to PHP and i have a very simple script that writes the contents of a text box with is HTML code to a text file.  The file is then read by another script which displays the output to the screen.

Whenever i use in the text box  ex "<h1>George's House</h1>" it writes "<h1>George\'s House</h1>" to the file leaving annoying backslashes in my web page.  How can i keep the script from writing these backslashes.

My code:

Writing the file



$code = $_POST['text'];

$file = fopen("../index.txt","w");

fwrite($file,"$code");

fclose($file);



Reading the file


$file = fopen("index.txt","r");

while(!feof($file)){

echo fgets($file);
}
Link to comment
https://forums.phpfreaks.com/topic/35608-string-question/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.