Setting variable types in PHP

I know I can do something like

$int = (int)99; //(int) has a maximum or 99 

To set the $int variable to an integer and set it to 99 .

Is there a way to set the type in LongBlob in MySQL for LARGE Integers in PHP?

+4
source share
2 answers

No. PHP does the so-called automatic type conversion.

In your example

 $int = (int)123; 

the "(int)" just guarantees that at that moment 123 will be treated as int.

I think it would be best to use a class to provide some kind of type safety.

+4
source

No, the type of LongBlob is specific to MySQL. In PHP, it is considered as binary data (usually characters), if you try to convert it to int, it will take the first 32 bits of data (depending on the platform) and insert them into a variable.

0
source

Source: https://habr.com/ru/post/1276541/


All Articles