Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Klasa nie widzi zmiennej z zewnetrznego pliku
demoh
post
Post #1





Grupa: Zarejestrowani
Postów: 4
Pomógł: 0
Dołączył: 18.02.2007

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


Mam klase News dolaczana poprzez require_once() a wyglada ona tak:

  1. <?php
  2. require_once("lang/module/news.lang.php");
  3.    
  4.    class News
  5.    {
  6.        private $title;
  7.        
  8.        public function __construct()
  9.        {
  10.            global $lang_module;
  11.            
  12.            $this->title = $lang_module['news']['defaultTitle'];
  13.        }
  14.    }
  15. ?>


I niestety $lang_module['news']['defaultTitle'] zwraca mi pusta zmienna. Jak dam require_once w index.php lub w __construct() (wywalam global przy dodaniu do konstruktora) to ladnie wszystko dziala.

Moze jakis pomysl czemu tak sie dzieje?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
bim2
post
Post #2





Grupa: Zarejestrowani
Postów: 1 873
Pomógł: 152
Dołączył: 9.04.2006
Skąd: Berlin

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


Nie możesz napisać klasy do czytania tych langów?
  1. <?php
  2. public function __construct()
  3.       {
  4.          
  5.           $this->title = Lang::get('news', 'defaultTitle');
  6.       }
  7. ?>

(IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
Albo już bez Singletona $this->oLang->get(); (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)

Ten post edytował bim2 1.06.2009, 11:32:44
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 12.10.2025 - 20:58