PHP manual Page-by-note (1)

Source: Internet
Author: User
PHP Manual Read notes (1)

1. Language Reference | Basic Syntax

? ? The end tag (?>) of the tail of the PHP file is best omitted to prevent extra spaces and carriage returns from the tail of the file

? ? You can use/*//, #方式的注释

?

2. Type

? ? Supports four types of scalars: Boolean, Integer, float (same as double), string

? ? supports two types of structures: Array, object

? ? Supports three special types: resource, NULL, callable

?

? ? Type does not have to be set, and PHP can derive itself from context during runtime.

?

<%php$a_bool = TRUE; $a _str = "str"; $a _str2 = ' str '; $an _int = 12;echo get_type ($a _bool); if (Is_int ($an _int)) {    echo "Int";}

?

? ? Boolean:true/false, (bool), empty array is also FALSE

? ? Integer: Similar to C

? ? float: similar to C

? ? String: Single quotation mark, double quotation mark (variable expandable), variable expansion in Heredoc,nowdoc,heredoc, Nowdoc not expanded, Heredoc is <<<><>< p=""><><>

? ? Array: An ordered map that can be used as an array, a linked list, a hash table, and so on. Use Array () to create a comma-separated key=>value.

???????? Key can be an integer, or it can be a string, the contents of the string is an integer, will be converted to an integer, float to an integer, a Boolean to an integer, value can be any value.

The array () structure can be replaced with [] after php5.4.

????????. PHP array key can have both integers and strings, because PHP does not differentiate between indexed arrays and associative arrays.

? ? ? ? ? ? ? ?" Key = "can be omitted, using the previous largest integer key+1,key starting from 0.

When assigning values to array members, key can also be omitted: $arr [] = 24; This is also the largest integer key+1

? ? ? ? ? ? ? Unset deleting members

? ? ? ? ? ? ? foreach Loop: foreach ($arr as $item) {$item ...}

? ? Object: An instance of a class created with new classname. Class can have method,object->xxx () access method defined by function xxx ().

?

3. Variables

? ? Use $ start, case sensitive

?

4. Constants

? ? Define ("name", "value");

? ? const Hello = "Hello";

?

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