개발! 딱 깔끔하고 센스있게!

$ _POST 대 $ HTTP_RAW_POST_DATA 대 file_get_contents (php : // input)? [복제] 본문

개발 스크랩 메모/PHP

$ _POST 대 $ HTTP_RAW_POST_DATA 대 file_get_contents (php : // input)? [복제]

렉사이 2020. 12. 14. 22:39

Possible Duplicate:
What’s the difference between POST and raw POST in PHP at all?

더 이해할 수 있도록 post,$htp u post u post u data, file u get uconts (php://input)의 근본적인 차이를 설명해 주시면 감사하겠습니다.

언제 어느 것을 사용합니까?

대답

  1. $_POST contains URL encoded (application/www-url-encoded) variables that are posted to your script and PHP decodes them for you. You use this one when you deal with HTML FORM data.
  2. file_get_contents("php://input") - gets the raw POST data and you need to use this when you write APIs and need XML/JSON/... input that cannot be decoded to $_POST by PHP.
  3. $HTTP_RAW_POST_DATA - in theory it is the same as the above but depends on php.ini.

내가 비응용 프로그램 / www url 인코딩 입력을 필요로 할 때, 나는 항상 방법을 2, 방법을 3이 아니다.

Comments