1. In PHP, the name of the current script (not including the path and query string) is recorded in the predefined variable (1), while the URL linked to the current page is recorded in the predefined variable (2). Copy the Code code as follows: Answer: Echo $_server[' php_self ']; echo $_server["Http_referer"];
2. The execution of the program segment outputs (3). Copy the Code code as follows: Answer: 0
3. In HTTP 1.0, the meaning of status code 401 is (4); If you return a prompt for "file not found", the header function is available with the statement (5). Copy the Code code as follows: Answer: (4) Unauthorized (5) header ("http/1.0 404 Not Found");
4. The function of array function Arsort is (6); the function of statement error_reporting (2047) is (7). Copy the Code code as follows: A: (6) Reverse-order the array and keep the index relationship (7) all errors and warnings
5. Write a regular expression that js/vbs all the scripts on the Web page (that is, remove the tags and their contents): (9). Copy the Code code as follows: Answer:/<[^>].*?>.*?<\/>/SI
6. Install PHP in the Apache module, and in the file http.conf, the PHP module should be loaded dynamically with the statement (10). Then use the statement (11) so that Apache will all files with the extension PHP as PHP script processing. Copy the Code code as follows: Answer: (LoadModule) php5_module "D:/xampp/apache/bin/php5apache2.dll" (one) AddType application/x-httpd-php-source. Phps AddType application/x-httpd-php. php. php5. PhP4. php3. phtml
7. Statements include and require can include another file in the current file, the difference is (12), in order to avoid multiple inclusion of the same file, you can use the statement (13) instead of them. Copy the Code code as follows: Answer: (12) When an exception occurs, the include generates a warning require a fatal error (require_once ()/include_once ()
8. The properties of the class can be serialized and saved to the session so that the entire class can be restored later, and the function to be used is (14). Copy the Code code as follows: Answer: Serialize ()/unserialize ()
9. The argument of a function cannot be a reference to a variable unless (15) is set to on in PHP.ini. Copy the Code code as follows: Answer: Allow_call_time_pass_reference
The meaning of the left join in 10.SQL is (16). If Tbl_user records the student's name and school Number (ID), Tbl_score recorded student (ID) and test scores (score) and test subjects (subject), which were expelled from the school after the exam, To print out each student's name and the corresponding total, the SQL statement (17) can be used. Copy the Code code as follows: Answer: (16) Natural left outer connection Select Name, count (score) as Sum_score from Tbl_user left join Tbl_score on Tbl_user.id=tbl_score.id GROUP by Tbl_us Er.id
11: In PHP, Heredoc is a special string, and its end flag must be (18). Copy the Code code as follows: A: The line where the end identifier is located cannot contain any other characters except ";"
12. The time format for printing the previous day in PHP is 2006-5-10 22:21:21 Copy the Code code as follows: Answer: Echo date (' y-m-d h:i:s ', Strtotime ('-1 day '));
13.echo (), print (), print_r () differences Copy the Code code as follows: Answer: ECHO is the language structure, no return value, print function and echo basically the same, the difference is that print is a function, there is a return value; Print_r is a recursive print for outputting array objects
14. How do I implement string flipping? Copy the Code code as follows: A: With Strrev function Bai, do not use PHP built-in on their own write: Strrev ($STR) { $len =strlen ($STR); $newstr = "; for ($i = $len; $i >=0; $i--) { $newstr. = $str {$i}; } return $newstr; }
15. The implementation of the text string interception without garbled method. Copy the Code code as follows: Answer: MB_SUBSTR ()
16. Use PHP to write a simple query, find all the names of "Zhang San" and print out the content Table name User Name Tel Content Date Zhang 313,333,663,366 College Graduation 2006-10-11 Zhang 313,612,312,331 Bachelor's degree 2006-10-15 Zhang Si 021-55665566 secondary school 2006-10-15 Copy the Code code as follows: Answer: SELECT name,tel,content,date from User WHERE name= ' Zhang San '
17. How to use the following class and explain what the following means? Class Test { Get_test ($num) { $num =MD5 (MD5 ($num). " En "); return $num; } } A. Usage: Copy the Code code as follows: $get _test = new Test (); $result = $get _test->get_test (2);
The $num variable is returned after two MD5, the 2nd time parameter in the MD5, after the first MD5 ($num) added en 18. Get the extension of a file using more than five different ways Requirements: dir/upload.image.jpg, find. jpg or JPG, Copy the Code code as follows: A: Use more than five ways to get the extension of a file 1) Get_ext1 ($file _name) { Return STRRCHR ($file _name, '. '); } 2) GET_EXT2 ($file _name) { Return substr ($file _name, Strrpos ($file _name, '. ')); } 3) GET_EXT3 ($file _name) { Return Array_pop (Explode ('. ', $file _name)); } 4) GET_EXT4 ($file _name) { $p = PathInfo ($file _name); return $p [' extension ']; } 5) GET_EXT5 ($file _name) { Return Strrev (substr (Strrev ($file _name), 0, Strpos (strrev ($file _name), '. ')); }
19. How to modify the session lifetime This library allows you to process and display a variety of formats, another common use is to make the document. Another option other than GD is ImageMagick, but the function library is not built into PHP and must be installed by the system administrator on the server A: In fact, the Session also provides a function session_set_cookie_params (); To set the lifetime of the Session, the function must be called before the session_start () function call: Save the day $lifeTime = 24 * 3600; Session_set_cookie_params ($lifeTime); Session_Start (); $_session["Admin"] = true; ? > 20. Write a function that enables the following functions: the string "Open_door" is converted to "Opendoor", "make_by_id" to "Makebyid". Copy the Code code as follows: For: Function Test ($STR) { $arr 1=explode (' _ ', $str); $arr 2=array_walk ($arr 1,ucwords ()); $str = Implode (' ', $arr 1); Return Ucwords ($STR); } $aa = ' Open_door '; echo Test ($AA); ?>
21. How do I get the content of a Web page address using PHP's environment variables? How do I get an IP address? Copy the Code code as follows: Answer: $_servsr[' Request_uri '] $_server[' REMOTE_ADDR ']
22. Ask for the difference of two dates, for example, 2007-2-5 ~ 2007-3-6 Date Differential Copy the Code code as follows: Answer: (Strtotime (' 2007-3-6 ')-strtotime (' 2007-2-5 '))/3600*24
23. There is a B C three column in the table, implemented with the SQL statement: When column A is greater than column B, select column B, or column B when column B is greater than column C, select column C otherwise. Copy the Code code as follows: Answer: Select Case is A>b then A else B end, Case is B>c then B else C end From Test
24. Briefly describe the ways in which the SQL statement performance is optimized in the project, and in what ways do you analyze it? Copy the Code code as follows: Answer: (1) Select the most efficient table name order (2) connection order in the WHERE clause (3) Avoid using ' * ' in the SELECT clause (4) Replace the HAVING clause with a WHERE clause (5) Improve SQL efficiency with intrinsic functions (6) Avoid using calculations on indexed columns. (7) Improve the efficiency of the group BY statement by filtering out unwanted records before group by.
What is the difference between 25.mysql_fetch_row () and mysql_fetch_array ()? Copy the Code code as follows: Mysql_fetch_row () stores a column of the database in a zero-based array, the first column in the array index 0, the second column at index 1, and so on. MYSQL_FETCH_ASSOC () stores a column of the database in an associative array, the index of the array is the column name, for example, my database query back to "First_Name", "last_name", "e-mail" three fields, the index of the array is "first _name "," last_name "and" email ". Mysql_fetch_array () can send back the values of Mysql_fetch_row () and MYSQL_FETCH_ASSOC () at the same time.
26. What does the following code do for you? Please explain. $date = ' 08/26/2003 ';p rint ereg_replace ("([0-9]+)/([0-9]+]/([0-9]+)", "\\2/\\1/\\3", $date); Copy the Code code as follows: This is the conversion of a date from MM/DD/YYYY format to dd/mm/yyyy format. A good friend of mine told me that this regular expression can be disassembled into the following statement, for such a simple representation is actually no need to disassemble, purely for the convenience of explanation: Corresponds to one or more 0-9, followed by an oblique number $regexpression = "([0-9]+)/";//should be one or more 0-9, followed by another oblique number $regexpression. = "([0-9]+)/";//corresponds one or more 0-9$regexpression. = "([0-9]+)"; \\2/\\1/\\3 is used to correspond to parentheses, the first pair of parentheses is the month,
What is 27.GD function library for? Copy the Code code as follows: A: This library allows you to process and display a variety of formats, another common use is to make the document. Another option other than GD is ImageMagick, but the function library is not built into PHP and must be installed by the system administrator on the server
28. Please give an example of how you can speed up the loading of pages in your development process. Copy the Code code as follows: A: To use the server resources to open, timely shut down the server resources, database Add index, the page can generate static, pictures and other large files separate server. Use the Code optimization tool.
29. Prevent SQL injection vulnerability generally with the __addslashes___ function. What is the difference between a value in 30.PHP and a pass-through or address? Copy the Code code as follows: A: The value of the argument is the value assigned to the parameter to the row parameter, so the modification of the parameter does not affect the value of the argument. An address is a special way of transmitting a value, except that he passes an address, not an ordinary one, such as an int. After the address, both the argument and the row parameter point to the same object
31. How to tell if a window has been blocked by JavaScript Copy the Code code as follows: A: Gets the return value of open (), or null if it is blocked
33. What are the ways you can solve traffic problems for large-volume websites? Copy the Code code as follows: A: First, verify that the server hardware is sufficient to support current traffic Second, optimize database access. Third, prohibit the external hotlinking. Four, control the download of large files. V. Use different hosts to divert the main flow VI, using traffic analysis statistics software
The above mentioned is the whole content of this article, I hope to be able to learn PHP to help you. |