Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP]Błąd funkcji php
Forum PHP.pl > Forum > Przedszkole
stroju
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ąquestionmark.gif
l0ud
Taka funkcja już istnieje w PHP5 i nie możesz jej nadpisać. Zmień nazwę na inną.
stroju
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
l0ud
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ć smile.gif Poza tym zajrzyj do wortalu, poczytaj phpedię. Sporo można się nauczyć winksmiley.jpg
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.