引导PHP头文件

引导PHP头文件,php,Php,我想在我的网站中使用一个PHP包含,所以创建新页面非常容易,但我有一个问题。我还想在header.php中包含我的导航,但我的问题是,我在活动页面上有一个活动类,所以我想知道如何使用php实现这一点。这就是我现在在header.php中看到的内容,但我无法理解 <?php function pageName( $name="" ){ print " <html lang="en"> <head> <meta http-equiv="Content-t

我想在我的网站中使用一个PHP包含,所以创建新页面非常容易,但我有一个问题。我还想在header.php中包含我的导航,但我的问题是,我在活动页面上有一个活动类,所以我想知道如何使用php实现这一点。这就是我现在在header.php中看到的内容,但我无法理解

<?php
function pageName( $name="" ){

print "
<html lang="en">
<head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <meta http-equiv="Content-Language" content="en-gb" />
    <meta name="keywords" content="Minecraft Hosting, Minecraft, Hosting, VoxelHost, VoxelHost, Cheap, Reliable, Great Support, Great, Support, Europe, Best Minecraft Host, Best, Minecraft, Host" />
    <meta name="description" content="Voxel Host delivers Cheap and Reliable Hosting Solutions for your daily needs." />
    <link rel="shortcut icon" type="image/png" href="https://www.voxelhost.com/img/icon.png" />
    <title>Voxel Host - Cheap And Reliable Hosting Solutions</title>
    <link rel="stylesheet" type="text/css" href="https://www.voxelhost.com/css/bootstrap.css" media="all" />
    <link rel="stylesheet" type="text/css" href="https://www.voxelhost.com/css/voxelhost.css" media="all" />
    <link rel="stylesheet" type="text/css" href="https://www.voxelhost.com/css/nivo-slider.css" media="all" />
    <link rel="stylesheet" type="text/css" href="https://www.voxelhost.com/css/default.css" media="all" />
    <link rel="stylesheet" type="text/css" href="https://www.voxelhost.com/css/font-awesome.css" />
    <script type="text/javascript" src="https://www.voxelhost.com/js/jquery.min.js"></script>
    <script type="text/javascript" src="https://www.voxelhost.com/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="https://www.voxelhost.com/js/jquery.slider.nivo.js"></script>
    <!--Start of Zopim Live Chat Script-->
    <script type="text/javascript">
        window.$zopim||(function(d,s){var z=$zopim=function(c){z._.push(c)},$=z.s=
        d.createElement(s),e=d.getElementsByTagName(s)[0];z.set=function(o){z.set.
        _.push(o)};z._=[];z.set._=[];$.async=!0;$.setAttribute('charset','utf-8');
        $.src='//cdn.zopim.com/?bIkq1WcfGahuJo4awX9QoDtEdvXXAClp';z.t=+new Date;$.
        type='text/javascript';e.parentNode.insertBefore($,e)})(document,'script');
    </script>
    <!--End of Zopim Live Chat Script-->
    <script type="text/javascript">
        var _gaq = _gaq || [];
        _gaq.push(['_setAccount', 'UA-35044907-1']);
        _gaq.push(['_setDomainName', 'voxelhost.com']);
        _gaq.push(['_trackPageview']);

        (function() {
          var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
          ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
          var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
        })();

    </script>
</head>
<body>
    <div class="alertbar inactive"></div>
    <div class="infobar">We are starting the 20th of October! See you soon!</div>
    <div class="succesbar inactive"></div>
    <div id="topbar">
        <ul>
            <li><a href="https://www.voxelhost.com/billing/supporttickets.php">Support Ticket</a></li>
            <li><a href="mailto:info@voxelhost.com">Email</a></li>
            <li><a href="skype:martijnriemers?chat">Skype</a></li>
        </ul>
    </div>
    <div id="logo">
        <div class="align">
            <div class="left" style="width: 500px;">
                <a href="#"><img src="https://www.voxelhost.com/img/logo.png" /></a>
            </div>
            <div class="clear"></div>
        </div>
    </div>
    <div id="wrapper">
        <div class="container">
            <div class="navbar" id="navbarhomepage">
                <div class="navbar-inner">
                    <div class="container">
                        <ul class="nav">
                            <li class="active"><a href="https://www.voxelhost.com/"><i class="icon-home"></i> &nbsp;Home</a></li>
                            <li class="dropdown">
                                <a href="#" class="dropdown-toggle"><i class="icon-star"></i> &nbsp;Services</a>
                                <ul class="dropdown-menu">
                                    <li><a href="https://www.voxelhost.com/minecraft/standard">Standard Minecraft Servers</a></li>
                                    <li><a href="https://www.voxelhost.com/minecraft/premium">Premium Minecraft Servers</a></li>
                                    <li><a href="https://www.voxelhost.com/minecraft_reseller">Minecraft Reseller</a></li>
                                    <li><a href="https://www.voxelhost.com/comingsoon">VPS Hosting</a></li>
                                    <li><a href="https://www.voxelhost.com/comingsoon">Dedicated Servers</a></li>
                                    <li><a href="https://www.voxelhost.com/comingsoon">Web Hosting</a></li>
                                </ul>
                            </li>
                            <li><a href="https://www.voxelhost.com/status"><i class="icon-ok-sign"></i> &nbsp;Server Status</a></li>
                            <li><a href="https://www.voxelhost.com/billing/cart"><i class="icon-shopping-cart"></i> &nbsp;Order Now</a></li>
                            <li><a href="https://www.voxelhost.com/billing/"><i class="icon-user"></i> &nbsp;Client Area</a></li>
                            <li class="dropdown">
                                <a href="#" class="dropdown-toggle"><i class="icon-dashboard"></i> &nbsp;Control Panels</a>
                                <ul class="dropdown-menu">
                                    <li><a href="https://mcpanel.voxelhost.com/">Minecraft Servers</a></li>
                                    <li><a href="https://mintpanel.voxelhost.com/">Game Servers</a></li>
                                    <li><a href="https://cpanel.voxelhost.com/">Webhosting</a></li>
                                </ul>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
        <div id="content">" ;

}
?>

您的报价引起了问题

要转储大字符串,请尝试使用herdoc:

print <<<EOT
<html lang="en">
   ..........
EOT;

print Ok,但是如何使用php更改活动类呢?我发现了这个,这是我应该使用的吗?但是如果我更新标题,我必须更新我所有的30页,这将花费很多时间。如果我可以使用一个header.php并在导航中使用一个管理“Active”类的代码,这将节省大量时间。正如@lawrencerone所说,您可以脱离php,转储大部分HTML,然后跳回php输出变量。在PHP5.4中(如果在早期版本中有短标记的话),您可以只写
来输出一个变量。我想我已经不懂了。但是如果不可能的话,我想我会在header.php中省略我的导航。放弃不会让你有任何进展。你说的导航CSS
class=“active
动态选择基于选择的页面?是的,没错。这是我的问题。
print <<<EOT
<html lang="en">
   ..........
EOT;