I have followed the discussion on
I tried to do that myself, but it doesn’t work?
It returns “SyntaxError: expected expression, got ‘<‘ “, resulting in the function to be undefined.
This is my code (at least the important part):
“`
<button id=”button” onclick=”reverseKillSwitch()”> Kill switch is off </button>
<?php
function KillSwitch(){
$kys = fopen(“killswitch.txt”, “r”);
$data = fread($kys, 1);
$kysw = fopen(“killswitch.txt”, “w”);
if ($data == “1”) {
fwrite($kysw, “0”, 200);
echo “<script>document.getElementById(‘exampleModalLabel’).innerHTML = ‘Kill switch is off’ </script>”;
}
else {
fwrite($kysw, “1”, 200);
echo “<script>document.getElementById(‘exampleModalLabel’).innerHTML = ‘Kill switch is on’ </script>”;
}
}
?>
<script>
function reverseKillSwitch(){
var kill = <?php echo KillSwitch(); ?>
}
</script>
What am I doing wrong? I would just use Node.js but I can’t figure out how to add it to WAMP.
Any help would be appreciated!