Prev: Pagination?
Next: Generic Email
From: "Tanel Tammik" on 8 Jun 2010 14:27 Hi, i like to find the web root where the current file is. is there a better solution? it must work both on linux and windows machines... <?php $root = explode('/', $_SERVER['DOCUMENT_ROOT']); $cwd = explode(DIRECTORY_SEPARATOR, __DIR__); $web_root = '/' . implode('/', array_diff($cwd, $root)); echo $web_root; ?> maybe there is a function for that :D:D:D Br Tanel
From: Jim Lucas on 8 Jun 2010 15:28 Tanel Tammik wrote: > Hi, > > i like to find the web root where the current file is. is there a better > solution? it must work both on linux and windows machines... > > <?php > $root = explode('/', $_SERVER['DOCUMENT_ROOT']); > $cwd = explode(DIRECTORY_SEPARATOR, __DIR__); > $web_root = '/' . implode('/', array_diff($cwd, $root)); > echo $web_root; > ?> > > maybe there is a function for that :D:D:D > > Br > Tanel > > > If I understand what you are asking for, I think this will work. <?php $web_root = basename($_SERVER['QUERY_STRING']); ?> -- Jim Lucas A: Maybe because some people are too annoyed by top-posting. Q: Why do I not get an answer to my question(s)? A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing?
From: "Tanel Tammik" on 8 Jun 2010 15:58 "Jim Lucas" <lists(a)cmsws.com> wrote in message news:4C0E99D9.20809(a)cmsws.com... > Tanel Tammik wrote: >> Hi, >> >> i like to find the web root where the current file is. is there a better >> solution? it must work both on linux and windows machines... >> >> <?php >> $root = explode('/', $_SERVER['DOCUMENT_ROOT']); >> $cwd = explode(DIRECTORY_SEPARATOR, __DIR__); >> $web_root = '/' . implode('/', array_diff($cwd, $root)); >> echo $web_root; >> ?> >> >> maybe there is a function for that :D:D:D >> >> Br >> Tanel >> >> >> > > If I understand what you are asking for, I think this will work. > > <?php > > $web_root = basename($_SERVER['QUERY_STRING']); > > ?> > > -- > Jim Lucas > > A: Maybe because some people are too annoyed by top-posting. > Q: Why do I not get an answer to my question(s)? > A: Because it messes up the order in which people normally read text. > Q: Why is top-posting such a bad thing? var_dump($_SERVER['QUERY_STRING']); //outputs: string(0) "" Br Tanel
From: Nathan Nobbe on 8 Jun 2010 17:00 On Tue, Jun 8, 2010 at 12:27 PM, Tanel Tammik <keevitaja(a)gmail.com> wrote: > Hi, > > i like to find the web root where the current file is. is there a better > solution? it must work both on linux and windows machines... > > <?php > $root = explode('/', $_SERVER['DOCUMENT_ROOT']); > $cwd = explode(DIRECTORY_SEPARATOR, __DIR__); > $web_root = '/' . implode('/', array_diff($cwd, $root)); > echo $web_root; > ?> $_SERVER['DOCUMENT_ROOT'] although a post on the manual mentions some variability between environments. -nathan
From: Micky Hulse on 8 Jun 2010 17:59
> $_SERVER['DOCUMENT_ROOT'] > although a post on the manual mentions some variability between > environments. $root = (array_key_exists('DOCUMENT_ROOT', $_ENV)) ? $_ENV['DOCUMENT_ROOT'] : $_SERVER['DOCUMENT_ROOT']; |