Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php][oo] Programowanie obiektowe z array
suryx
post
Post #1





Grupa: Zarejestrowani
Postów: 35
Pomógł: 0
Dołączył: 14.07.2007

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


Witam , mam problem bo zle wysietla i glupie kompinuje ;/

index.php :
  1. <?php
  2. class theme{
  3.  
  4. function __construct(){ 
  5.  
  6. $a = array( 'lista' => $this->theme(menu));
  7. include 'theme.php';
  8.  
  9. }
  10. function theme($menu)
  11. {
  12. if($menu='menu')
  13. {
  14. echo 'BOMBA';
  15. }
  16. }
  17.  
  18. }
  19. new theme;
  20. ?>



theme.php
  1. <?php
  2. echo '<div style=\"background-color:#000;\">'.$a['lista'].'';
  3.  
  4. ?>


TERAZ WYGLADA : bomba <div></div> to zle ! mial byc to <div>bomba</div> .. pomoz </div style=\"background-color:#000;\">

Ten post edytował ayeo 25.04.2008, 12:55:43
Powód edycji: dodanie tagów
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 5)
webdice
post
Post #2


Developer


Grupa: Moderatorzy
Postów: 3 045
Pomógł: 290
Dołączył: 20.01.2007




Proszę uzupełnić temat o brakujący tag, w przeciwnym wypadku temat zostanie zamknięty.
Go to the top of the page
+Quote Post
nospor
post
Post #3





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




nie: =
a: ==
pozatym ma byc return a nie echo
  1. <?php
  2. function theme($menu)
  3. {
  4. if($menu=='menu')
  5. {
  6. return 'BOMBA';
  7. }
  8. }
  9. ?>
Go to the top of the page
+Quote Post
suryx
post
Post #4





Grupa: Zarejestrowani
Postów: 35
Pomógł: 0
Dołączył: 14.07.2007

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


webdicepl jak zmienic temat ? gdzie jest opcje (IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif) prosze , nieusuwac ten temat i zaraz wroce po 1 h tak musze isc do szkoly ..

p.s
dziala (IMG:http://forum.php.pl/style_emoticons/default/biggrin.gif) @nospor , thx ;p

Ten post edytował suryx 25.04.2008, 12:15:42
Go to the top of the page
+Quote Post
MMPrime
post
Post #5





Grupa: Zarejestrowani
Postów: 79
Pomógł: 12
Dołączył: 23.04.2008

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


Dodatkowo klasa posiada dwa konstruktory theme i __construct.
Go to the top of the page
+Quote Post
dr_bonzo
post
Post #6





Grupa: Przyjaciele php.pl
Postów: 5 724
Pomógł: 259
Dołączył: 13.04.2004
Skąd: N/A

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


i ->theme('menu') a nie ->theme(menu)

Co do kontruktorow - w php5 __construct() zostanie uzyte
Go to the top of the page
+Quote Post

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 - 16:43