PHP using the principles and methods

1、php

Language Server: apache server by parsing the implementation of file extensions: .php

Xxx.php file server must be placed in the server directory to the next: www directory server

Server-parsed documents and where the directory does not allow Chinese, and other special symbols
server directory (www) run the file:
http://127.0.0.1/ name of the directory / subdirectory / file name extensions.
HTTP protocol default port number: 80

2, php decomposed symbol

<?php 
    php代码
?>

3, php principle generate dynamic pages

Dynamic pages: page data is retrieved from the server

4, php syntax specification

a, php can output a plurality of output string using the echo return value is not performed faster
print output can only output a string returns a value of 1 performs slowly
b, php // single line comment / ** / multi-line
c, php splicing using
d, php variable definition $ php variable must begin with $ symbol
e, solve the garbage file defines a header file header ( "content-type: text
/ html; charset = utf-8"); bis f, PHP in internal quotation marks can automatically identify the variables
g, syntax specification:
strictly case-sensitive
after the end of each line must have a statement;
H, PHP syntax structure of the three
selected structure:
IF ... the else
Switch
looping constructs:
the while
do ... the while
for

i, php array: associative arrays and index arrays
using array () method to get method defined number of elements in the array by the count ()
associative array using the foreach () traversal

foreach( 数组名  as  变量 ){
    xxxxx;
}

5, php converted into an array of objects

json_encode ()
an indexed array in an array of objects -js
json objects in associative array -js

6, the client wants the server receives the data server by value passed by the client (focus)

The client passes the data to the server
by value a: Form pass values name Crossing form values
illustrating registration function:
Detailed registration function data transfer
receiving a client transmission data server:
$ _GET [ "name value"] receiving client passes through get way data = Method "get"
$ _POST [ "name value"] receiving client data transmitted by way of post = Method "post"
$ _REQUEST data [ "name" value] received by the client get or post transfer

// submit registration information (form submission)
Verify and submit the registration informationThe server receives the output information and

7、xss

What is xss: cross-site scripting attacks, cross site scripting in order not to be confused with Cascading Style Sheets will be changed css xss
when input some characters have a specific meaning to the form when submitted to the server, the server recognizes this string, such as: hyperlink tags
from the server to resolve xss scripting attacks
resolve xss attack two principles: the filter input escape output

Guess you like

Origin blog.csdn.net/ZHANGJIN9546/article/details/93176425