Help us understand the problem. What is going on with this article?

PHP7調査(8)16進数が数値文字列として扱われなくなる

More than 5 years have passed since last update.

PHP7から16進文字列が数値文字列として扱われなくなります。これにより、==の挙動が変わったりします。

<?php
var_dump("0x10"=="16"); // PHP5: true, PHP7: false
var_dump(is_numeric("0x10")); // PHP5: true, PHP7: false

もともと誰も得しない仕様だったので、「今さら変えるなよ!」ってこと以外は特に問題ないように思います。

ちなみに、「1.2e3」のような浮動小数点数の指数表記は今まで通り数値文字列とみなされます。片手落ちな気もしますね…。

参照

hnw
境界値バグが大好物。自分の日記で書くには小ネタすぎるネタをQiitaに書いています。
https://hnw.hatenablog.com/
klab
モバイルオンラインゲーム、その他スマートフォン関連サービス、及びサーバーインフラ開発・運用
http://www.klab.com/jp/
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした