0

I'm using the below code to create an html file using fopen and fwrite. In the html source code I trying to add carriage returns using \n, but I'm not having any luck

$filename = 'textfile.html';
$newstring = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n' 
$newstring .= '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">\n';
$newstring .= '<head>\n';
$newstring .= '<title>IT Consulting In Your Local Area</title>\n';
$newstring .= '</head>\n';
$newstring .= '<body>\n';
$newstring .= '<p>This is a test<p>\n';
$newstring .= '</body>\n';
$newstring .= '</html>\n';
	
$newfile = @fopen($filename, "w+") or die ("Couldn't create file");
	
@fwrite($newfile, $newstring) or die ("Couldn't write to the file");
	
@fclose($newfile);

I'm getting the following as a result of the above code and everyhting runs together without any carriage returns. Any Ideas?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">\n<head>\n<title>IT Consulting In Your Local Area</title>\n</head>\n<body>\n<p>This is a test<p>\n</body>\n</html>\n
2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by pritaeas
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.