In the nearest column article ("
Common styles (on)
"with"
Common style errors (below)
") I discussed some in writing.
PHP
Multi-style makeup is difficult to read and can be caused
Bug
Cell habits.
In today's article, I will turn to discuss the focus of this series: when using PHP, the importance of security issues.
Focus on security issues
Far-not all
Prevent users from malignating your program is the most effective way to neglect it is to consider its possibilities when writing code. It is important to pay attention to the possible security issues in your code. Consider the following example functions designed to simplify the process of writing a large number of text files in PHP:
PHP Function Write_Text ($ FileName, $ text = ") {static $ open_files = array (); // If the file is empty, close all files IF ($ filename == null) {foreach ($ OPEN_FILES AS $ FR) ) {Fclose ($ fr);} $ index = md5 ($ filename); if (! Isset ($ OPEN_FILES [$ INDEX])) {$ Open_Files [$ 有DEX] = FOPEN ($ filename, "a "); If (! $ Open_files [$ index]) Return False;} fputs ($ OPEN_FILES [$ INDEX], $ TEX); RETURN TRUE;}?>
This function comes with two default parameters, file names, and text to be written. The function will check if the file has been opened; if so, the original file handle will be used. Otherwise, you will be created yourself. In both cases, the text will be written to the file. If the file name passed to the function is null, all open files will be turned off. The following is provided with an example.
If the developer is written in the format below to write multiple text files, then this function will be clear and easy to read.
Let us assume that this function exists in a separate file, this file contains code that calls this function. Next is a program, we call it quotes.php: