我想动态更改 PHP 页面的标题,但由于页眉和页 footer 分是包含文件,所以我无法使用 <title><?php echo $title;?></title>
一种解决方案。
我想知道是否有任何解决方案,例如Asp.NET Page.Title = "Some Title";
中的解决方案也许像 $page->set_title('Programmers Palace');
非常感谢...
最佳答案
Since the headers and footer sections are include files so I cannot use
<title><?php echo $title;?></title>
kind of solution.
你可以。仅仅因为包含这些文件并不意味着您不能回显那里的内容。
如果您有 Page
对象...
index.php
<?php
$page = new Page('Programmers\' Palace');
include 'includes/header.php';
包含/header.php
<head>
<title><?php echo $page->getTitle(); ?></title>
</head>
关于php - PHP 中的 Page.Title 等效项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6772417/