2019-07-21 10:59
浏览 152

如何在PHP代码中放入html href按钮

I'm trying to put an html href button inside of my php code, but when I run it, I get an error message saying "This Page Isn't Working."


echo "<button onclick="location.href='phpfile.php';">My Button</button>";

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dph87312 2019-07-21 11:06

    Either you need to escape the HTML double quotes:

    echo "<button onclick=\"location.href='phpfile.php';\">My Button</button>";

    Or the Javascript single quotes:

    echo '<button onclick="location.href=\'phpfile.php\';">My Button</button>';

    By the way,

    This Page Isn't Working.

    Means a 500 error, which means your php script does not compile. Most of the time it is due to syntax errors.

    打赏 评论

相关推荐 更多相似问题