Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Błąd z funkcją...
NorQ
post 4.07.2012, 13:53:49
Post #1





Grupa: Zarejestrowani
Postów: 91
Pomógł: 0
Dołączył: 15.07.2011

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


Witam, jestem początkujący w php. i natknełem się na błąd Call to undefined function w swoim skrypcie, proszę o wskazanie błędu i doradzenie:

templates.class.php
  1. <?php
  2.  
  3. class Template {
  4. var $templates_dir = 'templates/';
  5. var $templates_tags = '';
  6. var $templates_file = '';
  7.  
  8. function Template() { }
  9.  
  10. function assign($tags,$value='') {
  11. if (is_array($value)) {
  12. foreach($tags as $tag => $tagvalue) {
  13. if (!empty($tag)) {
  14. $this -> templates_tags['{$'.$tag.'}'] = $tagvalue;
  15. }
  16. }
  17. } else {
  18. $this -> templates_tags['{$'.$tags.'}'] = $value;
  19. }
  20. }
  21.  
  22. function display($file) {
  23. $this -> templates_file = file_get_contents($this -> templates_dir.$file);
  24. $tmp_ = str_replace(array_keys($this -> templates_tags), array_values($this -> templates_tags), $this -> templates_file);
  25. echo $tmp_;
  26. }
  27.  
  28. function modules() {
  29. echo 'Hello world!';
  30. }
  31.  
  32. }
  33. ?>


index.php

  1. <?php
  2. include('templates.class.php');
  3. $szablon = new Template();
  4. $modules = modules();
  5. $szablon -> assign('modules', $modules);
  6. $szablon -> assign('template_url', 'templates'); // nazwa katalogu z szablonem
  7. $szablon -> assign('title', 'Radio'); // Nazwa strony
  8. $szablon -> display('index.tpl'); // Nazwa szablonu
  9. ?>


Podejżewam że moja prośba o pomoc może być trochę śmieszna, gdyż dla was jest to prosta rzecz - ale niestety, mimo że jestem na forum rok nie mam czasu przesiadywać przy komputerze 24/h. oraz poznawać PHP...

Ten post edytował NorQ 4.07.2012, 13:54:39


--------------------
HTML, CSS, JS, PHP i inne nie idą w las...
Powoli się uczę co i jak ;]
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 Wersja Lo-Fi Aktualny czas: 19.07.2025 - 15:57