Skip to content

Instantly share code, notes, and snippets.

@emre
Forked from hmert/proxy.php
Created August 16, 2010 12:32
Show Gist options
  • Save emre/526871 to your computer and use it in GitHub Desktop.
Save emre/526871 to your computer and use it in GitHub Desktop.
just experimantal
<?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