Server Language/PHP40 AH02429: Response header name 'Last-Modified ' 에러 AH02429: Response header name 'Last-Modified ' 에러는 문서 상단에 header로 Ladt-Modified를 설정할 때 나타난다. header("Last-Modified: " .gmdate("D, M Y H : i: s") . " KST"); 형식으로 보통 많이 쓰는데 "Last-Modified: " 에서 공백이 들어가 나타나는 경우가 많다. 그러므로 아래와 같이 바꿔주자. 예시) header("Last-Modified: ".gmdate("D, M Y H : i: s") . " KST"); // Bad; header("Last-Modified:".gmdate("D, M Y H : i: s") . " KST"); // Good! Server Language/PHP 2020. 3. 10. PHP Fatal error: Uncaught Error: Call to undefined function 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(); } Server Language/PHP 2020. 3. 10. PHP Fatal error: Cannot redeclare function() (previously declared in ~) 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(){.. Server Language/PHP 2020. 3. 10. PHP Warning: sizeof(): Parameter must be an array or an object that implements Countable in PHP Warning: sizeof(): Parameter must be an array or an object that implements Countable in sizeof()함수를 사용할 때 array 혹은 object타입인지 체크를 하지 않아서 생기는 오류. 예시) sizeof($string); // Bad; if(is_array($stirng) || is_object($stirng)){ sizeof($string); // Good! } Server Language/PHP 2020. 3. 10. [Deprecated] session_is_registered() 대체 session_is_registered(), session_register() 는 deprecated되었다. 대체로 isset($_SESSION['session']), $_SEESION['session'] 으로 사용 가능. 예시) // Bad session_is_registered('seesion'); //Good isset($_SESSION['session']); Server Language/PHP 2020. 3. 10. [Deprecated] mysql 대체 [convert mysql to mysqli] mysql_connect mysql_select_db 등 mysql 함수가 deprecated되면서 mysqli 함수로 변경해 주어야 한다. 예시) //BAD $connect = mysql_connect($mysql_host,$mysql_user,$mysql_pw); mysql_select_db($mysql_db, $connect); mysql_query($query); mysql_affected_rows(); mysql_fetch_array($result); mysql_escape_string($string); //GOOD $connect =mysqli_connect($mysql_host,$mysql_user,$mysql_pw); mysqli_select_.. Server Language/PHP 2020. 3. 10. [Deprecated] $HTTP_GET_VARS 대체 // Bad; $HTTP_GET_VARS['get']; // Good; $_GET['get']; $HTTP_GET_VARS는 $_GET로 대체 가능 Server Language/PHP 2020. 3. 10. [Deprecated] $HTTP_POST_VARS 대체 $HTTP_POST_VARS는 $_POST로 대체 가능 // Bad $HTTP_POST_VARS['post']; // Good $_POST['post']; Server Language/PHP 2020. 3. 10. [Deprecated] $HTTP_COOKIE_VARS 대체 $HTTP_COOKIE_VARS는 $_COOKIE로 대체 가능 // Bad $HTTP_COOKIE_VARS['cookie']; // Good; $_COOKIE['cookie']; Server Language/PHP 2020. 3. 10. PHP Warning: Division by zero in PHP Warning: Division by zero in 주로 값이 0인 변수를 가지고 수식계산을 할 때 나타난다. 해결방법은 값이 0일때는 계산식에 들어가지 않게 분기처리 해준다. 예시) // Bad; $test = 0; $test2 = $test / 2; // Good! if($test != 0){ $test2 = $test / 2; } Server Language/PHP 2020. 3. 10. PHP Warning: Creating default object from empty value in PHP Warning: Creating default object from empty value in Object형식이 아닌 변수 혹은 empty value를 Object 형식으로 사용할 때 주로 나타나는 오류. 예시) // Bad; $stirng->etc->emai = 'email'; // Good! if(!isset($stirng->etc) || !is_object($stirng->etc)) { $stirng->etc = new stdclass(); $stirng->etc->emai = 'email'; } Server Language/PHP 2020. 3. 10. PHP Fatal error: Cannot use isset() on the result of an expression PHP Fatal error: Cannot use isset() on the result of an expression isset()함수를 사용할 때 안에 값에 변수에 $ 안붙였을 때 많이 발생. 예시) isset(test); // Bad; isset($test); // Good; Server Language/PHP 2020. 3. 9. 이전 1 2 3 4 다음