We have seen how to call Rebol Cgi from C#/ASP.NET through HttpWebRequest or Process.StartInfo. We’re now going to see how to do so in PHP.
PHP can relatively easily interface with Perl thanks to the Apache_Note function. This function can work with Perl because Perl has libraries suitable for that purpose.
Unfortunately Rebol doesn’t have that kind of library as far as I know so one should use another way (of course that could be not as performant as the previous one). For example, I am building this experimental Search Engine (Don’t use the search button yet, it’s not implemented) with PHP and Rebol to experiment the Interoperability between the two:

Actually to do so it’s tremendously easy as it can be done in one line using PHP system function like this:
<?php echo system('./cgi-bin/rebol-include.cgi'); ?>
Since you use the PHP echo function, you can make partial inclusion or a whole inclusion. In the case of a whole inclusion, your Rebol Cgi should just omit the usual first instruction (for people new to Rebol it’s just after Rebol Header Rebol[]):
#!/home/youraccount/yoursitedirectory/cgi-bin/rebol -c
REBOL [Title: "Not Found On Search Engine"]
;print "content-type: text/html^/" ; omit this line by commenting it
The rest of the script generates content by iterating though a text database - using the same technique as in previous article on Rebol CGI.
Important update: your last cgi print instruction should be
print ""
because the PHP command return the last line so that if you do not put the instruction above, the last line of your html output will be printed twice!
















Tags: cgi, Interoperability, php, Shell