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.