Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class template{
- private $variable = array();
- private $file = '';
- function __construct(){
- $this->load = false;
- }
- //Ładuje plik do zmiennej i zwraca true jeśli istnieje plik
- function load($file){
- if(file_exists(HTML.''.$file)){
- $this->file = HTML.''.$file;
- return $this->load = true;
- }
- else{
- return false;
- }
- }
- //"Tworzy" zmienne z tablicy po czym wyświetla szablon
- function display(){
- foreach($this->variable as $key => $value){
- $$key = $value;
- }
- include(HTML.'index.php');
- echo "\n<!--".round(memory_get_peak_usage()/1024)."kb -->";
- }
- //Ładuje plik który został pobrany przez load();
- function loadfile(){
- if($this->load){
- return $this->file;
- }
- else{
- return 'error_nofile.php';
- }
- }
- function __set($key, $value){
- $this->variable[$key] = $value;
- }
- function __get($key){
- return $this->variable[$key];
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement