简体   繁体   English

将PHP嵌入到HTML中

[英]Embed PHP into HTML

I'm trying to use PHP to print out values for my select statements but I can't get it to work. 我正在尝试使用PHP打印出我的select语句的值,但我无法让它工作。 I've even tried just to print something out in my html with php, but i can't even seem to do that. 我甚至尝试过在我的html中使用php打印出一些内容,但我甚至无法做到这一点。 Can anyone tell me what's wrong with this 任何人都可以告诉我这有什么问题

<html>
<head></head>
<body>
<ul> 
    <?php echo "register Student:"; ?>
</ul> 
</body>
</html>

Make sure you save your file as .php not .html. 确保将文件另存为.php 而不是 .html。

myfile.php: myfile.php:

<html>
<head></head>
<body>
<ul> 
    <?php echo "register Student:"; ?>
</ul> 
</body>
</html>

You will also need to run this file on a server that has php installed. 您还需要在安装了php的服务器上运行此文件。 It won't run directly in the browser like an .html file will. 它不会像.html文件一样直接在浏览器中运行。

Keep these things in mind. 记住这些事情。

  1. Your file name should always end with .php extension not .htm or .html 您的文件名应始终以.php扩展名结尾,而不是.htm或.html
  2. You should always run file on localhost/ where you set up your environment 您应始终在localhost /您设置环境的位置运行文件
  3. Please follow the standard of W3C Use a "li" in you "ul" 请遵循W3C的标准在你的“ul”中使用“li”

Hope it works. 希望它有效。

Name your file whatever.php Make sure it is NOT whatever.html 将你的文件命名为whatever.php确保它不是 whatever.html

If that doesn't work, be sure to check whether or not you installed php. 如果这不起作用,请务必检查是否安装了php。 I suggest a local testing ground such as XAMPP. 我建议使用XAMPP等本地测试场。 If you don't want to do that, upload it to a free or paid hosting service. 如果您不想这样做,请将其上传到免费或付费托管服务。

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

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