How to read the query string in PHP and HTML?

前端 未结 3 387
悲哀的现实
悲哀的现实 2020-12-06 07:37

a URL ending with something like portal.php?key2=hello how can I get the value of \"key2\"?

相关标签:
3条回答
  • 2020-12-06 07:55
    $_GET['key2']
    

    will get you the value from a query string.

    $_POST['key2']
    

    will get you the value from a form posted.

    $_REQUEST['key2']
    

    will get you either of the above if it exists.

    0 讨论(0)
  • 2020-12-06 08:02
    var_dump( $_GET['key2'] );
    
    0 讨论(0)
  • 2020-12-06 08:03

    GET data is decoded into the $_GET super-global array. See http://php.net/manual/en/language.variables.external.php

    0 讨论(0)
提交回复
热议问题