简体   繁体   English

如何在 HTML(CSS,JS)网站中包含 PHP?

[英]How to include PHP in a HTML (CSS,JS) website?

So I need to make a contact form for my website with PHP.所以我需要用 PHP 为我的网站制作一个联系表。 Why PHP?为什么是PHP? My dad said that our webhost only works with PHP and not Node.js or something else.我爸爸说我们的虚拟主机只能使用 PHP 而不能使用 Node.js 或其他东西。

So I downloaded XAMPP and started the Apache server, googled localhost:80 and my website was shown.所以我下载了 XAMPP 并启动了 Apache 服务器,用谷歌搜索 localhost:80 并显示了我的网站。 All good.都好。 I added the directory of my HTML, CSS, JS files to DocumentRoot and Directory in httpd.conf.我将我的 HTML、CSS、JS 文件的目录添加到 httpd.conf 中的 DocumentRoot 和 Directory。 Was that the right thing?那是对的吗?

Then I looked at how to integrate PHP with Apache.然后我研究了如何将 PHP 与 Apache 集成。 Then I found out that I have to add this in httpd.conf.然后我发现我必须在 httpd.conf 中添加它。

LoadModule php_module "c:/php/php8apache2_4.dll"
<FilesMatch \.php$>
    SetHandler application/x-httpd-php
</FilesMatch>
PHPIniDir "C:/php"

But that didnt work for me because I couldnt start my apache server anymore.但这对我不起作用,因为我无法再启动我的 apache 服务器。

The error log said that something was wrong in apache/htdocs/api.错误日志说 apache/htdocs/api 有问题。

I tried to find this directory and couldnt find api in htdocs.我试图找到这个目录,但在 htdocs 中找不到 api。 So now Im kinda overwhelmed.所以现在我有点不知所措。

Does anyone know what to do?有谁知道该怎么办?

If you download XAMPP then it's already set up with php.如果你下载 XAMPP 那么它已经用 php 设置好了。 You don't have to install php manually.您不必手动安装 php。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM