Folks,
Look at this tutorial.
Function: array_key_exists()
[code]
<!DOCTYPE html>
<html>
<head>
<title>
How to call PHP function
on the click of a Button ?
</title>
</head>
<body style=”text-align:center;”>
<h1 style=”color:green;”>
GeeksforGeeks
</h1>
<h4>
How to call PHP function
on the click of a Button ?
</h4>
<?php
if(array_key_exists(‘button1’, $_POST)) {
button1();
}
else if(array_key_exists(‘button2’, $_POST)) {
button2();
}
function button1() {
echo “This is Button1 that is selected”;
}
function button2() {
echo “This is Button2 that is selected”;
}
?>
<form method=”post”>
<input type=”submit” name=”button1″
class=”button” value=”Button1″ />
<input type=”submit” name=”button2″
class=”button” value=”Button2″ />
</form>
</head>
</html>
In the code, where is the array that lists the buttons ?
I don’t see any array like these:
$buttons = array(‘button_1′,’button_2’);
$buttons = array(‘0’=>’button_1′,’1′->’button_2’);
Or is php checking inside the built-in fuction ? Which built-in function ? Super Global $_POST ?
$GLOBALS[$
Did I write the Super Global correctly ?