php 无法在 wampserver 中的 html 代码中工作 [英] php not working inside html code in wampserver
问题描述
事情就是这样.. 我有一个名为 first.php 的文件,其中包含以下代码:
Here's the thing.. I have a file named first.php containing the following code:
<html>
<title>trial</title>
<head>welcome</head>
<body>
<br>
<?php
echo "hello world";
?>
</body>
</html>
但是,当我执行它时,不会解释 php 代码.短的开放标签似乎也打开了.我正在使用 wampserver.我错过了什么?
However when I execute it, the php code is not interpreted. The short open tag also seems to be on. I'm using wampserver. what have I missed?
推荐答案
<html>
<head>
<title>trial</title>
</head>
<body>
<?php echo "hello world"; ?>
</body>
</html>
尝试将标题包裹在头部内,就像它应该的那样.欢迎只是漂浮在无人区,可能已经破坏了你的密码.另外,使用 doctype 标签 - <!html>
没有空格是 HTML5.
Try it with the title wrapped inside the head like it should be. The welcome was just floating around in no mans land, may have broken your code. Also, use a doctype tag - < !html>
without the space is HTML5.
更新将此添加到本地主机文件夹中的空白 php 文件中.
Update Add this to a blank php file in your localhost folder.
<?php
// Show all information, defaults to INFO_ALL
phpinfo();
?>
如果没有收到报告,则是服务器配置问题.
If you don't get a report back, it's a server config problem.
还要确保将其放在 htdocs
或任何公共"文件夹中.
Also make sure your putting it in htdocs
or whatever your "public" folder is.
这篇关于php 无法在 wampserver 中的 html 代码中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!