Archive - Originally posted on "The Horse's Mouth" - 2006-04-08 07:43:56 - Graham Ellis
Our web site has grown over the years, and we've developed a number of very useful scripts such as our quotation system that's written in Perl and our live server test program in Tcl and Expect. Now we require to run those scripts within the current look and feel, with its printer friendly flexibility, customisation to reflect the country from whom our visitors arrive, and so on, all of which are facilities offered by PHP. This can't simply be done by adding PHP tags into the output of the Perl or Tcl programs - cgi output is NOT parsed by the PHP interpreter - so how have we done it?
* New PHP pages call up the cgi scripts, now using them as application servers, and extract the pertinant information they return.
* Our cgi-bin scripts are little changed, but we have added markers in the form of HTML comments to indicate the start and end of the content generated.
* In the case of CGI scripts which use form inputs, we have also updated the scripts so that they can read parameters from the command line in addition to URL-encoding.
The extra code in the PHP page is just:
$howsit = implode("",file("http://$_SERVER[SERVER_NAME]/cgi-bin/net/livetest.exp"));
preg_match('/<!-- start -->(.*)<!-- end -->/is',$howsit,$gotten);