Advertisement
Guest User

inc/class/create

a guest
Jun 20th, 2012
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.91 KB | None | 0 0
  1. <?php
  2. class template{
  3.     private $variable = array();
  4.     private $file = '';
  5.     function __construct(){
  6.         $this->load = false;
  7.     }
  8.    
  9.     //Ładuje plik do zmiennej i zwraca true jeśli istnieje plik
  10.     function load($file){
  11.         if(file_exists(HTML.''.$file)){
  12.             $this->file = HTML.''.$file;   
  13.             return $this->load = true;
  14.         }
  15.         else{
  16.             return false;
  17.         }
  18.     }
  19.    
  20.     //"Tworzy" zmienne z tablicy po czym wyświetla szablon
  21.     function display(){
  22.         foreach($this->variable as $key => $value){
  23.             $$key = $value;
  24.         }
  25.         include(HTML.'index.php');
  26.         echo "\n<!--".round(memory_get_peak_usage()/1024)."kb -->";
  27.     }
  28.    
  29.     //Ładuje plik który został pobrany przez load();
  30.     function loadfile(){
  31.         if($this->load){
  32.             return $this->file;
  33.         }
  34.         else{
  35.             return 'error_nofile.php';
  36.         }
  37.     }
  38.    
  39.     function __set($key, $value){
  40.         $this->variable[$key] = $value;
  41.     }
  42.    
  43.     function __get($key){
  44.         return $this->variable[$key];
  45.     }
  46. }
  47. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement