Relevant content about PHP

Source: Internet
Author: User
Tags array sort echo date session id

PHP Basic Stage content:

1 Basic PHP Concepts, general syntax
What is PHP:
The PHP Chinese name is a hypertext preprocessor, a server-side, HTML-embedded scripting language.

Comments in PHP mode:
Begins a single line comment. #开头单行注释. /* Start */end multiline comment.

PHP now the latest version:
5.6.22/5.5.36/7.07

What is Wamp?
A group of open-source software used to build dynamic Web sites or servers is itself a separate program, but because they are often used together,
With a growing degree of compatibility, together they form a powerful Web application platform

Data type of PHP:
Bool, Integer, float, String, object, array, null (stands for Nothing), resource (Resource)

The difference between single and double quotes for strings in PHP
PHP allows us to include string variables directly in a double-quote string, and the variables in the double-quote strings will be interpreted and replaced, and the contents of the single quotation-strings are always considered ordinary characters. of single quotes
Higher efficiency

Random number function for PHP? What is the difference between without parameters and with parameters?
Rand, Mt_rand: No parameter is a range that does not qualify it, and the minimum value is 0. The parameter is the limit of its scope, the minimum and maximum values are defined.


How do I define constants?
Set constants using the Define () function

How to output content to the page display?
Echo ("Content" or "content").

Echo, Print_r, var_dump difference?
echo is used to output a numeric variable or a string. But when you use echo to output a reference variable, such as an array, only the names of the arrays are output;
Print_r (expression) is the output of an array, in fact the type of expression can be numeric variables and reference variables;
Output of the var_dump (expression) function < variable type, variable value, variable length; The argument expression represents a variety of variable types, and the function is to output the details of a variable.


2 PHP base functions (array, date, string)
How do you define an array?
$array = Array ("Value", "value");


How to add 1 new values to an array?
$array [Subscript]= "Value"


foreach syntax structure?
foreach ($array as $key = = $value) {

}


Deletes the specified element in the array array_splice ()
Sort sort () and rsort () key values sorted by array sort () from small to large, rsort () from large to small
Array_unique () Removes the same element from the array
In_array () detects if a value is in the array (returns True and false)
Array_search () returns a key or value that returns the key name of the key value
Array_pop ()-Deletes the last element in the array
Array_push () adds one or more elements (into the stack) at the end of the array, returning the new length.
Array_search ()-Returns the key name by element value

How do I get the current date time?
Date_default_timezone_set ("PRC");
Date ("y-m-d h:i:s");

How does formatting display the current datetime?
echo Date ("y-m-d h:i:s");


What is the time of the system default?
GMT


How do I change the system's default time zone?
Date_default_timezone_set ("PRC");


Get the length of a string?
strlen function

Convert all strings to lowercase or uppercase?
Strtolower ();
Strtoupper ();


Find the position of the first or last occurrence of a character in a string?
First Appearance: Strpos ();
Last seen: STRRCHR ();


3 Web Development (HTTP protocol)
What is the Chinese name of HTTP? What's the latest version now? The default port number when accessing?
Chinese name: Hypertext Transfer Protocol;
Latest Version: 1.1;
Default port number: 80;


What are the features of the HTTP protocol?
HTTP follows the request/response model, simple, fast, flexible, non-connected, stateless.

HTTP Information processing process?
The client sends a request to the server side, the server handles the received information, and then returns the response to the client.

How many parts does the request information fall into?
Request line, request header (message format passed, browser name, reserved cookie information), blank line, message body.

How many requests are there in total? What 2 of the requests do we use?
8 kinds; get, post;


What information content is included in the request line?
Request method, Url,http version.


What information is included in the request header?
Passed message format, browser name, reserved cookie information

How many parts does the response information consist of?
Status line, response header, status code, message body.


What information is included in the status line?
The status line is described by the Protocol version, the status code in the digital form, and the corresponding status;


How many types of status codes are there? What do you mean by each other? Enumerate the common status codes and their meanings?
Category 5;
1XX: Indication information--Indicates that the request has been received and continues processing
2XX: Success-Indicates that the request has been successfully received, understood, accepted
3XX: Redirect--further action is required to complete the request
4XX: Client Error--Request syntax error or request not implemented
5XX: Server-side error-the server failed to implement a legitimate request

200-Server successfully returned to Web page
404-The requested page does not exist
503-Server Timeout


What does egpcs refer to?
Abbreviations for system-predefined variables

How do I get access to the user's IP address?
$_server["REMOTE_ADDR"];

What is the difference between get and post in a request?
The word is different, and get is placed in the address bar in clear text. Post length is unlimited, get is limited

What settings are required to upload a file?
File size, type of upload file

How to extract the information of the uploaded file?
$_files print out.

How do I get the path and name of the current file?
Gets the path to the current file: $_files["file" ["Tmp_name"];
Return file name: basename () function;

How do I get the folder path of the current file?
DirName (_file_) or GETCWD () function;

How to solve the problem of HTTP stateless?
Use a cookie or session;

What is a cookie?
A cookie is a small file that a server leaves on a user's computer. This computer sends a cookie whenever a page is requested by the same computer through a browser.

What is a session?
A session is actually a mechanism for preserving state information.


What is the difference between a cookie and a session?
1. The cookie data is stored on the client's browser and the session data is placed on the server.
2, consider the safety should use session.
3. In consideration of mitigating server performance, cookies should be used.
4, a single cookie can not save more than 4K of data, many browsers restrict a site to save up to 20 cookies.


How do I create settings cookie information?
Setcookie (cookie name, value);

How do I use the session?
Sesstion_start (); First Open session
$_session[' user '] = ' username '; Username exists $_session[' user ' inside
echo $_session[' user '; Direct output username
Session_destroy (); Destroy session


What are the common functions of the session? What is the use of each?
Session_destroy-destroys all data in a session;
Session_id-gets/sets the current session ID;
session_start-start a new session or reuse existing sessions;


What if the client forbids the cookie to be handled?
Use the Session in a browser that disables cookies


4 Ajax
The Chinese name of Ajax?
Ajax

Ajax brief?
AJAX is the acronym for asynchronous JavaScript and XML.
AJAX is not a new programming language, but just a new technology that can create better, faster, and more interactive Web applications.


What technologies are included in Ajax?
Include: HTML, CSS, JS, DOM, XML, JSON.

What are the common functions and functions of an Ajax object?
Open: Specifies the type of request, the URL, and whether the request is processed asynchronously.
Send: Sends the request to the server;

What are the common properties of Ajax objects?
Readystate/status.

The AJAX function format of jquery and its common parameters and notation?
$.ajax ({
Type: "GET",
URL: "Test.json",
Data: {username:$ ("#username"). Val (), content:$ ("#content"). Val ()},
DataType: "JSON",
Success:function (data) {
$ (' #resText '). empty (); Empty everything inside the restext.
var html = ';
$.each (data, function (Commentindex, comment) {
HTML + = ' <div class= "comment" >+ ': + ' </p></div> ';
});
$ (' #resText '). HTML (HTML);
}
});


5 php+mysql (MySQL function)
What do I need to set up before I connect to MySQL?
to open the database;

What are the steps for PHP to operate the MySQL database?
1) Connection: mysql-connect,2) Select database: mysql-select-db,3) Send SQL statement: mysql-query,4) Processing result: Mysql-fetch-array,
5) Close: Mysql-close.

Create a function for a database connection? How many parameters are there? What does each parameter mean?
mysql-connect://total of 5 parameters
First parameter: The server name or address, plus the upper port number (if it is the default of 3306, you can omit)
Second parameter: Login user name, third parameter: login password
Fourth parameter: whether to use the same connection object with the same duplicate name (if the object has already been created), false by default
The fifth parameter: constant combination, sets the mode of the connection, the default value is 0, the connection succeeds, the result is the resource type, and if it fails, the error is returned and false.


How do I select the name of the database to manipulate?
MYSQL-SELECT-DB ("Database name",);


Functions that Execute SQL statements? What type is the function return value?
Mysql-query; Resource type (Resource);

How do I get the number of query result sets?
Mysql_num_rows;

How do I extract data from a result set? What is the format of the extracted data?
Mysql_fetch_array (); is an array

How do I close a database connection?
Mysql-close ();


6 other

Empty ()
Checks whether a variable is null, if it is a non-null or nonzero value, the result is false, or null if it is true;

Isset ()
Detects if the variable is set and is not NULL.

GetType ()
Gets the type of the variable;

Settype ()
Sets the type of the variable;

Error control operator @
Meaning: Remove the warning;

Execute operator '

string concatenation.

Delimiter <<<+ Name





What's relevant about PHP

Related Article

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.