note 54485 added to reserved.variables
| From: | andy dot gajetzki at gmail dot com | Date: | Wed, 06 Jul 2005 01:22:12 +0000 |
| Subject: | note 54485 added to reserved.variables | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-91495@lists.php.net to get a copy of this message | ||
I wanted to be able to embed a variable in the path. This is useful when, for example, images are
rendered on the fly and you would like them to have different urls.
Here is an illustration:
www.somesite.com/image.php/IMAGETEXTHERE
This would return an image with the text after "image.php/" contained in it.
I could not recall the name of this feature, so I made a work-around in PHP...
<?
function getPathVariables() {
$sPathPS = $_SERVER[PHP_SELF];
$sPathFS = __FILE__;
$aPathPS = array_reverse(explode("/", $sPathPS));
$aPathFS = array_reverse(explode("/", $sPathFS));
$aImageArgs = array();
$x = 0;
while ( $aPathPS[$x] != $aPathFS[$x] && $aPathPS[$x] != $aPathFS[0] ) {
array_unshift($aImageArgs, $aPathPS[$x]) ;
$x++;
}
return $aImageArgs;
}
?>
This function will return an array containing each "/" delimited portion of the path after
the script name itself.
----
Manual Page -- http://www.php.net/manual/en/reserved.variables.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+54485
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54485&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54485&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54485&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54485&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54485&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54485&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+54485&report=yes
Search -- http://master.php.net/manage/user-notes.php