Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set $_GET variable

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

like image 339
dave Avatar asked Mar 24 '11 05:03

dave


People also ask

How does $_ GET WORK?

PHP $_GET is a PHP super global variable which is used to collect form data after submitting an HTML form with method="get". $_GET can also collect data sent in the URL. When a user clicks on the link "Test $GET", the parameters "subject" and "web" are sent to "test_get.

What is the difference between the $_ GET [] and $_ POST [] Superglobals?

These are superglobals, which means that they are always accessible, regardless of scope - and you can access them from any function, class or file without having to do anything special. 3) $_GET is an array of variables passed to the current script via the URL parameters.

What is $$ variable in PHP?

Syntax: $variable = "value"; $$variable = "new_value"; $variable is the initial variable with the value. $$variable is used to hold another value.


1 Answers

$_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.

like image 131
Pascal MARTIN Avatar answered Sep 19 '22 14:09

Pascal MARTIN