Php manual reading notes (1)

Source: Internet
Author: User
Php manual reading notes (1) 1. using agereference | BasicSyntax ?? End mark at the end of the PHP file (? & Gt;) it is best to omit it to prevent unnecessary spaces and carriage return characters from being added to the end of the file ?? Can I use/**/, //, # comment? 2. type ?? Php manual reading notes (1)

1. Language Reference | Basic Syntax

? ? End mark at the end of the PHP file (?>) It is best to omit it to prevent unnecessary spaces and carriage returns from being added to the end of the file.

? ? You can use/**/, //, # annotations.

?

2. type

? ? Four scalar types are supported: boolean, integer, float (same as double), string

? ? Two structures are supported: array and object.

? ? Three special types are supported: resource, NULL, and callable.

?

? ? You do not need to set the type. during The runtime, PHP can be derived based on the context.

?

<%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 marks, double quotation marks (variable extensible), variables in heredoc, nowdoc, and heredoc are expanded. variables in nowdoc are not expanded. heredoc is <

? ? Array: an ordered map, which can be used as an array, a linked list, or a hash table. Create With array (), where key => value can be separated by commas.

? ? ? ? ? ? ? ? The key can be an integer or a string. if the content in the string is an integer, it will be converted to an integer; float can be converted to an integer, boolean can be converted to an integer, and value can be any value.

? ? ? ? ? ? ? ? After php5.4, the array () structure can be replaced with [].

? ? ? ? ? ? ? ? Php array keys can have both integers and strings, because php does not distinguish between index arrays and associated arrays.

? ? ? ? ? ? ? ? "Key =>" can be omitted. the preceding largest integer key + 1 is used, and the key starts from 0.

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

? ? ? ? ? ? ? Unset

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

? ? Object: A class instance created through the new classname. Class can have function xxx () defined method, object-> xxx () access method.

?

3. variables

? ? Starts with $ and is 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.