Jean-Pierre Gallou schrieb:
> Goetz Lohmann wrote :
> 
>> wich means that "testinclude.php" includes "inc/inc1.php"
>> and "inc/inc1.php" includes "inc/inc2.php" ?
> 
> 
> Right. I'm sorry, I didn't modify testinclude.php as you suggested, but
> inc1.php. With a modified testinclude.php:
>   <? include ('./inc/inc1.php'); ?>
> I get:
>   Failed opening './inc/inc1.php' for inclusion \
>    (include_path='.:..:/usr/local/php-4.3.0/lib/php')
> 
> Seems it doesn't like './' ("inc/inc1.php" is OK). I think that since
> the name begins with '.', PHP tries to find a file in the working dir,
> which is null (see below).

this is very strange cause I got it working with "./inc/inc1.php" and with
"inc/inc1.php" ... "/inc/inc1.php" fail cause its searching the file in the
server root ... also "inc1.php" will fail cause it searches it in the
working dir of testinclude.php ... did you set

doc_root = /usr/local/www/htdocs

than maybe leave this blank !

>> insert something like into inc1.php and inc2.php:
>>
>> <?php
>>    echo "inc included<br>\n";
>>    echo "<br>\n";
>>    $folder=dir('inc');
>>    // print out folder "inc"
>>    while($datei = $folder->read()) {
>>       echo "$datei<br>\n";
>>    }
>>    $folder->close();
>>    echo "<br>\n";
>> ?>
> 
> 
> Unfortunately, this gives nothing. I guess this is because pathnames of
> files are relative to the working dir.

yes if the path not start with "/"

> There are only two variables,
> PATH and TZ in the environment of my Apache server, but nothing about a
> working dir: cwd() returns an empty string, and so does `pwd` or `ls`.
> Relative pathnames of included files are apparently resolved through a
> special way, unless they begin with '.' or '..'. But this is not clearly
> described in the documentation, and it's a bit confusing.

if a file is parsed, all include files a relativ to this parsed file.
with phpinfo() you could read the document root in the "PHP Variables"
section which might look like

PHP_SELF                   /phpinfo.php
_SERVER["DOCUMENT_ROOT"]   /usr/local/www/htdocs
...
_SERVER["SCRIPT_FILENAME"] /usr/local/www/htdocs/phpinfo.php
_SERVER["SCRIPT_URI"]      http://www.yourdomain.com/phpinfo.php
...
_SERVER["PATH_TRANSLATED"] /usr/local/www/htdocs/phpinfo.php
...

a "." mean working dir and ".." mean parent dir

echo exec('ls');

should print out not a empty string but

testinclude.php

and

echo exec('pwd');

should print "/usr/local/www/htdocs/tests"




-- 
 @  Goetz Lohmann, Germany   |   Web-Developer & Sys-Admin
\/  ------------------------------------------------------
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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

Reply via email to