简体   繁体   English

导入时对二进制IP地址的API调用显示奇怪的格式

[英]API call on a binary IP address shows weird format when imported

Im doing an API GET call to get some IP addresses. 我正在执行API GET调用以获取一些IP地址。 These are stored in a MySQL database, as Binary(16) type. 这些以Binary(16)类型存储在MySQL数据库中。 Example: 例:

0x00000000000000000000ffff0104ce7f

As this is in HEX format, by converting ffff0104ce7f I get the IP address (in this instance it converts to 1.4.206.127 ) 由于这是十六进制格式,因此通过转换ffff0104ce7f可以获得IP地址(在这种情况下,它将转换为1.4.206.127

When I make the API GET call I get 当我进行API GET调用时,我得到了

\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00??\x01\x04?\x7F

This is the hex i get, when trying to get the above mentioned IP address that is stored as 这是我尝试获取存储为的上述IP地址时得到的十六进制

0x00000000000000000000ffff0104ce7f

in the database. 在数据库中。

Im importing the data into a PHP website. 我将数据导入PHP网站。

How do I convert the HEX string ( \\x00\\x00.. ) into something readable in PHP, preferably an IP address as a string, eg 1.4.206.127 ? 如何将十六进制字符串( \\x00\\x00.. )转换为PHP可读的内容,最好将IP地址作为字符串,例如1.4.206.127

Above problem should have worked with this 上述问题应与工作过这个

solution but apparently it didn't ... SO I am thinking maybe the response 解决方案,但显然不是。所以我在想,也许是回应

\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00??\\x01\\x04?\\x7F

you are getting is not correct... but then I could be wrong! 你得到的是不正确的...但是那我可能是错的!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM