Home >> Snippet List >> Snippet

Call a PHP function when clicking on an HTML button
Use the onclick() event listener in the button to call a Javascript function that will call the PHP function Note that if any variables are declared as GLOBAL in the PHP function, they must be assigned values before the Javascript function is parsed by the HTML interpreter
PHP Snippet
function echoHello(){
 alert("<?PHP hello(); ?>");
FUNCTION hello(){
 ECHO $a;