![]() |
|
首页 │ Apache │ Linux│ Java│ MySQL│ 注册│帮助 | |||
我用PHP程序生成了一个PHP文件,其中有用\n来表示换行.
[php]
<?
//......
if(!file_exists($objfile) || @filemtime($tplfile) > @filemtime($objfile)) {
$fp = fopen($tplfile, 'r');
$template = fread($fp, filesize($tplfile)+1);
fclose($fp);
$template = preg_replace("/\\{template\\s+(.+?)\\}/is", "\\n<? include template('\\\\1'); ?>\\n", $template);
$template = preg_replace("/\\{(\\\\\\$[a-zA-Z0-9_\\[\\]\\'\\"\\$\\.\\x7f-\\xff]+)\\}/s", "<? echo \\\\1; ?>", $template);
$template = preg_replace("/\\<\\!\\-\\-\\s*\\{function\\s+(.+?)\\}\\s*\\-\\-\\>/s", "<? echo \\\\1; ?>", $template);
$template = preg_replace("/\\<\\!\\-\\-\\s*\\{if\\s+(.+?)\\}\\s*\\-\\-\\>/s", "<? if(\\\\1){ ?>", $template);
$template = preg_replace("/\\<\\!\\-\\-\\s*\\{elseif\\s+(.+?)\\}\\s*\\-\\-\\>/s", "<? }elseif(\\\\1){ ?>", $template);
$template = preg_replace("/\\<\\!\\-\\-\\s*\\{else\\}\\s*\\-\\-\\>/s", "<? }else{ ?>", $template);
$template = preg_replace("/\\<\\!\\-\\-\\s*\\{\\/if\\}\\s*\\-\\-\\>/s", "<? } ?>", $template);
$template = preg_replace("/\\<\\!\\-\\-\\s*\\{\\/loop\\}\\s*\\-\\-\\>/s", "<? } ?>", $template);
if($file=="header"){
$template = "<? include_once '".$tpldir."templates_'.\\$charset.'.lang.php'; ?>\\n".$template;
}
$template = preg_replace("/\\?>[\\n\\r\\t]*<\\?/s", "\\n", $template);
$fp = fopen($objfile, 'w');
flock($fp, 2);
fwrite($fp, $template);
fclose($fp);
}//........
?>
[/php]
直接用editplus打开生成的文件看不到换行,
但是用highlight_file()显示这个文件的时候有换行。
不知道是怎么一回事。我该怎样才能使其换行。
如果直接用一段简单的程序用\n生成一个文件,直接打开也是看得到换行的。
[ 本帖最后由 danyja 于 2007-2-16 01:48 AM 编辑 ]


