Some PHP interview titles

Source: Internet
Author: User
Some PHP interview questions preface life always has to go forward, wait for a day without Alibaba's interview notice, the mood is quite gloomy, but life always has to continue, still have to look forward, I have made several PHP interview questions. after all, my main development language is still PHP question 1. how to obtain the natural length of a string containing Chinese and English characters must consider the character encoding of Chinese characters, note that one Chinese character occupies 3 bytes in the UTF-8 & lt some PHP interview questions
Preface life always needs to go forward, wait for a day without Alibaba's interview notice, and the mood is quite gloomy, but life is always going on, still need to look forward, do several PHP interview questions, after all, my main development language is PHP.
Question 1: how to obtain the natural length of a string containing Chinese and English characters
Consider the character encoding of Chinese characters, note that a Chinese character occupies 3 bytes in the UTF-8
 "; $ Len = strlen ($ str); echo $ len ."
";


2. ask what an ORM is, sometimes ask what the full name of this word is, and ask him what his/her opinion on ORM
Object Relationl Mapping (ORM) is a technology designed to solve the mismatch between objects and relational databases. To put it simply, ORM automatically persists the objects in the program to a relational database by using metadata that describes the ing between objects and databases. Essentially, data is converted from one form to another.

3. Ask How ta designs a framework if he wants to implement it on his own.
Here I will talk about my understanding of MVC. I have used native php for development and have never used a framework.


So even if you don't need a framework, you can implement mvc layering in your own code.

4. ask how to consider the url dispatcher in the framework design.
Or MVC problem, can be designed through url: http://example.com/ // /, You can also jump through nginx rewrite

5. how to access session variables )?
A. Use $ _ GET
B. use $ _ POST
C. use $ _ REQUEST
D. use global variables
E. None of the above
E. Explanation: session variables can only be obtained through the $ _ SESSION array.

6. which function can let the server output the following header?
set-Cookie: foo=bar;

Answer: setcookie ('foo', 'bar', time () + 3600 );

7. how to use a new domain name different from the previously configured domain name to access a cookie while ignoring the browser bug?
A. access through HTTP_REMOTE_COOKIE
B. Impossible
C. set a different domain name when setcookie () is called.
D. send additional requests to the browser
E. use Javascript to include cookies in URLs and send them
B. Explanation: cookie cannot be accessed across domains

8. under HTTPS, how does the URL and query string pass from the browser to the Web server?
A. The two are transmitted in plaintext, and the information is encrypted after transmission.
B. encrypted transmission
C. URL plaintext transmission, query string encrypted transmission
D. encrypted URL transmission: query the plaintext transmission of strings
E. to ensure encryption, the query string is converted to the header and transmitted in the POST information.
B. Explanation: ssl encryption

9. what happens when I submit a form with two identical elements to a PHP script?
A. They form an array and are stored in the Super global variable array.
B. add the value of the first element to the value of the second element and store it in the Super global variable array.
C. The second element will overwrite the first element.
D. The second element will be automatically renamed.
E. PHP outputs a warning
C
10. how to store arrays in cookies?
A. add A pair of square brackets to the cookie name []
B. use the implode function
C. impossible, because there is a capacity limit
D. use the serialize function
E. add the ARRAY keyword to the cookie name
D. Explanation: serialization and serialize can serialize the array. using implode will lose the key value of the associated array.

11. what is the output of the following script? (E)
Ob_start ();
For ($ I = 0; $ I <10; $ I ++ ){
Echo $ I;
}
$ Output = ob_get_contents ();
Ob_end_clean ();
Echo $ output;
?>
A.12345678910
B .1234567890
C.0123456789
D. nothing
E. a prompt
C. Explanation: ob_start opens the output cache and stores the output characters in the buffer zone. Get the output string through ob_get_contents ()

12. by default, PHP stores session data in.
A. File system
B. Database
C. virtual content
D. shared memory
E. None of the above
A. Explanation: by default, files are stored in the file system. for distributed purposes, they are generally stored in Nosql databases, such as nginx + fastcgi + php5_fpm, and the fpm php is modified. ini session. save_path = tcp: // redisip: redisport? Auth = redispasswd

14. if the browser is not restarted, how long will the session expire and be recycled after the last visit?
A.1440 seconds later
B. After the time set in session. gc_maxlifetime has passed
C. It will never expire unless it is manually deleted
D. The browser will never expire unless it is restarted.
E. None of the above
B or E. Explanation: Although the session has an expiration mechanism, the default session is used. gc_maxlifetime is 1440 seconds, but the gc mechanism must be enabled. the startup of the gc mechanism is probability. sessions use sessions respectively. gc_probability and session. gc_divisor to determine the gc probability of the session

15. which function can convert line breaks into HTML tags?
?
Nl2br

16. how does the index. php script access the email value of the form element? (Double choice)

A. $ _ GET ['email ']
B. $ _ POST ['email ']
C. $ _ SESSION ['text']
D. $ _ REQUEST ['email ']
E. $ _ POST ['text']
BD, explanation: the submission method is POST. Therefore, values can only be obtained from arrays of Super global variables $ _ POST and $ _ REQUEST.

17. what if I don't set the expiration time for the cookie?
A. expire immediately
B. never expire
C. The cookie cannot be set.
D. expired when the browser session ends
E. it only expires when the script does not generate a server session
D. explanation: the cookie has no half-money relationship with the session. the unique function can be used to save the session id of the session.
18. How will the following script affect the $ s string? (Double choice)
$ S ='

Hello

';
$ Ss = htmlentities ($ s );
Echo $ s;
?>
A. angle brackets <> are converted into HTML tags, so the string will become longer
B. no changes
C. The angle brackets are visible when the string is printed in the browser.
D. when the string is printed in the browser, the angle brackets and their content are recognized as HTML tags, so they are invisible.
E. the string will be destroyed because htmlentities () is called.
BD, explanation: htmlspecialchars is assigned to $ ss after escaping $ s, and $ ss is output.








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.