Reply to How to make the include path universal?

Your name:

Reply:


Posted by tom pester on 09/05/05 19:53

Hi,

Im new to php and have a background in asp. All the help is very much appreciated.

today I was using the include function in a file that itself gets included :

***************
consumer.php : <? include "inc.php" ?>

inc.php : <? include "Common/functions.php" ?>

functions.php : common functions that all pages use
***************

This works fine if the path that's specified in
<? include "Common/functions.php" ?>
is relative to the path of the calling page consumer.php

I want to be able to specify <? include "inc.php" ?> in every page no matter
if its nested in a directory or not.

In asp I would use absolute paths like this : /Common/functions.php and it
would work.
PHP comes close to it when using paths like this : c:/website/site1/Common/functions.php

But thus breaks when I transfer the pages from the development server to
the live server cause there is no c:/website/site1

My next guess was that I could solve this with a variable like this : $docroot
.. "/Common/functions.php" but where do I specify $docroot in a central location?
(I would do this in asp's global.asa)

_SERVER["DOCUMENT_ROOT"] is blank when I request it and, if I understand
it correclty, I can set it in the php.ini . The problem is this value holds
for all the sites on the box.

I'm new to php so if I don't make sense than pls put me straight :)

Cheers,
Tom Pester

[Back to original 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

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