Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP]Błąd w kodzie stopki
neneth
post 13.10.2011, 11:49:44
Post #1





Grupa: Zarejestrowani
Postów: 80
Pomógł: 0
Dołączył: 21.06.2010

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


Witam,

mam problem z kodem stopki. Napisałem taki kod:

  1.  
  2. $time = time () ;
  3.  
  4. $year= date("Y",$time) . "<br>";
  5.  
  6.  
  7. echo "Copyright 2011 - " . $year;
  8.  
  9.  


i myślałem, że wszystko jest dobrze, ale na moim serwerze lokalnym wyskakuje mi taki błąd.

Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Paris' for '2.0/DST' instead in C:\xampp\htdocs\Polski\index.php on line 49
Copyright 2011 - 2011

Proszę o pomoc i o ewentualną korektę kodu. Będę wdzięczny.

Ten post edytował neneth 13.10.2011, 11:50:13
Go to the top of the page
+Quote Post
nospor
post 13.10.2011, 11:50:40
Post #2





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




Odpowiedź masz w komunikacie błędu:
You are *required* to use the date.timezone setting or the date_default_timezone_set() function.


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post
neneth
post 13.10.2011, 12:04:00
Post #3





Grupa: Zarejestrowani
Postów: 80
Pomógł: 0
Dołączył: 21.06.2010

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


Zmieniłem kod i teraz wygląda tak:

  1.  
  2. function copyright($fromYear,$author) {
  3. date_default_timezone_set('Europe/Warsaw');
  4. $dateRange = ($fromYear >= $currentYear ? '' : $fromYear.'-').$currentYear;
  5. return '&copy;'.$dateRange.' '.$author;
  6. }
  7. echo copyright(2011,'by 123');
  8.  

i jest jeszcze problem, bo wyświetla jedynie autora bez daty. Czy coś jeszcze powinienem dodać?
Go to the top of the page
+Quote Post
nospor
post 13.10.2011, 12:17:10
Post #4





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




Uzywasz zmiennej $currentYear która nie istnieje.


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post
neneth
post 13.10.2011, 12:25:43
Post #5





Grupa: Zarejestrowani
Postów: 80
Pomógł: 0
Dołączył: 21.06.2010

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


To jak powinien wyglądać kod?
Go to the top of the page
+Quote Post
nospor
post 13.10.2011, 12:32:47
Post #6





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




Używasz zmiennej $currentYear? Dlaczego?Cos miala zawierać? No to wstaw tam to cos....


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post

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: 14.08.2025 - 04:32