Re: Setting include path to same directory as .php file.?

From: Date: Mon, 27 Nov 2000 03:33:36 +0000
Subject: Re: Setting include path to same directory as .php file.?
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-27300@lists.php.net to get a copy of this message
Dan: Dan Lowe wrote: > > simply include "../header.php" for example, but then it tries to include > one or more other files and then it fails because they aren't in '.' with > my script. The include_path doesn't need to be set in your php.ini. What may be tripping you up is trying to include files from the wrong directories. Note, all directory requests are relative to the INITIAL PHP script called. So, you'll have to call things like this: -------------- <?php # This file is /htdocs/someone/subdir/home.php include("../head.inc"); echo "That's it"; ?> -------------- <?php # This file is /htdocs/someone/head.inc # Note, "subhead.inc" is in the same dir as this file. # BUT that doesn't matter. # What matters is it's up one dir from "home.php." include("../subhead.inc"); echo "<title>Blah Co</title>"; ?> -------------- <?php # This file is /htdocs/someone/subhead.inc echo "<h1>Blah Co</h1>"; ?> If that's not solving things for you, the problem could be file permissions. Good luck, --Dan -- PHP scripts that make your job easier http://www.analysisandsolutions.com/code/ SQL Solution | Layout Solution | Form Solution T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Ave, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409

« previous php.general (#27300) next »