• 20-10-2014, 13:22:18
    #1
    Reveloper
    <?php
    $settings = array
      (
      array("Volvo",22,18),
      array("BMW",15,13),
      array("Saab",5,2),
      array("Land Rover",17,15)
      );
     
    class page{
    	public function __construct(){
    		include("includes/header.php");
    	}
    	public function __destruct(){
    		include("includes/footer.php");
    	}
    }
    ?>
    header.php ve footer.php içerisinde $settings yayınlamak istiyorum nasıl yapacağım?
  • 20-10-2014, 13:38:07
    #2
    XYZ
    Kimlik doğrulama veya yönetimden onay bekliyor.
    Burti adlı üyeden alıntı: mesajı görüntüle
    <?php
    $settings = array
      (
      array("Volvo",22,18),
      array("BMW",15,13),
      array("Saab",5,2),
      array("Land Rover",17,15)
      );
     
    class page{
    	public function __construct(){
    		include("includes/header.php");
    	}
    	public function __destruct(){
    		include("includes/footer.php");
    	}
    }
    ?>
    header.php ve footer.php içerisinde $settings yayınlamak istiyorum nasıl yapacağım?
    Bu şekilde yayınlayabilirsin:

    $settings = array
      (
      array("Volvo",22,18),
      array("BMW",15,13),
      array("Saab",5,2),
      array("Land Rover",17,15)
      );
      
    class page{
       public function __construct(){
        global $settings;
          include("includes/header.php");
       }
       public function __destruct(){
        global $settings;
          include("includes/footer.php");
       }
    }
  • 20-10-2014, 22:52:40
    #3
    Burti adlı üyeden alıntı: mesajı görüntüle
    <?php
    $settings = array
      (
      array("Volvo",22,18),
      array("BMW",15,13),
      array("Saab",5,2),
      array("Land Rover",17,15)
      );
     
    class page{
    	public function __construct(){
    		include("includes/header.php");
    	}
    	public function __destruct(){
    		include("includes/footer.php");
    	}
    }
    ?>
    header.php ve footer.php içerisinde $settings yayınlamak istiyorum nasıl yapacağım?
    Buyrun bir örnek hazirladim ;

    Class page {
    protected $settings=null;
    /**
    Build the __construct()
    **/
    
    public function __construct(array $settings)
    {
    $this->settings=$settings;
    include("includes/header.php");
    return null;
    }
    
    /**
    Build the __destruct()
    **/
    
    public function __destruct()
    {
    include("includes/footer.php");
    unset($this->settings);
    return null;
    }
    }
    
    $setup_settings=array(
    array("Volvo",22,18),
    array("BMW",15,13),
    array("Saab",5,2),
    array("Land Rover",17,15)
    );
      
    $page=new page($setup_settings);
    erismek icin ise $this->settings["dizi"] seklinde.