Weird virtual() behavior for nested require()
| From: | Paul Cantrell | Date: | Mon, 15 Nov 2004 17:50:05 +0000 |
| Subject: | Weird virtual() behavior for nested require() | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-202055@lists.php.net to get a copy of this message | ||
I'm getting a weird behavior when virtual() calls another page that uses a require(). The behavior seems contrary to the docs for virtual.
Consider these four files:
------ foo.php ------
This is foo.
<?php virtual('subdir/bar.php'); ?>
------ foo.shtml ------
This is foo.
<!--#include virtual="subdir/bar.php"-->
------ subdir/bar.php ------
This is bar.
<?php require('./baz.php'); ?>
------ subdir/baz.php ------
This is baz.
According to the docs, virtual() handles the argument as an Apache subrequest -- in other words, it should be equivalent to an SSI include. But it's not. As I would expect, foo.shtml produces this:
This is foo. This is bar. This is baz.Here's what I get from foo.php:
This is foo. This is bar.
Warning: main(./baz.php): failed to open stream: No such file or directory in
/blah/blah/blah/subdir/bar.php on line 2
Fatal error: main(): Failed opening required './baz.php' (include_path='.:/usr/local/lib/php')
in /blah/blah/blah/subdir/bar.php on line 2
Oddly, it works if bar.php says require('baz.php') instead of require('./baz.php'). That smells really bad. Is this a bug, or am I missing something?
Cheers,
Paul
_________________________________________________________________
"After hearing ten thousand explanations, a fool is no wiser.
But an intelligent person needs only two thousand five hundred."
-- Mahabharata