. Fixed bug #60052 (Integer returned as a 64bit integer on X64_86). (Mariuz)
Standard:
+ . Fixed bug #71100 (long2ip() doesn't accept integers in strict mode).
+ (Laruence)
. Implemented FR #55716 (Add an option to pass a custom stream context to
get_headers()). (Ferenc)
. Implemented FR #69359 (Provide a way to fetch the current environment
- The first $varname argument for getenv() is no longer mandatory, the
current environment variables will be returned as an associative array
when omitted.
+- long2ip accepts interge as parameter now
========================================
6. New Functions
Converts an (IPv4) Internet network address into a string in Internet standard dotted format */
PHP_FUNCTION(long2ip)
{
- /* "It's a long but it's not, PHP ints are signed */
- char *ip;
- size_t ip_len;
- uint32_t n;
+ zend_ulong ip;
struct in_addr myaddr;
#ifdef HAVE_INET_PTON
char str[40];
#endif
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &ip, &ip_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &ip) == FAILURE) {
return;
}
- n = strtoul(ip, NULL, 0);
-
- myaddr.s_addr = htonl(n);
+ myaddr.s_addr = htonl(ip);
#ifdef HAVE_INET_PTON
if (inet_ntop(AF_INET, &myaddr, str, sizeof(str))) {
RETURN_STRING(str);
string(8) "10.0.0.1"
int(-1)
string(15) "255.255.255.255"
-int(-256)
+int(-1)
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 %s on line %d
+Warning: ip2long() expects exactly 1 parameter, 0 given in %sip.php on line %d
NULL
bool(false)
bool(false)
int(1869573999)
-Warning: ip2long() expects parameter 1 to be string, array given in %s on line %d
+Warning: ip2long() expects parameter 1 to be string, array given in %sip.php on line %d
NULL
-Warning: long2ip() expects exactly 1 parameter, 0 given in %s on line %d
+Warning: long2ip() expects exactly 1 parameter, 0 given in %sip.php on line %d
NULL
string(13) "255.254.82.80"
-string(7) "0.0.0.0"
-Warning: long2ip() expects parameter 1 to be string, array given in %s on line %d
+Warning: long2ip() expects parameter 1 to be integer, string given in %sip.php on line %d
+NULL
+
+Warning: long2ip() expects parameter 1 to be integer, array given in %sip.php on line %d
NULL
Done
int(1118019956)
string(14) "66.163.161.116"
-Warning: ip2long() expects exactly 1 parameter, 0 given in %s on line %d
+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 %s on line %d
+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 %s on line %d
+Warning: long2ip() expects exactly 1 parameter, 0 given in %sip_x86_64.php on line %d
NULL
string(13) "255.254.82.80"
-string(7) "0.0.0.0"
-Warning: long2ip() expects parameter 1 to be string, array given in %s on line %d
+Warning: long2ip() expects parameter 1 to be integer, string given in %sip_x86_64.php on line %d
+NULL
+
+Warning: long2ip() expects parameter 1 to be integer, array given in %sip_x86_64.php on line %d
NULL
Done
string(7) "0.0.0.0"
--empty array--
-Error: 2 - long2ip() expects parameter 1 to be string, array given, %s(%d)
+Error: 2 - long2ip() expects parameter 1 to be integer, array given, %slong2ip_variation1.php(%d)
NULL
--int indexed array--
-Error: 2 - long2ip() expects parameter 1 to be string, array given, %s(%d)
+Error: 2 - long2ip() expects parameter 1 to be integer, array given, %slong2ip_variation1.php(%d)
NULL
--associative array--
-Error: 2 - long2ip() expects parameter 1 to be string, array given, %s(%d)
+Error: 2 - long2ip() expects parameter 1 to be integer, array given, %slong2ip_variation1.php(%d)
NULL
--nested arrays--
-Error: 2 - long2ip() expects parameter 1 to be string, array given, %s(%d)
+Error: 2 - long2ip() expects parameter 1 to be integer, array given, %slong2ip_variation1.php(%d)
NULL
--uppercase NULL--
string(7) "0.0.0.0"
--empty string DQ--
-string(7) "0.0.0.0"
+Error: 2 - long2ip() expects parameter 1 to be integer, string given, %slong2ip_variation1.php(%d)
+NULL
--empty string SQ--
-string(7) "0.0.0.0"
+Error: 2 - long2ip() expects parameter 1 to be integer, string given, %slong2ip_variation1.php(%d)
+NULL
--string DQ--
-string(7) "0.0.0.0"
+Error: 2 - long2ip() expects parameter 1 to be integer, string given, %slong2ip_variation1.php(%d)
+NULL
--string SQ--
-string(7) "0.0.0.0"
+Error: 2 - long2ip() expects parameter 1 to be integer, string given, %slong2ip_variation1.php(%d)
+NULL
--mixed case string--
-string(7) "0.0.0.0"
+Error: 2 - long2ip() expects parameter 1 to be integer, string given, %slong2ip_variation1.php(%d)
+NULL
--heredoc--
-string(7) "0.0.0.0"
+Error: 2 - long2ip() expects parameter 1 to be integer, string given, %slong2ip_variation1.php(%d)
+NULL
--instance of classWithToString--
-string(7) "0.0.0.0"
+Error: 2 - long2ip() expects parameter 1 to be integer, object given, %slong2ip_variation1.php(%d)
+NULL
--instance of classWithoutToString--
-Error: 2 - long2ip() expects parameter 1 to be string, object given, %s(%d)
+Error: 2 - long2ip() expects parameter 1 to be integer, object given, %slong2ip_variation1.php(%d)
NULL
--undefined var--
string(7) "0.0.0.0"
--resource--
-Error: 2 - long2ip() expects parameter 1 to be string, resource given, %s(%d)
+Error: 2 - long2ip() expects parameter 1 to be integer, resource given, %slong2ip_variation1.php(%d)
NULL
===DONE===