Skip to content

Instantly share code, notes, and snippets.

@pjdietz
Created August 14, 2014 20:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pjdietz/4cde7573eef48f023e50 to your computer and use it in GitHub Desktop.
Save pjdietz/4cde7573eef48f023e50 to your computer and use it in GitHub Desktop.
PHP Exception for handling redirection
<?php
/**
* Exception to indicate the response should redirect to a different URI.
*/
class RedirectException extends \Exception
{
/** @var int Status code */
protected $code = 302;
/** @var string URI to use in the Location header */
protected $message = "/";
/**
* Output redirection headers.
*/
public function redirect()
{
header("Location: " . $this->getMessage(), true, $this->getCode());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment