开发者

"Invalid argument supplied for foreach()" - What happens next?

开发者 https://www.devze.com 2022-12-16 01:48 出处:网络
If \"Invalid argument supplied for 开发者_JAVA百科foreach()\" is a \"warning\" in PHP and doesn\'t halt execution, where does the script execution continue from? After the foreach block? After the fun

If "Invalid argument supplied for 开发者_JAVA百科foreach()" is a "warning" in PHP and doesn't halt execution, where does the script execution continue from? After the foreach block? After the function? What happens next?


It continues after the foreach.


If I remember it correctly, PHP runs the loop with an empty array because that is the result of the dynamic type cast from "not an array" into "array".

So basically, it will skip the loop while wasting a little bit of CPU time. Effectively nothing happens.

0

精彩评论

暂无评论...
验证码 换一张
取 消