$html .= '<a onmouseout="document.getElementById('title').style.display='none'" onmouseover="document.getElementById('title').style.display='block'" href="http://www.google.com" target="_blank">'
$html .= 'Over me'
$html .= '</a>'报错:Parse error: syntax error, unexpected T_STRING
怎么写规范呢?
$html .= 'Over me'
$html .= '</a>'报错:Parse error: syntax error, unexpected T_STRING
怎么写规范呢?
$html="<a onmouseout=document.getElementById('title').style.display='none' onmouseover=\"document.getElementById('title').style.display='block' href='\"http:\/\/www.google.com' target='_blank'>'";
$html='Over me';
$html='</a>';
?>
说实话,没有完全看懂你要怎么写,不过可以给你提点我发现的问题
第一、给一个变量赋值,不需要用“.”连接,如你的$html.='Over me',这个应该写成$html="Over me";
第二、在php中插入html或者js代码,要尽量少用“"”,一般尽可能使用单引号,这样会减少你的麻烦,当然实在无法使用单引号,就得用双引号,但记住要用转义符“\”,如果用双引号就应该写成“\"”,这样可以合php中的双引号区别开来。
第三、还是转义字符,如你输入网址,一定要写成“http:\/\/www.……”,这样的格式就不会报错了
<a target="_blank" www.google.com="" \="" http:\="" onmouseover="document.getElementById('title').style.display='block' href='" onmouseout="document.getElementById('title').style.display='none'">Over me</a>
$html='Over me';
$html='</a>';请高手们再帮我检查一下,这样对不对?
在连续的对 $html 赋值后,$html 的值为 </a>最好写作
$html =<<< HTML
<a onmouseout="document.getElementById('title').style.display='none'"
onmouseover="document.getElementById('title').style.display='block'"
href="http://www.google.com" target="_blank">Over me</a>
HTML;