Home > Article > Backend Development > Solution to foreach prompt Warning:Invalid argument supplied for foreach() under php, foreachsupplied_PHP tutorial
The example in this article describes the solution to the foreach() error message Warning: Invalid argument supplied for foreach() under PHP. Share it with everyone for your reference. The specific implementation method is as follows:
1. Question:
Foreach() error message under php Warning: Invalid argument supplied for foreach()
Error message: Warning: Invalid argument supplied for foreach() in E:wampwwwmyshopcart.php on line 95
2. Solution:
The error message Warning:Invalid argument supplied for foreach() in Chinese means that foreach needs to be an array and an invalid parameter is given to it.
Just add a judgment before the loop and directly use is_array to judge whether the given value is an array. The code is as follows:
I hope this article will be helpful to everyone’s PHP programming design.