#3 Automatic path detection

Wishlist
closed-later
nobody
Other (26)
1
2000-06-09
2000-04-11
Gerard Hickey
No

I include the following bit of code in all of my PHP scripts so that they know where they are being called from. This way I do not have to create a configuration variable to hold the path which will break the app when moved without updating the variable. It would be nice if you modified the code below and included it into new versions.

# Generate the local paths to be used
if (! isset ($SELF)) {
# Make some variables to point back to me
if ($PATH_INFO) {
$SELF = ereg_replace ($PATH_INFO, "", $PHP_SELF);
$SELF_BASE = ereg_replace ("/[^/]*$", "" , $SELF);
$IMAGES = sprintf ("%s/images", $SELF_BASE);
$SELF .= "$PATH_INFO";
} else {
$SELF = $PHP_SELF;
$SELF_BASE = ereg_replace ("/[^/]*$", "" , $SELF);
$IMAGES = sprintf ("%s/images", $SELF_BASE);
}
}

Discussion

  • David Norman
    David Norman
    2000-04-12

    • status: Error - status not found --> open-later
     
  • When translating the rest, I'll have a look.
    -mat-

     
    • priority: 5 --> 1
     
  • obsolete.
    -mat-

     
    • status: open-later --> closed-later