On Fri, Mar 6, 2009 at 08:37, PJ <af.gourmet@xxxxxxxxxxxx> wrote: > good morning all, > > How can I include src and href in include files that will refer the > right paths from files in different hierarchies(directory tree levels)? > Example: > include dirname(_FILE_)."/../lib/header1.php"; ? > > This does not work: > snippetysnip... > <LINK href="dirname(_FILE_).'/../lib/index.css'" rel="stylesheet" > type="text/css"> > </head> > Nor does this: (NOTE THE DIFFERENCES " AND ' IN THE SRC AND HREF) > <div id="frame"> > <IMG SRC=dirname(_FILE_)."/../images/bannerbae1.gif" ...snippetysnip > Perhaps it's not possible? It is when it's parsed by PHP. You're just putting it through as straight HTML, which - even though it may have a .php extension - won't work as you might be expecting. Instead, you have to instruct the parsing engine where and when to interpret, compile, and execute the code, like so: <img src="<?php echo dirname(dirname(__FILE__)); ?>/images/bannerbae1.gif"> In the above snippet, notice a few very important things: 1.) We use regular open tags to be compatible with all stock PHP configurations. 2.) We echo out the response from dirname() so that it's output to the HTML source. 3.) We use dirname() twice, so it gives the dirname() of the dirname(), rather than '..'. 4.) There are double underscores around FILE. The same is true with LINE, FUNCTION, etc. -- </Daniel P. Brown> daniel.brown@xxxxxxxxxxxx || danbrown@xxxxxxx http://www.parasane.net/ || http://www.pilotpig.net/ 50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW10000 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php