【问题标题】:trying to extract data from txt file into and html试图从txt文件中提取数据到html中
【发布时间】:2022-08-19 16:44:19
【问题描述】:

伙计们,我正在做一个项目游戏,当我尝试将文本文件内容提取到我制作的 HTML 中时,我遇到了困难。

目前,游戏会创建一个包含玩家分数的 score.txt 文件,我正在尝试制作一个 HTML 以自动在 HTML 中显示该分数。

我将添加我当前的 HTML 以供参考,以便您查看:

这是我正在努力的代码的一部分

<h1><div id =\"score\">The score is <?p$ filename = 
fopen(\'score.txt\', \'r\');
$file = fread($filename, filesize(\'score.txt\'));
echo $file;
fclose($filename); </div> </h1>
<hr class=\"w3-border-grey\" style=\"margin:auto;width:40%\">
<p class=\"w3-large w3-center\">Good job traveler!</p>
</div>
<div class=\"w3-display-bottomleft w3-padding-large\">
  • 请将代码发布为文本而不是图像。
  • 另外,这似乎不是Python?

标签: html css


【解决方案1】:

&lt;?php $myfile = fopen("webdictionary.txt", "r") or die("Unable to open file!"); echo fread($myfile,filesize("webdictionary.txt")); fclose($myfile); ?&gt;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-06-10
    • 1970-01-01
    • 2013-05-05
    • 2021-06-06
    • 1970-01-01
    • 1970-01-01
    • 2013-07-03
    相关资源
    最近更新 更多