How to set $_GET variable

前端 未结 9 470
梦如初夏
梦如初夏 2020-12-03 21:22

How do i set the variable that the $_GET function will be able to use, w/o submitting a form with action = GET?

9条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-03 21:37

    $_GET contains the keys / values that are passed to your script in the URL.

    If you have the following URL :

    http://www.example.com/test.php?a=10&b=plop
    

    Then $_GET will contain :

    array
      'a' => string '10' (length=2)
      'b' => string 'plop' (length=4)
    


    Of course, as $_GET is not read-only, you could also set some values from your PHP code, if needed :

    $_GET['my_value'] = 'test';
    

    But this doesn't seem like good practice, as $_GET is supposed to contain data from the URL requested by the client.

提交回复
热议问题