我有一个函数:
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。 请帮助我! 谢谢。