PHP오류

· Language/PHP
PHP Warning copy() expects parameter 1 to be a valid path, array given in 해결하기 1.copy() expects parameter 1 to be a valid path, array given in 오류 내용 로컬에서 파일 업로드 후 업로드한 파일에 대해 copy()함수 를 사용 할 때 많이 나타남. copy() 의 첫번째 parameter 1개 값이 파일값이 들어가야 하는데 배열,파일명 등이 가서 에러가 남. 2.해결방법 copy 함수의 첫 parameter 값이 제대로 나와있는지 확인해야 함. 파일 업로드시 ['name'] 값이 아닌 ['tmp_name'] 값으로 넘겨야 함. // bad copy($file,"/home/mingyu/testco..
· Language/PHP
PHP Fatal error: Uncaught Error: Call to undefined function 주로 사용하고자 하는 함수가 선언되지 않았을 때 나타나는 오류. function을 사용 할 때 function명을 올바로 썼는지 혹은 function이 선언되어 있는지 확인해야 한다. 예시) // Bad; @include_once('/data/funcstions.php'); $test = call_the_function(); // Good! @include_once('/data/funcstions.php'); if(function_exists('call_the_function')){ $test = call_the_function(); }
· Language/PHP
PHP Fatal error: Cannot redeclare function() (previously declared in ~) 주로 상단에 include한 파일중에 이미 선언된 function 이름과 같은 function을 또 선언했을때 나타나는 오류. function_exists()로 선언하고자 하는 function 이름이 이미 선언되어 있는지 체크 필요. 예시) // Bad; @include_once '/data/functions.php'; function test_function(){ } // GOOD! @include_once '/data/functions.php'; if(function_exists('test_function') == false){ function test_function(){..
· Language/PHP
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){} }
· Language/PHP
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');
· Language/PHP
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'] ;
MingyuKim
'PHP오류' 태그의 글 목록

페이지 로딩중입니다. 잠시 기다려주세요!

민규의 블로그

도움이 되셨다면 구독 부탁합니다!