Welcome! Log In Create A New Profile

Advanced

Filename/Path problems with includes

Posted by roothahn 
Filename/Path problems with includes
June 26, 2011 05:53AM
Hi all,

I'm stuck on a problem and I can't figure out how to solve. I'm using nginx 1.0.2 with php-fpm.

Let's create a file (in the docroot f.e.) called test.php:
<?php require 'test1/test1.php'; ?> # this works!

Then create the folder test1 and the file test1.php in it:
<?php require 'test2/test2.php'; ?> # this works too!

Then create the folder test1/test2 and the file test2.php in it:
<?php require 'test3/test3.php'; ?> # now this fails:

Warning: require(test3/test3.php): failed to open stream: No such file or directory in test2/test2.php on line 2 Fatal error: require(): Failed opening required 'test3/test3.php' (include_path='.:/opt/php5/lib/php') in test2/test2.php on line 2

The reason is that for test2/test2.php and test2/test3/test3.php the variable $_SERVER["SCRIPT_NAME"] is still /var/www/docroot/test1.php
. But it shoud be the specific current file to work...

How can I tell php-fpm (or nginx?) to do so?

any help is very appreciated :)
thanks guys,
silvio
Re: Filename/Path problems with includes
June 26, 2011 05:57AM
(of course I created the folder test3 and the file test3.php too ;-)

this maybe looks better:

#cat test.php
<?php require 'test1/test1.php'; ?>

# cat test1/test1.php
<?php require 'test2/test2.php'; ?>

# cat test1/test2/test2.php
<?php require 'test3/test3.php'; ?>

# cat test1/test2/test3/test3.php
<?php
echo $_SERVER["SCRIPT_NAME"]; echo '<br>';
echo $_SERVER["SCRIPT_FILENAME"];
?>
Re: Filename/Path problems with includes
June 26, 2011 06:02AM
I just found that under apache_mod_php5 the SCRIPT_NAME variables in test3.php are still /var/www/docroot/test.php, but nevertheless the file test3.php will be included from file test2/test2.php without error o.O
Re: Filename/Path problems with includes
June 26, 2011 06:22AM
Now I found out something interesting:
When I do a /etc/init.d/php-fpm restart, and refresh the browser page, it works!
When I refresh a second time, It tells me the error again ...

WTF ^^
Re: Filename/Path problems with includes
June 26, 2011 07:33AM
Uh, I think I found the reason: http://pecl.php.net/bugs/bug.php?id=22687

It's an APC bug. I deactivated APC and it seems to work now.

Thanks for the attention :D
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 206
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready