Xpress remember --------- PHP front-end basis

PHP variable rules
variables start with a $ sign, followed by the variable name.
Variable names must start with a letter or an underscore character
variable names can only contain alphanumeric characters and the underscore
variable names can not contain spaces
variable names are case-sensitive

PHP variable scope
local
for global within the function to access the global variables.
after the static when the function is completed, all of the variables will be deleted, however, something you do not want to touch a local variable is deleted, you can use static.
the Parameter

PHP echo and print statements
echo: can output a or more strings
print: allows only output a string, the return value is always an

extended output statement
to mark the beginning of the beginning <<< EOF, EOF end to end tags, end tags must write head, can not have indentation and spacing. and there must be a semicolon at the end of the closing tag
<? PHP
echo <<< EOF
<h1> my first title </ h1>
<the p-> my first paragraph. </ the p->
EOF;
// end requires a separate line and space before and after can not
>?

PHP data type
String string
Intrger integer
Float Float
Boolean Boolean
Array Array
Object object
NULL null

var_dump (); you can print the data types and data.
print_r; only returns results

provided PHP constants
a constant of letters, underline, and numbers, but the number can not occur as the first letter. (Constant names do not need to add $ modifier).

PHP strlen () function
returns the length of the string (number of characters)
the PHP the strpos () function
to find a character string or a piece of the specified text, if a match is found, the function returns the first matching character position, unmatched return . to false

print_r ($ _ the rEQUEST); // request object
print_r ($ _ gET); // parameter get request
print_r ($ _ POST); parameter // post request
print_r ($ _ SERVER [ '' HTTP_HOST]); // About Object server

Calculating the length of the array, and an output.
$ ARR = the Array ( 'Hello', 'World');
echo COUNT ($ ARR); // COUNT (ARR) length of the array is calculated
for ($ i = 0; $ i <count ( ARR $); $ I ++) {
echo $ ARR [$ I];
}


PHP JSON encode () encoding, transcoding Chinese not satisfy the following two conditions:
coded as 1. file
header ( "content-Type: text / HTML; charset =-Utf. 8 ");
2.
echo json_encode ($ Fruit, JSON_UNESCAPED_UNICODE);


associative array php array of assignment
first:
$ ARR [ 'Apple'] = 'apple';
second:
$ ARR = array ( 'apple') = > ' apple');
iF (isset ($ ARR)) {
print_r ($ ARR);}


if judged whether a variable already declared can be used when isset function
when to determine whether a variable has been assigned to the data is not empty can empty function 

php class and object
classes are the basic concepts of object-oriented programming, the abstract class is popular to say things in some kind of reality
![2511335ff25dd7f24a7bcf51f3b4d82c.jpeg](en-resource://database/484:1)


PHP class and object attributes such
public disclosure
protected protected
private private

663a7b1b4fb5b25a3e406fc4f1d1716b.jpeg  
PHP classes and objects of the constructor and destructor

Guess you like

Origin www.cnblogs.com/hudunyu/p/11685549.html