0

Possible Duplicate:
“Warning: Headers already sent” in PHP

Looking at the other threads relating to this error I can't seem to locate my issue. I don't have any output prior to the call so can anyone tell me what the issue is?

Error is:

Warning: Cannot modify header information - headers already sent by ... line 12

Here is the PHP code:

<?php if (!isset($_SESSION)) session_start();

require_once 'classes/mobile_detect.class.php';

$detect = new Mobile_Detect;
if ($detect->isMobile()) {
    $referer = 'http://my_site_name/m/index.php';

    header("Location: " . $referer);
    exit();
}     
?>

<!DOCTYPE html>
<html lang="en">
<head>
...
Community
  • 1
  • 1
Paul
  • 11,671
  • 32
  • 91
  • 143

3 Answers3

2

could very well be whitespace (or other output) in classes/mobile_detect.class.php

Patrick Moore
  • 13,251
  • 5
  • 38
  • 63
  • That was painful, not sure if was white space or something else. I opened it up in a text editor and cleaned it. Working now. Thanks! – Paul Dec 06 '12 at 02:12
1

Open the file in a hex editor and make sure you don't have a byte order mark in the beginning of the file.

Michael
  • 930
  • 5
  • 8
1

Never use a closing php tag ?> in library files. There not needed and can cause this kind of issues.

For a more complete answer, please read Why do some scripts omit the closing PHP tag, '?>'?

Community
  • 1
  • 1
Arnold Daniels
  • 16,516
  • 4
  • 53
  • 82