Re: variables via / (again)

From: Date: Sat, 06 Oct 2001 05:33:32 +0000
Subject: Re: variables via / (again)
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-70203@lists.php.net to get a copy of this message
Why are you specifying $script? Explode into an array instead; check the length for a known number of variables (or pop from the end if not static) depending on what your script needs. If you do need to point at a specific script without using the extension "script.php/foo/bar", redirect Apache for location /script as in the original thread <Location "/script"> ForceType application/x-httpd-php </Location> which will execute script/foo/bar as script.php/foo/bar. You can further choose script execution based on path variables, by using "if (isset($foo)) require(some_script.php)" in script.php or use multiple redirects for script that require different number and type of variables passed to them: domain.com/script_homepage/foo/bar domain.com/script_userpage/username/pref1/pagename.html Best regards, Andrew Hill On Saturday, October 6, 2001, at 01:09 AM, Ashley M. Kirchner wrote:
    Okay, so I have the following in my script:
      list($script,$var1,$var2) = explode('/',$_SERVER["PATH_INFO"]);
    ...now, this is assuming the URL is at
http://www.domain.com/script/foo/bar
    ...which would make $script = script, $var1 = foo and $var2 = bar
    How do people deal with scripts that are in other locations?
Manually change that 'list/explode' line every time? -- H | "Life is the art of drawing without an eraser." - John Gardner +-------------------------------------------------------------------- Ashley M. Kirchner <mailto:ashley@pcraft.com> . 303.442.6410 x130
  Director of Internet Operations / SysAdmin    .     800.441.3873 x130
  Photo Craft Laboratories, Inc.            .     3550 Arapahoe Ave, #6
  http://www.pcraft.com ..... .  .    .       Boulder, CO 80303, U.S.A.
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net


« previous php.general (#70203) next »