Server Language64 PHP Warning: Use of undefined constant string - assumed 'string' PHP Warning: Use of undefined constant string - assumed 'string' 배열을 사용할 때 많이 나는 warning으로, 배열[string] 형태로 값을 사용 할 때 쿼테이션을 안붙여서 주로 발생. 예시) $string[test] = 'test' ; //Bad; $string["test"] = 'test' ; //Good! Server Language/PHP 2020. 3. 9. PHP Warning: Invalid argument supplied for foreach() in PHP Warning: Invalid argument supplied for foreach() in foreach 반복문을 사용 할 때, 매개변수 배열값에 대한 null 혹은 공백 사전 필터링을 하지 않아서 값이 없는 배열 혹은 Object로 반복문을 실행하여 나는 오류. 아래의 형식으로 고쳐 쓸 수 있다. 예시) // Bad; foreache($test as $key){ } // Good! if(isset($test) && (is_array($test) || is_object($test)) ){ foreache($test as $key){} } Server Language/PHP 2020. 3. 9. PHP Warning: htmlspecialchars(): charset 'euc_kr' not supported, assuming utf-8 in PHP Warning: htmlspecialchars(): charset `euc_kr' not supported, assuming utf-8 in Error 예시) 1] htmlspecialchars(iconv('euc-kr','utf-8',$string)) 2] htmlspecialchars($string) 위 형태로 코딩할 때 주로 나타나는 것 같음. Error 해결 예시) // Good! htmlspecialchars(iconv("euc-kr", "utf-8",$string),ENT_QUOTES,'ISO-8859-1'); htmlspecialchars($string,ENT_QUOTES,'ISO-8859-1'); Server Language/PHP 2020. 3. 9. PHP Warning: Illegal string offset ' ' in PHP Warning: Illegal string offset ' ' in 에러는 string 형태의 변수 뒤에 오프셋 형태로 '인자'값을 붙여서 나는 에러. 주로 string 문자열 변수를 array 배열로 착각하여 변수 뒤에 오프셋 값을 넣을 때 나타나는 것 같다. 예시) $test = "테스트 입니다."; //Bad; echo $test['test'] ; // PHP Warning: Illegal string offset 'test' in /*.html on line xxxx // Good! if(is_array($test)) echo $test['test'] ; Server Language/PHP 2020. 3. 9. 이전 1 ··· 3 4 5 6 다음