<?php
include_once('HeadSection.php');
$headSectionParams = array(
'title' => 'My site',
'meta' => array('name'=>'keywords', 'content'=>'test, generate, head'),
'css' => array('style.css', 'style/common.css'),
'js' => array('functions.js', 'js/test.js')
);
//Passing array as first argument, that will set startingTags to false, as we don't want to render <head> tags in this example.
$headSection = new HeadSection(array('startingTags'=>false), $headSectionParams);
$headSection->addMeta(array('name'=>'robots', 'content'=>'noindex, nofollow'), HeadSection::SET); //Explicitly sets meta tag value, overwriting any previous value(s).
?>
<html>
<head>
<meta http-equiv = "Content-Type" content = "text/html; charset=utf-8" />
<link href = "default.css" rel = "stylesheet" type = "text/css" />
<?php echo $headSection->render(8); //Outputing head section and also passing $indent parametar to render() method. ?>
</head>
<body>
<p>Hello world!</p>
</body>
</html>
<?php
/*
Page source will look something like this:
<html>
<head>
<meta http-equiv = "Content-Type" content = "text/html; charset=utf-8" />
<link href = "default.css" rel = "stylesheet" type = "text/css" />
<title>My site</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name= "robots" content = "noindex, nofollow" />
<link href = "style.css" rel = "stylesheet" type = "text/css" />
<link href = "style/common.css" rel = "stylesheet" type = "text/css" />
<script type = "text/javascript" src = "functions.js"></script>
<script type = "text/javascript" src = "js/test.js"></script>
</head>
<body>
<p>Hello world!</p>
</body>
</html>
*/
?>
|