Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Singleton - problem, moze lamerski
bartyk
post
Post #1





Grupa: Zarejestrowani
Postów: 64
Pomógł: 0
Dołączył: 8.11.2004

Ostrzeżenie: (10%)
X----


console_class.php:
  1. <?php
  2.  
  3. class console_class {
  4.  
  5. var $content;
  6. var $window;
  7. var $title;
  8.  
  9. function &singleton() {
  10.  
  11. static $instance;
  12.  
  13. if (!isset($instance)) {
  14. $instance=new console_class();
  15. }
  16. return $install;
  17. }
  18.  
  19. function set_console($window, $title) {
  20.  
  21. $this->content='';
  22. $this->window=$window;
  23. $this->title=$title;
  24. }
  25.  
  26. ......
  27.  
  28. }
  29.  
  30. ?>


main.php:
  1. <?php
  2.  
  3. require_once('class.console.php');
  4.  
  5. var $MyConsole;
  6.  
  7. $MyConsole = &console_class::singleton();
  8. $MyConsole->set_console(&#092;"nazwa\", \"tytul\");
  9. ....
  10.  
  11. ?>


niestety pojawia sie komunikat:
Fatal error: Call to a member function on a non-object in ...

wskazując na linię z wywołaniem metody set_console

Gdzie tkwi błąd?
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: 22.08.2025 - 18:56