Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Bei Ausführung meines PHP Skripts: "Warning: Cannot add header information [...]"

Empfohlene Antworten

Veröffentlicht

Ich habe zwei PHP Dateien erstellt, in einer ("myphptest.php") befindet sich eine Funktion namens

"counter()", die andere ("myphptest2.php") enthält HTML Code und den Aufruf dieser Funktion. Die

"counter"-Funktion erstellt ein Cookie.

Der HTML Code sieht so aus:

<html>

<head>

<title></title>

</head>

<body>

</body>

<?

require("myphptest.php");

counter();

?>

</html>

Die Meldung bei Ausführung der Datei "myphptest2.php" sieht so aus:

Warning: Cannot add header information - headers already sent by (output started at

/www/docs/stl/myphptest2.php:7) in /www/docs/stl/myphptest.php on line 4

214

Ich habe gelesen, dass man vor der Erstellung eines Cookies nichts anderes senden darf, sonst kommt die

Meldung, die ich auch bekomme, aber meine Frage ist nun, wie man es denn sonst machen muss/kann.

Wie umgeht ihr dieses Problem?


<?php

  counter();

?>

<html>

<head>

<title></title>

</head>

<body>

</body>

<?

  require("myphptest.php");

?>

</html>

Aber wird denn so nicht der Counterstand über dem HTML Grundgerüst ausgegeben?

Du hast nicht geschrieben, dass counter() was ausgibt.

Dann musst du halt Cookie setzen und auslesen trennen oder die counter() Ausgabe in eine Variable speichern und an der passenden Stelle ausgeben.

Gruß Jaraz

OK, danke, dann werd' ich mal rumprobieren.

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.