PHP Interview Topics

Source: Internet
Author: User
Tags php language md5 encryption
1. The time format of the day before printing with PHP is 2006-5-10 22:21:21 (2 minutes) "u% j& q! S $}0 V8 ~?
Date ("Y-m-d h:i:s", Strtotime ("-1 Days"));

2, Echo (), print (), Print_r () difference (3 points)
ECHO is a PHP statement, print and Print_r are functions, the statement does not return a value, the function can have a return value (even if it is not used)
Print () prints only the values of a simple type variable (such as int,string)
Print_r () can print out values for complex type variables (such as arrays, objects)

2 W; q:j* q0 j T3 K4 \
3, the ability to make HTML and PHP separated from the use of the template (1 points)
Smarty, Fasttemplate


9 e% Q6 s% K9 {3 @2 x
4. What tools are used for version control? (1 points)
SVN, CSV


5, how to implement string rollover? (3 points)
function Newstr ($STR)
{
$rs = "";
For ($i =strlen ($STR); $i >=0; $i + +)
$rs. = $str [$i];
return $rs;
}


0 G5]0 z# \; w+ X7 A (a
* D3 Z6 F) U3 L U
6, optimize the MySQL database method. (4 points, more write more)
Select the most applicable field property
Use connection (join) instead of subquery (sub-queries)
Use Union (Union) instead of manually created temporary tables
Transaction
Lock table
Using foreign keys
Working with Indexes
Optimized query statements

7, the Meaning of PHP (give 1 points)
PHP, a nested abbreviated name, is an abbreviation for the English "super Text Preprocessing language" (Php:hypertext preprocessor)


f+ @5 n ' e:g-Y; B "b


8. What is the function of MySQL to get the current time?, the function to format the date is (2 points)
Now ();
Date_format ();


9, the implementation of the text string interception without garbled method. (3 points) $ \ '% B1 r6 c6 H4 B "I5 o/v
function Gbsubstr ($string, $start, $length) {
if (strlen ($string) > $length) {
$str =null;
$len = $start + $length;
for ($i = $start; $i < $len; $i + +) {
if (Ord (substr ($string, $i, 1)) >0xa0) {
$str. =substr ($string, $i, 2);
$i + +;
}else{
$str. =substr ($string, $i, 1);
}
}
return $str. ' ... ';
}else{
return $string;
}
}


10. Have you ever used version control software? If you have the name of the version control software you are using? (1 points)
Svn


; X8 K5 m& z* [/v. V
11. Have you ever used a template engine? If you have the name of the template engine you are using? (1 points)
Smarty


12, please briefly describe your most proud of the development of the work (4 points)


4 q; o# e]8 w* B: {
13, for the large-volume website, what method do you use to solve the traffic problem? (4 points)
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, use traffic analysis statistics software.

O1 J. h ' & M
14. Use PHP to write the code showing client IP and server IP 1 points)
Server Ip:echo $_server[' http_host ']
Client Ip:echo $_server[' REMOTE_ADDR ']

) p# @* r% p# G8 ~* y+ {"|) [2 R
15. What is the difference between statement include and require? To avoid including the same file multiple times, you can use (?) Statements instead of them? (2 points)
Include generates warning require fatal error when exception occurs
Contains only one time include_once,require_once

16, how to modify the session's survival time (1 points).
Session_set_cookie_params (number of seconds to live);
Setcookie ();

17, there is a web address, such as the PHP Lab homepage: http://www.phpv.net/index.html, how to get its content? ($/min)
File_get_contents ($url)

18, in HTTP 1.0, the meaning of status code 401 is (?); If you get a hint that "file not found" is returned, the header function is available and the statement is (?);( 2 min)
401 unauthorized access to unauthorized;
Header (' http/1.1 404 Not Found ');

: X5 N; a:u+ L7 [G; c
19, in PHP, Heredoc is a special string, its end flag must? (1 points)
Must be shelf.

20, talk about the advantages and disadvantages of asp,php,jsp (1 points)


-X6 V8 A! s*}. ?
21. Talk about MVC (1 points)
The MVC (Model/view/controller) pattern consists of three classes of objects. The model is the Application object, and view is its representation on the screen,
The controller defines how the user interface responds to user input.
Model-View-Controller (MVC) is a software design pattern appearing in the 80 's Smalltalk-80, which is now widely used.
(model) 1)
The model is the body part of the application. Models represent business data, or business logic.
2) Views (view)
A view is a part of the user interface in an application that is the interface that the user sees and interacts with.
3) Controllers (Controller)
Controller work is to control user interface data display and update model object state according to the user's input.

' 7 @6 U (G0?& j$ J6 N
22, write the number of the top 10 names of SQL, using the following table: Members (Id,username,posts,pass,email) (2 points)
SELECT username from members ORDER by posts DESC LIMIT 10


23. Please indicate the difference between the value of the transfer and the reference in PHP. When is the value passed? (2 points)
A pass value is a copy of a value in the delivery heap, and a reference is a copy of a symbol that points to a value in the pass stack. Change the original value to pass the reference, do not change the value.

24. What is the function of error_reporting in PHP? (1 points)
Set the level of error message return

25. Please write a function to verify that the e-mail is in the correct format (2 points)
function Validateemail ($email)
{
Return Ereg (' ^[-_\.a-za-z0-9]+@[-a-za-z0-9]+\.[ -\.a-za-z0-9]+$ ', $email);
}


; ]* m ' f+ _0 I. ' & R3 P6 R4 G
26. Describe how to get the current execution script path, including the obtained parameters. (2 points)
echo $_servepastingr[' Script_filename ']. "?" . $_server[' query_string '];


27. How to modify the lifetime of the session. (1 points)
Setcookie ();


28. JS Form Popup dialog function is? Get the input focus function? (2 points)
Alert ();p rompt (); Confirm ();
Focus ();


# h& g% k M0 g$ s/e/-C "l/u+ M
29, JS's steering function is? How to introduce an external JS file? (2 points)
Window.location = "";

30. What is the difference between foo () and @foo ()? (1 points)! s) x1 q# g* F1 t:f
@ Can mask errors!

31. How do I declare a class with no methods and properties named "MyClass"? (1 points)
Class myclass{};

6 n:i B. M. W3 x/s4 t$ s
32. How to instantiate an object named "MyClass"? (1 points)
$newClass = new MyClass ();


33. How do you access and set the properties of a class? (2 points)
$test = new MyClass ();
$test->oneparam = "Test";
Echo $test->twoparam;


34. What is the difference between mysql_fetch_row () and mysql_fetch_array? (1 points) 5 x# w+ V, G2 b
Mysql_fetch_row--Get a row from the result set as an enumerated array
Mysql_fetch_array--Gets a row from the result set as an associative array, or as a numeric array, or both

35, what is the GD library for? (1 points)
The GD library provides a range of APIs for working with images, using the GD library to process images, or to create images.
The GD library on the site is often used to generate thumbnails or to add watermarks to images or generate reports on site data.

36. Point out some ways to enter HTML code in PHP. (1 points), u$ o# N3 B)]; S "p/g
Print ("
");
echo "
";

37. Which of the following functions can open a file to read and write to a file? (1 points)
Select C
(a) Fget () (b) File_open () (c) fopen () (d) Open_file ()

38. Which of the following options does not add John to the users array? (1 points)
Select B, C, D where B is a function that does not exist
(a) $users [] = ' John ';
(b) Array_add ($users, ' John '); $ y0 b# B9 _ l:l
(c) Array_push ($users, ' John ');
(d) $users | | = ' John ';


* Z4 G4 s:q Q6 |/a& k& L
39, the following program will enter whether or not? (1 points); |-H (p! ~# ~$ |7 K0 x
$num = 10;8 L: @% v/t4 U6? 1 [
function Multiply () {9]$ g! V i+ o+ _: U5 ^ "e-h-C
$num = $num * 10;
}
Multiply ();-q+ y/^$ O2 X6 |4 H
echo $num; * Y6 L8 x-x% K. \% h% S5 P
?>
No, local variable # ~& J6 Q3 k$ {(' "]


40. Use PHP to write a simple query, find out all the names of "Zhang San" and print out (2 points) 5 t3 H0 r-j (P
Table name UserName Tel Content Date ' t:? 2 ' $ B; C4 '
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
Please complete the code according to the above topic:
$mysql _db=mysql_connect ("local", "Root", "pass");
@mysql_select_db ("db", $mysql _db);

$result =mysql_query ("select * from User where Name= ' Zhang San '");
while ($row =mysql_fetch_array ($result))
{
echo $row [' Name ']. $row [' Tel ']. $row [' Content ']. $row [' Date '];
echo "
";
}

41, how to use the following class, and explain what the following mean? (3) 2 L + R1 Z N) s, s ~. X
Class test{
function Get_test ($num) {$ x; B9 R7 v3 x& C # q$ s& C ' A0 I
$num =MD5 (MD5 ($num). " En ");
return $num;
}
}
Dual MD5 encryption
/G: To [# U3]# G) W. b


42, write the format of the SQL statement: INSERT, UPDATE, delete (4 points)) l& C5 m-_0 q (s0 q-k9 q
Table name UserName 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
(a) A new record (Xiao Wang 13254748547 High school 2007-05-06) please add a SQL statement to the table
INSERT into User (' Name ', ' Tel ', ' Content ', ' Date ') VALUES (' Xiao Wang ', ' 13254748547 ', ' High School graduate ', ' 2007-05-06 ')
E6 V "Q; Z-M3 B + A (' 2}
(b) Use an SQL statement to update the Zhang San time to the current system time
UPDATE User SET Date=date_format (now (), '%y-%m-%d ') WHERE name= ' Zhang San '
(c) Please write down all records named Zhang Xi
DELETE from User WHERE name= ' Zhang four '


43. Please write the meaning of the data type (int char varchar datetime text); What is the difference between varchar and char (2 points)
int numeric type char fixed length string varchar variable long string datetime date Time Type text character string
The length of the char column is fixed to the length declared when the table was created. The value in the varchar column is a variable-length string.

44. MYSQ Self-increment type (usually the table ID field) must be set to (?) Field (1 points)
PrimaryKey, Auto_increment

45, write out the following program output results (1 points) "' (Q6 @% r/z
$b =201;/ Y1 Z8 s (e! z& D8 u* \. Y) X1 J
$c = 40;
$a = $b > $c? 4:5; ^4 N4 i:x-B ' S
echo $a;
?>
The result is: 4


46. Is there a function to detect if a variable is set? is the function empty? (2 points) 3 x& i& m2 R "C # h$ s& G1 W
Isset () Empty ()

* Y0 l:p-e& T4 w) I "U
47. What is the function that gets the total number of query result sets? (1 points)
Count ()


48, $arr = Array (' James ', ' Tom ', ' Symfony '); Please print out the value of the first element (1 points) (K7 C4 S:])]# I
echo $arr [0];


49. Separate the values of the array of 48 questions with ', ' and combine them into a string output (1 points)
$arr 1 = Implode (",", $arr);

* C3 Q3 N) |5 i. F "c) |+ P8 S; P
50, $a = ' abcdef '; Please remove the value of $ A and print out the first letter (1 points)
echo $a [0];
Echo substr ($a, 0, 1)


51. Can PHP connect to a database such as SQL Server/oracle? (1 points)
OK


8]7 c.} -F5 L "o* W 0 I0?
52. Please write out the PHP5 permission control modifier (3 points)
Private protected public

/X2?. E) f/d
53. Please write the PhP5 constructor and destructor (2 points)
__construct __destruct

"{/e+ C1 p# o5 d ^
54, the following please complete with phpMyAdmin
(a) Create a press release system with the following field (3 points)/z) Q (G0 G7 K. w$ r-c& _8 y+ y5 Q3 F
ID Article ID:}5 |: G0 L! S4 I9 f& T3 h$ V2 _
Title article Heading 6 m+ W1 P4 F; Y% _0 ^
Content article contents
CATEGORY_ID article Category ID
Hits Click Volume

7 k$ Z.} 9 w$ x; W1 |
(ii) The same press release system: Table comment Record the user reply content, the field is as follows (4 points) 9 u# k-x O8 P1 J6 M9 n
comment_id reply id-w-M "]: [& a ' f& d-y-b
ID article ID, ID in the associated message table
Comment_content Reply Content 7 n/j, l% K6 W (A. {+ F-r
Now by querying the database need to get the following format of the article title list, and according to the number of replies sorted, the highest ranked top: [, [-^9 x J6 f*?& D,]
Article ID article title click Reply Quantity
Use an SQL statement to complete the above query, if the article does not reply to the number of replies displayed as 0
SELECT message.id ID, message.title title IF (Message.hit is NULL, 0, message.hit) hits,
IF (comment.id, 0, COUNT (*)) number
From message
Left JOIN
Comment on comment.id = message.id
GROUP by Message.id

(c) The above Content management system, table category to save the classification information, the field is as follows (3 points)
category_id Int (4) not NULL auto_increment; "_3 r-r ' r" y& \$ W
Categroy_name varchar (+) not null;
When the user enters the article, select the article category by selecting the drop-down menu, E "k* Y9 _% M7 Z1 M; H
Write how to implement this drop-down menu


Blank questions
1. In PHP, the name of the current script (not including the path and query string) is recorded in the predefined variable $_server["php_self", whereas the URL linked to the current page is recorded in the predefined variable $_server["Http_referer".
2. Execution of program segments Will output 0. ' B8 o& w% J d:h% c5 q
3. In HTTP 1.0, the meaning of status Code 401 is not authorized, if you return the "File not found" prompt, you can use the header function, the statement is the header (http/1.0 404 Not Found).
4. The function of array function arsort is to reverse order and maintain index relationship, and the function of statement error_reporting (2047) is all errors and warnings. 6 g+ o ' O! f% E
The database connection string format in 5.PEAR is "Mysql://root:123@192.168.0.1/testdb (phptype://username:password@protocol+hostspec/database )" 。
6. Write a regular expression that js/vbs all the scripts on the Web page (that is, remove the scrīpt tag and its contents): "/ ].*?>.*?<\/script>/si.
7. Install PHP as an Apache module, and use the LoadModule php5_module "D:\xampp\apache\bin\php5apache2.dll" to dynamically load PHP modules in file http.conf , and then use the statement AddType application/x-httpd-source. Phps addtype application/x-httpd. php3. PhP4. PHP5 to enable Apache to put all extensions Files for PHP are processed as PHP scripts.
8. Statements include and require can include another file in the current file, the difference is that include generates a warning, require a fatal error, in order to avoid multiple inclusion of the same file, you can use the statement include_once () and Request_once () to replace them. The properties of the
9. 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 serialize ()/unserialize (). 5 M]-v# Q. J \8 H
10. A function parameter cannot be a reference to a variable unless allow_call_time_pass_reference is set to ON in php.ini. ^-q U2 b6?; f3 \; G
11.sql is the natural outer connection. If Tbl_user records the student's name (name) and school number (ID), Tbl_score records the student (ID) and test score (score) and the test subject (subject), which were expelled from the student's exams, without their records. To print out each student's name and corresponding section scores, you can use the SQL statement select Name, COUNT (score) as Sum_score from Tbl_user left join Tbl_score on tbl_user.id=t Bl_score.id GROUP by Tbl_user.id.
12. In PHP, Heredoc is a special string whose end flags must end with identifiers where the line cannot contain any other characters except ";".


. D9 T/'! F "J4 |; V. K + F
Programming question 2}9 Z0 g:u! Z6 T2 O
$ x:f& G}1 y+ K6 R) K7 G7 W, T
1. Write a function that is as efficient as possible, remove the file extension from a standard URL $ n+ M7?& K. ^/^8 A
For example: http://www.sina.com.cn/abc/de/fg.php?id=1 need to remove PHP or. PHP7 ~ "T3 M5}, W
2. In the HTML language, the meta tag of the header of the page can be used to output the encoding format of the file, the following is a standard META statement
Use the PHP language to write a function that changes the value of the charset part of a standard HTML page to big57 ~. h* O; p% q+ ~: G}
Please note:
1. The full HTML page needs to be processed, i.e. not only this META statement 4 t# l/v7 U7 L, K
2. Ignore case
3. ' and ' can be interchanged in this place
4. The quotation marks on both sides of ' content-type ' are negligible, but ' text/html; CHARSET=GBK ' not on either side ' O5 L6 v* P! F r! W, U
5. Pay attention to handling extra spaces
3. Write a function that calculates the relative path of the two files
such as $a = '/a/b/c/d/e.php ';
$b = '/a/b/12/34/c.php '; 8 q-j-B. E/M (M1 D
Calculates $b relative path relative to the $a should be http://www.cnblogs.com/c/d () added
3. Write a function that can traverse all the files and subfolders under a folder. * T4 ^. B/k ' q$ G5 L4 P! {$ G
4. Briefly describe the implementation principle of infinite classification in the forum.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.