|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-01-31 21:06 UTC] e-phpbug at erowid dot org
Description: ------------ Documentation for virtual() claims that it should work like an apache sub-request like the shtml #include virtual command. It does not. Bug 26500 is reporting the same bug but appears to have been closed by someone who does not understand the issue. It is clear that it is not doing this as advertised for php scripts. What should be creating an http request is instead clearly short-circuting to a PHP include() call with the docroot pre-pended when the target is a php script. This results in any CGI PHP called through virtual being called as a sub-component of the current PHP script instead of as its own execution, with its own environment, own POST/GET variables, etc. This clearly violates the documented purpose of the call (to replicate the apache shtml functionality). Also, as a side effect of how this behaves, virtual changes the cwd in the calling script (a behaviour that should not happen with an apache subrequest). Both of these problems are solved if http://www.host.com/ is pre-pended to the string and passed to include() instead, which actually generates an http sub-request. Proposed solutions: 1) change the documentation so that it doesn't claim this is the same as apache's include-virtual directive. 2) fix the problem since this is clearly the intended behaviour for the function. Reproduce code: --------------- The following should have equivalent effect, given the documentation: <!--#include virtual="/path/to/stuff.php?Var=Value"--> and <? virtual("/path/to/stuff.php?Var=Value"); ?> with stuff.php as: <? $Var = $_GET['Value']; print "Var: $Var <br>\n"; ?> Expected result: ---------------- The shtml results in: Var: Value <br> Actual result: -------------- the php results in: PHP warnings (if you E_ALL set) Var: <br> PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 04 19:00:01 2025 UTC |
Yes, I tried it. It seems that this function works as expected only with Apache 2. I tried these simple scripts: main.php: <?php virtual("virtual.php?a=c"); ?> virtual.php: <?php echo $_SERVER["QUERY_STRING"]; ?> Apache 1: Parameters of main.php are printed Apache 2: "a=c" is printed virtual.php is not listed in Apache access log in either case. It's independent if you use PHP 4 or PHP 5. I tried it under Windows. Do you agree with this description?