Some advanced php interview questions are displayed on the Internet .. I had nothing to worry about. I made some answers... It may not be comprehensive. leave it for future use. 1. Basic Knowledge Point 1.1the meaning of several status codes in http: 503500401403404200301302... 200:... "/> <scripttype =" text/javascript "sr
Some advanced php interview questions are displayed on the Internet ..
I had nothing to worry about. I made some answers... It may not be comprehensive. leave it for future use.
I. basic knowledge points
1.1 Meaning of several status codes in HTTP: 503 500 401 403 404 200 301 302...
200: The request is successful, and the requested data is returned accordingly.
301: permanent redirection.
302: temporary row redirection.
401: the current request requires user verification.
403: the server does not have the permission to execute the request.
404: The request failed. the request data is not found on the server.
500: server error. Generally, the server program execution is incorrect.
503: temporary server maintenance or overload. This status is temporary.
1.2 Differences Between Include require include_once require_once.
Different processing failure methods:
When require fails, a fatal error is generated and the program is stopped.
When the include operation fails, only one warning error is generated, and the program continues to run.
Include_once/require_once and include/require handle errors in the same way,
The only difference is that when the included file code already exists, it is not included.
History of several versions in 1.3 PHP/Mysql, such as major improvements from mysql4.0 to 4.1 and from PHP 4.x to 5.1.
1.4 HEREDOC introduction
A method for defining strings.
Structure:
<. At the end of the prompt, you must define an identifier (a single line ),
Then there is a new line. Next is the string itself,
Finally, use the identifier defined above as the end sign (a separate row)
Note:
The naming of identifiers should follow the PHP rules like other labels:
It can only contain letters, numbers, and underscores, and must begin with a letter or underscore
1.5 write some php magic methods;
_ Construct () is automatically called when the class is instantiated.
The _ destruct () class object is automatically called when it is used.
_ Set () is called when an undefined attribute is assigned a value.
_ Get () is called when an undefined attribute is called.
_ Isset () is called when isset () or empty () functions are used.
_ Unset () is called when unset () is used.
_ Sleep () is called when serialize is used for serialization.
_ Wakeup () is called when unserialize is used for deserialization.
_ Call () is called when a nonexistent method is called.
_ CallStatic () calls a non-existent static method.
_ ToString () is called when the object is converted to a string. For example, echo.
_ Invoke () is called when an object is called as a method.
_ Set_state () is called when var_export () function is used. Accept an array parameter.
_ Clone () is called when clone is used to copy an object.
1.6 some configure parameters for php compilation
-Prefix =/usr/local/php installation directory
-With-config-file-path =/usr/local/php/etc specify the php. ini location
-With-mysql =/usr/local/mysql installation directory, which supports mysql
-With-mysqli =/usr/local/mysql/bin/mysql_config mysqli file directory, optimized support
-Enable-safe-mode: enable safe mode.
-Enable-ftp support for enabling ftp
-Enable-zip: supports zip.
-With-bz2 opens support for bz2 files
-With-jpeg-dir: Support for jpeg images
-With-png-dir open support for png images
-With-freetype-dir: Support for freetype library
-Without-iconv: disable the iconv function to convert character sets.
-Support opening libxml2 library with-libxml-dir
-With-xmlrpc open the C language of xml-rpc
-Support opening zlib library with-zlib-dir
-With-gd supports opening the gd Library
For more information, see./configure help.
1.7 three methods for passing parameters to php.
/*
* Method 1 use $ argc $ argv
* Run/usr/local/php/bin/php./getopt. php-f 123-g 456 in the command line.
*/
// If ($ argc> 1 ){
// Print_r ($ argv );
//}
/**
* Running result
*
Sync @ MySUSE11 :~ /Web_app/channel3/interface>/usr/local/php/bin/php./getopt. php-f 123-g 456
Array
(
[0] =>./getopt. php
[1] =>-f
[2] => 123.
[3] =>-g
[4] = & gt; 456
)
*/
/*
* Method 2 use the getopt function ()
* Run/usr/local/php/bin/php./getopt. php-f 123-g 456 in the command line.
*/
// $ Options = "f: g :";
// $ Opts = getopt ($ options );
// Print_r ($ opts );
/**
* Running result
*
Sync @ MySUSE11 :~ /Web_app/channel3/interface>/usr/local/php/bin/php./getopt. php-f 123-g 456
Array
(
[F] = & gt; 123
[G] = & gt; 456
)
*/
/*
* Method 3 prompt the user to enter and then obtain the input parameters. A bit like C language
* Run/usr/local/php/bin/php./getopt. php in the command line.
*/
Fwrite (STDOUT, "Enter your name :");
$ Name = trim (fgets (STDIN ));
Fwrite (STDOUT, "Hello, $ name! ");
/**
* Running result
*
Sync @ MySUSE11 :~ /Web_app/channel3/interface>/usr/local/php/bin/php./getopt. php
Enter your name: francis
Hello, francis!
*/
1.8 (mysql) please write out the meaning of the data type (int char varchar datetime text); what is the difference between varchar and char;
Int: Numeric type
Char: fixed-length string type
Varchar: Variable-length string type
Datetime: Time type
Text: text type
What is the difference between varchar and char:
A. The char length is fixed. no matter how much data you store, it will be fixed.
Varchar can be a variable in length, but it needs to add 1 character to the total length, which is used to store the location.
B. char has a fixed length, so the processing speed is much faster than varchar, but it wastes storage space,
Therefore, it is not suitable for storage, but the char type can be used for speed requirements. Otherwise, the varchar type can be used for instances.
1.9 use of error_reporting and other debugging functions
The error_reporting () function can set the error_reporting command in php. ini at runtime.
Therefore, you can adjust the displayed error level at any time in the program.
When using this function, display_errors must be enabled.
1.10 have you used version control software? What is the name of the version control software you use?
1.11 differences between posix and perl standard regular expressions;
1.12 where is the Safe_mode restricted after it is enabled.
When safe_mode is started, many PHP functions are restricted, especially system-related functions such as file opening and command execution.
The function of all operation files can only operate files with the same UID as the script.
1.13 write code to solve the problem of multiple processes/threads simultaneously reading and writing a file.
PHP does not support multithreading. you can use php's flock locking function.
$ Fp = fopen ("/tmp/lock.txt", "w + ");
If (flock ($ fp, LOCK_EX) {// sort it to lock
Fwrite ($ fp, "Write something here \ n ");
Flock ($ fp, LOCK_UN); // release lock
} Else {
Echo "Couldn't lock the file! ";
}
Fclose ($ fp );
1.14 write code for uploading a file.
Upload.html
Upload. php
$ Uploads_dir = '/uploads ';
Foreach ($ _ FILES ["error"] as $ key => $ error ){
If ($ error = UPLOAD_ERR_ OK ){
$ Tmp_name = $ _ FILES ["tmp_name"] [$ key];
$ Name = $ _ FILES ["name"] [$ key];
Move_uploaded_file ($ tmp_name, "$ uploads_dir/$ name ");
}
}
1.15 what is the difference between the storage engine myisam and innodb of Mysql.
A. The MyISAM type does not support advanced processing such as transaction processing, whereas the InnoDB type does.
B. MyISAM tables emphasize performance, and the execution speed is faster than that of InnoDB tables.
C. InnoDB does not support FULLTEXT indexes.
D. InnoDB does not save the specific number of rows of the table, that is,
When executing select count (*) from table, InnoDB needs to scan the entire table to calculate the number of rows,
However, MyISAM simply needs to read the number of lines saved.
E. for fields of the AUTO_INCREMENT type, InnoDB must contain only the index of this field. However, in the MyISAM table, you can create a joint index with other fields.
F. delete from table, InnoDB does not create a new table, but deletes a row.
G. load table from master operation does not work for InnoDB. the solution is to first change the InnoDB TABLE to the MyISAM TABLE, and then the InnoDB TABLE after the data is imported,
However, it is not applicable to tables that use additional InnoDB features (such as foreign keys.
H. MyISAM supports table locks and InnoDB supports row locks.
2. web architecture, security, and project experience
2.1 introduce the experience of xdebug, apc, eAccelerator, Xcache, and Zend opt.
2.2 When mod_rewrite is used and there is no physical file/archivers/567.html on the server, redirect to index. php? Id = 567. open mod_rewrite first.
First, open the mod_rewrite module.
Next, find the following code segment in http. conf:
Options FollowSymLinks
AllowOverride None
Change AllowOverride None to AllowOverride All, and restart the httpd service.
Then fill in the rule in the resume. htaccess file under the root directory of the project.
2.3 MySQL database is used as the storage of the publishing system, with more than 50 thousand increments per day. it is expected to be maintained for three years. how can this problem be optimized?
A. a well-designed database structure allows some data redundancy and avoids join queries as much as possible to improve efficiency.
B. select the appropriate table field data type and storage engine, and add indexes as appropriate.
C. mysql database master/slave read/write splitting.
D. find regular table shards to reduce the data volume in a single table and increase the query speed.
E. Add cache mechanisms, such as memcached and apc.
F. generate static pages for infrequently modified pages.
G. write highly efficient SQL statements. For example, SELECT * from tabel is changed to SELECT field_1, field_2, field_3 from table.
2.4 write a sorting algorithm (principle) and explain the method to optimize it.
2.5 briefly describe your most proud development work
2.6 what kind of method do you use to solve the problem of page access statistics for high-traffic websites?
A. Check whether the server can support the current traffic.
B. optimize database access. Reference 2.3
C. prohibit external access links (leeching.
D. Control file download.
E. use different hosts for shunting.
F. use the browser statistics software to understand the traffic volume and perform targeted optimization.
2.7 have you used the template engine? What is the name of the template engine that you use?
Smarty
2.8 introduce the principle of Session. what should I pay attention to when using sessions on large websites?
2.9 tools for testing php performance and mysql database performance, and methods for identifying bottlenecks.
2.10 regular expressions indicate all links in a web page.
2.11 introduce the principles of common SSO (single-point login) solutions (such as dedecms integrated discuz passport.
2.12 The characteristics of the PHP framework you have written mainly solve what problems are different from those of other frameworks.
What are the differences between 2.13 large forums, news articles, and SNS websites in terms of performance optimization?
2.14 album applications: multiple files must be selected and uploaded simultaneously in the browser. images must be cropped and compressed on the server. Upload a single file up to 50 MB. A progress bar is displayed during the upload process. Each image can generate four types of thumbnails, and the video file must be converted to flv for flash playback. Describes all types of open-source software and simple applications involved.
A group of monkeys are arranged in a circle ,..., N is numbered in sequence. Then start counting from 1st, count to m, kick it out of the circle, start counting from behind it, count to m, and kick it out ..., The monkey is called the King until there is only one monkey. Programming to simulate this process, input m, n, and output the number of the last king. Use a program to simulate the process.
III. basic usage of unix/linux
3.1 How to view the current system load information in linux.
3.2 Basic shortcut for vim.
3.3 ssh security enhancement method; password and rsa key configuration.
3.4 rpm/apt/yum/ports: basic commands for package installation, query, and deletion.
3.5 The basic format of Makefile, gcc compilation, connection command,-O0 and-O3 differences.
3.6 Basic usage of gdb, strace, and valgrind.
4. front-end, HTML, and JS
Css box model.
Prototype in javascript.
The scope of this object in javascript.
The difference between IE and firefox event bubbles.
What is the weird mode, standard mode, and near Standard mode.
DTD definition
Hack is commonly used in IE/firefox.
Front-end js/css debugging tools in firefox and IE.