domingo, 23 de junio de 2019

difference $_ POST $HTTP_RAW_POST_DATA

  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.
I always use method #2 instead of #3 when I need non application/www-url-encoded input.

No hay comentarios:

Publicar un comentario