PHP - how to change title of the page AFTER including header.php?

前端 未结 9 1294
暗喜
暗喜 2020-12-13 03:10

page.php:


header.php:

<?php echo $title; ?>&         
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-5408099190056760"
     data-ad-slot="7305827575"
     data-ad-format="auto"
     data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>        </div>
      </div>
      
      <div class="fly-panel detail-box" id="flyReply">
        <fieldset class="layui-elem-field layui-field-title" style="text-align: center;">
          <legend>9条回答</legend>        </fieldset>

        <ul class="jieda" id="jieda">
                    <li data-id="111" class="jieda-daan">
            <a name="item-1111111111"></a>
            <div class="detail-about detail-about-reply">
                         <a class="fly-avatar" href="">
                <img src="https://www.e-learn.cn/qa/data/avatar/000/00/00/small_000000036.jpg" alt=" 南笙 ">
              </a>
              <div class="fly-detail-user">
                <a href="" class="fly-link">
                  <cite> 南笙</cite>
                                             
                </a>
                
                <span>(楼主)</span>
            
              </div>              <div class="detail-hits">
                <span>2020-12-13 03:36</span>
              </div>

            </div>
            <div class="detail-body jieda-body photos">
              <p>          
<p>It's very easy.
Put this code in header.php </p>

<pre><code>        <? 
$sitename = 'Your Site Name'
$pagetitle;

if(isset($pagetitle)){
 echo "<title>$pagetitle." | ". $sitename";
} 
  else {
echo "$sitename";
}
?>

Then in the page put there :

 

So if you are on Index.php , The title is Your Site Name. And for example if you are on sign up page , The title is Sign up | Your Site Name

提交回复
热议问题