Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Explain about Type Juggling in PHP?

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


Please Help Members By Posting Answers For Below Questions

How is csrf token generated?

937


What are the popular content management systems (cms) in php?

872


Do while loops php?

925


Can php run without apache?

972


What is the timeout period on session values?

1036


List types of array are available in php?

937


When should you use a stored procedure?

906


What is php data type?

926


What is the value for this auto incremented field user_pri_id?

891


How do I sort numbers in php?

990


Tell me what is the definition of a session?

976


What are majic methords in php?

1035


How to remove duplicate values from a PHP Array?

1010


Explain what does the unset() function means?

1054


What is difference between strstr() and stristr() in PHP?

932