Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class UrlValidator {
- private $url;
- function __construct($url){
- $this->checkUrl($url);
- $this->url = $url;
- }
- private function checkUrl($url){
- $urlHeaders = get_headers($url);
- if ($urlHeaders[0] == 'HTTP/1.1 404 Not Found') {
- throw new Exception("Url is incorrect.");
- }
- return true;
- }
- public function getUrl(){
- echo $this->url;
- }
- }
- $a = new UrlValidator('https://www.paperplane.io/404');
- $a -> getUrl();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement