出现这个问题就是空格造成的(可清空格符,换行符等)
示例代码如下:
php 下报错
<?php
echo "<a href=javascript:if(window.confirm('Are you Sure ?')){window.location.href='xxxx'; }>xxxxxx</a>"; // 会出错就是空格的问题
echo "<a href=javascript:if(window.confirm('Sure?')){window.location.href='xxxx'; }>xxxxxx</a>"; // 去空格正确
echo "<a href="javascript:if(window.confirm(' Are you Sure ?')){window.location.href='xxxx'; }">xxxxxx</a>"://用双引号正确
?>