User Contributed Notes: virtual
tomwk@mail.utexas.edu
24-Jul-1999 07:41
It seems that virtual changes the current directory, so you will have problems if you do a virtual( "/someotherdir/file.shtml" ) then an include( "./myfile.php3" )
A workaround is:
<pre>
$curDir = dirname( getenv( "SCRIPT_FILENAME" ) );
virtual ( "/someotherdir/file.shtml" );
chdir( $curDir );
</pre>
alex@nefedov.spb.ru
26-Aug-1999 04:40
I installed php4 b2 with Apache and mysql.
if i use virtual("banner.cgi") ; as a first function on my page, and without any html tag befor it prints the output of banner.cgi and than something like
HTTP/1.1 200 OK Date: Thu, 26 Aug 1999 20:39:31 GMT Server: Apache/1.3.9 (Unix) PHP/4.0B2 rus/PL28.17 Keep-Alive: timeout=20 Connection: Keep-Alive Transfer-Encoding: chunked Content-Type: text/html; charset=windows-1251 Vary: accept-charset, user-agent b05
stange.
debot@xs4all.nl
22-Oct-1999 09:29
Yes, it seems not to be working on Win32 platform. Lucky me, my virtual server has a unix system running.
david@audiogalaxy.com
28-Nov-1999 10:44
The above problem still occurs in php4 b3. virtual returns the HTTP entity header after the requested file, when it's the first output to the page.
Now, what is the proper behavior? Should virtual *never* output the HTTP header, or should it return the header but put it *before* any other output?
The work-around to prevent seeing the header is, of course, to output something (such as echo " "; ) before calling virtual.
alex@inforcer.com
08-Dec-1999 01:48
Well I got it running good.
Complex SSI scripts and PHP3 on one page.
Its at http://www.inforcer.com/
rwidmer@developersdesk.com
08-Dec-1999 03:38
If the .html file you reference in virtual() contains <!--#include virtual""--> of a php file it will result in a Segmentation fault of the Apache process. At least with php 3.0.12, but I suspect this is actually an Apache issue, and all php versions will do it.
AndyK@AndyK.com
17-Dec-1999 08:14
HELP! Is there anybody out there who knows how to set variables which can be read by the virtually included shtml? Normally this is done by <PRE><!--#set var="varname" value="mycontent" --></PRE> Thank you!!
dev@null.com
20-Jan-2000 06:01
Hello. I am wondering if its possible to use <? echo ?> statements within the virtual function. For instace, I want to display a number of af ile downloads with a SSI counter. How would i go about this?
<? virtual("/cgi-bin/showload.cgi?<? echo $count; ?>"); doesn't seem to work.
$count is already defined as:
$count=("http://www.somehomepage.com/files/yaya.zip");
phester@home.com
13-Mar-2000 04:40
Ok, here's my solution for win32 based Servers... It would probaly be better with a random filename generater but i'll leave that up to you..
<pre>
$data = implode("\n", file("http://www.url.com/cgi-bin/script.cgi"));
$fp = fopen( "$tempdir/$tempfile","w");
fwrite( $fp, "$data");
fclose( $fp );
include ("$tempdir/$tempfile");
</pre>
Hope that help anyone on NT, it's a bit slower than virtual() but it works... now only if they could implement virtual() in the win32 version
jcarnley@c-gate.net
02-May-2000 03:14
<PRE>
Fatal error: Call to unsupported or undefined function virtual()
why???
</PRE>
jknapp@villageauction.com
17-May-2000 11:08
another win32 solution that doesn't require file manipulation.
$temp_path = substr($PHP_SELF, 1);
$temp_path = eregi_replace("[^/]","",$temp_path);
if ($temp_path) $temp_path = eregi_replace("/","../",$temp_path);
jknapp
17-May-2000 11:19
oops. then call w/
include(temp_path."filename");
chris-tery@lineone.net
13-Jul-2000 04:21
I'm trying to include files from another website I have using include virtual('www.***.com/**/*.shtml') and having some problems! It appears I can only use "../../" to find a file on the host site. Is there a work around or am I mising the obvious?
nospam@php.net
24-Jul-2000 05:53
If you want to have a cgi passed with args you do it like this:
<pre>
<?php
virtual("/cgi-bin/lastuser.cgi?arg");
?>
</pre>
Which works fine for me