Skip to content

Instantly share code, notes, and snippets.

@sangheonhan
Created January 11, 2019 07:07
Show Gist options
  • Save sangheonhan/22e4dca38a91da3e9cdd6606351a7f4b to your computer and use it in GitHub Desktop.
Save sangheonhan/22e4dca38a91da3e9cdd6606351a7f4b to your computer and use it in GitHub Desktop.
SplType을 이용해 SplIp 타입을 만드는 예제
<?php
class SplIp extends SplType
{
const __default = 0;
public function __construct($initial_value = '0.0.0.0', $strict = true)
{
if ($strict && ip2long($initial_value) === false) {
throw new Exception('Invalid IP');
}
$this->ip = ip2long($initial_value);
}
}
$ip = new SplIp();
echo $ip."\n";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment