Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class page {
- private $head;
- private $body;
- public function __construct(){
- $this->head = array('scripts'=>array(),'styles'=>array());
- $this->body = '';
- }
- public function addStylesheet($link) {
- $this->head['styles'][] = $link;
- }
- public function addScript($link) {
- $this->head['scripts'][] = $link;
- }
- public function setBody($content) {
- $this->body = $content;
- }
- public function buildOutput() {
- $c_styles = count($this->head['styles']);
- $c_scripts = count($this->head['scripts']);
- $styles = '';
- $scripts = '';
- for ($i = 0; $i < $c_styles; $i++) {
- $styles .= '<link rel="stylesheet" type="text/css" href="'.$this->head['styles'][$i].'" />'."\n";
- }
- for ($i = 0; $i < $c_scripts; $i++) {
- $scripts .= '<script src="'.$this->head['scripts'][$i].'"></script>'."\n";
- }
- $html = "
- <html>
- <head>
- $styles
- $scripts
- </head>
- <body>
- $this->body
- </body>
- </html>
- ";
- return $html;
- }
- }
- $page = new page;
- $page->addStylesheet('http://www.example.com/my.css');
- $page->addStylesheet('http://www.example.com/their.css');
- $page->addScript('http://www.example.com/my.js');
- $page->addScript('http://www.example.com/their.js');
- $page->setBody('<p>This is my body</p>');
- echo $page->buildOutput();
- // Jesus that's right, $html = include(structure.php) !!!!!!!! fuck im an idiot and should sleep now.
- ?>
Advertisement
Add Comment
Please, Sign In to add comment