Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP]Klasa w klasie
Forum PHP.pl > Forum > Przedszkole
xxdrago
Witam, chciałbym uruchomić klasę w klasie co muszę zrobić aby nie wyskakiwały błędy?
Daiquiri
Jeżeli tworzysz instancję klasy B wewnątrz klasy A, to musisz zapewnić dostęp do definicji klasy B.

O jakich błędach piszesz?
xxdrago
Kod
Notice: Constant geshi_version already defined in C:\Program Files (x86)\xampp\xampp\htdocs\function\geshi.php on line 44

Notice: Constant GESHI_LANG_ROOT already defined in C:\Program Files (x86)\xampp\xampp\htdocs\function\geshi.php on line 53

Notice: Constant GESHI_NO_LINE_NUMBERS already defined in C:\Program Files (x86)\xampp\xampp\htdocs\function\geshi.php on line 58

Notice: Constant GESHI_NORMAL_LINE_NUMBERS already defined in C:\Program Files (x86)\xampp\xampp\htdocs\function\geshi.php on line 60

Notice: Constant GESHI_FANCY_LINE_NUMBERS already defined in C:\Program Files (x86)\xampp\xampp\htdocs\function\geshi.php on line 62

Notice: Constant GESHI_HEADER_NONE already defined in C:\Program Files (x86)\xampp\xampp\htdocs\function\geshi.php on line 66

Notice: Constant GESHI_HEADER_DIV already defined in C:\Program Files (x86)\xampp\xampp\htdocs\function\geshi.php on line 68

Notice: Constant GESHI_HEADER_PRE already defined in C:\Program Files (x86)\xampp\xampp\htdocs\function\geshi.php on line 70

Notice: Constant GESHI_CAPS_NO_CHANGE already defined in C:\Program Files (x86)\xampp\xampp\htdocs\function\geshi.php on line 74

Notice: Constant GESHI_CAPS_UPPER already defined in C:\Program Files (x86)\xampp\xampp\htdocs\function\geshi.php on line 76

Notice: Constant GESHI_CAPS_LOWER already defined in C:\Program Files (x86)\xampp\xampp\htdocs\function\geshi.php on line 78

Notice: Constant GESHI_LINK already defined in C:\Program Files (x86)\xampp\xampp\htdocs\function\geshi.php on line 82

Notice: Constant GESHI_HOVER already defined in C:\Program Files (x86)\xampp\xampp\htdocs\function\geshi.php on line 84

Notice: Constant GESHI_ACTIVE already defined in C:\Program Files (x86)\xampp\xampp\htdocs\function\geshi.php on line 86

Notice: Constant GESHI_VISITED already defined in C:\Program Files (x86)\xampp\xampp\htdocs\function\geshi.php on line 88

Notice: Constant GESHI_START_IMPORTANT already defined in C:\Program Files (x86)\xampp\xampp\htdocs\function\geshi.php on line 94

Notice: Constant GESHI_END_IMPORTANT already defined in C:\Program Files (x86)\xampp\xampp\htdocs\function\geshi.php on line 96

Notice: Constant GESHI_NEVER already defined in C:\Program Files (x86)\xampp\xampp\htdocs\function\geshi.php on line 103

Notice: Constant GESHI_MAYBE already defined in C:\Program Files (x86)\xampp\xampp\htdocs\function\geshi.php on line 106

Notice: Constant GESHI_ALWAYS already defined in C:\Program Files (x86)\xampp\xampp\htdocs\function\geshi.php on line 108

Notice: Constant GESHI_SEARCH already defined in C:\Program Files (x86)\xampp\xampp\htdocs\function\geshi.php on line 112

Notice: Constant GESHI_REPLACE already defined in C:\Program Files (x86)\xampp\xampp\htdocs\function\geshi.php on line 115

Notice: Constant GESHI_MODIFIERS already defined in C:\Program Files (x86)\xampp\xampp\htdocs\function\geshi.php on line 117

Notice: Constant GESHI_BEFORE already defined in C:\Program Files (x86)\xampp\xampp\htdocs\function\geshi.php on line 120

Notice: Constant GESHI_AFTER already defined in C:\Program Files (x86)\xampp\xampp\htdocs\function\geshi.php on line 123

Notice: Constant GESHI_CLASS already defined in C:\Program Files (x86)\xampp\xampp\htdocs\function\geshi.php on line 126

Notice: Constant GESHI_COMMENTS already defined in C:\Program Files (x86)\xampp\xampp\htdocs\function\geshi.php on line 129

Notice: Constant GESHI_ERROR_NO_INPUT already defined in C:\Program Files (x86)\xampp\xampp\htdocs\function\geshi.php on line 135

Notice: Constant GESHI_ERROR_NO_SUCH_LANG already defined in C:\Program Files (x86)\xampp\xampp\htdocs\function\geshi.php on line 137

Notice: Constant GESHI_ERROR_FILE_NOT_READABLE already defined in C:\Program Files (x86)\xampp\xampp\htdocs\function\geshi.php on line 139

Notice: Constant GESHI_ERROR_INVALID_HEADER_TYPE already defined in C:\Program Files (x86)\xampp\xampp\htdocs\function\geshi.php on line 141

Notice: Constant GESHI_ERROR_INVALID_LINE_NUMBER_TYPE already defined in C:\Program Files (x86)\xampp\xampp\htdocs\function\geshi.php on line 143

Fatal error: Cannot redeclare class geshi in C:\Program Files (x86)\xampp\xampp\htdocs\function\geshi.php on line 158


  1. <?php
  2.  
  3. /**
  4. * Tag CODE
  5. * @package Parser
  6. * @subpackage Filters
  7. * @author wookieb
  8. * @version 1.1
  9. */
  10. class BbCodeFilterCode {
  11. public $tags = array(
  12. 'code' => array(
  13. 'open' => 'div class="code_wrapper"',
  14. 'close' => 'div',
  15. 'notallowed_child' => 'all',
  16. 'leave_notallowed_child' => 1,
  17. 'leave_notallowed_parent' => 1,
  18. 'parse_body' => 'parseCode'
  19. )
  20. );
  21.  
  22. public function parseCode($tag, &$openNode, &$body, &$closeNode)
  23. {
  24. // laczymy tresc w całość
  25.  
  26. $content = '';
  27. foreach($body as $key => &$node)
  28. {
  29. $content.= $node['text'];
  30. $node['text'] = '';
  31.  
  32. // usuwamy zbedne elementy
  33. if($key!=0) unset($body[$key]);
  34. }
  35.  
  36. require_once 'function/geshi.php';
  37.  
  38.  
  39.  
  40.  
  41. $geshi = new GeSHi($content, 'php');
  42. $geshi->enable_classes(false);
  43. $body[0]['tagText'] = $content;
  44. $body[0]['text'] = $geshi->parse_code();
  45. $body[0]['nohtmlspecialchars'] = 1;
  46.  
  47. $openNode['text'].='<div class="code_title">Kod</div><div class="code_area">';
  48. $closeNode['text']='</div>'.$closeNode['text'];
  49. }
  50. }
  51.  
  52.  
Crozin
PHP nie obsługuje "klas w klasie" więc tego po prostu nie zrobisz.
Chyba, że Tobie chodzi o utworzenie obiektu, ale wtedy wystarczy w której z metod wpisać new NazwaKlasy.
xxdrago
Czyli np. :

  1. new GeShi;
  2.  
  3. $geshi = new GeSHi($content, 'php');
  4. $geshi->enable_classes(false);
  5. $body[0]['tagText'] = $content;
  6. $body[0]['text'] = $geshi->parse_code();
  7. $body[0]['nohtmlspecialchars'] = 1;


Nie pomaga... albo ja źle coś robię.

Dobra, już wiem czemu wszystko chodzi... smile.gif
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.