summaryrefslogtreecommitdiff
path: root/ext/standard/tests/network/ip_x86_64.phpt
blob: 3c530b8371352de8cb9aa60c386b573f9583c466 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
--TEST--
ip2long() & long2ip() tests
--SKIPIF--
<?php
if (PHP_INT_SIZE == 4) die("skip this test is for >32bit platform only");
?>
--FILE--
<?php

$array = array(
	"127.0.0.1",
	"10.0.0.1",
	"255.255.255.255",
	"255.255.255.0",
	"0.0.0.0",
	"66.163.161.116",
);

foreach ($array as $ip) {
	var_dump($long = ip2long($ip));
	var_dump(long2ip($long));
}

var_dump(ip2long());
var_dump(ip2long(""));
var_dump(ip2long("777.777.777.777"));
var_dump(ip2long("111.111.111.111"));
var_dump(ip2long(array()));

var_dump(long2ip());
var_dump(long2ip(-110000));
var_dump(long2ip(""));
var_dump(long2ip(array()));

echo "Done\n";
?>
--EXPECTF--
int(2130706433)
string(9) "127.0.0.1"
int(167772161)
string(8) "10.0.0.1"
int(4294967295)
string(15) "255.255.255.255"
int(4294967040)
string(13) "255.255.255.0"
int(0)
string(7) "0.0.0.0"
int(1118019956)
string(14) "66.163.161.116"

Warning: ip2long() expects exactly 1 parameter, 0 given in %sip_x86_64.php on line %d
NULL
bool(false)
bool(false)
int(1869573999)

Warning: ip2long() expects parameter 1 to be string, array given in %sip_x86_64.php on line %d
NULL

Warning: long2ip() expects exactly 1 parameter, 0 given in %sip_x86_64.php on line %d
NULL
string(13) "255.254.82.80"

Warning: long2ip() expects parameter 1 to be int, string given in %sip_x86_64.php on line %d
NULL

Warning: long2ip() expects parameter 1 to be int, array given in %sip_x86_64.php on line %d
NULL
Done