Home Backend Development PHP Tutorial ip地址怎么转换为IPCDBL

ip地址怎么转换为IPCDBL

Jun 13, 2016 pm 01:07 PM
floor intval key long

ip地址如何转换为IPCDBL
ip地址如何转换为IPCDBL?
如192.168.1.255转换后是3232236031,
求ip转换为ipcdbl的算法和ipcdbl转换为ip的算法

------解决方案--------------------

PHP code
<?php function iptolong($ip){
    $key = explode('.', $ip);
    if(count($key) >= 4){
        $long = intval($key[0]) * 16777216 + intval($key[1]) * 65536 + intval($key[2]) * 256 + intval($key[3]);
    }
    return $long;
}

function longtoip($long){
    $long = floor($long);
    $p4 = $long - floor($long / 256) * 256;
    $long = ($long - $p4) / 256;
    $p3 = $long - floor($long / 256) * 256;
    $long = ($long - $p3) / 256;
    $p2 = $long - floor($long / 256) * 256;
    $long = ($long - $p2) / 256;
    $p1 = $long;
    $ip = $p1.'.'.$p2.'.'.$p3.'.'.$p4;
    return $ip;
}




?> <div class="clear">
                 
              
              
        
            </div>
Copy after login
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to query long type in oracle How to query long type in oracle Jun 12, 2023 pm 05:05 PM

How to query long type in oracle: 1. TO_LOB function, use "SELECT TO_LOB()" syntax to convert the LONG type column in the table to CLOB type and return it as the query result; 2. SUBSTR function, use "SELECT SUBSTR() )" will return the 250 characters starting from the 100th character in the LONG type column in the table, which are returned as VARCHAR type.

What does the identity attribute in SQL mean? What does the identity attribute in SQL mean? Feb 19, 2024 am 11:24 AM

What is Identity in SQL? Specific code examples are needed. In SQL, Identity is a special data type used to generate auto-incrementing numbers. It is often used to uniquely identify each row of data in a table. The Identity column is often used in conjunction with the primary key column to ensure that each record has a unique identifier. This article will detail how to use Identity and some practical code examples. The basic way to use Identity is to use Identit when creating a table.

How SpringBoot monitors redis Key change events How SpringBoot monitors redis Key change events May 26, 2023 pm 01:55 PM

1. Function Overview Keyspace notification allows clients to receive events that modify Rediskey changes in some way by subscribing to channels or patterns. All commands that modify key keys. All keys that received the LPUSHkeyvalue[value…] command. All expired keys in the db database. Events are distributed through Redis's subscription and publishing functions (pub/sub), so all clients that support subscription and publishing functions can directly use the keyspace notification function without any modifications. Because the current subscription and publishing functions of Redis adopt a fireandforget strategy, if your program

How to determine whether two Long objects are equal in Java? How to determine whether two Long objects are equal in Java? Apr 20, 2023 pm 09:10 PM

Throws a question: Longa=4l;Longb=4l;a==b//trueLonga=128l;Longb=128l;a==b//false If the value of Long is between [-127,128], use "==" There is no problem in judging whether they are equal. If they are not in this range, "==" cannot be used. The reason is explained in the source code as follows: publicstaticLongvalueOf(longl){finalintoffset=128;if(l>=-128&&l

What is the assignment method of java long type data? What is the assignment method of java long type data? Apr 28, 2023 pm 03:52 PM

Assignment problem of javalong type data When the program has a large value (exceeding the int type: -2^31 to 2^31-1), the type needs to be changed to the Long type. longl=1507772738542;Longl1=(long)1507772738542;The above writing method will report an error during compilation, which probably means that the data is too long and exceeds the value of type int. Solve Longl=1507772738542L; you can add L or l after the data. A strange problem occurs when assigning null to long. The reason for the problem is that I obtain a Long type data from an object and assign it to a long variable.

Unpatchable Yubico two-factor authentication key vulnerability breaks the security of most Yubikey 5, Security Key, and YubiHSM 2FA devices Unpatchable Yubico two-factor authentication key vulnerability breaks the security of most Yubikey 5, Security Key, and YubiHSM 2FA devices Sep 04, 2024 pm 06:32 PM

An unpatchable Yubico two-factor authentication key vulnerability has broken the security of most Yubikey 5, Security Key, and YubiHSM 2FA devices. The Feitian A22 JavaCard and other devices using Infineon SLB96xx series TPMs are also vulnerable.All

How to solve the problem of batch deletion of key values ​​in redis How to solve the problem of batch deletion of key values ​​in redis May 31, 2023 am 08:59 AM

Problems encountered: During the development process, you will encounter keys that need to be deleted in batches according to certain rules, such as login_logID (ID is a variable). Now you need to delete data such as "login_log*", but redis itself only has batch query. Command keys for class key values, but there is no command for batch deletion of a certain class. Solution: Query first, then delete, use xargs to pass parameters (xargs can convert pipe or standard input (stdin) data into command line parameters), execute the query statement first, and then remove the queried key value and the original del parameters. delete. redis-cliKEYSkey* (search condition)|xargsr

How many bytes does long occupy? How many bytes does long occupy? Feb 01, 2023 am 11:49 AM

long occupies 4 bytes; long represents a kind of long integer data, which is a basic data type in programming languages. It is the abbreviation of "long int". The default is signed long integer type, containing 4 bytes. The value range is "-2^31 ~ (2^31 -1)".

See all articles