1

我想在我的网站中使用 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">" ;

}
?>

这就是我在 index.php 等中的内容。

<?php
include( "header.php" );
pageName( "Home" );
?>

非常感谢您阅读本文,也许可以帮助我!

4

1 回答 1

3

您的报价引起了问题。

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

print <<<EOT
<html lang="en">
   ..........
EOT;
于 2012-10-09T14:42:10.887 回答