Using $_POST or $HTTP_POST_VARS etc. ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • luftikus143
    New Member
    • Jan 2007
    • 97

    Using $_POST or $HTTP_POST_VARS etc. ?

    Hi there,

    I am using in principal the $HTTP_xxx_VARS since quite a while and have, because it seemed the $_POST was newer and "more efficient" slightly changed that little script which is running on my site:

    [PHP]if (sizeof($_POST) > 0)
    $HTTP_FORM_VARS = $_POST;
    elseif (sizeof($_GET) > 0)
    $HTTP_FORM_VARS = $_GET;
    else
    $HTTP_FORM_VARS = array("");
    [/PHP]

    Nevertheless, it seems when used in functions, $_POST is readable without problem whereas $HTTP_FORM_VARS isn't... Perhaps it's a problem of my script? Should I use $_POST generally?

    Thanks for any advice!
  • chromis
    New Member
    • Jan 2008
    • 113

    #2
    As far as I know $HTTP_POST_VARS etc are deprecated for php versions below 4.1.0. $_POST was introduced in this version. This link may help you some more:

    Almost every PHP developer is familiar with $_POST and $HTTP_POST_VARS arrays. Can you tell any significant difference between them? Well, you may think that there is no difference except that the …


    Hope this helps.

    Chromis

    Comment

    • Markus
      Recognized Expert Expert
      • Jun 2007
      • 6092

      #3
      Should I use $_POST generally?
      Yes. Yes. Yes!

      $_HTTP_blah is deprecated, as someone already mentioned. Therefore, should not really be used.

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by luftikus143
        ...
        Nevertheless, it seems when used in functions, $_POST is readable without problem whereas $HTTP_FORM_VARS isn't... Perhaps it's a problem of my script? Should I use $_POST generally?

        Thanks for any advice!
        The reason is because $_POST is a superglobal while those old things are just globals.
        Why not just replace references to those old things rather than aliasing them like you are trying to do? Also ensure that you've set register globals to off after removing those things from your code.

        Comment

        Working...