Created
August 14, 2014 20:41
-
-
Save pjdietz/4cde7573eef48f023e50 to your computer and use it in GitHub Desktop.
PHP Exception for handling redirection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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