重複の可能性:
PHP によって既に送信されたヘッダー
セッション ベースのヒット カウンターを作成しようとしています。そして、私のコードは機能していないようです。いつでも、ページをリロードします。出力は「ページを 0 回閲覧しました」です。
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
session_start();
if(!isset($_SESSION['count']))
$_SESSION['count'] = 0;
else
$_SESSION['count']++;
echo "You Have Viewed this page ", $_SESSION['count'], " times.";
echo session_id(); ?>
</body>
</html>
いつ、このコードをローカルホストで実行します。コードは単に機能しません。そして、Webサーバー(hostgator)で実行すると、次のエラーが発生します。
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/rohitink/public_html/uiet.org/s4/index.php:8) in /home/rohitink/public_html/uiet.org/s4/index.php on line 9
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/rohitink/public_html/uiet.org/s4/index.php:8) in /home/rohitink/public_html/uiet.org/s4/index.php on line 9
You Have Viewed this page 0 times.788141cfa1329643918f87f5f6c9eb5a
このエラーを修正する方法の詳細を教えてください。どうもありがとうございました。