note 57822 added to function.include

From: Date: Sat, 15 Oct 2005 04:30:18 +0000
Subject: note 57822 added to function.include
Groups: php.notes 
Request: Send a blank email to php-notes+get-97048@lists.php.net to get a copy of this message
A problem you might be having is if you include a file from one directory and then that file in turn includes another file in yet another directory (relative to its current position). If you are experiencing this problem you need a work around. Eg, File A.php located in directory 'somedir' includes file B.php located in 'somedir2'. File B.php includes file C.php which is located in 'somedir3'. For this example 'somedir' contains both 'somedir2' and 'somedir3'. A.php's include statement: ------- include("somedir2/B.php"); //Works fine... ------- B.php's include statement: ------- include("../somedir3/C.php"); //Doesn't work when included in A.php ------- So a work around is needed. One option is to use the work around provided by "rainfalling at yahoo dot com" or, you could use the following adaptation of that example: B.php's include statement that will work all the time: ------- $pathFix = dirname(__FILE__); include("$pathFix/../somedir3/C.php"); //Works all the time... ------- ---- Manual Page -- http://www.php.net/manual/en/function.include.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+57822 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+57822&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+57822&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+57822&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+57822&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+57822&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+57822&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+57822&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+57822&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#97048) next »