| Execute remote scripts |
|
|
|
Description: This is an example used for executing remote scripts or just reading the content of a remote file. This example uses php to execute remote perl script. The variables can be passed using either a database or $_GET. (i.e. http://www.example.com/cgi-bin/perlcode.pl?variable=value) the returned result can be saved into a php variable. Code:
<?php // Get a file into an array. In this example //we'll go through HTTP to get // the HTML source of a URL. $lines = file('http://www.example.com/cgi-bin/perlcode.pl'); // Loop through our array, show HTML source //as HTML source; and line numbers too. foreach ($lines as $line_num => $line) { echo "Line #<b>{$line_num}</b> : " . htmlspecialchars($line) . "<br />\n"; } ?> This one is useful if the script output is one line:
<?php // Another example, let's get a web page into a string. //See also file_get_contents(). $html=implode('', file('http://www.example.com/cgi-bin/perlcode.pl')); ?> |



