[thelist] PHP breadcrumbs & directory navigation

Howard Cheng howcheng at ix.netcom.com
Thu Jan 23 13:21:01 CST 2003


For images, it's easy, just start from the root folder:

<img src="/images/logo.gif">

For your includes, you'll want to do something similar, except that to
start from your web folder root, you should be using $DOCUMENT_ROOT (or
$_SERVER['DOCUMENT_ROOT'] for PHP 4.2+).

<?
include("{$_SERVER['DOCUMENT_ROOT']}/incl/conf.php");
?>

The braces {} are necessary for interpreting hash (associative array)
variables properly. If it's just an indexed array, you wouldn't need the
braces.

HTH.

At 11:00 AM 1/23/2003 +0000, kristina wrote:

>   <?php
>     include("../../../incl/conf.php");
>     include("../../../incl/css.php");
>     include("../../../incl/header.php");
>     include("../../../incl/footer.php");
>   ?>
>
>   <img src="../../../images/logo.gif" />
>
>   which kind of works, but I'm not convinced
>   having all those ../../../ is a good idea!  It
>   occurred to me to turn it into an explicit
>   variable
>
>   $baseurl = http://www.foo.com/
>
>   so
>   <img src="../../../images/logo.gif" />
>
>   becomes
>   <img src="<?php $baseurl ?>/images/logo.gif" />

::::::::::::::::::::::::::::::::::
Howard Cheng
http://www.howcheng.com/
howcheng at ix dot netcom dot com
AIM: bennyphoebe
ICQ: 47319315




More information about the thelist mailing list