I need the virtual() function and it is not available.
Applies to: Grid System
When PHP runs as a cgi, that function is not available. However, you do not need it to accomplish your goals, which is having some other program executed at the same time as your php script, likely with output emitted as part of the html returned by the php script.
In order to do this, you must first set in the PHP script whatever environmental variables your second script needs to use, such as REQUEST_METHOD and QUERY_STRING. Then, you execute the secondary script with a shell command with PHP.
For example, suppose you want your PHP script to display the output of a perl script that you wanted to run like:
Instead of the above in your PHP, you would do this:
Notice that when using virtual() you refer to the script to be executed by a path that begins at the Apache DOCUMENT_ROOT, which is in most cases /htdocs/www on the physical filesystem. However, when exec'ing the script from a shell, you refer to it using the entire path starting at your home directory, which is "/".
Also, myscript.pl must have executable permissions such as chmod 755.
The only change you need to make to myscript.pl would be to get rid of any content type header that it output when called by virtual(), such as:
Any line such as the above is now no longer needed when you exec your script through a shell as described in this document and it should therefore be deleted or commented out, otherwise you will get that output printed in your PHP page.
13749/0%Last update: 2010-10-03 16:31
Author: FAQ Admin
You can comment this FAQ