我的目标:创建一个按钮(或超链接),在点击时生成一个 word 文档。
下面是我创建的代码,但它不起作用。没有显示错误。我知道 PHP 是一种服务器端脚本语言,所以我认为它与此有关。
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript">
function createReport() {
$fp = fopen("report.doc", 'w+');
$str = "This is the text for the word file created through php programming";
fwrite($fp, $str);
fclose($fp);
return false;
}
</script>
超链接:
echo '<a href="#" onclick="createReport();">Generate</a>';