如何将 PHP 方法导入 HTML。我是新来的;我有什么选择

how to Import PHP method into HTML. I'm new; what are my opions

我一直在寻找一种方法将 php 方法导入 html 索引。 PHP 函数是将用户输入存储到 sql 数据库中。我只需要 html 语法来导入 php 脚本。 谢谢

您不能在 HTML 文件中导入 PHP 文件。

PHP 是一种服务器端脚本语言。 HTML 完全是浏览器端。您不能从浏览器执行服务器端代码。它们是两个完全不同的东西。

但是,您可以使用 JavaScript 将信息从 PHP 结果传递到 HTML。

<?php
$thisVariable = "hello world";
?>

<script>
var thisVariable = '<? echo $thisVariable ?>'
</script>

这真的是你能做到的最好的了。