Re: How to pass variables to php functions from url's?

From: Date: Fri, 07 Sep 2001 12:31:48 +0000
Subject: Re: How to pass variables to php functions from url's?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-66398@lists.php.net to get a copy of this message
> > > Let's assume we have a server called www.test.com > > > When a user access http://www.test.com/path/username, > > > I want a php script to execute, as if the url entered was > > > http://www.test.com/path.php?value=username. > > > > > > I'm running PHP 4.0.6 on Apache 1.3.20. Step 1: Rename "path.php" to "path" Step 2: Add this to your Apache conf file: <Location /path> ForceType application/x-httpd-php </Location> This causes "path" to be executed as a PHP script even though it does not have a .php extension. Step 3: Add this to your "path" php script: // $PATH_INFO = the rest of the URI after dmb/ // remove anything other than letters, numbers, dots, underscores, // and dashes, and put into an array // for example "trading/toptraders" will be an array consisting // of "trading" ($args[1]) and "toptraders" ($args[2]). The / is discarded. ereg("(^[-_.\/a-zA-Z0-9]*$)", $PATH_INFO, $arg); $args = split( "/", $arg[1]); Hope this helps. Doug Granzow dig@cynosure.net

« previous php.general (#66398) next »