[PHP] url vs dirname(__FILE__)

2005-11-29 Thread Chris
I trying to create an absolute path to include scripts and images in another 
directory. For includes, I have found $path = dirname(__FILE__) 
./mydir/myscript.php;

However, I am unable to reference an image using this path, like
echo img src= . dirname(__FILE__) . /mydir/myimage.gif;

To reference an image I have to create another path variable which assembles 
a url like:

echo img src=http://; . $_SERVER['HTTP_HOST'] . 
dirname($_SERVER['SCRIPT_NAME']) . /mydir/myimage.gif;

Is it possible to create just one absolute path variable for both the 
include and img src= or do I need to create two paths?

Thanks
cw

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] url vs dirname(__FILE__)

2005-11-29 Thread Chris Shiflett

Chris wrote:

I trying to create an absolute path to include scripts and images
in another directory.


These are two different things, but there is a relationship in the sense 
that URLs are translated to filesystem paths using document root:


http://host/path/to/script.php = [document root]/path/to/script.php

I think it's pretty important to understand the difference as well as 
the relationship. Once you do, your question might go away.


Hope that helps.

Chris

--
Chris Shiflett
Brain Bulb, The PHP Consultancy
http://brainbulb.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php