Created
January 11, 2019 07:07
-
-
Save sangheonhan/22e4dca38a91da3e9cdd6606351a7f4b to your computer and use it in GitHub Desktop.
SplType을 이용해 SplIp 타입을 만드는 예제
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 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