...

View Full Version : Why am I not getting linefeeds?



carl_mcdade
07-07-2004, 11:50 AM
This code is running on RedHAt, Apache 1.3 with PHP 4.3.6
The \n's in the header variable just shows as \n. no breaks nospaces no binary space... :mad:


$header = '<?php $use_zlib=\''.$use_zlib.'\';\n if(!file_exists(\'freelock.php\')) { echo "freelock not found - exiting"; exit; }"'.$s.'\n<?php include_once(\'freelock.php\');?><?php freelock_run($s1); ?>';
if($output == '') {
$fp = fopen($file,'wb');
fwrite($fp,$header,strlen($header));
fclose($fp);
} else {
$fp = fopen($output.'/'.basename($file),'wb');
fwrite($fp,$header,strlen($header));
fclose($fp);
}

raf
07-07-2004, 12:08 PM
to get a linebreak in your source (html-source) you can only use

"\n" --> needs to be surrounded by double quotes

carl_mcdade
07-07-2004, 12:19 PM
Arrrgh!!!

I new there was a reson I only use double quotes. This is someone elses code. Had me up until 3am.

Thanks Raf :thumbsup:

raf
07-07-2004, 01:19 PM
you're welcome.

actualy, i also use single quotes for strings, except for sql-querys, eval()'ed code and the formatting codes. because everything between doublequotes is parsed, which is in most case not required.

so if i wan't to layout my sources, then i'll have

echo 'some javascript i need to be able to read' . "\n" ;

trib4lmaniac
07-07-2004, 03:02 PM
I also use single quotes for regexps, they are almost always meant to be taken literally.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum