url vs dirname(__FILE__)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux