Answer Posted / rekha_sri
In PHP there is no need to declare the variable with
explicit type declaration. Variable type is specify by the
context.
For example, if we assign the integer value into variable,it
will be integer variable and if we assign the string value
into variable it will be string.
Example:
--------
<?php
$a=10;
$b="string";
echo "$a"; // 10
echo "$b"; // String
?>
If we want to force the variable type into different type we
can do the type casting.
Type casting example:
---------------------
<?php
$one = 10; // $one is an integer
$two = (boolean) $one; // $two is a boolean
?>
In PHP we are having function called settype() for setting
the particular variable type.
settype() example:
------------------
<?php
$first = "10rose"; // string
$second = true; // boolean
settype($first, "integer"); // $first is now 10 (integer)
settype($second, "string"); // $second is now "1" (string)
?>
| Is This Answer Correct ? | 8 Yes | 0 No |
Post New Answer View All Answers
What does a special set of tags do in php?
How do I run a php script in windows?
Are php sessions cookies?
Which MySQL function would you use to select a database?
What is nan value?
What is the difference between static and dynamic websites?
What is the difference between array_pop() and array_push()?
How do I clear my browser session?
What is the difference between get and post method in php?
How can you make a connection with mysql server using php?
Why and where do we use htaccess?
Define anonymous classes in php7?
How are sessions maintained?
Write a program to display a table of any given number?
How failures in execution are handled with include() and require() functions?