Main Menu
Home
About Us
Contact Us
Careers
Client Login
Solutions
Products
Web Design
IT Services
DB Development
Quickhelp
PHP Examples
Mail Clients
Linux
Links


Client Login





Lost Password?

 

Knowledge Base
For quick help and some common problems, please see our knowledge base.
Latest News

Home arrow PHP Examples arrow File Manipulation arrow Execute remote scripts
Execute remote scripts Print E-mail

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'));
?>