SoFunction
Updated on 2025-04-12

Super comprehensive PHP interview question sorting collection page 2/2


40. Use php to write a simple query, find out all the content named "Zhang San" and print it out (2 points)
Table name UserName Tel Content Date
Zhang San 13333663366 College graduation 2006-10-11
Zhang San 13612312331 Undergraduate graduation 2006-10-15
Zhang Si 021-55665566 Technical College Graduation 2006-10-15
Please complete the code according to the above question:
$mysql_db=mysql_connect("local","root","pass");
@mysql_select_db("DB",$mysql_db);

41. How to use the following class and explain what the following means? (3)
class test{
function Get_test($num){
$num=md5(md5($num)."En");
return $num;
}
}

----------------------------------------------------------------------------

42. Write out the format of SQL statements: Insert, update, delete (4 points)
Table name UserName Tel Content Date
Zhang San 13333663366 College graduation 2006-10-11
Zhang San 13612312331 Undergraduate graduation 2006-10-15
Zhang Si 021-55665566 Technical College Graduation 2006-10-15
(a) There is a new record (Xiao Wang 13254748547 High School Graduation 2007-05-06) Please use SQL statement to add it to the table
(b) Please use the SQL statement to update Zhang San's time into the current system time
(c) Please write down all records named Zhang Si

43. Please write out the meaning of the data type (int char varchar datetime text); What is the difference between varchar and char (2 points)

44. MySQ auto-increment type (usually a table ID field) must be set to (?) field (1 point)

45. Write out the output results of the following program (1 point)
$b=201;
$c=40;
$a=$b>$c?4:5;
echo $a;
?>

46. ​​Is there a function that detects whether a variable has a set function? Is it an empty function? (2 points)

-----------------------------------------------------------------------------

47. What is the function that obtains the total number of query result sets? (1 point)

48. $arr = array('james', 'tom', 'symfony'); Please print out the value of the first element (1 point)

49. Please separate the values ​​of the array of questions 41 with the ',' sign and merge them into a string to output (1 point)

50. $a = 'abcdef'; Please take out the value of $a and print out the first letter (1 point)

51. Can PHP connect to databases such as SQL server/oracle? (1 point)

52. Please write out the PHP5 permission control modifier (3 points)

53. Please write out the constructor and destructor of php5 (2 points)

------------------------------------------------------------------------------

54. Please use PHPMYADMIN to complete the following

(1) Create a news release system, the table name is message and has the following fields (3 points)
id Article id
title
content
category_id Article category id
hits clicks

(II) The same above-mentioned news release system: the table comment records the user's reply content, the fields are as follows (4 points)
comment_id reply id
id Article id, associated id in message table
comment_content Reply content
Now, by querying the database, you need to get a list of article titles in the following format, and sort it by the number of replies, and the highest replies are ranked first.
Article id Article title Number of clicks Number of replies
Use an SQL statement to complete the above query. If the article has no reply, the number of replies will be displayed as 0.

(3) The above content management system, the table category saves classification information, and the fields are as follows (3 points)
category_id int(4) not null auto_increment;
categroy_name varchar(40) not null;
When a user enters an article, select the article category by selecting the drop-down menu.
Write out how to implement this drop-down menu


Fill in the blanks

1. In PHP, the name of the current script (excluding paths and query strings) is recorded in the predefined variable ____; and the URL linked to the current page is recorded in the predefined variable ____.

2. Execute the program block and output ____.

3. In HTTP 1.0, the meaning of status code 401 is ____; if the prompt "file not found" is returned, the header function can be used, and its statement is ____.

4. The function of the array function array is ____; the function of the statement error_reporting(2047) is ____.

The database connection string format in the format is ____.

6. Write a regular expression and consider all JS/VBS scripts on the web page (that is, remove the script tag and its content): ____.

7. Install PHP in the Apache module. In the file, you must first use the statement ____ to dynamically load the PHP module, and then use the statement ____ to make Apache handle all files with php extensions as PHP scripts.

8. Statements include and require can both include another file in the current file. The difference is ____; in order to avoid including the same file multiple times, the statement ____ can be used instead of them.

9. The attributes of the class can be serialized and saved into the session, so that the entire class can be restored later. The function to be used is ____.

10. The parameters of a function cannot be references to variables unless ____ is set to on in it.

The meaning of LEFT JOIN in the ____. If tbl_user records the student's name (name) and student ID (ID), tbl_score records the student ID (ID) and test scores (score) and test subjects (subject) of students (some students were expelled after the exam), if you want to print out the names of each student and the corresponding total scores of each subject, you can use SQL statement ____.

12. In PHP, heredoc is a special string, and its end flag must be ____.

Programming questions


1. Write a function, and take out the file extension from a standard url as efficiently as possible
For example: /abc/de/?id=1 needs to be removed php or .php

2. In HTML language, the meta tag at the head of the page can be used to output the encoding format of the file. The following is a standard meta statement
Please use PHP language to write a function and change the charset part value in a meta tag in a standard HTML page to big5
Please note:
1. You need to process the complete html page, that is, not only this meta statement
2. Ignore case
3. ' and " are interchangeable here
4. The quotes on both sides of 'Content-Type' can be ignored, but 'text/html; charset=gbk' cannot
5. Pay attention to handling unnecessary spaces

3. Write a function to calculate the relative paths of two files
For example $a = '/a/b/c/d/';
$b = '/a/b/12/34/';
Calculate that the relative path of $b relative to $a should be ../../c/d and add()

3. Write a function that can traverse all files and subfolders in a folder.

4. Briefly describe the implementation principle of infinite classification in the forum.
Previous page12Read the full text