Is there a way in PHP to include or execute code from a separate file?
For example, if we have 2 files:
a.php which contains:
<?php echo "i'm a.php"; ?>开发者_StackOverflow;
and b.php which contains:
<?php
echo "i'm b.php";
// some code here to "execute" a.php so that it prints i'm a.php as the output.
?>
When b.php is run it should display:
i'm b.php
i'm a.php
<?php
echo "i'm b.php";
include('a.php');
?>
C.
just universal solution (but maybe denied by local PHP-server configuration):
echo file('http://your-remote-host/path/a.php');
or your a.php must provide some gate:
<? # a.php
function a_php_output()
{
return "i'm a.php";
}
?>
<? # b.php
echo "i'm b.php";
include('a.php');
echo a_php_output();
?>
精彩评论