【发布时间】:2017-03-23 02:56:40
【问题描述】:
我有一个函数:
myfunc () {
$a = "John";
$str = "Hello $a, how are you today?"
return $str;
}
echo myfunc(); //Hello John, how are you today?
我想将该函数中的所有句子保存到另一个文件中,因为它们的长度太长,无法放入我的函数中。
myfunc () {
$a = "John";
$str = file_get_contents("inc_file.html");
return $str;
}
inc_file.html:
Hello $a, how are you today?
但它并没有像我预期的那样返回。变量 $a 未更改为 John。 请帮我 ! 谢谢
【问题讨论】:
-
不,我不想用某些功能保存文件。我手动创建 html 文件。 php代码仅用于读取和显示html文件中的内容
标签: php variables file-get-contents