.html文件中的Php标签在WebMatrix中不起作用 [英] Php tags in .html files don't work in WebMatrix

查看:126
本文介绍了.html文件中的Php标签在WebMatrix中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在学习web开发,而我正在学习的书是在html文件中使用php标签,但它们不适合我,这是我的标题页:

I've been learning web development and the book I am learning from is using php tags within html files but they don't work for me, here is my header page:

<!DOCTYPE html>

<html lang="en">
<head>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
    <title><?php echo $page_title; ?></title>
    <style type="text/css" media="all">@import "./includes/layout.css";</style>
</head>
<body>
    <a href="index.php" class="logo"> <img src="Includes/Images/NameIconSplash.png" /></a>
    <div id="wrapper">
        <div id="content">
            <div id="news">
                <div id="nav">
                    <ul>
                        // Tags don't work here
                        <?php
                            if ( (isset($_COOKIE['user_id'])) && (!strpos($_SERVER['PHP_SELF'], 'logout.php')) ) 
                            {
                                echo '<li><a href="logout.php">                                           Logout</a></li>'
                            } 
                            else 
                            {
                                echo '<li><a href="login.php">                                            Login</a></li>'
                                echo '<li><a href="register.php">                                         Register</a></li>'
                            }
                        ?>




                    </ul>
                </div>

php代码只是普通的黑色文本,但它可以识别php代码中的html代码。是否有人知道为什么它不承认他们?

The php code is just normal black text but it recognises the html code within the php tags. Does someone know why it doesn't recognise them?

提前谢谢。

推荐答案

请将.html文件扩展名改为.php

Please change file extention from .html to .php

这篇关于.html文件中的Php标签在WebMatrix中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆