Author Topic: PHP: Response Status  (Read 1908 times)

webwhy

  • Jackass IV
  • Posts: 608
  • Karma: +15/-10
PHP: Response Status
« on: November 05, 2011, 04:43:34 PM »
I haven't worked in PHP for a long time, and I know a couple of you guys do.

I need to set a http response status code in php.  I've read that it depends on how php is executing.


<?php
header
("HTTP/1.1 403 Forbidden"); // for mod_php
header("Status: 403 Forbidden"); // for fastcgi
?>


is this true?  if so, how do i determine the type of php environment, i.e. cgi/fastcgi or mod_php?  it's required that i do this in PHP and not via an apache setting, is there a better way?

Mike

  • Jackass In Charge
  • Posts: 11257
  • Karma: +168/-32
  • Ex Asshole - a better and more caring person.
Re: PHP: Response Status
« Reply #1 on: November 05, 2011, 04:50:03 PM »
http://www.php.net/manual/en/function.php-sapi-name.php will tell you.

As for as the reponse code I've only ever used the first one.

webwhy

  • Jackass IV
  • Posts: 608
  • Karma: +15/-10
Re: PHP: Response Status
« Reply #2 on: November 05, 2011, 04:54:40 PM »
Perfect. Thanks