Code: Select all
<? echo("Hello World!"); ?>Code: Select all
<?
$output = file_get_contents("helloworld.php");
echo($output);
?>Moderator: General Moderators
Code: Select all
<? echo("Hello World!"); ?>Code: Select all
<?
$output = file_get_contents("helloworld.php");
echo($output);
?>Code: Select all
$output = file_get_contents("http://localhost/helloworld.php");Bad idea. That requires an unnecessary HTTP request. Capture the output buffer instead.awebtech wrote:lenton, do you want to grab the output of "helloworld.php" ? If so - specify the full WEB path to this script. For example:
Code: Select all
$output = file_get_contents("http://localhost/helloworld.php");
Code: Select all
ob_start();
include('helloworld.php');
$output = ob_get_flush();Code: Select all
$output = shell_exec('php helloworld.php');
// or
$output = `php helloworld.php`;
It depends on the situation. Output buffering or include usage (which I think is better) are no doubt if the only purpose of "helloworld.php" is to produce some output for the main script and we have direct server access to "helloworld.php" from the main script.Jonah Bron wrote:Bad idea. That requires an unnecessary HTTP request. Capture the output buffer instead.