Well,if so,why <?php require 'inc2.php';        ?> works?
I didn't change the default include_path.Sure that '/inc' isn't in the
include_path.But it just works.

You see,the include_path ".:/usr/local/lib/php" refers to the current
dirctory where the file locates and the PEAR directory.The focus is what
this current directory "." refers to when the demo.php includes another
file inc/inc1.php -- well,to demo.php, without question ,it refers to
where the demo.php locates,but to inc/inc1.php what this "."  refers to
?  '/' or '/inc'? It seems that both are ok except in the case we use
'./'.

-----Original Message-----
From: Nicholas Robinson [mailto:[EMAIL PROTECTED] 
Sent: Friday, August 08, 2003 3:15 PM
To: CaiYongzhou; Php General
Subject: Re: [PHP] Problem occurs when included file includes anther
file.

ooops, sorry, ignore my last post, I must get larger text on my screen!
Missed 
the .: element of your path!

Can you confirm that this file is a replacement for demo.php?

"Problem occurs when the code is like this
<?php
//file inc/inc1.php
require './inc2.php';
?>"

If so, then it won't find it because you haven't include ./inc in your
include 
path.

Otherwise your example works fine on my machine.

HTH

Nick

On Friday 08 Aug 2003 6:38 am, CaiYongzhou wrote:
> The directory structure is as follows:
> /
>
> |-- demo.php
> |-- inc/
> |
>     |-- inc1.php
>     |-- inc2.php
>
> === file demo.php ==
> <?php
> require 'inc/inc1.php';
> ?>
>
> === file inc/inc1.php ==
> <?php
> require 'inc2.php';
> ?>
>
> == file inc/inc2.php ==
> this is a test
>
> The above inc/inc1.php is ok for testing.And this would be ok too:
> <?php
> //file inc/inc1.php
> require 'inc/inc2.php';
> ?>
>
> Problem occurs when the code is like this
> <?php
> //file inc/inc1.php
> require './inc2.php';
> ?>
> Fatal error: main(): Failed opening required './inc2.php'
> (include_path='.:/usr/local/lib/php')
>
> It seems that there's noxplanation about this in php manual.Could
> someone give some?
>
> Btw,I am using redhat 7.2 / Apache 2.0.47 / PHP 4.3.3RC1 as my testing
> server.
> Thank you for reading my post:)





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

Reply via email to