Hello, I have this problem that I cannot get my variable to change more than once. For example, if I press the link that adds 1 to $hey’s value (which is 2 to start with) it then echoes 3. But, if I press it again, it still echoes 3. I got another code with this same problem but a lot more code for other things. I’ve tried to analyze the problem, but I just can’t find the solution :’(
Anyways, here’s the code:
[code]
<?php $hey = 2; function runMyFunction1() { echo 'I just ran php function1'; global $hey; $hey++; ?> <br>
<?php
echo "Blev plus 1: ".$hey;
}
function runMyFunction2() {
echo 'I just ran php function2';
global $hey;
?>
<br>
<?php
echo "Blev plus 0: ".$hey;
}
function runMyFunction3() {
echo 'I just ran php function3';
global $hey;
$hey--;
?>
<br>
<?php
echo "Blev minus 1: ".$hey;
}
if (isset($_GET['hello'])) {
runMyFunction1();
}
if (isset($_GET['cow'])) {
runMyFunction2();
}
if (isset($_GET['ninja'])) {
runMyFunction3();
}
?>
Run PHP Function +1
Run PHP Function +0
Run PHP Function -1
Thanks in advance
/failstar