-1
我正在做一个设置页面,人们可以写自己的数据库登录等,然后将创建它们与Web服务器的信息一个config.php文件,但显然我不能只是写
$file = fopen("config.php", "w");
fwrite($file, "$dbName = $dbName");
其实我试过
$file = fopen("config.php", "w");
fwrite($file, "$" . "dbName = $dbName");
但这也行不通。
任何方式将它作为PHP变量存储在我使用PHP编写的文件中?
使用单引号代替双引号 –
'的fwrite($文件, '$ DBNAME'。 “= $ dbName”);' – Farkie
有关参考,请参见[PHP:Strings](http://php.net/manual/en/language.types.string.php)和[...单引号和双引号字符串...](http://stackoverflow.com/questions/3446216/what-is-the-difference-between-single-quoted-and-double-quoted-strings-in-php) – showdev