关于php引入head.php问题

head.php为我的头部文件, head里面包含了title标签,我在1.php和2.php调用了head.php,我想实现的是1.php中标题为1,2.php中标题为2,但title标签在head中,如何动态修改head.php中的title实现呢?

用js
this.document.title = "xxx"

head标签里面引用变量,然后在倒入head前申明这个变量的值
head.php

 <title><?php echo $title;?></title>

1.php


<?php 
    $title="页面1的标题内容";
    include 'head.php';
?>