hi I write a php file that contains two methods :
1)
function restart(){ echo('restart') };
2)
function shutdown(){echo ('shutdown')};
then I include the index.php file to the foo.php and when I want to call index.php methods in an eventHandler in foo.php it doesn't work like this:
<?php
include ('index.php');
?>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<button id='res'>restart</button>
<button id='sht'>shutdown</button>
<script>
document.getElementById('res').addEventListener('click',function(){
console.log('restarted');
<?php
restart();
?>
})
</script>
</body>
</html>
output: nothing and no errors
and when I remove the php code inside the eventHandler it works! like this:
<?php
include ('index.php');
?>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<button id='res'>restart</button>
<button id='sht'>shutdown</button>
<script>
document.getElementById('res').addEventListener('click',function(){
console.log('restarted');
})
</script>
</body>
</html>
output: restarted
WHAT IS THE PROBLEM?