【发布时间】:2023-03-28 05:25:01
【问题描述】:
我对 Web 开发相当陌生,遇到了一个小问题。 我正在我管理的集群上创建一个 html 网站。我想在主页 (index.html) 上显示服务器正常运行时间。
我用以下代码创建了一个 php 脚本(称为 test.php):
<?php
$uptime = shell_exec("cut -d. -f1 /proc/uptime");
$days = floor($uptime/60/60/24);
$hours = $uptime/60/60%24;
$mins = $uptime/60%60;
$secs = $uptime%60;
echo "up $days days $hours hours $mins minutes and $secs seconds";
?>
仅查看 test.php 文件时,代码本身就可以正常工作,但我想拥有它,以便我可以在 index.html 页面上获得相同的信息。
我不知道如何将 php 文件嵌入到 html 文件中。
【问题讨论】:
-
为什么不用
index.php而不是html? -
include它。