url vs dirname(__FILE__)

From: Date: Wed, 30 Nov 2005 03:25:23 +0000
Subject: url vs dirname(__FILE__)
Groups: php.general 
Request: Send a blank email to php-general+get-226613@lists.php.net to get a copy of this message
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

« previous php.general (#226613) next »