jestem dopiero raczkujący z php obiektowo także prosiłbym o pomoc....
a mianowicie, mam dwa pliku
config.php
Kod
class Config{
public function changeSite(){
$siteName = 'test';
echo 'mam siteName: --'.$siteName.'--<br/>';
return $siteName;
}
}
public function changeSite(){
$siteName = 'test';
echo 'mam siteName: --'.$siteName.'--<br/>';
return $siteName;
}
}
i plik Index
Kod
include_once 'class/Tables.php';
include_once 'class/TopAds.php';
include_once 'config/config.php';
include_once 'libs/Smarty.class.php';
class Enoclegi {
private $smarty;
private $topAds;
private $tables;
private $config;
//constructor
public function Enoclegi() {
$this->smarty = new Smarty();
$this->config = new Config();
$this->topAds = new TopAds();
$this->tables = new Tables();
}
public function init(){
//$this->topAds -> lastAdd();
$this->config -> changeSite($siteName);
$this->smarty -> assign('VoivodeshipShow', $this->tables->getVoivodeship());
$this->smarty -> assign('CategoryShow', $this->tables->getCategory());
$this->smarty -> display('tpl/index.tpl');
}
}
include_once 'class/TopAds.php';
include_once 'config/config.php';
include_once 'libs/Smarty.class.php';
class Enoclegi {
private $smarty;
private $topAds;
private $tables;
private $config;
//constructor
public function Enoclegi() {
$this->smarty = new Smarty();
$this->config = new Config();
$this->topAds = new TopAds();
$this->tables = new Tables();
}
public function init(){
//$this->topAds -> lastAdd();
$this->config -> changeSite($siteName);
$this->smarty -> assign('VoivodeshipShow', $this->tables->getVoivodeship());
$this->smarty -> assign('CategoryShow', $this->tables->getCategory());
$this->smarty -> display('tpl/index.tpl');
}
}
jak sprawić aby zmienna $siteName z configu została przekazana do
Kod
$this->config -> changeSite($siteName);