本文整理汇总了PHP中IP::create方法的典型用法代码示例。如果您正苦于以下问题:PHP IP::create方法的具体用法?PHP IP::create怎么用?PHP IP::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IP
的用法示例。
在下文中一共展示了IP::create方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testPlusMinusOob
/**
* @dataProvider invalidOperations
* @expectedException OutOfBoundsException
*/
public function testPlusMinusOob($ip, $plus, $minus)
{
$ip = IP::create($ip);
if ($plus !== null) {
$ip->plus($plus);
} elseif ($minus !== null) {
$ip->minus($minus);
}
}
示例2: IP
public static function
add(User $user) {
if (!$user->id or !$user->currentIP) {
return false;
}
$count = IP::getCount($user, $user->currentIP);
if ($count == 0) {
$ip = new IP();
$ip->IP = $user->currentIP;
$ip->uid = $user->id;
$ip->time = time();
$ip->create();
}
return true;
}
示例3: testContains
/**
* @dataProvider blockContent
*/
public function testContains($block, $ip_in, $block_in, $ip_not_in, $block_not_in)
{
$block = IPBlock::create($block);
foreach ($ip_in as $ip) {
$this->assertTrue($block->contains($ip), "{$block} contains {$ip}");
$this->assertTrue(IP::create($ip)->isIn($block), "{$ip} is in {$block}");
}
foreach ($block_in as $ip) {
$this->assertTrue($block->contains($ip), "{$block} contains {$ip}");
$this->assertFalse(IPBlock::create($ip)->contains($block), "{$ip} does not contain {$block}");
}
foreach ($ip_not_in as $ip) {
$this->assertFalse($block->contains($ip), "{$block} does not contain {$ip}");
$this->assertFalse(IP::create($ip)->isIn($block), "{$ip} is not in {$block}");
}
foreach ($block_not_in as $ip) {
$this->assertFalse($block->contains($ip), "{$ip} is not in {$block}");
}
}
示例4: containsIP
/**
* Determine if the current block contains an IP address
*
* @param $ip mixed
* @return bool
*/
public function containsIP($ip)
{
if (!$ip instanceof IP) {
$ip = IP::create($ip);
}
return $ip->numeric() >= $this->getFirstIp()->numeric() && $ip->numeric() <= $this->getLastIp()->numeric();
}