faqts : Computers : Programming : Languages : PHP : Common Problems : Variables

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

13 of 16 people (81%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

Passing a variable from a URL - I can echo variables from within the PHP file, but not from the URL.

Feb 20th, 2005 08:50
Philip Olson, Midavalo,


Most likely this is because you assume the PHP directive
register_globals is on when it's off. Regardless, the following will
work for (GET) variables from the URL (QUERY_STRING).
  http://www.example.com/index.php?fruit=apple&color=red
  echo $_GET['fruit']; // apple
  echo $_GET['color']; // red
This is further described here:
  http://php.net/variables.external
Note that variables "from the URL" are GET variables as they come from
the QUERY_STRING.