PHP代码无法正常工作,无法找到语法错​​误

时间:2014-03-25 16:21:11

标签: php html wamp

我有一个带有一些非常基本的php的html页面。我不知道它为什么不起作用。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta name="author" content="Robin Van Campen">
    <meta name="description" content="Website showing XSS and HMAC" />
    <meta name="keywords" content="html, security "/>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <link href="bootstrap.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" href="global.css" />
    <link href="Resources/Icons/favicon.ico" rel="icon" type="image/x-icon" />
    <link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
    <title>Example 2</title>
</head>
<body>

<div class="container">
    <?php
        echo "<p>name</p>";
    ?>
</div>

</body>
</html>

问题是当我从点击表单按钮加载该页面时,我在屏幕上看到了这个。

name
"; ?>

我看不出我做错了什么。

4 个答案:

答案 0 :(得分:3)

您的文件扩展名是否设置为PHP?看起来你只是将php添加到html文件中。您需要将PHP设置为文件扩展名。

答案 1 :(得分:2)

您需要创建文件.php而不是.html或将服务器配置为解析.html文件。

答案 2 :(得分:0)

您的文件必须是PHP扩展名,即:myFile.php,并且必须先将其上传到您的服务器,因为PHP预处理器是服务器端。

答案 3 :(得分:0)

  1. 使用扩展名.php

  2. 保存文件
  3. 您使用的服务器是什么? 阿帕奇 WAMP 灯 可以随时处理php页面

  4. 如果您使用IIS for Windows,则需要安装php扩展

    1. 如果您在某处托管了您的网页,请检查您的主机是否提供了php支持