jetpack_convert_ip_address

Uses inet_pton if available to convert an IP address to a binary string.

Description

(int|string|bool) jetpack_convert_ip_address( $ip ); 

If inet_pton is not available, ip2long will convert the address to an integer. Returns false if an invalid IP address is given.

NOTE: ip2long will return false for any ipv6 address. servers that do not support inet_pton will not support ipv6

Returns (int|string|bool)

Parameters (1)

0. $ip
The ip.

Usage

  1. if ( !function_exists( 'jetpack_convert_ip_address' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'jetpack-by-wordpress-com/modules/protect/shared-functions.php'; 
  3.  
  4. // The ip. 
  5. $ip = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = jetpack_convert_ip_address($ip); 
  9.  

Defined (1)

The function is defined in the following location(s).

/modules/protect/shared-functions.php  
  1. function jetpack_convert_ip_address( $ip ) { 
  2. if ( function_exists( 'inet_pton' ) ) { 
  3. return inet_pton( $ip ); 
  4.  
  5. return ip2long( $ip );