- In PHP, the name of the current script (excluding the path and query string) is recorded in the predefined variable (1); and the URL linking to the current page is recorded in the predefined variable (2).
echo $_SERVER['PHP_SELF']; echo $_SERVER["HTTP_REFERER"];
- Execution program segmentwill output (3).
0
- In HTTP 1.0, the meaning of status code 401 is (4); if a "File not found" prompt is returned, the header function can be used, and its statement is (5).
(4) Unauthorized (5) header("HTTP/1.0 404 Not Found");
- The function of array function arsort is (6); the function of statement error_reporting(2047) is (7).
(6) Reverse sort the array and maintain the index relationship (7)All errors and warnings
- The database connection string format in PEAR is (8).
- Write a regular expression to filter all JS/VBS scripts on the web page (that is, remove the tags and their contents): (9).
/<[^>].*?>.*?>/si
- To install PHP as an Apache module, first use statement (10) in the file http.conf to dynamically load the PHP module, and then use statement (11) to make Apache treat all files with the extension php as PHP scripts deal with.
(10) LoadModule php5_module "D:/xampp/apache/bin/php5apache2.dll"
(11) AddType application/x-httpd-php-source .phps
AddType application/x-httpd-php .php .php5 .php4 .php3 .phtml
- The statements include and require can both include another file into the current file. The difference between them is (12); in order to avoid including the same file multiple times, you can replace them with statement (13).
(12) include generates a warning when an exception occurs and require generates a fatal error (13) require_once()/include_once()
- The attributes of the class can be serialized and saved to the session, so that the entire class can be restored later. The function used is (14).
serialize() /unserialize()
- The parameter of a function cannot be a reference to a variable, unless (15) is set to on in php.ini.
allow_call_time_pass_reference
- The meaning of LEFT JOIN in SQL is (16).
If tbl_user records the student’s name (name) and student number (ID),
tbl_score records the student number (ID), test score (score), and test subject (some students were expelled after taking the exam, and there is no record of them).
If you want to print out the name of each student and the corresponding total score of each subject, you can use SQL statement (17).
(16) Natural left outer join
(17) select name , count(score) as sum_score from tbl_user left join tbl_score on tbl_user.ID=tbl_score.ID group by tbl_user.ID
- In PHP, heredoc is a special string, and its end flag must be (18).
The line containing the terminating identifier cannot contain any other characters except ";"
- Write a function that can traverse all files and subfolders in a folder.
/**
* 遍历目录,结果存入数组。支持php4及以上。php5以后可用scandir()函数代替while循环。
* @param string $dir
* @return array
*/
my_scandir($dir)
{
$files = array();
if ( $handle = opendir($dir) )
{
while ( ($file = readdir($handle)) !== false )
{
if ( $file != ".." && $file != "." )
{
if ( is_dir($dir . "/" . $file) )
{
$files[$file] = rec_scandir($dir . "/" . $file);
}
else
{
$files[] = $file;
}
}
}
closedir($handle);
return $files;
}
}
- Briefly describe the implementation principle of unlimited classification in the forum.
- Design a web page so that a full-screen window pops up when it is opened, with a text box and a button in the window. After the user enters information in the text box and clicks the button, the window can be closed, while the entered information is displayed on the main web page.