Chubby Learn PHP summary 1-php data types

Source: Internet
Author: User
PHP supports a total of 8 primitive types, including 4 winning types, namely: Boolean (Boolean), Integer (Shape), float/double (floating point), and String (string), two composite types: Array (array) and object (objects) ; Two special types, namely: resource (Resource) and null.

1.1 Scalar data types

1.1.1 Boolean type

Typically, Boolean types are used in expressions that are applied to a condition or loop statement, and the following in the IF condition statement determines whether the value in the variable is true, and then outputs the respective information.

 
  
Note: In PHP, not only false values are false, in some special cases the Boolean value is also considered false, these special cases are: 0, 0.0, "0", a blank string (""), only declare an array with no assignment, and so on.

Description: The dollar sign $ is the identifier for the variable, and all variables begin with the $ character, whether declaring a variable or calling a variable, should use the $ symbol.

1.1.2 The String type (string)

In PHP, there are 3 ways to define strings, namely single quotation marks ('), double quotation marks ("), and delimiters (<<<).

 
  ";? >
If you need to use a swivel chair character, use single quotation marks to escape only single quotes "'", when using double quotation marks, there is a lot to be aware of escaping, usually using backslashes \ to escape.

1.1.3 Integer Integer

The integral type does not have to say more, look at the code:

 
  The result of "; echo" decimal is: $str 1
The result of "; echo" hexadecimal is: $str 2
The result of "echo" octal is: "; if ($str 3 = = $str 4) { echo ' &str3=&str4= '. $str 3;} else{ echo ' $str 3! = &str4 ';}? >

1.1.4 floating Point type

Floating-point data types can be used to store numbers or to hold decimals, and in previous versions of PHP4.0, floating-point markers are double, also called double-precision floating-point numbers, but not both. Floating-point numbers have two writing formats, one of which is the standard format: 3.1415; and one is the scientific notation format: 3.58E1.

 
  '; Echo ' pi 3 in writing:

'; Echo ' the first type: pi () = '. Pi (). '

'; Echo ' the second type: 3.1415926 = '. 3.1415926. '

'; Echo ' third: 3145926E-11 = '. 314159265359E-11. '

';? >


Not to be continued ...



Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

  • 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.