March 2009 Sina php face question and answer (a)

Source: Internet
Author: User

1. Echo count ("abc"); Output what?

Answer: 1

2. Write the code that displays the client IP and server IP in PHP code.

Answer: Client getenv (' REMOTE_ADDR '); Server-side getenv (' server_addr ');

gethostbyname ("www.phpmst.com");

3. error_reporting (2047) what role?

Answer: Equivalent to error_reporting (' E_all '); All errors are output.

4. How to implement PHP and JSP interaction?

Answer: The topic is a bit vague, soap,xml_rpc,socket function,curl can achieve these, if it is a test of PHP and Java integration, PHP built-in this mechanism (if you test PHP and. NET integration, can also answer this), such as $foo = New Java (' Java.lang.System ');

5. Which parameters will be affected by opening the Safe_mode in php.ini? Say at least 6 of them.

Answer: When this module is opened, PHP will check that the owner of the current script is the same as the owner of the manipulated file, so it will affect the file operation class function and the program execution function (Programs execution Functions). These functions have. pathinfo,basename,fopen,system,exec,proc_open functions;

6. Please write a function to verify that the e-mail message is in the correct format (requires regular use).

function Checkemail ($mail) {

$reg = '/^\\w+ ([-+.] \\w+) *@\\w+ ([-.] \\w+) *\\.\\w+ ([-.] \\w+) *$/';

$rst = Preg_match ($reg, $mail);

if ($rst) {

return TRUE;

}else {

return FALSE;

} }

7. Write a function to sort the two-dimensional array.

Answer: Array_multisort ().

8, optimize the MySQL database method.

Answer: (1). Database design Aspects, this is the responsibility of the DBA and architect, the design of a well-structured database, when necessary, to regularization (English is this: denormalize, Chinese translation into what I do not know), allow partial data redundancy, avoid join operation, To improve query efficiency.

(2). System architecture design, the table hash, the huge amount of data scattered into several different tables. speed table, fast table only keep the latest data, slow table is a historical archive. Cluster, master server Read & write, from server read only, or n servers, each machine is master.

(3). (1) and (2) Beyond PHP programmer requirements, will be better, will not matter. Check that there are no fewer indexes.

(4). Write efficient SQL statements to see if there are any inefficient SQL statements, such as the full connection of the generated Cartesian product, a large number of group by and order by, no limit, and so on. When necessary, the database logic is encapsulated in the DBMS side of the stored procedure. Cache query Results, Explain each SQL statement.

(5). All that is required is to fetch only the necessary data from the database, such as querying the number of comments for an article, select COUNT (*) ... where article_id =? Yes, don't select * ... where article_id =? Then Msql_num_rows. Transfer only the necessary SQL statements, such as when modifying the article, if the user only modified the title, then ... set title =? where article_id =? Do not set content =? (large text).

(6). When necessary, use a different storage engine, such as InnoDB, to reduce the deadlock, and the heap can increase the query speed by an order of magnitude.

March 2009 Sina php face question and answer (a)

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.