Ask a question about the foreach () function

Source: Internet
Author: User
Ask a question about the foreach () function: PHP Warning: Invalid argument supplied for foreach () in C: \ inetpub \ wwwroot \ hp \ client_list.php on line 126
Foreach ($ idcheck as $ u => $ s) // This foreach write method reports an error


Is there any way to solve this error problem without changing the original sentence (the original sentence is used in many places on the website)? Besides (blocking the error reporting function) can php. ini be changed to implement this function? Solution!


Reply to discussion (solution)

If a problem occurs, take the initiative to solve it, rather than avoiding it.

The problem should be solved at the source rather than remedy afterwards.
Make sure that $ idcheck is an array (even an empty array ).

foreach($idcheck as $key =>$s) 

Don't let code change, don't block errors ...!

If a problem occurs, take the initiative to solve it, rather than avoiding it.

The problem should be solved at the source rather than remedy afterwards.
Make sure that $ idcheck is an array (even an empty array ).



Many projects are written using this function. there are more than 30 items. now all PHP upgrades have reported errors, so we hope to have a systematic solution, otherwise, a project and a project will be modified... Understanding

Added:
Error_reporting (0); // Close the error report
?> Try

Or
In php. ini · All errors close display_errors = Off; try.

Added:
Error_reporting (0); // Close the error report
?> Try

Or
In php. ini · All errors close display_errors = Off; try.



Thank you. you still need to change the 1L method to an array.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.