View Full Version : Using virtual() to execute Perl scripts on a PHP page?
I just read that it's possible to use the PHP function virtual() to include a page/execute a perl script as if this page is .shtml. For example:
<?
virtual("test.pl");
?>
I never realized before this was even possible. It should definitely make converting my current .shtml pages to PHP a lot easier, considering I have perl scripts I need to continue using.
Has anyone tried the above function on their pages, and are there any pitfalls to watch out for?
firepages
12-07-2002, 12:06 PM
the only issue I hear of (on *NIX) is if you do a virtual on say
virtual('./cgi-bin/script.pl');
then that changes your current working directory to the cgi-bin or wherever, then any later include()'s work from the `new` current working directory ./cgi-bin as opposed to ./
but using include($_SERVER[DOCUMENT_ROOT].'/path/file.inc');
would solve that.
Dalsor
12-07-2002, 09:02 PM
So you mean place the call to virtual in the .inc file or use include instead of virtual? Curious, as would may help me convince my workplace to begin using php.
firepages
12-08-2002, 07:04 AM
no, the call to virtual() would be in your main page (though you can call virtual() in an include()'d file)
this is perhaps better explained in the user notes at http://www.php.net/virtual as I have rarely used virtual (and have issues with it & SSI on win32 !)
but hang 5 because when apache2 gets stable enough you will be able to use apache2 filters which will allow PHP/PERL/whatever in the same page without any of these issues.
For more information on the virtual() command, also see here: http://www.zytrax.com/tech/php/php_ssi.htm
Dalsor
12-09-2002, 05:09 AM
Great!
I can see a lot of potential uses for this. Never even knew the virtual command existed before now. Thanks for a bunch for the head's up and the links.
Gonna go play with it now and see if I can trash some code. :D
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.