I am trying to set some dynamic variables to NULL to avoid the "Warning: Undefined variable" warning. I am using this piece of code:
$i = 1;
while($i <= 15){
if(!isset(${"ss".$i})){
${"ss".$i} = null;
$i = $i + 1;
}
}
However, it just times out at 60 seconds Fatal error: Maximum execution time of 60 seconds exceeded in /www/sites/164/edit.php on line 94
Any idea why this is happening?
You only increase $i inside the IF statement. If the IF is false, it'll be trapped in an infinite loop.
You're getting in infinite loop. Change your code to:
$i = 1;
while($i <= 15) {
if(!isset(${"ss".$i})){
${"ss".$i} = null;
}
$i = $i + 1;
}
I suggest you use Error Control Operators to suppress the warnings instead of having to run that loop every time.