Verification code to ensure that PHP no output, the package of SQL statements, File Upload Tool class "These three key tool class implementation"

Source: Internet
Author: User

1.php code does not end in the introduction or ensures that there are no spaces after the end to ensure that PHP is included without being output "prevent headers and session_start () from controlling the output"
In essence, it is important to note that there is no space before the output cache control and PHP start tag

Verification code This function requires header and session two functions "especially need to pay attention to the problem of output"

"Summary: Prevent problems with some output in your PHP code"
(1) before starting <?php in PHP tags shelf
(2) The PHP terminator does not write, do not have to write after the end of the line after the "prevent the file is included in the pre-outgoing output"
(3) or script to control the output cache

There is also the problem of coding:
utf-8+
Utf-8+bom: the equivalent of adding UTF8 's signature "That's why SVN demands the BOM"


2. Use the Verification code as a tool class
Now know the tool class has: Database operation class, session Storage tool class, verification code, File Upload Tool class

For this, you also need to mark the user's login status "to ensure that you do not need to authenticate again after logging back in." The survival time of the cookie is consistent with the duration of the session, otherwise it will be wasted or conflicted. "
"Save username ID for cookie sign-in"


Any one jump must be forced to stop "this should be noted, to prevent the following code is still executed, resulting in efficiency or code errors"

3. Login processing for the entire background
"User's login, has logged in the login-free, change the password, delete the user, the password encryption, logout, login password retention time and other processing needs to consider"

"Branch processing for multiple times"

"Note: The flexible use of SQL statements. can also be called Automation of SQL. SQL statements require only the business layer to be passed in for SQL use "
4. Control of tables that use prefixes in the model "is also configured before table settings"
You can use the read and stitching configuration.

In an SQL statement, the declaration of a keyword is used in an inverted quotation mark, and an object-oriented invocation can be used in the SQL statement. {$this->method ()}, {$this->proporty} implements access to the members of the object to enable dynamic configuration table prefixes, table fetching, and so on. Make the SQL statement more dynamic.

"Using object-oriented invocation methods in SQL statements to automate the way SQL is written, the encapsulation of SQL can also become very strong"
"This piece of SQL re-piecing the syntax of the SQL processing of code calls strictly, passing in the table name to manipulate, fields and other implementation of the operation of the database. This enables the optimization of the SQL tool class "
"Tool class: Http://blog.sina.com.cn/s/blog_6568a85d0100ltyj.html. Perfect tool class to realize automatic processing (increase and deletion check) function, stronger encapsulation "


5. File Upload class implementation:
Upload files from the browser to the server.

Data is stored or transmitted in a format that has: bytecode, binary code.
The normal string is uploaded to the server by means of a byte-code transmission.
The encoding of the file upload is binary code.
By default, the browser does not process the binary encoding and converts the data into bytecode processing. "So we need to make a statement."


"Uploading a file is essentially a browser, and the server is receiving it, regardless of the script." The script is responsible for system administration "

Steps to upload a file:
(1) Tell the browser, the current form, there is a need to be binary encoded data (enctype= "Multipart/form-data") "declaration of the uploaded data is binary encoding"
(2) The server-specified script, the processing of files "is also two forms: The byte code is stored in the $_post variable, binary encoding processing: in a temporary folder (during sleep processing time, you can see the temporary folder saved the file.) Otherwise you won't see it) "
(3) The process of uploading files to the server "path, file type management (the HTTP protocol has the administrative MIME type of the file type), the file rename" "Upload the file information is saved in the $_files, save the information about the file, and then change the information, The ability to implement Linux-like commands to manipulate files "
"This is the implementation of the upload file Essence!!!! 】
(4) The path of the specified file is returned after successful upload


The script itself is like a Linux script, and it is the processing of server resources


"After understanding the essence, complete a tool class for uploading files"
"Note the configuration issues with file uploads in php.ini (two configuration issues: upload and post restrictions on files)"

"Errors in File Upload: Error in $_files"
(1) Two configurations limit the size of a file
(2) file submitted without uploading or uploading files
(3) Error saving temporary folder for uploading files

Verification code to ensure that PHP no output, the package of SQL statements, File Upload Tool class "These three key tool class implementation"

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.