You are here: Re: use virtual hosts to develop locally but upload throws error in source file references « PHP Programming Language « IT news, forums, messages
Re: use virtual hosts to develop locally but upload throws error in source file references

Posted by Toby Inkster on 01/19/07 16:23

Paul wrote:

> require_once($_SERVER['DOCUMENT_ROOT']."/utility/top.php");

That's not a great way of referencing included files. It makes it
difficult to move your site around.

Try instead creating a directory called "includes", and putting all your
included files into there, like:

includes/search_functions.php
includes/database_functions.php
includes/utility/top.php
includes/utility/bottom.php
includes/utility/left.php
includes/utility/right.php

Now, when you need to refer to them, use:

require_once 'utility/top.php';

Note here that we've not specified the full path for the file, not even a
normal relative path -- we've specified where it is RELATIVE TO THE
"includes" DIRECTORY, not relative to where we are now.

Now in your .htaccess file, you can set:

php_value includes_path /full/path/to/includes/

So when PHP sees a 'include' or 'require' statement, it will search
through the path(s) in the includes_path setting and look for
/full/path/to/includes/utility/top.php.

Yay

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

 

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

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