dp152153 2016-10-06 20:00
浏览 68

在没有java / jquery的情况下更改页面标题[duplicate]

This question already has an answer here:

so my index page looks like this

<?php include 'header.php';?>
 <main id="main" role="main">
   <?php
    if ($_GET['page'] == "") {
        if ($_POST['page'] <> "") {
            $page = $_POST['page'];
            }
        else {
            $page = "homepage";
            }
        }
    else {
        $page = $_GET['page'];
        }

    switch($page) {
    case "about": include "about.php"; break;
    case "mission": include "mission.php"; break;
    ?>
  </main>
 <?php include 'footer.php';?>

The header got a standard title tag, my question is how can i change the title for each index.php?page=page-name

</div>
  • 写回答

1条回答 默认 最新

  • duande3134 2016-10-06 20:15
    关注

    By the time your page check has started, header.php has already been interpreted. So there is no way to inject the title unless you put the page check above the title.

    Additionally, since you're checking both GET and POST, you might consider simplifying your code as follows:

    <?php
    
    switch($_REQUEST['page']) {
        case "about":
            include "about.php";
            break;
    
        case "mission":
            include "mission.php";
            break;
    
        default:
            include "homepage.php";
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 Macbookpro 连接热点正常上网,连接不了Wi-Fi。
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程