1. In PHP, the name of the current script (excluding the path and query string) is recorded in a predefined variable (1), while the URL linked to the current page is recorded in a predefined variable (2).
Copy Code code as follows:
Answer: Echo $_server[' php_self ']; echo $_server["Http_referer"];
2. The execution segment will be output (3).
Copy Code code as follows:
3. In HTTP 1.0, the meaning of status code 401 is (4), and if you return a "file not found" prompt, the header function is available and the statement is (5).
Copy Code code as follows:
Answer: (4) not authorized (5) header ("http/1.0 404 Not Found");
4. The function of the array function is Arsort (6), and the function of the statement error_reporting (2047) is (7).
Copy Code code as follows:
A: (6) Reverse ordering of arrays and keeping index relationships (7) all errors and warnings
5. Write a regular expression, worry about all the Js/vbs script on the page (that is, the tag and its contents are removed): (9).
Copy Code code as follows:
Answer:/<[^>].*?>.*?<\/>/SI
6. To install PHP in the way of Apache module, the PHP module is dynamically loaded with the statement (10) in the file http.conf.
The statement (11) is then used to enable Apache to process all files that have extensions php as PHP scripts.
Copy Code code as follows:
Answer: (a) 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. Statement include and require can include another file in the current file, the difference being (12); To avoid including the same file multiple times, you can replace them with statements (13).
Copy Code code as follows:
A: (12) When an exception occurs, include generates a warning require fatal error () require_once ()/include_once ()
8. The properties of a class can be serialized and saved into session so that the entire class can be recovered later, and the function to be used is (14).
Copy Code code as follows:
Answer: Serialize ()/unserialize ()
9. An argument to a function cannot be a reference to a variable unless (15) is set to on in PHP.ini.
Copy Code code as follows:
Answer: Allow_call_time_pass_reference
The meaning of the left join in 10.SQL is (16).
If the Tbl_user records the student's name and school Number (ID),
Tbl_score recorded the student (ID) and exam results (score) as well as the examination subjects (subject) of students (some of whom were expelled after the exams),
To print out each student's name and corresponding section score, you can use the SQL statement (17).
Copy 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_u Ser.id
11. In PHP, Heredoc is a special string whose ending flag must be (18).
Copy Code code as follows:
A: The line containing the end identifier cannot contain any other characters except ";"
12. Use PHP to print out the day before the format is 2006-5-10 22:21:21
Copy Code code as follows:
Answer: Echo date (' y-m-d h:i:s ', Strtotime ('-1 day '));
13.echo (), print (), the difference between print_r ()
Copy Code code as follows:
A: Echo is a language structure with no return value; The print function is essentially the same as ECHO, unlike print, which is a function and has a return value; Print_r is a recursive print that outputs an array object
14. How to implement string flip?
Copy Code code as follows:
A: Use the Strrev function chant, do not use PHP built 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 Code code as follows:
16. Use PHP to write a simple query, find all the names of "John" content and print out
Table name User
Name Tel Content Date
313,333,663,366 College graduate 2006-10-11
313,612,312,331 Graduate 2006-10-15
Zhang Four 021-55665566 secondary school graduation 2006-10-15
Copy Code code as follows:
Answer: SELECT name,tel,content,date from User WHERE name= ' John '
17. How do I use the following class and explain what the following means?
Class Test
{
Get_test ($num)
{
$num =MD5 (the MD5 ($num). En ");
return $num;
}
}
Answer: Use:
Copy Code code as follows:
$get _test = new Test ();
$result = $get _test->get_test (2);
The $num variable is returned after two MD5, and the 2nd MD5 parameter is added en after the first MD5 ($num).
18. Get the extension of a file in more than five ways
Requirements: dir/upload.image.jpg, find. jpg or JPG,
Copy Code code as follows:
A: Use more than five ways to get a file name extension
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 lifetime of sessions
This library allows you to work with and display a variety of formats, and another common use is to make the map files. Another alternative to GD is ImageMagick, but this function library is not built into PHP and must be installed by the system administrator on the server: 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 one day
$lifeTime = 24 * 3600;
Session_set_cookie_params ($lifeTime);
Session_Start ();
$_session["Admin"] = true;
? >
20. Write a function that implements the following functions: the string "Open_door" is converted to "Opendoor" and "make_by_id" to "Makebyid".
Copy 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 to use PHP environment variables to get the content of a Web page address? How do I get the IP address?
Copy Code code as follows:
Answer: $_servsr[' Request_uri ']
$_server[' REMOTE_ADDR ']
22. Find the difference of two dates, such as the date difference of 2007-2-5 ~ 2007-3-6
Copy Code code as follows:
A: (Strtotime (' 2007-3-6 ')-strtotime (' 2007-2-5 '))/3600*24
23. The table contains a B C three column, which is implemented using SQL statements: Select column A When column A is greater than column B, or select column B when column B is greater than column C, or select column B.
Copy Code code as follows:
A: Select Case when A>b then A else B end,
Case when B>c then B else C end
From Test
24. Please describe the method of optimizing the execution efficiency of SQL statements in the project, and from what aspects, how does SQL statement performance be analyzed?
Copy Code code as follows:
Answer: (1) Choose the most efficient table name order
(2) The order of joins in the WHERE clause
(3) Avoid the use of ' * ' in the SELECT clause
(4) Replace the HAVING clause with the WHERE clause
(5) Improve SQL efficiency through internal functions
(6) Avoid using calculations on indexed columns.
(7) Increase 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 Code code as follows:
Mysql_fetch_row () stores a column of the database in a zero-base array, the first column in the array index 0, the second column in index 1, and so on. MYSQL_FETCH_ASSOC () store a column of the database in an associative array, the array index is the field name, such as my database query sent back to the "first_name", "last_name", "email" three fields, the array index is "first _name "," last_name "and" email ". Mysql_fetch_array () can return the value of Mysql_fetch_row () and MYSQL_FETCH_ASSOC () at the same time.
26. What is the following code to do? Please explain.
$date = ' 08/26/2003 ';p rint ereg_replace ("([0-9]+)/([0-9]+]/([0-9]+)", "\\2/\\1/\\3", $date);
Copy Code code as follows:
This is to convert a date from MM/DD/YYYY format to dd/mm/yyyy format. A good friend of mine told me that the normal expression could be broken down into the following statement, for such a simple representation is in fact 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]+)/";/again corresponds to one or more 0-9$regexpression. = "([0-9]+)"; As for \\2/\\1/\\3, it is used to correspond to parentheses, the first bracket is the month,
What is the 27.GD function library for?
Copy Code code as follows:
A: This library allows you to process and display various formats of the document, and its other common use is to make the map files. Another alternative to GD is ImageMagick, but this function library is not built into PHP and must be installed by the system administrator on the server
28. Please provide an example of how you can speed up the loading of the page in your development process
Copy Code code as follows:
A: To use the server resources to open, timely shutdown server resources, database Add index, page can generate static, pictures and other large files separate server. Using the Code optimization tool.
29. The __addslashes___ function is generally used to prevent SQL injection vulnerabilities.
What is the difference between a 30.PHP pass value and a reference, or an address?
Copy Code code as follows:
A: The value is to assign the value of the argument to the row parameter so that the modification of the row parameter does not affect the value of the argument
An address is a special way of passing a value, except that he delivers an address, not an ordinary one. After the address is passed, the argument and the row parameter all point to the same object
31. How to determine whether a window has been blocked by JavaScript
Copy Code code as follows:
A: Gets the return value of open (), if it is null, it masks the
33. What methods do you use to solve traffic problems for large traffic sites?
Copy Code code as follows:
A: First, verify that the server hardware is adequate to support current traffic
Second, optimize database access.
Third, the prohibition of external hotlinking.
Four, control the download of large files.
V, the main flow of the use of different mainframe streaming
Use traffic analysis and statistics software
The above mentioned is the entire content of this article, hope to be able to learn PHP to help you.