-1

我将一些内容放入名为“index.php”的文件中,代码如下:

$put=<<<DEMO
<div id='container' style='width:100%'>
<style>
h1 {font-size:45px;}
</style>
<div id='header' style='background-color:#FFFFFF;'>
<h1 style='margin-bottom:0;margin-top:0;height:20%;float:center;'>
while($row = mysql_fetch_array($result))
{

第 108 行

<table align='left'><tr><td><img src="$row['Website_Name']/index.jpg" align='center' width='240' height='170'></td></tr></table>
 <table align='center'><br><tr><td><h1>$row['Business_Name']</td></tr></table>
 }

</h1></div>
</div>

DEMO;
file_put_contents("$str/index.php","$put");

但是在浏览器中运行代码时,出现错误:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in E:\Program Files\xampp\htdocs\registration.php on line 108
4

1 回答 1

1

你的问题是你的变量插值语法。要么是

"$var[foo]"

或者

"{$var['foo']}"

不是

"$var['foo']"

阅读: http: //php.net/manual/en/language.types.string.php#language.types.string.parsing

于 2013-02-16T14:21:11.450 回答