PHP basic data type

Source: Internet
Author: User
: This article mainly introduces the basic data types of PHP. if you are interested in the PHP Tutorial, refer to it.
  • PHP reference type
    • Note:
  • PHP Boolean type
  • PHP string type
    • String declaration
      • Use and declaration
      • Arbitrary string using the delimiter
    • Differences between single quotes and double quotes
  • PHP constants
    • Constant declaration name
    • Constant usage
    • Note:

PHP reference type

The PHP reference type is similar to the "reference type" in C ++, which is equivalent to the alias of a variable. The syntax is as follows:


  

The variableBYesvariableA.

Note:

  • Only variables are referenced.

  
  • A variable value (suchB), The value of another variable (A) Will also change.

  " ;        echo"b = $b" ;?>
  • In useunset()Function, if there is a reference relationship, just removed this reference relationship, deleted an alias, and the other is

  
  • If two variables are reference relationships, if the value assigned to one of the variables is a new reference, you can choose to change the reference relationship.

  " ;// a = 100echo"b = $b
" ; // b = 25echo"c = $c" ; // c = 25?>

PHP Boolean type

  1. booleanType variable value can betrue,false
  2. When other types of variables are converted to the Boolean type, the following values representfalse:
    • Integer:0
    • Floating point type:0
    • String:"","0"
    • Array:array()
    • Special type:Null

PHP string type

String declaration

Use""And''Statement

  1. One or more characters in PHP are strings;
  2. To declare a string in PHP, you must use"Single quotes"Or"Double quotation marks;
  3. Single quotation marks and double quotation marks are not allowed in single quotes;
  4. You can use single quotes in double quotes, but not double quotes;
  5. If you want to use double quotation marks to emphasize certain phrases in a string, you can use transfer characters."\".

Use delimiters<+ Any string


  

Differences between single quotes and double quotes

  1. Variables can be parsed in double quotes, but not in single quotes.

  
  1. Escape characters can be used in double quotation marks, but not in single quotation marks (only escapeSingle quotesAndEscape characters)

  

PHP constants

Constant declaration and naming

  1. Declaration: use functionsdefine(string name, mixedtype value)
  2. Name: a string starting with an underscore (_) or a letter, usually in upper case.

  

Constant usage


  ";        echo constant("CONSTANT");    }?>

Note:

  • The constant value cannot be changed.
  • Constants only support standard data types
  • Constants cannot be used.unset()Function clearing
  • define()The third parameter of the function determines whether the constant name supports case sensitivity.

** To Be Continued ······**

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

The above describes the basic data types of PHP, including the content, and hope to help those who are interested in the PHP Tutorial.

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.