Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class pageHeader() {
- private $data = null;
- private $pdo = null;
- public function __construct(PDO $pdo) {
- $this->pdo = $pdo;
- }
- private function getData() {
- if (is_null($this->data)) {
- $statement = $PDO->prepare("SELECT * FROM head_info WHERE page_name = :page");
- $statement->bindParam(':page', $page->createBinds(), PDO::PARAM_STR);
- $statement->execute();
- $this->data = $statement->fetch();
- }
- return $data;
- }
- public function getDescription() {
- return $this->getData('page_description');
- }
- public function getTitle() {
- return $this->getData('page_keywords');
- }
- public function getKeywords() {
- return $this->getData('page_title');
- }
- }
- $PDO = new PDO("mysql:host=localhost;dbname=oop", "root", "");
- $PDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
- $PDO->setAttribute(PDO::ATTR_ORACLE_NULLS, PDO::NULL_TO_STRING);
- $header = new pageHeader($PDO);
- // index.php ////////////////////////////////////////////////////////////////////
- <?php require_once 'classes.php'; ?>
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <meta name="description" content="<?php echo $header->getDescription(); ?>">
- <meta name="keywords" content="<?php echo $header->getKeywords(); ?>">
- <title><?php echo $header->getTitle(); ?></title>
- </head>
- <body>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement