Thank you. This works great.
Quote:
Originally Posted by CrazeD Your function works, however you have a scope problem. By default, functions don't inherit variables from the rest of the script. It has no idea that $bg was ever initialized.
To fix this, just add global $bg; to the top of your function. PHP Code: <?php
function backgroundColor() {
global $bg;
if ($bg == 'yes') {
echo '';
$bg = 'no';
}
elseIf ($bg == 'no') {
echo 'bgColor';
$bg = 'yes';
}
else {
echo 'error';
}
}
$bg = 'no';
?> |