Re: Really slow include

From: Date: Wed, 03 Apr 2002 01:11:09 +0000
Subject: Re: Really slow include
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-91239@lists.php.net to get a copy of this message
What you need to do is include the path to the file in relation to the file that is including it, this can be an absolute path or a relative path. Eg. Assuming the file is located in /www/foo/htdocs/foo/index_test.php and the include file is in /www/foo/htdocs/ Absolute path: require("/www/foo/htdocs/header.htm"); Relative path: require("../header.htm"); It may be easiest to use a variable for the include path. Eg. $includePath = "/www/foo/htdocs/"; require($includePath."header.htm"); I hope this helps. "Anti-Blank" <anti@anti-blank.com> wrote in message news:007c01c1da8e$a12062f0$6601a8c0@noblesse... > I have a header section for my website and I'd like to include it into each page. Since this is where > I'm housing all of my navagation. Here is my problem though. I have the header tables sitting in a page > header.htm. I'm calling it as so: > <? > require ("header.htm") > ?> > > This works fine as long as I stay in the main folder /htdocs where the header.htm file is. > The problem lies when I go any deeper. I tried replacing the link with: > <? > require ("/header.htm") > ?> > Hoping that would put it back to the /htdocs folder as it works for my standard links. Instead > I get this: > Fatal error: Failed opening required '/header.htm' (include_path='.:/usr/local/lib/php') in /www/foo/htdocs/foo/index_test.php on line 82 > > I've tried correcting it by including the full path: > <? > require ("http://www.foo.com/header.htm") > ?> > > This does work but it's so amazingly slow. Even on my cable connection it will take 20-30 seconds > to load this. I've switched back and forth between require and include with no change in speed. Anyone > have a suggestion or an idea on why my load time is suffering so much? > > I hope all of that was clear enough. > > Thanks > anti-blank >

« previous php.general (#91239) next »