Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting Variable Types in PHP

Tags:

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?

like image 831
UnkwnTech Avatar asked Sep 04 '08 07:09

UnkwnTech


1 Answers

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.

like image 143
erlando Avatar answered Sep 21 '22 21:09

erlando