What the code does today is: 1. Read data from the database 2. Judge the value, and process the subsequent business logic based on the judgment result
step1: Fields read from the database: table $table_name, Id The field data type is int
Select Id from $table_name
$id = $value['Id'];
step2: Judgment value: if($id === 1){ ....}
Since the subsequent logic was not executed, I printed out $id, and the actual value was 1
Then I did what every programmer would do: that's Denying reality - how could this be wrong, this is obviously like this, this is impossible (I have always enjoyed this~). I was puzzled, and I finally started to have all kinds of doubts, and then I saw it: ===, the identity sign, so I tried it anxiously: gettype($id), and it returned: string ! Therefore, in PHP, be careful when using === when making judgments on values retrieved from the database. Then, the problem was solved
I asked the master, and the master said that PHP is a weakly typed language. No one stipulates what type the data returned by select is. Alas, it is arbitrary. . I have been looking for the bug for so long, and it was just dismissed. .
The above introduces the types of data that PHP retrieves from the database, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.