A summary of JavaScript and PHP essentials

Source: Internet
Author: User
Tags arithmetic arithmetic operators logical operators

J S Essentials Overview including:

Variable:

Define a container, store content inside

Global variables: Variables outside the scope

Local variables: Within the scope

Data type: base data type and reference data type

Basic:undefined,null,Boolean,number(int/float) and the string ;

Reference:object,array,data

Operator:

Arithmetic operators:

+ + in front: Calculates the return value first

+ + in the back: first return value and then calculate

Comparison operators:

>,>=,<,<=,!=,== ( Comparison of Values ), = = = ( values and types are compared ),!==

Logical operators:

&& | | They result in the number of one of the operations

|| Short Circuit Operation

Note: As long as the previous result is true, then the result is not important; on the contrary, once it is false, the back is meaningless.

! Take a non-boolean result usage: When judging and when establishing an identity

string Operator:+

Control statements:

If ElseIf Switch

Loop structure:

while () do{} and for ()

An expression:

if{

}else{

}

If ( judging condition ) {

}else if () {

}

Switch () {

Case Expression :

Branch ;

Case Expression:

Branch ;

}

Key words:

Break: Jump out of the current page of this layer loop

Continue: Jumps out of the current loop to the next loop

Array:

A container where a set of data is filled

Statement:

Var arr = [ element 1 ...];

Var arr = new Array ( element 1 ...);

array Lengths:length

Array Traversal:

for (var i = 0;i< judging condition;i++) {

}

For (Var A in arr) {

}

Function:

to be declared after a call; written in the script tag .

function function name () {

}

Assignment function declaration: NOTE: no " preload " must be declared before calling

Var function name = function () {

}

Function arguments: formal parameters and arguments

return value:return

Function call:

Name of function ();

Anonymous functions:

(function () {

})();

usage of Eval:

Eval () receives the string and calculates the result inside

PHP Essentials are summarized as follows:

Variable:

"$" symbol

Variable name refers to the corresponding value

Value passing:

Procedure for value passing: passing a value to another variable

Reference delivery:

The passing of a reference relationship: One result is changed, the other results are changed.

mutable variable: It is a variable in itself and can also be used as another variable

pre-defined variables: fixed variables such as:

$get: A link /<form action= "Jump page" method= "get" > form content </form>

$post:<form action= "Jump page" method= "post" > form content </form>

$request: All of the data collection that is sent (committed) by Get and post.

$_server:

Data type:

scalar type: int(integer), float(decimal), string(String) , bool(Boolean)

Composite type: array(array), object

Special type: null(null value), Resource(Resource)

type of array:array

Type: Object

Operator:

Arithmetic operators:

+ - * / % ++ --

Note: take the remainder operation %, take the whole first, then take the remainder

Self-increment decrement operator:

$a + +;

Boolean Increment decrement invalid

Null decrement is invalid, increment result is 1

Front + +: Calculate first and then do something else

Post + +: Store and calculate first

Comparison operators:

> < >= < <= = = Data Equal = = Unequal = = = value and type must be equal!==

Logical operators:

&& | | or! Non-

|| Attention Short Circuit

String operators:

./ .=

Assignment operators:

= += -= *= /= %= .=

Three-mesh operators:

form: Data 1 ? Data 2 : Data 3;

Control statements:

For Loop :

foreach (var $arr as $k = = $v) {

}

Array :

$arr 1 = Array ( element 1, Element 2, ...). );

Associative arrays: Arrays that are labeled as strings

Indexed arrays: arrays labeled as numbers

Array Traversal:

foreach ($arr as [$key = =] $value)//$key is a key,$value is a value variable.

{

Function:

function function name ( parameter 1, parameter 2,...)

{

Formal parameter (variable name), argument (actual data)

There is usually a " one by one correspondence " relationship between an argument and a parameter in PHP:

function function name ( parameter 1, parameter 2,...)

{

Invocation form: function name (argument 1, argument 2,... ) )

Default value parameter: is to give the parameter a default value, use the time directly with the default value

A summary of JavaScript and PHP essentials

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.