Advertisement
tolikpunkoff

generate-php-status-code

Apr 3rd, 2018
417
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.49 KB | None | 0 0
  1. <?php
  2.     ini_set('error_reporting', E_ALL);
  3.     ini_set('display_errors', 1);
  4.     ini_set('display_startup_errors', 1);
  5.    
  6.     $code=0;
  7.     if (empty($_GET))
  8.     {
  9.         echo "Use ?code=http_status_code";     
  10.     }
  11.     else
  12.     {
  13.         if (!isset($_GET['code']))
  14.         {
  15.             echo "Use ?code=http_status_code";
  16.         }
  17.         else
  18.         {
  19.             $code=$_GET['code'];
  20.             if (($code<100)||($code>599))
  21.             {
  22.                 echo "Wrong code (min 100, max 599)";
  23.             }
  24.             else
  25.             {
  26.                 echo $code;
  27.                 http_response_code($code);
  28.             }
  29.         }
  30.     }  
  31. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement