Re: Variable Passing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* Jordi Canals <jcanals@xxxxxxxxx>:
> What I do to control it only by PHP without using the mod_rewrite for
> apache is to use URL with this format:
>
> http://sample.com/script.php/param1/param2/param3
>
> Then, work in the script looking at the variable
> $_SERVER['REQUEST_URI'] wich will contain, in this sample:
> /script.php/param1/param2/param3
>
> You can explode the uri in an array:
>
> $params = explode('/', substr($_SERVER['REQUEST_URI'], 1);
> I used the substr dunction to remove the first slash.
>
> On the resulting array you will have, by index
>
> [0] = script.php
> [1] = param1
> [2] = param2
> [3] = param3
>
> This works with Apache. I've not tested it on IIS, but suspect that it
> will not work on ISS.

I noted in a previous post, you can also do this using
$_SERVER['PATH_INFO'] (though the first element from exploding will be
the first parameter, and not the script name) -- and, to my
understanding, this *does* work with IIS. (Somebody, correct me if I'm
wrong.)

Another note -- you can still pass a query string with either method --
which can make for some nice behaviour as well.

> On Apr 8, 2005 4:11 PM, Brad Brevet <bradbrevet@xxxxxxxxxxxxxxxxx> wrote:
> > Hi, I am curious how to pass a variable without using something like id=321.
> > 
> > I have seen sites that have something like
> > http://www.website.com/something/321 and the variable is passed how exactly
> > is that done? And is it called something specific so I know how to refer to
> > it in the future?

-- 
Matthew Weier O'Phinney           | WEBSITES:
Webmaster and IT Specialist       | http://www.garden.org
National Gardening Association    | http://www.kidsgardening.com
802-863-5251 x156                 | http://nationalgardenmonth.org
mailto:matthew@xxxxxxxxxx         | http://vermontbotanical.org

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux