Advanced PHP surface Questions and partial answers _php tutorial

Source: Internet
Author: User
Tags apc flock flock lock php framework types of tables
See some advanced PHP interview topics on the web.

Nothing to do, got some answers ... may not be very comprehensive, leave this after the spare bar.

I. Basic knowledge points
1.1 The meaning of several status codes in the HTTP protocol: 503 500 401 403 404 200 301 302 ...
200: The request is successful and the requested data is returned with it.
301: Permanent redirect.
302: Temporary row redirection.
401: The current request requires user authentication.
403: The server refuses to execute the request, that is, no permissions.
404: The request failed and the requested data was not found on the server.
500: Server error. General server-side program execution error.
503: The server is temporarily maintained or overloaded. This state is temporary.

1.2 Include require include_once require_once the difference.
Processing failed in different ways:
Require fails with a fatal level error and stops the program from running.
The include fails with only a warning level error, and the program continues to run.

Include_once/require_once and Include/require handle the wrong way,
The only difference is that when the included file code already exists, it is not contained.

1.3 Php/mysql Several versions of the evolutionary history, such as mysql4.0 to 4.1,php 4.x to 5.1 significant improvements and so on.


1.4 Heredoc Introduction
A method that defines a string.
Structure:
<<<. After this prompt, you define an identifier (a single row),
Then there is a new line. Next is the string itself,
Finally, use the previously defined identifier as the end flag (a single row)
Attention:
The name of the identifier is also subject to the rules of PHP like any other tag:
Can only contain letters, numbers, and underscores, and must begin with a letter and an underscore


1.5 Write some magic (technique) method of PHP;
__construct () is called automatically when the class is instantiated. The
__destruct () class object is automatically invoked at the end of the use.
__set () is called when a value is assigned to an undefined property. Called when
__get () calls an undefined property.
__isset () is called when the isset () or empty () function is used.
__unset () is called when the unset () is used.
__sleep () is called when serialized using Serialize. Called when
__wakeup () is deserialized using Unserialize. Called when
__call () calls a non-existent method.
__callstatic () calls a non-existent static method that is called.
__tostring () is called when the object is converted to a string. Like Echo.
__invoke () is called when an attempt is made to invoke an object as a method call.
__set_state () is called when the Var_export () function is used. accepts an array parameter.
__clone () is called when copying an object using clone.

1.6 Some configure parameters when compiling PHP
–prefix=/usr/local/php PHP installation directory
–with-config-file-path=/usr/local/php/etc Specifying php.ini location
–with-mysql=/usr/local/mysql MySQL installation directory, support for MySQL
–with-mysqli=/usr/local/mysql/bin/mysql_config mysqli file directory, optimization support
–enable-safe-mode Turn on Safe mode
–ENABLE-FTP Support for Open FTP
–enable-zip opening support for zip
–WITH-BZ2 opening support for bz2 files
–with-jpeg-dir opening support for JPEG images
–with-png-dir opening support for PNG images
–with-freetype-dir opening support for the FreeType font library
–without-iconv Close Iconv function, conversion between kinds of character sets
–with-libxml-dir opening support for LIBXML2 libraries
–WITH-XMLRPC Open the C language of XML-RPC
–with-zlib-dir opening support for zlib libraries
–WITH-GD opening the GD library support

More can be used./configure Help View

1.7 Three ways to pass in parameters to PHP.

/*
* Method one uses $ARGC $argv
* Run/usr/local/php/bin/php under the command line./getopt.php-f 123-g 456
*/
if ($ARGC > 1) {
Print_r ($ARGV);
// }


/**
* Running Results
*
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] = 456
)
*/


/*
* Method two using the Getopt function ()
* Run/usr/local/php/bin/php under the command line./getopt.php-f 123-g 456
*/


$options = "F:g:";
$opts = getopt ($options);
Print_r ($opts);


/**
* Running Results
*
Sync@mysuse11:~/web_app/channel3/interface>/usr/local/php/bin/php./getopt.php-f 123-g 456
Array
(
[F] = 123
[g] = 456
)
*/


/*
* Method Three prompts the user for input, and then gets the input parameters. Kind of like C language.
* Run/usr/local/php/bin/php./getopt.php at the command line
*/
Fwrite (STDOUT, "Enter Your Name:");
$name = Trim (fgets (STDIN));
Fwrite (STDOUT, "Hello, $name!");
/**
* Running Results
*
Sync@mysuse11:~/web_app/channel3/interface>/usr/local/php/bin/php./getopt.php
Enter your Name:francis
Hello, francis!.
*/


1.8 (MySQL) please write the meaning of the data type (int char varchar datetime text); What is the difference between varchar and char, please?
int: Numeric type
Char: fixed-length string type
VARCHAR: variable-length string type
DateTime: Period Time Type
Text: literal type

What is the difference between varchar and char:
A. Char length is fixed, regardless of the amount of data you store, he will be fixed length.
The varchar is variable in length but he adds 1 characters to the total length, which is used to store the location.

B. Char fixed length, so the processing speed is much faster than varchar, but a waste of storage space,
Therefore, the storage is not small, but the speed of the requirements can use the char type, and vice versa can be used to instantiate the type of varchar.


1.9 Error_reporting and other debugging functions use
The error_reporting () function can set the error_reporting instruction in php.ini at run time.
So you can adjust the level of error displayed at any time in the program.
The display_errors must be open when using this function.

1.10 Have you ever used version control software? If you have the name of the version control software you are using?

1.11 The POSIX and Perl standard regular expression differences;

1.12 Safe_mode is opened and where it is limited.
Starting Safe_mode will limit many PHP functions, especially those related to the system, such as file opening, command execution, and so on.
All functions that manipulate files will only operate with the same file as the script UID.


1.13 Write code to solve the problem of multi-process/thread reading and writing a file at the same time.
PHP does not support multithreading, you can use the PHP flock lock function implementation.
$fp = fopen ("/tmp/lock.txt", "w+");
if (Flock ($FP, LOCK_EX)) {//row-type locking
Fwrite ($fp, "Write something here\n");
Flock ($FP, lock_un); Release lock
} else {
echo "couldn ' t lock the file!";
}
Fclose ($FP);


1.14 Write the code to upload the 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 Mysql's storage engine, the difference between MyISAM and InnoDB.
A. MyISAM types do not support advanced processing, such as transaction processing, and InnoDB type support.
B. MyISAM types of tables emphasize performance, which is performed more quickly than the InnoDB type.
C. InnoDB does not support indexes of fulltext types.
D. InnoDB does not save the exact number of rows in the table, that is,
When you execute SELECT COUNT (*) from table, InnoDB to scan through the entire table to calculate how many rows,
But MyISAM simply reads out the number of saved rows.
E. For fields of type auto_increment, InnoDB must contain only the index of the field, but in the MyISAM table, you can establish a federated index with other fields.
F. Delete from table, InnoDB does not reestablish the table, but deletes one row at a time.
G. LOAD table from master operation does not work for InnoDB, the solution is to change the InnoDB table to MyISAM table first, import the data and then change to the InnoDB table,
However, tables that use additional InnoDB attributes, such as foreign keys, do not apply.
H. MyISAM supports table locks, InnoDB supports row locks.


Two. Web architecture, security, project experience
2.1 Introduce the experience of using xdebug,apc,eaccelerator,xcache,zend opt.


2.2 Using Mod_rewrite, when the physical file is not/archivers/567.html on the server, redirect to index.php?id=567, please open mod_rewrite first.
First, open the Mod_rewrite module.

Second, http.conf finds the following code snippet:

Options FollowSymLinks
AllowOverride None

Change one of the following: AllowOverride None to allowoverride all, restart the httpd service.

Then, under the project root directory, resume. htaccess file, fill in the rules.

2.3 MySQL database for the storage of the publishing system, more than 50,000 increments per day, estimated operations three years, how to optimize?
A. Well-designed database structure, allowing partial data redundancy, to avoid join query, improve efficiency.
B. Select the appropriate table field data type and storage engine, and add the index as appropriate.
C. mysql Library master-slave read/write separation.
D. Find regular tables and reduce the amount of data in a single table to improve query speed.
E. Add caching mechanisms, such as MEMCACHED,APC.
F. Pages that do not change frequently, generating static pages.
G. Writing high-efficiency SQL. For example, select * from Tabel to select Field_1, Field_2, field_3 from TABLE.


2.4 Write a sort algorithm (principle) and say how to optimize it.


2.5 Please briefly describe your most proud development.


2.6 For large traffic sites, what kind of method do you use to solve the statistic problem of each page access quantity?
A. Confirm that the server can support the current traffic.
B. Optimize database access. Reference 2.3
C. prohibit external access link (hotlinking), than slice hotlinking.
D. control file download.
E. Use different host shunts.
F. Use the Browse statistics software to understand the volume of visits, targeted optimization.


2.7 Have you ever used a template engine? If you have the name of the template engine you are using?
Smarty

2.8 Please introduce the principle of the session, the large site of the session should pay attention to what?


2.9 Tools for testing PHP performance and MySQL database performance, and ways to find bottlenecks.


2.10 Regular presents all the links in a Web page.


2.11 Introduce the principle of common SSO (single Sign-on) scenarios such as DEDECMS integrated Discuz Passport.


2.12 The features of the PHP framework you have written, the main solution to what the problem is, different points from other frameworks.


2.13 Large Forums/news articles System/sns What is the difference in performance optimization?


2.14 Album Class application: Require in the browser can also select and upload multiple files, picture requirements can be clipped, compressed package on the server side decompression. Can upload a single file up to 50M. A progress bar is displayed during the upload process. Each image can generate four sizes of thumbnails, video files to be converted to FLV for flash playback. Describe the various types of open source software and simple uses to be covered.
A group of monkeys in a circle, according to 1,2,...,n sequentially numbered. Then, starting from the 1th, Count to M., Kick It Out of the loop, start counting from behind it, Count to M., and Kick It out ... and so on, until the last monkey is left, the monkey is called the King. Requires programming to simulate this process, enter M, N, and output the number of the last king. Simulate the process with a program.


Three. Unix/linux Basic use
3.1 Some methods for viewing current system load information under Linux.


3.2 Vim's basic shortcuts.


3.3 SSH Security enhancement method, password mode and RSA key mode configuration.


3.4 rpm/apt/yum/ports Pack, query, delete the basic commands.


3.5 Makefile's basic format, GCC compilation, connection commands,-o0 and-o3 differences.


Basic use of 3.6 gdb,strace,valgrind.


Four. Front end, Html,js
CSS box model.
The prototype in JavaScript.
The scope of this object in JavaScript.
The difference between IE and Firefox event bubbling.
What is weird mode, Standard mode, near Standard mode.
Definition of DTD
Ie/firefox commonly used hack.
The front-end js/css debugging tool under Firefox,ie.


http://www.bkjia.com/PHPjc/477584.html www.bkjia.com true http://www.bkjia.com/PHPjc/477584.html techarticle See some advanced PHP interview topics on the web. Nothing to do, got some answers ... may not be very comprehensive, leave this after the spare bar. I. Basic knowledge Point 1.1 HTTP protocol ...

  • 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.