1

新しいページを簡単に作成できるように、Web サイトに PHP インクルードを使用したかったのですが、問題が 1 つあります。また、この 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 に答える