Advertisement
Guest User

Untitled

a guest
Jun 29th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. class UrlValidator {
  2. private $url;
  3.  
  4. function __construct($url){
  5. $this->checkUrl($url);
  6. $this->url = $url;
  7. }
  8.  
  9. private function checkUrl($url){
  10. $urlHeaders = get_headers($url);
  11. if ($urlHeaders[0] == 'HTTP/1.1 404 Not Found') {
  12. throw new Exception("Url is incorrect.");
  13. }
  14. return true;
  15. }
  16.  
  17. public function getUrl(){
  18. echo $this->url;
  19. }
  20. }
  21.  
  22. $a = new UrlValidator('https://www.paperplane.io/404');
  23. $a -> getUrl();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement