¿Cómo mejorar estos códigos?

Iniciado por Richter{};, 11 Noviembre 2014, 22:44 PM

0 Miembros y 1 Visitante están viendo este tema.

Richter{};

1. Core.php

Código (php) [Seleccionar]
<?php

class Core {
      public 
$MySQLi;
      public 
$instance;

      public static function 
getInstance() {
         static 
$instance = null;
         if(
$instance == null) {
             
$instance = new Core();
          }
         return 
$instance;
      }

     private function 
__construct() {
        require 
$_SERVER['DOCUMENT_ROOT'] . '/Core/Configuration.php';
        
$this->MySQLi = new MySQLi($host, $user, $pass, $db);
          if (
$this->MySQLi->connect_error) {
            echo 
'ERROR MySQLi';
          }
      }

      private function 
__destruct() {
         
$this->MySQLi->close();
      }
   }

   
$heart = Core::getInstance();

?>



2. Templates.php

Código (php) [Seleccionar]
<?php

  
class Templates {
    public static function 
show($theme, $file_html, $lang) {
        
$file = $_SERVER['DOCUMENT_ROOT'] . '/Templates/' . $theme . '/' . $file_html . '.html';
        
$open = fopen($file, 'r');
        
$html = fread($open, filesize($file));
      foreach (
$lang as $key => $value) {
        
$html = str_replace('%' . $key . '%', $value, $html);
      }
      echo 
$html;
    }
  }
  
$templates = new Templates();

?>


dimitrix

Veo que tienes un core y una vista... podrías usar  directamente codeigniter y así si vendes el proyecto o se te une alguien será un punto a tu favor...