kirby/vendor/getkirby/toolkit/lib/header.php
/**
   * Sends a status header 
   * 
   * @param int $code The HTTP status code
   * @param boolean $send If set to false the header will be returned instead
   * @return mixed
   */
Sends a status header

@param int $code The HTTP status code
@param boolean $send If set to false the header will be returned instead
@return mixed
Sends a status header @param int $code The HTTP status code @param boolean $send If set to false the header will be returned instead @return mixed
public static function status($code, $send = true) {
    $codes    = static::$codes;
    $code     = !array_key_exists('_' . $code, $codes) ? 400 : $code;
    $message  = isset($codes['_' . $code]) ? $codes['_' . $code] : 'Something went wrong';
    $protocol = isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0';
    $header   = $protocol . ' ' . $code . ' ' . $message;
    if(!$send) return $header;
    header($header);
  }
public static function status ( $ code , $ send = true ) { $ codes = static :: $ codes ; $ code = ! array_key_exists ( '_' . $ code , $ codes ) ? 400 : $ code ; $ message = isset ( $ codes [ '_' . $ code ] ) ? $ codes [ '_' . $ code ] : 'Something went wrong' ; $ protocol = isset ( $ _SERVER [ 'SERVER_PROTOCOL' ] ) ? $ _SERVER [ 'SERVER_PROTOCOL' ] : 'HTTP/1.0' ; $ header = $ protocol . ' ' . $ code . ' ' . $ message ; if ( ! $ send ) return $ header ; header ( $ header ) ; }
Sends a status header
Sends a status header
// try to send the header