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."
<?php
echo "<button onclick="location.href='phpfile.php';">My Button</button>";
?>
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.