A summary of common data types in PHP

Source: Internet
Author: User

  This article has sorted out the types of data that are common in PHP, and interested friends can refer to the following

PHP data type     PHP supports eight original types (type).     Four scalar types:  string (string)   Integer (integer)   float (floating-point type, also double)   Boolean (Boolean)     Two composite types:  Array (array)   Object (object)     Two special types:  resource (resources)   NULL (empty)     View variable types     The GetType () function makes it easy to view the type of a variable:  copy code code as follows: <?php$var_bool = TRUE; A boolean$var_str = "foo"; a string$var_int = 12; An Integerecho GetType ($var _bool); Output Booleanecho GetType ($var _str); Output Stringecho GetType ($var _int); Output integer?> (ps:t good PHP Q-button 峮: 276167802, Validation: CSL)     hint     for historical reasons, if it is float type data, the GetType () function returns a D Ouble, not float.   If you want to see the value and type of an expression, use the Var_dump () function.     Judgment Variable type     If you want to determine the next logical action by judging the variable type, do not use GetType (), and use the Is_type series function:  Copy the code as follows: <?php$var_i NT = 12;//If $var _int is of type int, this makes addition if (Is_int _int) {$var _int = $var _int+4;} echo $var _int; Output 16?>    Above is this article on the PHP data type rollup, I hope this article for the vast number of PHP developers help, thank you for reading thisText  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.