Loading
Hosting Unlimited Indonesia

Types


Types

Introduction
PHP supports eight primitive types.
Four scalar types:
  • boolean
  • integer
  • float (floating-point number, aka 'double')
  • string
Two compound types:
  • array
  • object
And finally two special types:
  • resource
  • NULL
This manual also introduces some pseudo-types for readability reasons:
  • mixed
  • number
  • callback
You may also find some references to the type "double". Consider double the same as float, the two names exist only for historic reasons. The type of a variable is usually not set by the programmer; rather, it is decided at runtime by PHP depending on the context in which that variable is used.
If you want to check out the type and value of a certain expression, use var_dump().
If you simply want a human-readable representation of the type for debugging, use gettype(). To check for a certain type, do not use gettype(), but use the is_type functions. Some examples:
<?php
$a_bool 
TRUE;   // a boolean$a_str  "foo";  // a string$a_str2 'foo';  // a string$an_int 12;     // an integer
echo gettype($a_bool); // prints out:  booleanecho gettype($a_str);  // prints out:  string

// If this is an integer, increment it by four
if (is_int($an_int)) {
    
$an_int += 4;
}
// If $bool is a string, print it out
// (does not print out anything)
if (is_string($a_bool)) {
    echo 
"String: $a_bool";
}
?>
If you would like to force a variable to be converted to a certain type, you may either cast the variable or use the settype() function on it.
Note that a variable may be evaluated with different values in certain situations, depending on what type it is at the time. For more information, see the section on Type Juggling. Also, you may be interested in viewing the type comparison tables, as they show examples of various type related comparisons.

14 Comments:

Unknown said...
This comment has been removed by the author.
Unknown said...
This comment has been removed by the author.
Unknown said...
This comment has been removed by the author.
Unknown said...
This comment has been removed by the author.
Unknown said...
This comment has been removed by the author.
Unknown said...
This comment has been removed by the author.
Unknown said...
This comment has been removed by the author.
Unknown said...
This comment has been removed by the author.
Unknown said...
This comment has been removed by the author.
Unknown said...
This comment has been removed by the author.
Unknown said...

Excellant event organisers

Unknown said...


Buy Wesson Smith Guns Online

Guns For Sale Online

Buy S and W Pistols Guns Online

Buy M&P BODYGUARD 380 CRIMSON TRACE Online

Buy M&P BODYGUARD 380 CRIMSON TRACE GREEN LASERGUARD NO THUMB SAFETY Online

Buy M&P BODYGUARD 380 ENGRAVED Online

Buy M&P BODYGUARD 380 ENGRAVED RSR EXCLUSIVE Online

Buy M&P 22 12 ROUND THREADED BARRELL Online

Buy
M&P 22 COMPACT Online


Buy M&P 22 COMPACT CERAKOTE FLAT DARK EARTH THREADED BARREL Online

Unknown said...

Buy Legal Weed Plug Online

Buy Weed Online

Buy Marijuana Flower Online

Buy Sativa Strains Online

Buy White Widow Indica Strains Online

Buy Acapulco Gold Sativa Strains Online

Buy AK 47 Sativa Strains Online

Buy Amnesia Haze Sativa Strains Online

Buy Candyland Sativa Strain Online

Buy Cinderlla 99 Sativa Strain Online

Unknown said...

Great information here.

Post a Comment

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Top WordPress Themes