PHP Basics Review

Source: Internet
Author: User
Tags php session php basics scalar switch case

One. PHP Data type
Three large data types (scalar, compound, special)
In PHP, there are a total of eight primitive data types: They are 4 scalar types, Boolean (Boolean), Integer (integer), float (float), and string (string), two conforming types, array (array), and object (objects) ; Two special types, resource (Resource) and null (NULL)
How strings are defined
1. Single quotation marks
To express a single quotation mark itself, you need to escape it by adding a backslash (\) in front of it. To express a backslash itself, use two backslashes (\). Any other backslash is treated as a backslash itself: that is, if you want to use a different escape sequence such as \ r or \ n, it does not represent any special meaning, it is simply the two characters themselves.

2. Double quotes
The most important feature of a string defined in double quotation marks is that the variable is parsed, as described in variable parsing.

3.heredoc and Newdoc
Heredoc similar to double quotation marks
Newdoc similar to single quotation marks
Both are used to handle large text
Code
Header ("content-type:text/html; Charset=utf-8 ");
$var = ' php variable ';
$vara = ' php variable 555555 ';
echo <<< ' AAA '

PHP Heredoc Technology

$var
$vara

aaa

Echo <<

PHP Heredoc Technology

$var

Zhangshan;

The code implements the differential variable with quotation marks and no quotation marks.
Data type

Scalar:
1. Floating-point types
Floating-point types cannot be used for comparison calculations (cause computer calculations are based on binary, with precision missing)
Example: 0.1+0.7==0.7999! =0.8
2. Type of Boolean (7)
0,0.0, ", False,array (), NULL
3. Array type
Hyper-Global Array
$GLOBALS, $_get,$_post,$_request,$_session,$_cookie,$_server,$_files,$_env

$_server
1. Record the result code of the request
2. Record the required information (Request IP Source address request time, request method, source address resolution, etc.)
3. Record server configuration information (domain name path, environment configuration information, execution path, execution file path, etc.)
PHP Reference variables
Defined:
PHP reference variables: Different variable names point to the same address. Symbols &
Essence:
Multiple variables share a single memory space. (Memory_get_usage memory Space usage view function, xdebug_debug_zval view variable)
Assigning values between direct variables will open up new memory space when the assignment variable changes. (The general variable is assigned to another variable, the memory space is still shared, but when the assignment variable changes, PHP will open up new memory space to hold different values)
Attention:
Unset one of the reference variables does not affect other variables.
One of the reference variables is re-assigned, and the other variable values change, and if a variable is a reference variable that points to another address space, it jumps out of the shared space of the previous variable and opens up a new space independently.
The data value is an array (b,c,c);br/> Summary: The shared space between multiple variables is assigned by the & address character, a single variable is dereferenced through the unset variable, or a new address is added through the address character & re-assignment, jumping out of the shared space with the other variables. All reference variables in the shared space, where one variable changes the value of other variables.
Two. Operators
Operator Precedence
@ All error information operators for masked expressions
PHP three ways to iterate through an array
1.for
2.foreach
3.list while each
Reset () reset-points The inner pointer of the array to the first cell
PHP Branch Statements
1.If Else:
2.Switch case
The different values of the Switch case are stored directly inside the index array, which is more efficient than the IF branch. belong to the exact query. The code is as follows
Switch (n)
{
Case Label1:
If N=label1, the code here will be executed;
Break
Case LABEL2:
If N=label2, the code here will be executed;
Break
Default
If n is neither equal to Label1 nor equal to Label2, the code will be executed here;
}
Four. Custom functions and intrinsic functions
You cannot directly use global variables directly to local. You need to set the global as follows:
static variables
Explanation: Often as a way of judging recursion.
$a $b each other as references
External File Introduction:
Five. Regular expressions
Six Files and directories
Append string ideas to the front of the file
Seven. PHP Session Control Technology
For details, refer to the article (HTTPS://WWW.JIANSHU.COM/P/7EC08EC8BA36)
(https://www.cnblogs.com/wswang/p/6062461.html)
Eight. Object-oriented
Article (https://www.imooc.com/article/23924)
Method overrides
Article Reference (https://www.cnblogs.com/giantpanda/archive/2012/11/07/2759458.html)
constructor function
Constructors can accept parameters and be able to assign values to object properties when creating an object
Constructors can call class methods or other functions
Constructors can call constructors of other classes
Destructors
Destructors are calls that are automatically called when an object is destroyed and cannot be displayed.
Destructors cannot take parameters.
Destructors may be called (but not necessarily) in the following situations:

After the PHP page has finished loading;
Unset () class;
When a variable reference points to another object or value;
PHP's memory recovery mechanism is similar to that of Java, where no reference objects are destroyed and recycled, using a reference counter technique.
constructor function
function __construct ([Argument1,argument2,..., argumentn]) {
/Class Initialization code/
}

Destructors
function __destruct () {
// ...
}
Nine Network protocol

PHP Basics Review

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.