I recommend a PHP programmer pen question (with answers)

Source: Internet
Author: User
Summary (50 points) 1. print the time format of the previous day in php in the format of 2006-5-(2 points) echodate (& quot; Y-m-dG: I: s & quot ;, strtotime (& quot;-1day & quot;); 2. differences between echo (), print (), and print_r () (3 points) ech (50 points)

1. use php to print the time format of the previous day in the format of 22:21:21 (2 points)

echo date("Y-m-d G:i:s",strtotime("-1 day"));

2. differences between echo (), print (), and print_r () (3 points)

  • Echo () is a php statement, so it can print simple data without returning values.
  • Print () is a function that has returned values and can print simple data.
  • Print_r () is a function that can print complex (mix) data.

For example:

 ';    echo "the value is $value
"; $arr = array('name'=>'nowamagic','qq'=>'123456'); print_r($arr);?>

Program running result:

hello wordthe value is 1Array ( [name] => nowamagic [qq] => 123456 ) ......

3. templates that can separate html and php (1 point)

Smarty Template

4. what tools are used for version control? (1 point)

TortoiseSVN

5. how to implement string flip? (3 points)

strrev("Hello world!");

6. optimize the mysql database. (4 points, more writes)

  • In terms of database design, this is the responsibility of DBA and impact ect. a database with a good design structure should be de-normalized when necessary (I don't know what the Chinese translation is ), some data redundancy is allowed to avoid JOIN operations to improve query efficiency.
  • In terms of system architecture design, the table is hashed, and massive data is hashed into several different tables. fast and Slow tables: only the latest data is retained. slow tables are archived in history. cluster, Master server Read & write, slave server read only, or N servers, each machine is a Master
  • (1) and (2) better than PHP Programmer's requirements. it doesn't matter. check whether there are any missing indexes.
  • Write efficient SQL statements to see if there are any inefficient SQL statements, such as generating full connections to Cartesian products, a large number of Group By and order by statements, and no limit. when necessary, encapsulate the database logic in the stored procedure of the DBMS. cache query results and explain each SQL statement
  • All the results are required. only necessary data is obtained from the database. for example, to query the number of comments of an article, select count (*)... where article_id =? You can. do not select *... where article_id =? Then, msql_num_rows only transmits the required SQL statements. for example, if you modify only the title when modifying an article, update... set title =? Where article_id =? Do not set content =? (Large text)
  • Use different storage engines when necessary. for example, InnoDB can reduce deadlocks. HEAP can increase the query speed by an order of magnitude.

7. php meaning (1 minute)

Hypertext Preprocessor

8. mysql gets the current time function and format the date function (2 points)

now()         DATE_FORMAT(date, format) .

9. implement the method of intercepting Chinese strings without garbled characters. (3 points)

No garbled characters will appear when mb_substr () is intercepted using the mbstring Extension Library.

10. Briefly describe your most proud development work (4 points)

11. What methods do you use to solve the traffic issue for high-traffic websites? (4 points)

12. use php to write the code for displaying the client ip address and server ip address (1 point)

Print the client IP address: echo $ _ SERVER ['remote _ ADDR ']; or: getenv ('remote _ ADDR ');

Print Server IP: echo gethostbyname ("http://www.nowamagic.net /")

13. what is the difference between include and require statements? To avoid multiple accesses to the same file (?) Statement instead of them? (2 points)

The use of require is as follows: require ("MyRequireFile. php ");. This function is usually placed at the beginning of the PHP program. before the PHP program is executed, it will first read the file specified by require to make it a part of the PHP program webpage. This method can also be used to introduce common functions into webpages.

Include usage methods such as include ("mydomaindefile. php ");. This function is generally placed in the process of process control. The PHP program webpage reads the include file. In this way, you can simplify the process during program execution.

To avoid multiple inclusion of the same file, use the require_once ()/include_once () statement instead.

14. how to modify the session survival time (1 point ).

 

15. there is a webpage address http://www.phpres.com/index.html. how can this problem be solved? ($1)

$contents = file_get_contents("http://www.phpres.com/index.html");

16. in http 1.0, status code 401 indicates (?); If the message "File Not Found" is returned, the header function is available. The statement is (?); (2 points)

401 indicates not authorized;

Header ("HTTP/1.0 404 Not Found ");

17. in php, heredoc is a special string and its end mark must be? (1 point)

18. Advantages and disadvantages of asp, php, and jsp (1 point)

Asp: simple and easy to maintain. it is suitable for small-sized website applications. through DCOM and MTS technology, ASP can even complete small-scale enterprise applications, however, ASP does not support cross-platform systems, which is very difficult for large-scale project development and maintenance.

PHP: The syntax is simple, easy to learn, and easy to use. it is conducive to the rapid development of custom websites with different functions. due to the structural defects of PHP, it is difficult to develop and maintain PHP on complex large projects.

JSP: for website development, it is not as easy to learn and use as PHP and ASP, and the number of hosts supporting JAVA is smaller than that supporting PHP. This restricts the development of Java technology on the website to a certain extent, however, in terms of enterprise software applications, MVC still has considerable advantages. although its configuration and deployment are more complex than other scripting languages, however, for cross-platform medium and large enterprise application systems, the MVC architecture based on JAVA technology has almost become the only choice.

19. about mvc (1 point)

The Model-View-Controller (MVC) mode refers to the Model-attempt-Controller mode. its core idea is to divide the entire program code into three components that are relatively independent and can work collaboratively, the specific functions are as follows: Model: business logic layer. Implements specific business logic and status management functions. View: presentation layer. It is a page for interaction with users. Generally, the data input and output functions are implemented. Controller: control layer. To control the entire business process, and realize the collaboration between the View layer and the Model layer.

20. write the SQL statement for the top 10 people with the most posts. use the following table: members (id, username, posts, pass, email) (2 points)

SELECT username FROM membersGROUP BY id ORDER BY count(posts) DESC LIMIT 0 , 10

21. The difference between passing a value in php and transferring a reference. When will the value be passed for reference? (2 points)

Pass by value: any changes to the value within the function range will be ignored outside the function. Pass by reference: any changes to values within the function range can also reflect these changes outside the function.

Advantages and disadvantages: when passing by value, php must copy the value. This is especially costly for large strings and objects. Transferring by reference does not require copying values, which is good for performance improvement.

22. what is the role of error_reporting in php? (1 point)

Error_reporting () sets the PHP error level and returns the current level.

23. please write a function to verify that the email format is correct (2 points)

Function checkEmail (sText) {var reg =/^ (? : W + .?) * W + @(? : W + .?) * W + $/; var email = document. getElementById (sText). value; if (! Reg. test (email) {alert ("email detection failed") ;}else {alert ("the email format is correct ");}}

24. briefly describe how to obtain the path of the script to be executed, including the obtained parameters. (2 points)

echo $_SERVER['SCRIPT_FILENAME']."?".$_SERVER['QUERY_STRING'];

25. what is the function in the js form pop-up dialog box? What is the input focus function? (2 points)

1) alert (), prompt (), confirm ()

2) focus ()

26. what is the conversion function of js? How to introduce an external js file? (2 points)

Window. location. href

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.