я следующий код, изменить Заголовок на странице:Изменить название на странице
class.php
<?php
class Title_And_Page
{
public $pagekey;
public $title;
public $page;
private $pages = array(
'start_page' => array("Startsida", "start_page.php"),
'products' => array("Produkter", "products.php"),
'max_ot' => array("Max-OT", "max_ot.php"),
'blog' => array("Blogg", "blog.php"),
'tools' => array("Verktyg", "tools.php"),
'about_us' => array("Om oss", "about_us.php"));
public function __construct($pagekey)
{
$this->pagekey = $pagekey;
}
public function setTitle()
{
if(array_key_exists($this->pagekey, $this->pages))
{
$this->title = $this->pages[$this->pagekey][0]; //Returns the value in title, that it gets when the constructs is run
return $this->title;
}
}
public function includePage()
{
if(array_key_exists($this->pagekey, $this->pages))
{
$this->page = $this->pages[$this->pagekey][1]; //Returns the value in page, that will be included
return $this->page;
}
}
}
?>
Вот мой некоторый код из моего index.php
if(isset($_GET['page']))
{
$page = $_GET['page'];
}
$page_title = new Title_And_Page($page);
<title><?= $page_title->setTitle(); ?></title>
<li id="info"><a href="?page=products" class='clickme'>Produkter</a></li>
<li id="info"><a href="?page=max_ot">MAX-OT</a></li>
<li id="info"><a href="?page=blog">Blogg</a></li>
<li id="info"><a href="?page=tools">Verktyg</a></li>
<li id="info"><a href="?page=about_us">Om oss</a></li>
Это работает. Тем не менее, у меня есть статьи на странице блога, содержащие ссылки «Подробнее». Когда я нажимаю ссылку «Читать дальше», URL-адрес изменяется на это: index.php? Page = blog & readmore_from_firstpage = 1 & article_header = Vilken kolhydrat är bäst att äta efter träningen?
Как изменить заголовок страницы на значение в $ _GET ['article_header'], как вы можете видеть выше?
Спасибо большое :) – user500468