[英]PHP in HTML, php code showing
I'm sure this is simple and stupid on my part, but my php code keeps showing up in my html page. 我确定这对我来说既简单又愚蠢,但是我的php代码一直显示在我的html页面中。
This is just a simple test: 这只是一个简单的测试:
<html>
<body>
Test 1<br>
<?php
print "Test 2";
echo "Test 3";
print "<b>Test 4</b>";
?>
Test 5<br>
</body>
</html>
And this is how it looks: 这是它的外观:
Test 1<br>
Test 4"; ?> Test 5
What the heck am I doing wrong? 我到底在做什么错? Above I've mixed echo and print to show it doesn't seem to make a difference.
在上面,我混合了echo和print来显示它似乎没有什么不同。
You are not accessing the program through a web server that supports PHP and is configured to parse that page for PHP directives. 您不是通过支持PHP的Web服务器访问该程序,该Web服务器已配置为解析该页面的PHP指令。
.php
file extension") .php
文件扩展名”) if you are using a local server (XAMPP, for example), and you access your webpage by double clicking on the html file, then the address in the browser will be 如果您使用的是本地服务器(例如XAMPP),并且通过双击html文件访问网页,则浏览器中的地址为
file:///C:/xampp/htdocs/(filename).html 文件:/// C:/ xampp / htdocs /(文件名).html
which will NOT run PHP for some reason. 由于某种原因,它将无法运行PHP。 The correct address to use to access your html file with PHP code in it is
用于访问包含PHP代码的html文件的正确地址是
http://localhost/(filename).html http:// localhost /(文件名).html
which accesses the html file in a way that the PHP works, and needs to be entered directly into the browser, then bookmark your local host directory so you can easily access your files through the browser instead of clicking on the icons in explorer or through the terminal 它会以PHP可以正常工作的方式访问html文件,并且需要直接输入到浏览器中,然后为本地主机目录添加书签,以便您可以轻松地通过浏览器访问文件,而无需单击资源管理器中的图标或通过终奌站
fyi the address prefix is persistent, so it will carry through to linked pages, which means if PHP doesn't work on the first page then it won't work on any of the other pages on your website, conversely, if the first page works, then the rest will too 如果地址前缀是持久性的,则它将通过链接的页面传递,这意味着如果PHP在首页上不起作用,那么它将在您网站上的其他任何页面上都不起作用,反之,如果首页可以,其余的也可以
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.