Why does this result in Warning: Undefined variable $coin in C:\xampp\htdocs\test\index.php on line 16
<?php
$coin = 1;
if (array_key_exists('button1', $_POST)) {
button1();
}
function button1() {
$coin += 1; //error
echo $coin; //error
}
?>