Re: something like __URL__ (analogous to __FILE__)
| From: | Evan Nemerson | Date: | Wed, 24 Mar 2004 00:59:48 +0000 |
| Subject: | Re: something like __URL__ (analogous to __FILE__) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-181340@lists.php.net to get a copy of this message | ||
Take a look at $_SERVER['REQUEST_URI']
On Tuesday 23 March 2004 04:50 pm, motorpsychkill wrote:
> This is tricky to explain, so bear with me please. I have a file like:
>
> c:\htdocs\project_bunny\includes\config.php
>
> In my browser address bar, this would look like:
>
> http://localhost/project_bunny/includes/config.php
>
>
>
>
> If within this document (i.e. config.php), I had:
>
> <?php
> //config.php
>
> define("CONFIG_FILE", __FILE__);
>
> echo CONFIG_FILE; //this will return
> "c:\htdocs\project_bunny\includes\config.php"
>
> ?>
>
> Now, if I have another file (e.g. rabbits.php):
>
> <?php
> //rabbits.php
>
> include("config.php");
>
> echo CONFIG_FILE; //this will also return
> "c:\htdocs\project_bunny\includes\config.php"
>
> ?>
>
> This is all great up to this point. What I'm trying to do is:
>
> <?php
> //config.php
>
> define("CONFIG_FILE_URL", __URL__);
>
> echo CONFIG_FILE_URL; //would return
> "http://localhost/project_bunny/includes/config.php"
>
> ?>
>
> So no matter what file I use (like rabbits.php) and I include config.php,
> CONFIG_FILE_URL will always return the url for the config file and NOT the
> file doing the calling (rabbits.php).
>
> Sorry for the longwinded explanation. I hope someone can help! Thank you.
>
> -m
--
Evan Nemerson
evan@coeus-group.com
http://coeusgroup.com/en
--
"There is a certain right by which we may deprive a man of life, but none by
which we may deprive him of death."
-Nietzsche