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;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.