-
-
Save emre/526871 to your computer and use it in GitHub Desktop.
just experimantal
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 | |
class ProxyRouterException extends Exception {} | |
class ProxyRouter { | |
public $url; | |
public function __construct($url) { | |
$this->url = $this->_control_url($url); | |
} | |
public function get() { | |
return file_get_contents($this->url); | |
} | |
private function _control_url($url) { | |
if(filter_var($url, FILTER_VALIDATE_URL) === FALSE) { | |
throw new ProxyRouterException("invalid url."); | |
} | |
return $url; | |
} | |
} | |
try { | |
$proxy = new ProxyRouter("http://www.emreyilmaz.me"); | |
echo $proxy->get(); | |
} catch (ProxyRouterException $e) { | |
echo $e; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment