Warning: Invalid argument supplied for foreach() di PHP

Operator ModulusOperator Modulus

Pamulang – Kebiasaan ngeblok warning biar ga nongol dan akhirnya risih aja pas gunain foreach, nongol itu warning Invalid argument supplied for foreach(). Menururt gw sih kayaknya itu warning nongol gegara nilai array itu jangan NULL alias kosong. Kasus gw disini coba gw jabarin biar enak ngintip kodenya..

Class buat manggil data news..

Kode awal yg gw gunain akhirnya muncul itu warning..

Karena kebiasaan di fungsi itu gw masupin fungsi biar warning ga nongol, jadinya gw pikir kode ini ga masalah. Dan ternyata pas dieksekusi nongol dah itu warning.. Lanjut ke bagian ngatasin masalahnya…

Kode lengkapnya..

DONE!!! Semoga bermanfaat, salam 🙂

About the Author

Anshori Wahyu

My name is Mas Wahyu Anshori, 32 years old. I am a student from STIE Ahmad Dahlan Jakarta, work at Seratus Company since Oct 2012. Before I came to Seratus Company, I was doing web content at Melodia Group and be part of Kehati as a freelance web developer. I was also a freelance web developer with simple HTML, CSS base, jQuery, and PHP. Learned HTML and CSS base (with a help of Google) by myself would be my achievement so far. I’am an Indonesian football junkie, as well as addicted to HTML, CSS and jQuery coding.

Be the first to comment on "Warning: Invalid argument supplied for foreach() di PHP"

Leave a Reply