3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class NewEraProxy { private $proxy_full_url; private $proxy_protocol; private $proxy_ssl; private $proxy_name; private $proxy_port; /** Constructor */ public function __construct($proxy_full_url) { $this->update_object($proxy_full_url); } /** Object updater */ public function update_object($proxy_full_url) { $this->proxy_full_url = $proxy_full_url; $this->proxy_ssl = ((strpos($this->proxy_full_url, 'ssl') === 0) ? true : false); $this->proxy_protocol = ($this->proxy_ssl ? 'ssl' : 'tcp'); // Grab other parameters if(false !== ($tmp = strpos($proxy_full_url, '://'))) $proxy_full_url = substr($proxy_full_url, $tmp + 3); $proxy_full_url = explode(':', $proxy_full_url); // Host, Port, Path $this->proxy_name = $proxy_full_url[0]; $this->proxy_port = (int)(isset($proxy_full_url[1]) ? $proxy_full_url[1] : ($this->proxy_ssl ? '443' : '80')); } /** Getter for the private properties */ public function __get($var) { $var = 'proxy_'.$var; if(isset($this->{$var})) return $this->{$var}; } } $newEraProxy = new NewEraProxy('tcp://127.0.0.1:8080'); var_dump($newEraProxy); var_dump($newEraProxy->full_url); var_dump($newEraProxy->protocol); var_dump($newEraProxy->ssl); var_dump($newEraProxy->name); var_dump($newEraProxy->port); var_dump($newEraProxy->non_existent_property);
Output for 5.3.0 - 7.1.0
object(NewEraProxy)#1 (5) { ["proxy_full_url":"NewEraProxy":private]=> string(20) "tcp://127.0.0.1:8080" ["proxy_protocol":"NewEraProxy":private]=> string(3) "tcp" ["proxy_ssl":"NewEraProxy":private]=> bool(false) ["proxy_name":"NewEraProxy":private]=> string(9) "127.0.0.1" ["proxy_port":"NewEraProxy":private]=> int(8080) } string(20) "tcp://127.0.0.1:8080" string(3) "tcp" bool(false) string(9) "127.0.0.1" int(8080) NULL
Output for 5.0.0 - 5.2.17
object(NewEraProxy)#1 (5) { ["proxy_full_url:private"]=> string(20) "tcp://127.0.0.1:8080" ["proxy_protocol:private"]=> string(3) "tcp" ["proxy_ssl:private"]=> bool(false) ["proxy_name:private"]=> string(9) "127.0.0.1" ["proxy_port:private"]=> int(8080) } string(20) "tcp://127.0.0.1:8080" string(3) "tcp" bool(false) string(9) "127.0.0.1" int(8080) NULL
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/c0Av3 on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/c0Av3 on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/c0Av3 on line 4
Process exited with code 255.