我想用fwrite來用PHP編寫下面的字符串,但我不能寫 字符串是寫是$config['xxx']
: 它顯示了錯誤 任何人可以幫助我嗎?使用php在文件中寫雙引號?
這裏是我的代碼
$stringData = "$config['xxx']";
fwrite($fh, $stringData);
我有以下錯誤
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in D:\xampplite\htdocs\PHP test\filecreate.php on line 6
哪些錯誤(我可以想像,一個或其他,但你應該添加這些到你的問題)?你想寫的文本原樣或變量的內容? – hakre
請參閱手冊中的轉義規則:http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.double - 您示例的實際問題是解析器期望PHP3風格的數組語法'print'$ config [xxx]「;'在雙引號內有效。 - 你的片段的實際目的是什麼? – mario