Home > Backend Development > PHP Tutorial > Comparison exceptions in PHP code

Comparison exceptions in PHP code

WBOY
Release: 2016-07-25 08:47:49
Original
958 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!
  1. $a = '440103001012201310030'; //Student ID 1
  2. $b = '440103001012201310032'; //Student ID 2
  3. if($a == $b)
  4. {
  5. echo '1---< br />';
  6. }
  7. else
  8. {
  9. echo '0---
    ';
  10. }
  11. $a = '2201310030'; //Comparison of short characters, student number 1
  12. $ b = '2201310032'; //Student number 2
  13. if($a == $b)
  14. {
  15. echo '2---
    ';
  16. }
  17. else
  18. {
  19. echo '0-- -
    ';
  20. }
Copy code
  1. 1---
  2. 0---
Copy code


Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template