You are here: Re: A direct url within an include « PHP Programming Language « IT news, forums, messages
Re: A direct url within an include

Posted by stevenowicki on 05/03/06 11:40

include('somefile.ext') assumes that somefile.ext is in the same
directory as the PHP file containing the include statement. If the
included file is in another directory, for example the parent
directory, then you need to call include('../somefile.ext'). Realizing
that this can be something of a PITA when trying to include it in files
that may be spread over multiple directories, my suggestion is to
define a constant that points to the physical path to the application
root, which would allow you to do something like the following:

//in constants.php included into all page requests
define('APP_ROOT', '/opt/websites/mysite/');

//somewhere else in the application
include(APP_ROOT . 'includes/somefile.ext');

 

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

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