Jump to content

<?php header('Location: http://www.google.com/'); ?>


Recommended Posts

<?php header('Location: http://www.google.com/'); ?>

 

The above code consistently gives me a headers already sent error. The above code is the only piece of code on the page there is absolutely no other code/html on the page it's simply that one line. I read the initial post in the forum, but I really feel like whitespace can't be the issue? Could my text-editor (Text Wrangler) be adding something?

 

Does anyone have any suggestions? Any help would be appreciated because I feel like I'm going insane. I've used this plenty of times before and had no problems.

Link to comment
https://forums.phpfreaks.com/topic/201029--/
Share on other sites

So this is the code that I've entered into Aptana saved as index.php and uploaded to the site.

<?php header('Location: http://www.google.com/'); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
	<title>Untitled Document</title>
</head>
<body>
	<p>Test</p>
</body>
</html>

 

This is what I get showing up in my error_log.

 

PHP Warning:  Cannot modify header information - headers already sent by (output started at /mnt/target03/364491/www.dcd-support.com/web/content/sandbox/index.php:1) in /mnt/target03/364491/www.dcd-support.com/web/content/sandbox/index.php on line 1

 

The only thing that shows up on the page is the "Test" copy.

 

Link to comment
https://forums.phpfreaks.com/topic/201029--/#findComment-1054712
Share on other sites

Ok so the saga has ended.

 

Ken was correct. What I needed to do was change the text format in Text Wrangler from UTF-8, to UTF-8, no BOM.

 

Not till I uploaded this onto my development server did I see these awkward marks . Did a quick google search and it mentioned something about BOM.

 

Apparently something changed in my Text Wrangler because this has never been an issue before1

 

Thanks for the help!

Link to comment
https://forums.phpfreaks.com/topic/201029--/#findComment-1054727
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.