为什么不显示这个html?

时间:2015-09-08 13:54:04

标签: php html

为什么要赢得这项工作?如果$ a Boolean为true,它应该只显示html。 我是否正确地使用PHP有条不紊地显示HTML? 我真的不知道为什么它不会工作。我真的很感激能给予我任何帮助。 :)

<!DOCTYPE html>
 <html>

<?php
 $a = False;
 if($a == True){
 <head>
    <title>No Sidebar - Escape Velocity by HTML5 UP</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <!--[if lte IE 8]><script src="assets/js/ie/html5shiv.js"></script><![endif]-->
    <link rel="stylesheet" href="assets/css/main.css" />
    <!--[if lte IE 8]><link rel="stylesheet" href="assets/css/ie8.css" /><![endif]-->
</head>
<body class="no-sidebar">
    <div id="page-wrapper">

        <!-- Header -->
            <div id="header-wrapper" class="wrapper">
                <div id="header">

                    <!-- Logo -->
                        <div id="logo">
                            <h1><a href="index.html">Escape Velocity</a></h1>
                            <p>A free responsive site template by HTML5 UP</p>
                        </div>

                    <!-- Nav -->
                        <nav id="nav">
                            <ul>
                                <li class="current"><a href="index.html">Home</a></li>
                                <li>
                                    <a href="#">Dropdown</a>
                                    <ul>
                                        <li><a href="#">Lorem ipsum</a></li>
                                        <li><a href="#">Magna veroeros</a></li>
                                        <li><a href="#">Etiam nisl</a></li>
                                        <li>
                                            <a href="#">Sed consequat</a>
                                            <ul>
                                                <li><a href="#">Lorem dolor</a></li>
                                                <li><a href="#">Amet consequat</a></li>
                                                <li><a href="#">Magna phasellus</a></li>
                                                <li><a href="#">Etiam nisl</a></li>
                                                <li><a href="#">Sed feugiat</a></li>
                                            </ul>
                                        </li>
                                        <li><a href="#">Nisl tempus</a></li>
                                    </ul>
                                </li>
                                <li><a href="left-sidebar.html">Left Sidebar</a></li>
                                <li><a href="right-sidebar.html">Right Sidebar</a></li>
                                <li><a href="no-sidebar.html">No Sidebar</a></li>
                            </ul>
                        </nav>

                </div>
            </div>

        <!-- Main -->
            <div class="wrapper style2">
                <div class="title">No Sidebar</div>
                <div id="main" class="container">

                    <!-- Content -->
                        <div id="content">
                            <article class="box post">
                                <header class="style1">
                                    <h2>Lorem ipsum dolor sit amet magna egestas<br class="mobile-hide" />
                                    morbi bibendum sed malesuada</h2>
                                    <p>Tempus feugiat veroeros sed nullam dolore</p>
                                </header>
                                <a href="#" class="image featured">
                                    <img src="images/pic01.jpg" alt="" />
                                </a>
                                <p>Fringilla nisl. Donec accumsan interdum nisi, quis tincidunt felis sagittis eget.
                                odio eleifend. Duis commodo fringilla commodo. Aliquam erat volutpat. Vestibulum
                                facilisis leo magna. Cras sit amet urna eros, id egestas urna. Quisque aliquam
                                tempus euismod. Vestibulum ante ipsum primis in faucibus.</p>
                                <p>Phasellus nisl nisl, varius id porttitor sed, pellentesque ac orci. Pellentesque
                                habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Morbi
                                bibendum justo sed mauris vehicula malesuada aliquam elit imperdiet. Aliquam eu nibh
                                lorem, eget gravida mi. Duis odio diam, luctus et vulputate vitae, vehicula ac dolor.
                                Pellentesque at urna eget tellus lobortis ultrices sed non erat. Donec eget erat non
                                magna volutpat malesuada quis eget eros. Nullam sodales cursus sapien, id consequat
                                leo suscipit ut. Praesent id turpis vitae turpis pretium ultricies. Vestibulum sit
                                amet risus elit.</p>
                                <p>Donec consectetur vestibulum dolor et pulvinar. Etiam vel felis enim, at viverra
                                ligula. Ut porttitor sagittis lorem, quis eleifend nisi ornare vel. Praesent nec orci
                                eget quam rutrum bibendum. Proin pellentesque diam non ligula commodo tempor. Vivamus
                                eget urna nibh. Curabitur non fringilla nisl. Donec accumsan interdum nisi, quis
                                tincidunt felis sagittis eget. Donec elementum ligula dignissim sem pulvinar non semper
                                odio eleifend. Duis commodo fringilla commodo. Aliquam erat volutpat. Vestibulum
                                facilisis leo magna. Cras sit amet urna eros, id egestas urna. Quisque aliquam
                                tempus euismod. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices
                                posuere cubilia.</p>
                                <p>Phasellus nisl nisl, varius id porttitor sed, pellentesque ac orci. Pellentesque
                                habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Morbi
                                bibendum justo sed mauris vehicula malesuada aliquam elit imperdiet. Aliquam eu nibh
                                lorem, eget gravida mi. Duis odio diam, luctus et vulputate vitae, vehicula ac dolor.
                                Pellentesque at urna eget tellus lobortis ultrices sed non erat. Donec eget erat non
                                magna volutpat malesuada quis eget eros. Nullam sodales cursus sapien, id consequat
                                leo suscipit ut. Praesent id turpis vitae turpis pretium ultricies. Vestibulum sit
                                amet risus elit.</p>
                            </article>
                            <div class="row 150%">
                                <div class="4u 12u(mobile)">
                                    <section class="box">
                                        <header>
                                            <h2>Magna pulvinar tempus</h2>
                                        </header>
                                        <a href="#" class="image featured"><img src="images/pic05.jpg" alt="" /></a>
                                        <p>Rutrum bibendum. Proin pellentesque diam non ligula commodo tempor. Vivamus
                                        eget urna nibh. Curabitur non fringilla nisl. Donec accumsan interdum nisi, quis
                                        tempus.</p>
                                        <a href="#" class="button style1">More</a>
                                    </section>
                                </div>
                                <div class="4u 12u(mobile)">
                                    <section class="box">
                                        <header>
                                            <h2>Magna pulvinar tempus</h2>
                                        </header>
                                        <a href="#" class="image featured"><img src="images/pic06.jpg" alt="" /></a>
                                        <p>Rutrum bibendum. Proin pellentesque diam non ligula commodo tempor. Vivamus
                                        eget urna nibh. Curabitur non fringilla nisl. Donec accumsan interdum nisi, quis
                                        tempus.</p>
                                        <a href="#" class="button style1">More</a>
                                    </section>
                                </div>
                                <div class="4u 12u(mobile)">
                                    <section class="box">
                                        <header>
                                            <h2>Magna pulvinar tempus</h2>
                                        </header>
                                        <a href="#" class="image featured"><img src="images/pic07.jpg" alt="" /></a>
                                        <p>Rutrum bibendum. Proin pellentesque diam non ligula commodo tempor. Vivamus
                                        eget urna nibh. Curabitur non fringilla nisl. Donec accumsan interdum nisi, quis
                                        tempus.</p>
                                        <a href="#" class="button style1">More</a>
                                    </section>
                                </div>
                            </div>
                        </div>

                </div>
            </div>

        <!-- Highlights -->
            <div class="wrapper style3">
                <div class="title">The Endorsements</div>
                <div id="highlights" class="container">
                    <div class="row 150%">
                        <div class="4u 12u(mobile)">
                            <section class="highlight">
                                <a href="#" class="image featured"><img src="images/pic02.jpg" alt="" /></a>
                                <h3><a href="#">Aliquam diam consequat</a></h3>
                                <p>Eget mattis at, laoreet vel amet sed velit aliquam diam ante, dolor aliquet sit amet vulputate mattis amet laoreet lorem.</p>
                                <ul class="actions">
                                    <li><a href="#" class="button style1">Learn More</a></li>
                                </ul>
                            </section>
                        </div>
                        <div class="4u 12u(mobile)">
                            <section class="highlight">
                                <a href="#" class="image featured"><img src="images/pic03.jpg" alt="" /></a>
                                <h3><a href="#">Nisl adipiscing sed lorem</a></h3>
                                <p>Eget mattis at, laoreet vel amet sed velit aliquam diam ante, dolor aliquet sit amet vulputate mattis amet laoreet lorem.</p>
                                <ul class="actions">
                                    <li><a href="#" class="button style1">Learn More</a></li>
                                </ul>
                            </section>
                        </div>
                        <div class="4u 12u(mobile)">
                            <section class="highlight">
                                <a href="#" class="image featured"><img src="images/pic04.jpg" alt="" /></a>
                                <h3><a href="#">Mattis tempus lorem</a></h3>
                                <p>Eget mattis at, laoreet vel amet sed velit aliquam diam ante, dolor aliquet sit amet vulputate mattis amet laoreet lorem.</p>
                                <ul class="actions">
                                    <li><a href="#" class="button style1">Learn More</a></li>
                                </ul>
                            </section>
                        </div>
                    </div>
                </div>
            </div>

        <!-- Footer -->
            <div id="footer-wrapper" class="wrapper">
                <div class="title">The Rest Of It</div>
                <div id="footer" class="container">
                    <header class="style1">
                        <h2>Ipsum sapien elementum portitor?</h2>
                        <p>
                            Sed turpis tortor, tincidunt sed ornare in metus porttitor mollis nunc in aliquet.<br />
                            Nam pharetra laoreet imperdiet volutpat etiam consequat feugiat.
                        </p>
                    </header>
                    <hr />
                    <div class="row 150%">
                        <div class="6u 12u(mobile)">

                            <!-- Contact Form -->
                                <section>
                                    <form method="post" action="#">
                                        <div class="row 50%">
                                            <div class="6u 12u(mobile)">
                                                <input type="text" name="name" id="contact-name" placeholder="Name" />
                                            </div>
                                            <div class="6u 12u(mobile)">
                                                <input type="text" name="email" id="contact-email" placeholder="Email" />
                                            </div>
                                        </div>
                                        <div class="row 50%">
                                            <div class="12u">
                                                <textarea name="message" id="contact-message" placeholder="Message" rows="4"></textarea>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="12u">
                                                <ul class="actions">
                                                    <li><input type="submit" class="style1" value="Send" /></li>
                                                    <li><input type="reset" class="style2" value="Reset" /></li>
                                                </ul>
                                            </div>
                                        </div>
                                    </form>
                                </section>

                        </div>
                        <div class="6u 12u(mobile)">

                            <!-- Contact -->
                                <section class="feature-list small">
                                    <div class="row">
                                        <div class="6u 12u(mobile)">
                                            <section>
                                                <h3 class="icon fa-home">Mailing Address</h3>
                                                <p>
                                                    Untitled Corporation<br />
                                                    1234 Somewhere Rd #987<br />
                                                    Nashville, TN 00000-0000
                                                </p>
                                            </section>
                                        </div>
                                        <div class="6u 12u(mobile)">
                                            <section>
                                                <h3 class="icon fa-comment">Social</h3>
                                                <p>
                                                    <a href="#">@untitled-corp</a><br />
                                                    <a href="#">linkedin.com/untitled</a><br />
                                                    <a href="#">facebook.com/untitled</a>
                                                </p>
                                            </section>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="6u 12u(mobile)">
                                            <section>
                                                <h3 class="icon fa-envelope">Email</h3>
                                                <p>
                                                    <a href="#">info@untitled.tld</a>
                                                </p>
                                            </section>
                                        </div>
                                        <div class="6u 12u(mobile)">
                                            <section>
                                                <h3 class="icon fa-phone">Phone</h3>
                                                <p>
                                                    (000) 555-0000
                                                </p>
                                            </section>
                                        </div>
                                    </div>
                                </section>

                        </div>
                    </div>
                    <hr />
                </div>
                <div id="copyright">
                    <ul>
                        <li>&copy; Untitled.</li><li>Design: <a href="http://html5up.net">HTML5 UP</a></li>
                    </ul>
                </div>
            </div>

    </div>

    <!-- Scripts -->

        <script src="assets/js/jquery.min.js"></script>
        <script src="assets/js/jquery.dropotron.min.js"></script>
        <script src="assets/js/skel.min.js"></script>
        <script src="assets/js/skel-viewport.min.js"></script>
        <script src="assets/js/util.js"></script>
        <!--[if lte IE 8]><script src="assets/js/ie/respond.min.js"></script><![endif]-->
        <script src="assets/js/main.js"></script>

</body>
    } ?>



    </html>

2 个答案:

答案 0 :(得分:7)

您需要在输出原始HTML时关闭PHP,以便在此处更改

import UIKit
import GoogleMobileAds

class ViewController: UIViewController, GADInterstitialDelegate {

    var admobInterstitial : GADInterstitial?
    var timer : NSTimer?

    override func viewDidLoad() {
        super.viewDidLoad()

        admobInterstitial = createAndLoadInterstitial()
        timer = NSTimer.scheduledTimerWithTimeInterval(5.0, target:self, selector: Selector("presentInterstitial"), userInfo: nil, repeats: false)
    }

    func createAndLoadInterstitial()->GADInterstitial {
        var interstitial = GADInterstitial(adUnitID: "yourAdMobADUnitID")
        interstitial.delegate = self
        interstitial.loadRequest(GADRequest())
        return interstitial
    }

    func presentInterstitial() {
        if let isReady = admobInterstitial?.isReady {
            admobInterstitial?.presentFromRootViewController(self)
        }
    }

    func interstitial(ad: GADInterstitial!, didFailToReceiveAdWithError error: GADRequestError!) {
        println("interstitialDidFailToReceiveAdWithError:\(error.localizedDescription)")
        admobInterstitial = createAndLoadInterstitial()
    }

在最底层改变

<!DOCTYPE html>
 <html>

<?php
 $a = False;
 if($a == True){
?>                         <-- new line
<head>

答案 1 :(得分:1)

您的问题是您正在尝试将HTML解析为PHP。您必须关闭PHP标记,或者回显它。关闭PHP标签可能更好,因为:

if($a == True){
    ?>
    <head>
    <!--- More HTML here --->

并在if语句的结束括号之前打开它:

    <!--- HTML coming in here... --->
    </body>
<?php } ?>