Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to deal with hexadecimal strings in PHP7

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

Specific questions: $T1 = 0x3FFFFFFF & (1 * (0xd5b42e11)); $T2 = 0x3FFFFFFF & (1 * ("0xd5b42e11")); var_dump ($T1)

The values of the above code for the following platforms in php7 (not included) are:

Int (364129809) int (364129809)

In php7, the value is:

Int (364129809) int (0)

Excuse me, in the php7 environment, how to deal with 0x.$str to make it the same as the above face value?

Solution:

Starting with PHP7, hexadecimal strings are no longer considered numbers

If you have to detect whether a string contains hexadecimal numbers, the officially recommended code is

In view of the above problems, it should be changed to

$T1 = 0x3FFFFFFF & (1 * (0xd5b42e11)); $T2 = 0x3FFFFFFF & (1 * (filter_var ("0xd5b42e11", FILTER_VALIDATE_INT, FILTER_FLAG_ALLOW_HEX)); var_dump ($T1) Thank you for your reading, the above is the content of "how to deal with hexadecimal strings in PHP7". After the study of this article, I believe you have a deeper understanding of how to deal with hexadecimal strings in PHP7, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report