Php 11th days

Source: Internet
Author: User
Php 11th days 1. if you do not want to use a variable in a function
You can use unset (variable name
) To completely delete the variable.
$ A = 12;
Function abc ($ ){
Unset ($ );
$ A = 50;
}

Abc ($ );
Echo '$ a ='. $ a; // the result is $ a = 12
2. in the Php function, we can assign a default value to some parameters.

Function abc (){

}

3. when passing variables in php, the default value is passed. if you need to reference
(Address) transfer, you can use & variable name


---------------------------------------
Bitwise operation

Binary: every two to one (0, 1, the most stable, easy to implement electronically
At the same time, through 0, 1, a combination can represent any number)
Three important concepts: source code, reverse code, and complement code
1. the highest bit of binary is the sign bit. 0 indicates a positive number, and 1 indicates a negative number.
2. the original codes, backcodes, and supplementary codes of positive numbers are the same.
3. negative anticode. its original symbol bit remains unchanged, and other digits are reversed.
4. complement the negative number = its anticode + 1
5. the reverse code of 0 and the complement code are both 0.
6. there is no unsigned number in php, that is, the number in php is signed.
7. during computation on the computer, the computation is based on the complement method.
That is, whether a number is positive or negative, it must be converted into a complement.
Before performing operations
Php has four bitwise operations: bitwise AND &, bitwise OR |, bitwise XOR or ^, and
Bitwise inversion ~
Bitwise AND &: both are 1, and the result is 1.
Bitwise OR |: one of the two is 1 and the result is 1.
Bitwise OR ^: one of the two is 0, one is 1, and the result is 1.
Bitwise inversion ~ : 0-> 1, 1-> 0
During calculation, the original code must be converted into a complement code, and the result is a complement code.
Converting to the original code is the final result
~ 2 =?
2 & 3 =?
2 | 3 =?
~ -5 =?
13 & 7 =?
5 | 4 =?
-3 ^ 3 =?

Php has two shift operations: Left shift <, right shift>
Right shift of arithmetic: low overflow, the symbol bit remains unchanged, and the symbol bit is used to fill in overflow
High
Arithmetic shift left: the symbol bit remains unchanged, and the low position is 0.
$ A = 1> 2;
$ B =-1> 2;
$ C = 1 <2;
$ D =-1 <2;

3*8 <----> 3 <3 Quick start

-----------------------------------------------
Array sorting and searching
In php, arrays are the set of keywords and values.
1. create an array
Method 1:
$ Arr [0] = 123;
$ Arr [1] = 1;
$ Arr [2] = 12;

[0] ---> it is called a subscript or a keyword.
$ Arr [0] ---> an element called an array
$ Arr [0] = 123 ---> 123 indicates the value of the $ arr [0] = element.
$ Arr ---> This is the name of the array.

In the php array, each element can store any data type.

Method 2:
$ Array name = array (value ,......);
$ Arr = array (2, hello, 4, 8.9 );

Method 3:
By default, the subscript of an element starts from 0, but the actual
You can also specify
$ Arr ['logo '] = 'Beijing ';
$ Arr ['shb'] = 33;

Or
$ Arr = array ("logo" => "Beijing", "shb" => "33", "hard" => "easy ");
Foreach has a wider application scope
Note:
1. if an array is not specified for an element
Set the subscript, and php will automatically use the current maximum value (integer
), Plus 1 as the subscript of the element (keyword)
2. if the subscript of an element is the same, the original value will be overwritten.
3,
$ Arr [true] <==>$ arr [1]
$ Arr [false] <==>$ arr [0]
$ Arr [null] <==>$ arr [''] or $ arr [" "]
If the decimal point is used as the key value, the fractional part is automatically truncated.
4. we can usually use print_r to display the entire array.
5. in php, arrays can grow dynamically.

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.