Basic knowledge of PHP (2)

Source: Internet
Author: User

December 9, 2016, Friday

first, Types of Variables:

1. Basic Type:

Integral type (integer);

Float type (float);

Strings (string);

Boolean type (boolean);

2. Composite type:

Arrays (array);

Objects (object);

3. Special Type:

NULL

Resource Type resource;


Note: if a string and a number are added, the string is automatically converted to a pure number, and then the addition is DONE.

If the strings are added, they are automatically converted to numbers and then Added.


second, variable:

definition: $ variable name;


note: variable name: can only be letters, numbers, underscores, cannot start with a number

Custom variables are case-sensitive

Writing variables: using small humps (onetwothree)

three, constant:

define ("constant name", constant value);

Note: The constant name is generally all uppercase;

Constant name: only letters, numbers, underscores, constant names cannot begin with a number, and can only be assigned once.

Iv. the difference betweenisset () and empty () :

Empty () determine if the value of a variable that has been defined is null {', 0, 0.0, [], false, ' 0 '}

isset () Determines whether a variable has a value (initialized );


v. Type conversion methods:

first: Change the value only, the type of the variable is the same

(type) $ variable Name

$a = ' 123abc ';

$b = (int) $a;

Echo $b;

Second: variable types are changed

Settype ($ variable name, "type")

$a = ' 123abc ';

$b = Settype ($a, "integer");

Echo $b;


Third: use system-provided functions (val-family Functions) to change only the value, without changing the variable type

boolval ($ variable Name)

doubleval ($ variable Name)

Floatval ($ Variable Name)

intval ($ variable Name)

strval ($ variable Name)





Basic knowledge of PHP (2)

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.