Headfirst Php&mysql key knowledge points record (ii)

Source: Internet
Author: User
Tags http authentication session id php script setcookie

1. Theforeach statement is used to loop through an array, processing one element at a time without using test conditions. Inside the loop, you can access each element of the array. (This is the same as JS)
2. Built-in PHP isset () function to see if a variable exists, this is whether it has been assigned a value. Empty () determines whether a variable contains a null value (0, empty string, false, or null).
3.include,include_once,require,require_once, this type of PHP statement allows scripting code to be shared between multiple script files in the application, eliminating duplicate code and making the code easy to maintain.
4.$FILES This built-in PHP Super global variable stores information about files uploaded through file upload forms. You can use it to determine file names, temporary storage locations for files, file sizes, file types, and other aspects of the file.
5.header () this built-in PHP function is used to send a header from the server to the browser to accomplish tasks such as redirecting a page, specifying a content type, or completing HTTP authentication.
6.exit () this built-in PHP function will cause the PHP script to stop immediately. Once the script encounters this function, it will no longer execute any other PHP code, nor will it pass other HTML code to the browser.
7.is_numeric () this built-in PHP function to see if a value is a number. It is useful to see that a numeric form field does contain numeric values.
8.trim (), mysqli_real_escape_string () These two built-in functions make it easy to work with form data and prevent problematic characters from interfering with SQL queries. The trim () function removes leading and trailing spaces, and mysqli_real_escape_string () escapes special characters.
9.HTTP Authentication is a simple web security technology that restricts access to Web pages by using a user name and password. The user name and password entered by the user can be obtained through $_server.
Form Validation can be more secure for web apps.
One by one .SQL injection is a way of breaking security, and the bad guys are somehow destroying an SQL query to access the database illegally. Most SQL injections cheat Web Forms to pass in dangerous data directly in a dynamically falsified query. So the solution to this problem is often form validation.
SHA () represents a secure hash algorithm, and a hash (hash) represents a unique fixed-length string that uniquely represents a text string. SHA () is a MySQL function that encrypts a piece of text and gets a string containing 40 hexadecimal characters. However, this is a one-way encryption. SHA () is more secure than MD5 (). PHP also provides equivalent functions, such as SHA1 () and MD5 ().
13.HTTP authentication persists the data to the alas client, but does not allow you to delete it at the end of the work. cookies allow the persistence of small pieces of data to be stored on the client side, which can exist across scripts and can be deleted by setting the expiration date of the cookie.
14.setcookie () user sets the variable name of the cookie, storing the text value and expiration date. If you do not set an expiration date, the cookie will be destroyed when the browser is closed. The value of the cookie variable is accessed through the $_cookie's super global variable.
15.cookie is restricted by the browser, but session sessions are stored on the server side, so it is not dependent on the browser. Because session data is stored on the server, it is more secure than a cookie.
the 16.session_start () function starts a session, $_session can be used to set the session variable, and the Session_destroy () function ends a session.
17. The session variable has no expiration date and is automatically deleted at the end of the session. However, the session is not automatically deleted when it is destroyed, so you need to set $_session=array () to manually clear all session variables in the current session.
18. The session will actually use cookies in the background. If the browser supports cookies, the session may set a cookie to temporarily store the session ID. So when you close a session, you also delete the cookie that might be automatically created on the browser to store the session ID. The code is as follows

1 if (isset($_cookie[session_name())) {2Setcookie(session _name(), ", Time() -3600); 3 }

Headfirst Php&mysql key knowledge points record (ii)

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.