2

I am using the following code to display a cutom 404 not found with PHP:

header("HTTP/1.0 404 Not Found");
header("Status: 404 Not Found");
include('404.php');
exit();

However, the default browser's 404 page shows up. What is the right code for producing 404 while including a PHP file?

Thanks,

Joel

James A Mohler
  • 11,060
  • 15
  • 46
  • 72
Joel
  • 5,949
  • 12
  • 42
  • 58

1 Answers1

5

However, the default browser's 404 page shows up. What is the right code for producing 404 while including a PHP file?

Some browsers (namely IE and Chrome) show their own 404 page when the size of the page that was output is less than 512 bytes.

Pad your output to go beyond that. I like to use some nice ASCII art.

Community
  • 1
  • 1
Pekka
  • 442,112
  • 142
  • 972
  • 1,088
  • I personally prefer Doge images, but to each his own. http://i2.kym-cdn.com/photos/images/original/000/581/296/c09.jpg – Scott C Wilson Jun 23 '17 at 16:22
  • 1
    @Scott there is absolutely nothing wrong with Doge images... although they won't show in "view source" while the ASCII art will. – Pekka Jun 23 '17 at 17:32
  • Can't we just compromise and work across the aisle? What about asking the art of Doge dogs? – Scott C Wilson Jun 23 '17 at 17:41
  • @Scott How about Doge ASCII art? It could revolutionize everything. And I mean *everything.* A whole new cultural paradigm. – Pekka Jun 23 '17 at 18:24
  • lol transcription error. Yes I meant Doge ASCII art. We are on the same page. All that's left is the IPO! – Scott C Wilson Jun 23 '17 at 18:46
  • @ScottCWilson I'll speak to a lawyer tomorrow. Better start thinking about what to wear for our "Men of the year 2017" photo in TIME. And who you want to play you in the eventual movie – Pekka Jun 23 '17 at 18:50
  • 1
    Who has time? I'm busy looking at oceanfront property! – Scott C Wilson Jun 23 '17 at 18:53
  • @Scott that's nice and all, but... a private island is where it's at these days. Can't look like a pauper. – Pekka Jun 23 '17 at 19:41