RE: Newbie Question: How to pass URL info to .php script ?

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

 



Have you tried CodeIgniter http://www.codeigniter.com?

Not as restrictive as many MVC frameworks and very easy to work with.

What you wish to achieve can be done with one line.

$myvar = $this->uri->segment(2);

http://codeigniter.com/user_guide/libraries/uri.html

Likely not to everyone's taste but on a personal level I think it's one of
the better MVCs about.
 
Bob.

-----Original Message-----
From: Ethan Whitt
Sent: 19 June 2008 17:19
To: Nathan Nobbe
Cc: php-general@xxxxxxxxxxxxx
Subject: Re:  Newbie Question: How to pass URL info to .php script ?

I pasted your example in and it doesn't work for me (again, newbie).  I will
play with it and see if I can get it working.  My main goal is to have
Ruby-like URL's vs "?var=3425".  Is this possible with .php (without
mod_rewrite / something in the http server?)
Thanks,

Ethan




On Wed, Jun 18, 2008 at 9:59 PM, Nathan Nobbe <quickshiftin@xxxxxxxxx>
wrote:

> On Wed, Jun 18, 2008 at 10:45 PM, Ethan Whitt <ethan.j.whitt@xxxxxxxxx>
> wrote:
>
>> Not sure how to achieve this.  How can I grab a portion of a URl to send
>> to
>> a .php script in this fashion?
>>
>> www.test.com/article/3435   <- Grab the "3435" to process in a script?
>
>
> take a look at the $_SERVER superglobal array,
>
> http://www.php.net/manual/en/reserved.variables.server.php
>
> most likely you are looking for, $_SERVER['PATH_TRANSLATED'], but it
really
> depends on what you want out of the url, so make sure to read through the
> options, and their explanations.  those values are just strings, so its
> quite easy to extract portions of the string using a variety of
techniques.
> for example, give the url in your question (suppose we find it in
> $_SERVER['PATH_TRANSLATED'])
>
> $lastPath = substr($_SERVER['PATH_TRANSLATED'],
> strrpos($_SERVER['PATH_TRANSLATED']), '/') + 1); // $lastPath = '3435'
>
> -nathan
>


-- 
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