• Register

How to define data type in PHP?

asked Dec 2, 2012 by Arshita Rihani

1 Answer

+1 vote
There is no need to define data type of variable.
PHP provides a facility which allows to program to perform operations in the way of how variables assigned.
If you wrote
$a=5;        // it will acts as int
if you wrote
$a='5';      // it will acts as string
answered Dec 2, 2012 by Sandeep Kane
So it means it defines variable type automatically in context?
Yes. There is no need any data type to any variable.
You can assign any type of value afterwards you have declared. (still no need to declare a variable  you can directly use any variable w/o declaration).

Related questions

...