Re: include path file errors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2006-04-08 (토), 12:18 -0400, John Hicks 쓰시길:
> kmh496 wrote:
> > 2006-04-08 (토), 18:20 +0900, kmh496 쓰시길:
> > 
> >>hi,
> >>my webroot is 
> >>
> >>/a/b/current/
> >>
> >>i am in /a/b/current/d/file.php
> >>
> >>file.php has a line
> >>
> >>require_once ($_SERVER[document_root]."/d/common.php");
> >>
> >>common.php has a line which says
> >>
> >>require_once ($_SERVER[document_root]."/_common.php");  
> >>// main include file for whole site
> >>
> >>it sends me no errors about missing files, but the variables inside main
> >>include file _common.php are not set and don't exist in file.php
> >>
> >>where is my mistake?
> > 
> Just a thought:
> 
> Are your variable definitions, by any chance, inside functions? That
> would explain why they aren't set when you continue. The 'global'
> statement will help in that case.
> 
> I can assure you that includes are not "advanced PHP". You should be
> able to do what you are trying to do. There is no doubt a simple
> explanation for your problem. Finding it is always the hard part.
> Patience and perserverence and calm rational thought will get you there.
the problem is when i want to expand a site with a new application,
usually that comes in its own directory.  but, to include the new
application i have to wrap it inside the main directory -- in this
case /a/b/current  .... which requires of course that i call
first /a/b/current/common.php which starts the sessions, sends the
cookies, checks post variables.  

but that doesn't work, really, because then all of the includes for the
application says "include(main.php)" ... but php thinks it's
in /a/b/current not in /a/b/current/d/ ..... so it says "cannot find
include file "main.php" in path:  path:::;; .."

my wish list:
1) applications came with a configurable directory to preced every
include or require.  
like, change "include(main.php)" -->  include( $config[dir] .
"main.php" )

alternatively, 
2) all applications come with a unique prefix affixed to the files so
they can simply be laid out in the document root and be visually and
mentally and upgradably separate from the files of the other
applications existing in the same $_SERVER[document_root]


i honestly don't understand the include mechanism.  i have encountered
many cases ( sorry, can't be explicit) where a file which was 2 includes
away wouldn't have any variables in the main script, unless i added a
line to include that file in that file directly.  

as an example:

/a/b/current/index.php        
	include("common.php");
	include("lib/functions2.php");
/a/b/current/lib/functions2.php 
	you would think would be able to simply run with what was 
	included "above" it but you can't.  you have to redeclare

include_once($g4[bbs]. "/dbconfig.php");
include_once($g4[bbs]. "/common.php");

the include of the common.php file.

i am looking for the rule for that.... they say it's global, but it's
not.  However, i found that if you include "common.php" again then it
finds the functions it misses, because it itself was included by
"common.php".  as if the direction of the includes matters .........
explicitly:
if common.php includes lib/functions.php common.php can access
lib/functions.php
but if lib/functions.php needs common.php then lib/functions.php needs
to include common.php

is that correct?

because of these problems, when i have to wrap another application
inside an existing SKIN and common.php, i end up changing the file
names, running a SED script to replace all occurrences of filenames with
their newly-uniquely-prefixed-names .....  

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux