テキストファイルを開いて文字列を置き換える必要があります。私はこれが必要ですPHPを使用してテキストファイルに文字列を置き換えます。
Old String: <span id="$msgid" style="display: block;">
New String: <span id="$msgid" style="display: none;">
これはこれまで私が持っていたものですが、余分な空白の他にテキストファイルに変更はありません。
$msgid = $_GET['msgid'];
$oldMessage = "";
$deletedFormat = "";
// Read the entire string
$str = implode("\n", file('msghistory.txt'));
$fp = fopen('msghistory.txt', 'w');
// Replace something in the file string - this is a VERY simple example
$str = str_replace("$oldMessage", "$deletedFormat", $str);
fwrite($fp, $str, strlen($str));
fclose($fp);
どうすればいいですか?あなたのコメントへ
$msgid = $_GET['msgid'];
$oldMessage = "";
$deletedFormat = "";
//read the entire string
$str=file_get_contents('msghistory.txt');
//replace something in the file string - this is a VERY simple example
$str=str_replace("$oldMessage", "$deletedFormat",$str);
//write the entire string
file_put_contents('msghistory.txt', $str);
msghistory.txtファイルの書き込み権限 – Lobo
これは正しいですか? '$ deletedFormat =" "';' –
構文エラーがあります。 '$ deletedFormat =" "';'あなたは余分な一重引用符を持っています。 –