You are here: Re: can an included file find out where it's been included from? « PHP Programming Language « IT news, forums, messages
Re: can an included file find out where it's been included from?

Posted by Jerry Stuckle on 05/12/05 18:15

micha wrote:
> suppose i have 3 files:
>
> script.php
> somedir/include.php
> somedir/config.php
>
> 1. script.php includes include.php
> 2. include.php includes config.php, so the structure looks like a cascade
>
> now if i include config.php (without path) from include.php the script
> tries to include from the directory script.php is in, which makes sense but
> is not what i want.
>
> question: how can i find out which dir include.php has been included from?
>
> micha

Micha,

Use the full absolute path to the file

<? include ($_SERVER['DOCUMENT_ROOT'] . '/somedir/config.php'); ?>

$_SERVER['DOCUMENT_ROOT'] gives you the absolute path to the root
directory for your web site. Then just concatenate the path and
filename to the one you want included.



--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация