我正在学习使用AngularJS和php进行编码,并且在尝试使用PHP将其中一个变量的值写入文本文件时遇到困难。
我的变量是,
{{sample.getString()}}
当我尝试使用php打印它时,它适用于我,
<?php echo "{{sample.getString()}}" ?>
但是,当我尝试在文本文件中写入时,
<?php
$myfile = fopen("newfile.txt", "w") or die("Unable to open file!");
$txt = "{{sample.getString()}}";
echo $txt;
fwrite($myfile, $txt);
fclose($myfile);
?>
它写入变量本身而不是写入变量的值。
有人可以告诉我如何解决这个问题?