디버그

문제가 생겼을 때 찾을 수 있게



JavaScript 에서 에러

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">

  </head>
  <body>
    <script type="text/javascript">
      doccument.write("Hello world");
    </script>
  </body>
</html>


document 라고 써야 하는데 doccument 라고 썼을 때, 웹브라우저의 도움을 받으면 오타를 쉽게 찾을 수 있다. 

크롬 -> 오른쪽 상단의 세로로 점 세개 클릭 -> 도구 더보기 -> 개발자 도구 -> Console 클릭




위와 같은 에러 화면 확인 가능 



php 에서 에러

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">

  </head>
  <body>
    <script type="text/javascript">
      document.write("Hello world");
    </script>
    <?php
        

  </body>
</html>


위와 같이 php를 닫기를 안해주었다. 그러면

 


이러한 화면이 나온다. 에러를 찾는 방법은 

Atom -> File -> Openfile -> Wampstack -> apache2 -> logs -> error.log 클릭

txt 중에서 가장 밑에 있는 내용이 가장 최근에 발생한 error. 

[Mon Dec 18 20:02:23.691878 2017] [php7:crit] [pid 8896:tid 924] [client ::1:63567] PHP Parse error:  syntax error, unexpected '<', expecting end of file in C:\\Bitnami\\wampstack-7.1.12-0\\apache2\\htdocs\\phpjs\\3.php on line 14

이러한 에러메세지를 확인하고 에러 수정 가능 하다. 



보충수업 - error를 찾아서 보지 말고 error메세지를 화면에 바로 띄우게 해주기.

php.ini를 연다. (php폴더 안에 있다.)

Ctrl + F 로 display_errors 를 연다. 

477라인의 display_errors 를 On으로 바꿔준다. 

wamp-manager에서 Manage Servers에서 Restart를 누른다.   






















'웹 프로그래밍' 카테고리의 다른 글

자바스크립트, PHP로 로그인 기능 구현하기  (0) 2017.12.19
변수  (0) 2017.12.18
데이터타입과 연산자  (0) 2017.12.18
웹 페이지에 코드 삽입하기  (0) 2017.12.18
PHP &amp; JavaScript  (0) 2017.12.18

+ Recent posts