Comparison exceptions in PHP code
Release: 2016-07-25 08:47:49
Original
943 people have browsed it
A big bug I encountered this morning is that when the student ID number on the school platform is an extremely long pure number, when comparing, it is found that they are all the same! I wrote a simple one and pasted it up, and I’d like experts to explain why! I really didn’t notice this before~
This situation must be judged by ===. The judgment by == is always the same!
- $a = '440103001012201310030'; //Student ID 1
- $b = '440103001012201310032'; //Student ID 2
- if($a == $b)
- {
- echo '1---< br />';
- }
- else
- {
- echo '0---
';
- }
-
- $a = '2201310030'; //Comparison of short characters, student number 1
- $ b = '2201310032'; //Student number 2
- if($a == $b)
- {
- echo '2---
';
- }
- else
- {
- echo '0-- -
';
- }
Copy code
|
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
Latest Articles by Author
-
2024-10-22 09:46:29
-
2024-10-13 13:53:41
-
2024-10-12 12:15:51
-
2024-10-11 22:47:31
-
2024-10-11 19:36:51
-
2024-10-11 15:50:41
-
2024-10-11 15:07:41
-
2024-10-11 14:21:21
-
2024-10-11 12:59:11
-
2024-10-11 12:17:31