Security questions

I know that I can do something like

$int = (int)99; //(int) has a maximum or 99
To set the variable $int to an integer and give it a value of 99, Is there a way to set the type to something like LongBlob in MySQL for LARGE Integers in PHP?

2 ANSWERS

16 febrero, 2017 a las 10:07 am admin

No, the type LongBlob is specific to MySQL. In PHP it is seen as binary data (usually characters), if you tried to convert it to an int it would take the first 32 bits of data (platform dependent) and push that into the variable.

16 febrero, 2017 a las 10:07 am admin

No. PHP does what is called automatic type conversion.

In your example

$int = (int)123;
the “(int)” just assures that at that exact moment 123 will be handled as an int.

I think your best bet would be to use a class to provide some sort of type safety.

Viendo 2 respuestas - de la 1 a la 2 (de un total de 2)

You must be logged in to reply to this topic.