我想尝试一个例子,你可以在这里找到:http://php.net/manual/en/function.include.php,但我似乎不能使它工作。
在第一个文件index1.php中,我这样写:
<?php
$color = 'green';
$fruit = 'apple';
?>
在第二个文件index2.php中,我这样写:
<?php
include("http://www.domain.com/mypathtothefile/index2.php");
echo "A $color $fruit";
?>
它应该回复'A green apple',但是它什么也没有回复。路径是正确的,虽然,因为当我把echo部分在第一个文件(index1.php),然后它回波'一个绿色的苹果',都在index1.php作为index2.php。
希望有人能帮忙。提前感谢!
应该是:
include('index1.php');
编辑:更正为反映文件名