PHP で HTML ファイルを作成する際に問題があります。
私はこの機能を持っています:
function openHTML ($file) {
if (file_exists($file)) {
$handle = fopen($file, "r");
$output = fread($handle, filesize($file));
fclose($handle);
return $output; // output file text
}else{
return "This file is not exists";
}
}
function saveHTML ($file,$string) {
$a = fopen($file, 'w');
fputs($a,stripslashes($string));
fclose($a);
return "success";
}
使っopenHTMLているときは大丈夫です。しかし、残念ながら、私が開いたファイルopenHTML()にはいくつか&あり、次に保存してsaveHTML()いますが、保存する文字列またはコードは char で停止しています&。
例:更新!
で空白を開きfile.html、openHTML()次の文字列を入力し始めます。
<html>
<head>
</head>
<body>
This is my login page & user page
</body>
</html>
コードで保存した後saveHTML():
<html>
<head>
</head>
<body>
This is my login page
最後にコードが欠落しています。で失速&。
私は、、、を使用しfputsてutf8_encodeいfwriteますfile_put_contents。まだ解決していません。