This is a simplified version of what I want to accomplish:
In my script I want a variable that changes true and false everytime the script is executed.
<?php
static $bool = true;
// Print differente messages depending on $bool
if( $bool == true )
echo "It's true!";
else
echo "It's false!";
// Change $bools value
if( $bool == true )
$bool = false
else
$bool = true;
?>
But obviously what I'm doing is wrong. The variable $bool
is constantly true
and I haven't fully grasped the concept of static variables I presume. What am I doing wrong?