Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] Problem z przekazaniem argumentu funkcji
tomi1985
post
Post #1





Grupa: Zarejestrowani
Postów: 192
Pomógł: 12
Dołączył: 23.09.2010
Skąd: Warszawa

Ostrzeżenie: (0%)
-----


Witam,
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;
    }
}


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');
    }
}



jak sprawić aby zmienna $siteName z configu została przekazana do
Kod
$this->config     ->      changeSite($siteName);
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 19.08.2025 - 16:26