Reputation: 379
I am trying to implement a little code in HTML; calling a PHP onclick in HTML using the solution here and it just runs to a blank page. Upon inspection, I noticed a typo in my code but after i corrected it the output is still the same i.e. it opens a blank page with no echo or anything.
My question: Is there a way to debug my code so my browser (i suspect) can notify me as to what part or line of my code the error is coming from, like in Java IDEs?
<?php
function working(){
echo 'WORKED ';
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Dice Game</title>
</head>
<body>
<div>
<div>
<h1 id="player1" onclick="document.write('<?php working(); ?>')">
ENTER PLAYER 1 NAME
</h1>
</div>
</div>
</body>
</html>
Note: I use Chrome
Upvotes: 0
Views: 1164
Reputation: 57
On Chrome or Firefox use F12
to Debug (Window) or simply right click any in page select Inspect Elements
then choose Console tabs
Upvotes: 0
Reputation:
You are "implementing a little code in HTML; calling a PHP onclick in HTML"
Firstly if your are using a php code in html, So extension of file should .php and there should be a server(ex. wamp,xamp,lamp) to run it. if it having extension .html then it will not show any error, because html files is compiled at browser lever and php is server side language. So if make right extension of your file means make ext .php then run you file, then if there will be any error then you will got message on browser also hinting line number of error.
Upvotes: 1
Reputation: 3270
Browsers like Firefox, Chrome, etc. have Developer Tools. Hit F12 to activate it and then look at Console, then reload the page. That should tell you what your errors are.
Upvotes: 1