Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - php mysql problem. The field type I save in mysql is int, why does it change to string type when taken out in php?
php mysql problem. The field type I save in mysql is int, why does it change to string type when taken out in php?

No need to cast

Because PHP is a weak type

So even if you think it is string type data, when you need it to be int, PHP It will be processed into int.

Give me an example

Suppose your mysql saves a char type "10"

and then assigns it to $a;

Then print($a+1);

The result will be 11.

That is to say, php does not care what type it is.

If you want to get a result like 101 you should write print($a.'1');