我有一個index.php頁面是主頁面。所有頁面都通過GET變量動態包含在index.php中。動態頁面標題
這是UFLEX類的一部分。這將產生基於所述文件的文件名的標題包含與我不喜歡這種方式..
<?php
$page = @$_GET['page'];
$page = !$page ? "home" : $page;
$ext = ".php";
$page_inc = "page/" . str_replace("-", "_", $page) . $ext;
//Page not found
if(!file_exists($page_inc)) send404();
if(!$page_title){
$page_title = ucfirst($page);
}
?>
// HTML CODE <head>, <title>, ecc
// And then
<?php include($page_inc); ?>
例:I查看http://sitename.ext/?page=user&id=nickname
它將包括user.php
,因爲包括在<title>
標籤後面。我不能根據php變量設置標題。 裏面user.php
我有$user['username']
,我想設置這個var當成一個冠軍。
我需要重寫的新途徑,包括與possibilty從包含該文件設置標題文件。
建議?謝謝!
您不應該只接受輸入值並在其中包含腳本。過濾或白名單。至少使用'basename()'或正則表達式來限制它。 – mario
[使用include()設置$變量的內容的可能的重複](http://stackoverflow.com/questions/8725607/setting-variables-content-using-include) – mario