Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP]Błąd funkcji php
stroju
post
Post #1





Grupa: Zarejestrowani
Postów: 179
Pomógł: 2
Dołączył: 17.11.2005

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


mam taką funkcję:
  1. <?php
  2. function date_format($format, $data, $no_today = 0)
  3. {
  4.          $tz = 1;
  5.          $auto = 1;
  6.       $tz_add = ($auto) ? (3600 * ($tz + (@date('I', $data) && @date('I', time())))) : (3600 * $tz);
  7.  
  8.       $epoch_time = $data + $tz_add;
  9.       $current_time = time() + $tz_add;
  10.  
  11.       $cyear = @gmdate('Y', $current_time);
  12.       $cmonth = @gmdate('n', $current_time);
  13.       $cday = @gmdate('j', $current_time);
  14.       $chour = @gmdate('G', $current_time);
  15.       $cmin = @gmdate('i', $current_time);
  16.  
  17.       $today_begin = @gmmktime(0, 0, 0, $cmonth, $cday, $cyear, @date('I', $current_time));
  18.       $today_end = @gmmktime(23, 59, 59, $cmonth, $cday, $cyear, @date('I', $current_time));
  19.       $yesterday_begin = $today_begin - 86400;
  20.  
  21.       if ($epoch_time > $yesterday_begin && $epoch_time < $today_end && !$no_today)
  22.       {
  23.              if ($epoch_time < $today_begin)
  24.              {
  25.                     return 'Wczoraj '.@gmdate('H:i', $epoch_time);
  26.              }
  27.              else
  28.              {
  29.                     return 'Dzisiaj '.@gmdate('H:i', $epoch_time);
  30.              }
  31.       }
  32.        return gmdate($format, $epoch_time);
  33.        
  34. }
  35. ?>


i mi ciągle wywala taki błąd:

Fatal error: Cannot redeclare date_format() in /home/gta4life/public_html/stroju/pliki/funkcje.php on line 311

co jest winą(IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif)
Go to the top of the page
+Quote Post
l0ud
post
Post #2





Grupa: Zarejestrowani
Postów: 1 387
Pomógł: 273
Dołączył: 18.02.2008

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


Taka funkcja już istnieje w PHP5 i nie możesz jej nadpisać. Zmień nazwę na inną.
Go to the top of the page
+Quote Post
stroju
post
Post #3





Grupa: Zarejestrowani
Postów: 179
Pomógł: 2
Dołączył: 17.11.2005

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


właśnie, bo ja się tym bawiłem 2 lata temu gdzieś, i nie bardzo jestem w temacie php5, gdzie bym mógł sobie taką wiedzę nadrobić??

bo miałem już też problemy z funkcjami jak tworzyłem to wywalało problemy statystyczne i trzeba było static dawać przez funkcje, też nie wiem czemu

Ten post edytował stroju 29.10.2008, 19:31:00
Go to the top of the page
+Quote Post
l0ud
post
Post #4





Grupa: Zarejestrowani
Postów: 1 387
Pomógł: 273
Dołączył: 18.02.2008

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


Odnośnie funkcji, mogłeś zobaczyć w manualu, że taka już istnieje:
http://pl2.php.net/manual/pl/function.date-format.php

Kup jakąś dobrą książkę o PHP5. Jest gdzieś tutaj o nich temat, wystarczy poszukać (IMG:http://forum.php.pl/style_emoticons/default/smile.gif) Poza tym zajrzyj do wortalu, poczytaj phpedię. Sporo można się nauczyć (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg)
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 - 11:51