Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Widocznosc/Dostepnosc wlasciwosci - wybiorczo, Wlasciwosc w klasie /
JakubBab
post
Post #1





Grupa: Zarejestrowani
Postów: 96
Pomógł: 2
Dołączył: 13.07.2015

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


Czesc,

Taka oto zagwozdka:

- przypisuje wlasciwosci wartosc w funkcji. Jest ona widoczna w innej klasie nastomiast w drugiej ma on wartosc null. Why?! Chodzi o -> protected $temp;

  1.  
  2.  
  3. .....
  4.  
  5. protected $temp;
  6. public function tableTh() {
  7.  
  8. for ($i = 0; $i <= 7; $i++) {
  9.  
  10. if ($i == 0) {
  11. $this->tableTh.='<td width="25px" style="background: #c0c0c0;">X</td>';
  12. } else if ($i == 1) {
  13. // -7 because it has to get the day commencing the week - monday
  14.  
  15. $this->tableTh .= '<td style="background: #c0c0c0;">' . $this->giveCalendarName() . "</br>" . $this->giveCalendarNumber('null',7) . '</td>';
  16. $this->temp= $this->giveCalendarNumber(7,$i-7);
  17.  
  18. } else if ($i > 1) {
  19. // -7 because it has to get the day commencing the week - monday
  20. $this->tableTh .= '<td style="background: #c0c0c0;">' . $this->giveCalendarName($i - 1) . "</br>" . $this->giveCalendarNumber(7,$i-1) . '</td>';
  21. $this->temp= $this->giveCalendarNumber(7,$i-7);
  22.  
  23. }
  24. }
  25.  
  26. return $this->tableTh;
  27. }


Tutaj (ponizej) ma rece i nogi i po wywolaniu dostaje wartosc taka jaka chce czyli - (w tym konkretnym przypadku) string 07.03.2016.

  1. public function tableRow() {
  2.  
  3.  
  4. for ($i = 1; $i <= 8; $i++) {
  5. echo "<tr></tr>";
  6.  
  7. for ($j = 0; $j <= 7; $j++) {
  8.  
  9. if ($j == 0) {
  10. echo '<td width="30px" style="background: #c0c0c0;">' . $this->giveTime(9 + $i - 1) . '</br></td>';
  11. } else {
  12.  
  13. echo '<td><input type="checkbox" name="Reservation[' . $j . ']['.$this->temp.'][' . $i . ']" value="1"></br></td>';
  14. }
  15. }
  16. }
  17.  
  18. }


Natomiast gdy chce uzyc tej samej wlasciwosci ($this->temp) w innej funkcji ma ona wartosc NULL. Jakies pomysly?

Ten post edytował JakubBab 9.03.2016, 22:24:09
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: 23.08.2025 - 18:51