IT이야기
PHP AH1071 Invalid argument supplied for foreach
영은파더♥
2020. 6. 12. 09:31
728x90
foreach 함수로 배열을 사용할때 변수값에 배열이 없으면 나는 에러군요~
AH01071: Got error 'PHP message: PHP Warning:
Invalid argument supplied for foreach() in /volume1/web/www/index.html on line 51
PHP message: PHP Stack trace:
PHP message: PHP 1. {main}()
AH01276: Cannot serve directory /volume1/web/www/:
No matching DirectoryIndex (index.html,index.htm,index.cgi,index.php,index.php5) found,
and server-generated directory index forbidden by Options directive
이런 경우 foreach 함수를 호출 하기전에 배열값이 있는지 먼저 확인하는 조건을 걸어주면 됩니다.
PHP 7.x 버전이면
if(!empty(배열변수)) {
foreach ...
}
이하 버전에서는
if(count(배열변수) > 0) {
foreach ...
}
항상 변수값을 체크하는 습관을 길러야 하겠습니다.
AH01276 에러는 해당 디렉토리에 index.html 파일이 없어서 생기는 오류입니다.
728x90
반응형