Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php] Warning: Cannot modify header information - headers already sent by..., nie lada zagadka
Jarod
post
Post #1





Grupa: Zarejestrowani
Postów: 1 190
Pomógł: 27
Dołączył: 23.04.2005

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


Piszę tego posta w tym dziale, bo sam nie wiem w czym problem - na pewno nie w php. Korzystam z apache 2.0.58 i php 5.2.0.

Mam dosyć dużą aplikację, która została tak zaprojektowana, że wszystkie headery wysyłam na samym początku, zbudowana o wzorzec MVC. Jakiś czas temu potrzebowałem kalendarz w JS i znalazłem pod adresem: http://www.kubiczek.biz/uploaded/datetimepicker.zip

Po dodaniu dwóch linijek aplikacj sypie błędami (...)headers already sent(...) Szczerze - nie wiem w czym problem..

Przy poniższym kodzie brak problemów
  1. <link rel="stylesheet" href="Css/main.css" type="text/css" />
  2. <!--[if gte IE 6]><link rel="stylesheet" href="Css/main_ie.css" type="text/css" /><![endif]-->
  3. <script type="text/javascript" src="Js/PopUp.js"></script>


Przy poniższym kodzie występuję błąd jak w tytule posta
  1. <link rel="stylesheet" href="Css/main.css" type="text/css" />
  2. <!--[if gte IE 6]><link rel="stylesheet" href="Css/main_ie.css" type="text/css" /><![endif]-->
  3. <script type="text/javascript" src="Js/PopUp.js"></script>
  4. <link rel="stylesheet" href="Css/DateTimePicker.css" type="text/css" />
  5. <script type="text/javascript" src="Js/DateTimePicker.js"></script>



Przy poniższym kodzie brak problemów
  1. <link rel="stylesheet" href="Css/main.css" type="text/css" />
  2. <script type="text/javascript" src="Js/PopUp.js"></script>
  3. <link rel="stylesheet" href="Css/DateTimePicker.css" type="text/css" />
  4. <script type="text/javascript" src="Js/DateTimePicker.js"></script>


Proszę o pomoc


EDIT:


Przeprowadziłem małe testy.. Wyniki są dla mnie zaskakujące - nie potrafię ich racjonalnie wytłumaczyć..

Brak błędu headers...
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl">
  3. <?php echo '<base href="http://' . $_SERVER['HTTP_HOST'] . Config::$SystemPath . '" />'; ?>
  4. <link rel="stylesheet" href="Css/main.css" type="text/css" />
  5. <link rel="stylesheet" href="Css/main1.css" type="text/css" />
  6. <link rel="stylesheet" href="Css/main2.css" type="text/css" />
  7. <link rel="stylesheet" href="Css/main3.css" type="text/css" />
  8. <link rel="stylesheet" href="Css/main4.css" type="text/css" />
  9. <link rel="stylesheet" href="Css/main5.css" type="text/css" />
  10. <link rel="stylesheet" href="Css/main6.css" type="text/css" />
  11. <link rel="stylesheet" href="Css/main7.css" type="text/css" />
  12. <link rel="stylesheet" href="Css/main8.css" type="text/css" />
  13. <link rel="stylesheet" href="Css/main9.css" type="text/css" />
  14.  
  15. <title>TransBag</title>
  16. </head>


Błąd headers already sent...
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl">
  3. <?php echo '<base href="http://' . $_SERVER['HTTP_HOST'] . Config::$SystemPath . '" />'; ?>
  4. <link rel="stylesheet" href="Css/main.css" type="text/css" />
  5. <link rel="stylesheet" href="Css/main1.css" type="text/css" />
  6. <link rel="stylesheet" href="Css/main2.css" type="text/css" />
  7. <link rel="stylesheet" href="Css/main3.css" type="text/css" />
  8. <link rel="stylesheet" href="Css/main4.css" type="text/css" />
  9. <link rel="stylesheet" href="Css/main5.css" type="text/css" />
  10. <link rel="stylesheet" href="Css/main6.css" type="text/css" />
  11. <link rel="stylesheet" href="Css/main7.css" type="text/css" />
  12. <link rel="stylesheet" href="Css/main8.css" type="text/css" />
  13. <link rel="stylesheet" href="Css/main9.css" type="text/css" />
  14. <link rel="stylesheet" href="Css/main10.css" type="text/css" />
  15.  
  16. <title>TransBag</title>
  17. </head>


Czy jest ograniczona ilość znaczników meta/itp, którą można zamieścić w sekcji head ?

Ten post edytował nospor 4.12.2007, 10:26:05
Go to the top of the page
+Quote Post
2 Stron V   1 2 >  
Start new topic
Odpowiedzi (1 - 21)
webdice
post
Post #2


Developer


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




Błąd wyskakuje bo wysyłasz coś do przeglądarki (print, echo) lub tworzysz cookie, przed wysłaniem nagłówków. Najszybszym rozwiązaniem jest użycie ob_start" title="Zobacz w manualu PHP" target="_manual.
Go to the top of the page
+Quote Post
Jarod
post
Post #3





Grupa: Zarejestrowani
Postów: 1 190
Pomógł: 27
Dołączył: 23.04.2005

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


Cytat(webdicepl @ 24.11.2007, 22:22:26 ) *
Błąd wyskakuje bo wysyłasz coś do przeglądarki (print, echo) lub tworzysz cookie, przed wysłaniem nagłówków. Najszybszym rozwiązaniem jest użycie ob_start" title="Zobacz w manualu PHP" target="_manual.


Proponuje przeczytać dokładnie to co napisałem a nie klepać gotowych rozwiązań przeczytanych w innych postach.
Go to the top of the page
+Quote Post
webdice
post
Post #4


Developer


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




Z treści błędu jasno wynika że coś wcześniej zostało wysłane do przeglądarki i nie wydaje mi się żeby to co napisałeś powodowało błąd.

P. S. Nie dość że próbuje Ci pomóc to jeszcze mnie oskarżasz o "klepanie gotowych rozwiązań przeczytanych w innych postach". Równie dobrze mógłbym powiedzieć że bezmyślnie skopiowałeś skopiowałeś kalendarz i nie umiesz umieścić go na stronie.
Go to the top of the page
+Quote Post
Jarod
post
Post #5





Grupa: Zarejestrowani
Postów: 1 190
Pomógł: 27
Dołączył: 23.04.2005

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


Cytat(webdicepl @ 24.11.2007, 22:41:24 ) *
Z treści błędu jasno wynika że coś wcześniej zostało wysłane do przeglądarki i nie wydaje mi się żeby to co napisałeś powodowało błąd.

P. S. Nie dość że próbuje Ci pomóc to jeszcze mnie oskarżasz o "klepanie gotowych rozwiązań przeczytanych w innych postach". Równie dobrze mógłbym powiedzieć że bezmyślnie skopiowałeś skopiowałeś kalendarz i nie umiesz umieścić go na stronie.


Klepiesz gotowe rozwiązania. Mało tego myślę że nabijasz posty. Gdybyś przeczytał to co napisałem szczególnie bo pogrubionym napisie "EDIT:" to zauważyłbyś że z kalendarzem nie ma to nic wspólnego. Z testów wynika, że w <head> po umieszczeniu jednego wpisu więcej zaczyna pojawiać się błąd. Pozostały kod pozostał bez zmian. Więc wcześniej nic nie mogłem wysłać do przeglądarki, skoro raz działa a raz nie. Pomyśl logicznie. Doceniam to że starasz się pomóc ale staraj się także czytać dokładnie i analizować fakty a nie zakładać z góry, że skoro pojawia się taki błąd to jedynym rozwiązaniem jest ob_start. Bo tak się składa, że to nie jest rozwiązanie. Równie dobrze mógłbym wyłączyć wyświetlanie błędów w pliku konfiguracyjnym. Ale nie tędy droga.

pzdr

Ten post edytował Jarod 24.11.2007, 22:52:52
Go to the top of the page
+Quote Post
Daimos
post
Post #6





Grupa: Zarejestrowani
Postów: 1 319
Pomógł: 118
Dołączył: 26.11.2003
Skąd: Lublin

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


to musi byc wina wysylanych naglowkow przez PHP, nie wiem czego tak wjezdzasz na webdice
html Ci tego nie wyrzuci
  1. <?php echo '<base href="http://' . $_SERVER['HTTP_HOST'] . Config::$SystemPath . '" />'; ?>

po wywaleniu tej linii zapewne bledu nie bedzie
cos namieszales

wylaczajac bledy, nie rozwiazesz problemu z naglowkami, nie beda przekazywane, tylko blad sie nie wyswietli
z uzyciem ob_start()... nie bedzie bledu, no i naglowki pojda
Go to the top of the page
+Quote Post
Jarod
post
Post #7





Grupa: Zarejestrowani
Postów: 1 190
Pomógł: 27
Dołączył: 23.04.2005

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


Cytat(my salsa @ 25.11.2007, 01:52:33 ) *
to musi byc wina wysylanych naglowkow przez PHP, nie wiem czego tak wjezdzasz na webdice
html Ci tego nie wyrzuci
  1. <?php echo '<base href="http://' . $_SERVER['HTTP_HOST'] . Config::$SystemPath . '" />'; ?>

po wywaleniu tej linii zapewne bledu nie bedzie
cos namieszales

Po wywaleniu tej linijki błędy nadal są..

Cytat(my salsa @ 25.11.2007, 01:52:33 ) *
z uzyciem ob_start()... nie bedzie bledu, no i naglowki pojda

Nie satysfakcjonuje mnie takie rozwiązanie.
Go to the top of the page
+Quote Post
Daimos
post
Post #8





Grupa: Zarejestrowani
Postów: 1 319
Pomógł: 118
Dołączył: 26.11.2003
Skąd: Lublin

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


nie pokazujesz nam chyba calego kodu, cos tam musi jeszcze siedziec (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg)
Go to the top of the page
+Quote Post
Jarod
post
Post #9





Grupa: Zarejestrowani
Postów: 1 190
Pomógł: 27
Dołączył: 23.04.2005

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


Cytat(my salsa @ 25.11.2007, 03:11:02 ) *
nie pokazujesz nam chyba calego kodu, cos tam musi jeszcze siedziec (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg)


Cały kod? Masz czas na analizowanie ponad 300 plików z klasami?(IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg) Dobra tak poważnie dzisiaj wstałem, wypoczęty i znalazłem miejsce gdzie mogłem popełnić błąd - cała problem sprowadzał się do tego, że skutki tego błędu ujawniły się po dodaniu w sekcji <head> dwóch linijek...

Zrobiłem kolejny test.. Sprawdźcie sami..

index.php
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl">
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <meta http-equiv="Content-Language" content="pl" />
  5. <meta name="Description" content="Description" />
  6. <meta name="Author" content="Author" />
  7. <meta name="Robots" content="all" />
  8. <meta name="Pragma" content="no-cache" />
  9. <meta name="Cache-Control" content="no-store, no-cache, must-revalidate" />
  10.  
  11. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  12. <!--[if gte IE 6]><link rel="stylesheet" href="Css/t1_ie.css" type="text/css" /><![endif]-->
  13. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  14. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  15. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  16. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  17. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  18. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  19. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  20. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  21. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  22. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  23. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  24. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  25. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  26. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  27. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  28. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  29. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  30. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  31. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  32. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  33. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  34. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  35. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  36. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  37. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  38. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  39. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  40. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  41. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  42. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  43. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  44. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  45. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  46. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  47. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  48. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  49. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  50. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  51. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  52. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  53. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  54. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  55. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  56. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  57. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  58. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  59. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  60. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  61. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  62. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  63. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  64. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  65. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  66. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  67.  
  68. <title>Tytuł</title>
  69. </head>
  70. <?php
  71. header('Location: http://www.interia.pl');
  72. ?>
  73. </body>
  74. </html>


Komunikat "Warning: Cannot modify header information - headers already sent by...". Usuńcie jedną linijkę <link style...> i wszystko jest ok. Kto mi to wytłumaczy? Sprawdzałem najnowszą wersję php i apache (myślałem że to jakiś bug..)
Go to the top of the page
+Quote Post
webdice
post
Post #10


Developer


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




Daj zipa z wszystkim tak żeby można było to łatwo uruchomić.
Go to the top of the page
+Quote Post
SirZooro
post
Post #11





Grupa: Zarejestrowani
Postów: 243
Pomógł: 32
Dołączył: 14.06.2007

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


W tym ostatnim przykładzie wywołujesz funkcję header() w sekcji <body>, gdy już kawał HTML'a został wysłany. Przenieś to na sam początek i profilaktycznie dodaj po nim jeszcze funkcję exit() - powinno pomóc. Ew. pobaw się z buforowaniem strony.
Go to the top of the page
+Quote Post
Jarod
post
Post #12





Grupa: Zarejestrowani
Postów: 1 190
Pomógł: 27
Dołączył: 23.04.2005

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


@webdicepl: Nie mogę - kod nie jest darmowy. Przetestuj na ostatnim kawałku kodu który podałem - bardzo prosty test.

@SirZooro: Funkcję header() specjalnie umieściłem w body.. Bo nie rozumiem dlaczego raz wywala błąd a raz nie.. Tak jakby to było uzależnione od ilości danych w sekcji <head>. Czy ktoś to potrafi wytłumaczyć. Pomińcie pierwsze przykłady. Przetestujcie ostatni, który podałem.
Go to the top of the page
+Quote Post
kevinsz
post
Post #13





Grupa: Zarejestrowani
Postów: 23
Pomógł: 2
Dołączył: 26.04.2007

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


Myślę, że bez podania choćby kawałka kodu nikt Ci nie pomoże. To, co piszesz jest delikatnie mówiąc "absurdalne". W Twoim ostatnim przykładzie choćby nie wiem co się zamieściło przed wywołaniem header() to zawsze będzie błąd. Wystarczy, że będzie tam tylko spacja! I nie chodzi mi tu o kod HTML, który nie ma nic wspólnego z tym błędem, tylko o PHP;)
Go to the top of the page
+Quote Post
Jarod
post
Post #14





Grupa: Zarejestrowani
Postów: 1 190
Pomógł: 27
Dołączył: 23.04.2005

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


(IMG:http://forum.php.pl/style_emoticons/default/smile.gif) Wiecie co? Oglądałem przed chwilką film 1408. Czytając tego posta odnoszę wrażenie że znalazłem się w takim pokoju:)
Przecież zamieściłem kod.. W swoim programie powiedzmy, że miałem błąd (już wiem gdzie) ale nie zauważyłem go, bo dopóki nie dodałem kolejnego wpisu w sekcji <head> nie wyświetlał się...

Koledzy utwórzcie plik index.php o takiej zawartości.
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl">
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <meta http-equiv="Content-Language" content="pl" />
  5. <meta name="Description" content="Description" />
  6. <meta name="Author" content="Author" />
  7. <meta name="Robots" content="all" />
  8. <meta name="Pragma" content="no-cache" />
  9. <meta name="Cache-Control" content="no-store, no-cache, must-revalidate" />
  10.  
  11. <link rel="stylesheet" href="Css/t1.css" type="text/css" />
  12. <!--[if gte IE 6]><link rel="stylesheet" href="Css/t1_ie.css" type="text/css" /><![endif]-->
  13. <link rel="stylesheet" href="Css/t2.css" type="text/css" />
  14. <link rel="stylesheet" href="Css/t3.css" type="text/css" />
  15. <link rel="stylesheet" href="Css/t4.css" type="text/css" />
  16. <link rel="stylesheet" href="Css/t5.css" type="text/css" />
  17. <link rel="stylesheet" href="Css/t6.css" type="text/css" />
  18. <link rel="stylesheet" href="Css/t7.css" type="text/css" />
  19. <link rel="stylesheet" href="Css/t8.css" type="text/css" />
  20. <link rel="stylesheet" href="Css/t9.css" type="text/css" />
  21. <link rel="stylesheet" href="Css/t10.css" type="text/css" />
  22. <link rel="stylesheet" href="Css/t11.css" type="text/css" />
  23. <link rel="stylesheet" href="Css/t12.css" type="text/css" />
  24. <link rel="stylesheet" href="Css/t13.css" type="text/css" />
  25. <link rel="stylesheet" href="Css/t14.css" type="text/css" />
  26. <link rel="stylesheet" href="Css/t15.css" type="text/css" />
  27. <link rel="stylesheet" href="Css/t16.css" type="text/css" />
  28. <link rel="stylesheet" href="Css/t17.css" type="text/css" />
  29. <link rel="stylesheet" href="Css/t18.css" type="text/css" />
  30. <link rel="stylesheet" href="Css/t19.css" type="text/css" />
  31. <link rel="stylesheet" href="Css/t20.css" type="text/css" />
  32. <link rel="stylesheet" href="Css/t21.css" type="text/css" />
  33. <link rel="stylesheet" href="Css/t22.css" type="text/css" />
  34. <link rel="stylesheet" href="Css/t23.css" type="text/css" />
  35. <link rel="stylesheet" href="Css/t24.css" type="text/css" />
  36. <link rel="stylesheet" href="Css/t25.css" type="text/css" />
  37. <link rel="stylesheet" href="Css/t26.css" type="text/css" />
  38. <link rel="stylesheet" href="Css/t27.css" type="text/css" />
  39. <link rel="stylesheet" href="Css/t28.css" type="text/css" />
  40. <link rel="stylesheet" href="Css/t29.css" type="text/css" />
  41. <link rel="stylesheet" href="Css/t30.css" type="text/css" />
  42. <link rel="stylesheet" href="Css/t31.css" type="text/css" />
  43. <link rel="stylesheet" href="Css/t32.css" type="text/css" />
  44. <link rel="stylesheet" href="Css/t33.css" type="text/css" />
  45. <link rel="stylesheet" href="Css/t34.css" type="text/css" />
  46. <link rel="stylesheet" href="Css/t35.css" type="text/css" />
  47. <link rel="stylesheet" href="Css/t36.css" type="text/css" />
  48. <link rel="stylesheet" href="Css/t37.css" type="text/css" />
  49. <link rel="stylesheet" href="Css/t38.css" type="text/css" />
  50. <link rel="stylesheet" href="Css/t39.css" type="text/css" />
  51. <link rel="stylesheet" href="Css/t40.css" type="text/css" />
  52. <link rel="stylesheet" href="Css/t41.css" type="text/css" />
  53. <link rel="stylesheet" href="Css/t42.css" type="text/css" />
  54. <link rel="stylesheet" href="Css/t43.css" type="text/css" />
  55. <link rel="stylesheet" href="Css/t44.css" type="text/css" />
  56. <link rel="stylesheet" href="Css/t45.css" type="text/css" />
  57. <link rel="stylesheet" href="Css/t46.css" type="text/css" />
  58. <link rel="stylesheet" href="Css/t47.css" type="text/css" />
  59. <link rel="stylesheet" href="Css/t48.css" type="text/css" />
  60. <link rel="stylesheet" href="Css/t49.css" type="text/css" />
  61. <link rel="stylesheet" href="Css/t50.css" type="text/css" />
  62. <link rel="stylesheet" href="Css/t51.css" type="text/css" />
  63. <link rel="stylesheet" href="Css/t52.css" type="text/css" />
  64. <link rel="stylesheet" href="Css/t53.css" type="text/css" />
  65. <link rel="stylesheet" href="Css/t54.css" type="text/css" />
  66.  
  67. <title>Tytuł</title>
  68. </head>
  69. <?php
  70. echo 'test';
  71. header('Location: http://www.google.pl');
  72. ?>
  73. </body>
  74. </html>


i odpalcie go. Powinien pojawić się błąd "Headers already sent...". I bardzo dobrze - bo próbuję wysłać nagłówek po tym, jak wyświetliłem w przeglądarce tekst... A teraz z tego samego pliku, z sekcji <head> usuńcie wpis <link rel="stylesheet" href="Css/t54.css" type="text/css" />
i odpalcie w przeglądarce jeszcze raz plik index.php. Teraz zostaniecie przekierowani na stronę googla.. Dlaczego? Przecież dalej wysyłam nagłówek po wyświetleniu w przeglądarce tekstu "test"... Chciałbym, żeby ktoś mi wytłumaczył dziwne zachowanie php, opierając się na tym przykładzie... Nie proszę o nic innego tylko o skopiowanie powyższego kodu i wklejenie go do pliku index.php i przetestowaniu.. Nie wiem jeszcze jak to wytłumaczyć.. Mam nagrać filmik?
Go to the top of the page
+Quote Post
phpion
post
Post #15





Grupa: Moderatorzy
Postów: 6 072
Pomógł: 861
Dołączył: 10.12.2003
Skąd: Dąbrowa Górnicza




Hmmm mnie od razu przenosi na google, nic nie muszę usuwać. Nie powiem, ciekawe (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)

OT & Edit:
Hmmm teraz zauważyłem, że przestało mi się wyświetlać "Cannot modify..." :| wszelkie display_errors mam włączone. Może gdy swego czasu aktualizowałem PHP do 5.2.4 to wtedy coś się namieszało?

Ten post edytował phpion.com 25.11.2007, 21:26:58
Go to the top of the page
+Quote Post
Jarod
post
Post #16





Grupa: Zarejestrowani
Postów: 1 190
Pomógł: 27
Dołączył: 23.04.2005

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


Mam włączone wyświetlanie wszystkich błędów + E_STRICT. Zmieniałem php na najnowszą wersję i apacha także. Zachowanie pozostaje takie samo. Dla niedowiarków do pobrania filmik (spakowany zipem).

Filmik

Wirtualna gorzałka dla tego kto potrafi to wytłumaczyć (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg)
Go to the top of the page
+Quote Post
seiya
post
Post #17





Grupa: Zarejestrowani
Postów: 12
Pomógł: 0
Dołączył: 18.04.2007

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


(IMG:http://forum.php.pl/style_emoticons/default/blink.gif) No jaja jak berety (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
Go to the top of the page
+Quote Post
Daimos
post
Post #18





Grupa: Zarejestrowani
Postów: 1 319
Pomógł: 118
Dołączył: 26.11.2003
Skąd: Lublin

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


ostatnio mialem podobny problem, robiac kodowanie UTF-8
kwestia tego ze nie ktore edytory zle wstawiaja znaki o tym kodowaniu, cos szukalem w googlach, nie wiem czy dobrze zrozumialem, ale to powoduje wyslanie jakiegos cookies do przegladarki
proponuje zmienic edytor
bylem w szoku, ze to pomoglo
php expert editor
swietnie sobie radzi z UTF-8
Go to the top of the page
+Quote Post
Jarod
post
Post #19





Grupa: Zarejestrowani
Postów: 1 190
Pomógł: 27
Dołączył: 23.04.2005

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


Korzystam z eclipse no ale sprawdzę..
Go to the top of the page
+Quote Post
miska
post
Post #20





Grupa: Zarejestrowani
Postów: 28
Pomógł: 0
Dołączył: 23.11.2003

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


  1. <link rel="stylesheet" href="Css/t51.css" type="text/css" />
  2. <link rel="stylesheet" href="Css/t52.css" type="text/css" />
  3. <link rel="stylesheet" href="Css/t53.css" type="text/css" />
  4. <link rel="stylesheet" href="Css/t54.css" type="text/css" />
  5.  
  6. <title>Tytuł</title>


Usuń odstęp między
  1. <link rel="stylesheet" href="Css/t54.css" type="text/css" />

a
  1. <title>Tytuł</title>


i jest OK

Nawet we wklejonym kodzie widać że masz spacje w tej pustej linijce
Go to the top of the page
+Quote Post
nospor
post
Post #21





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




@miska te spacje nie maja tu nic do gadania. Jako cos wyslalengo liczy sie jaki kolwiek tekst, nawet te "link"

Cytat
Wirtualna gorzałka dla tego kto potrafi to wytłumaczyć
Sprawa jest banalnie prosta. Zapewne w php.ini masz ustawione:
output_buffering = 4096
Czyli wszystko co sie miesci w tym zakresie zostanie zbuforowane i mozesz wysylac naglowki spokojnie. Twoj tekst przekracza ten zakres buforowania, wiec header nie moze juz poleciec. Jednak ten tekst jest na granicy buforowania i gdy usuniesz jedna linijke, to automatycznie lapiesz sie w zakres buforowania i mozesz naglowki spokojnie wysylac.

Krótko rzecz mówiąc robisz z igły widły (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg)
Go to the top of the page
+Quote Post
Jarod
post
Post #22





Grupa: Zarejestrowani
Postów: 1 190
Pomógł: 27
Dołączył: 23.04.2005

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


@nospor: Wprowadziłem ostatnio drobne zmiany w kontrolerze i teraz wszystko jest ok. Nagłówki wysyłane są zawsze przed treścią.
Sprawdziłem to co napisałeś z output_buffering i miałeś racje. Dla testów ustawiłem wartość 0 i nie ma żadnych "przecieków".

(IMG:http://sebo5.w.interia.pl/finlandia.jpg)
Go to the top of the page
+Quote Post

2 Stron V   1 2 >
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:08