PHP interview 01

Source: Internet
Author: User
Tags echo date http post php print



1. The difference between get and post in a form



(1) Get is from the server to get data, post is to send data to the server;



(2) Get is the transfer of data through the URL, post is through the HTTP post mechanism;



(3) The amount of data sent by get is small, the amount of data that post can transmit is large;



(4) Get security is low, post security is high, efficiency get better than post;



(5) For Get mode, the server side uses Request.QueryString to get the value of the variable, for the Post method, the server side uses Request.Form to obtain the submitted data.



2. The similarities and differences between session and Cookie



Session is a temporary user data saved on a server side of a Web service stateless session, which allows the server to reconstruct user session information.
Cookies are data retention functions that adapt to local script temporary data storage and session authentication with server-side interaction

Simply put, thesession requires a cookie to be enabled for normal use .

If the server side only consider the initial html+ script to consider the way, there is no session of the file, because it is a static page, does not have a follow-up relationship with the server (put aside the AJAX request). So the cookie becomes the local storage file for the script to run . The cookie exists in the form of "Key name = key value", with ";" Separated.

The difference between the duration length:
A cookie has a defined duration that is longer than the length of time that the browser will consider outdated and will discard and delete this cookie file. Therefore, even if the server side of the session still exists, because the cookie information has been lost, unable to retrieve the corresponding PHPSESSID value to achieve the reconstruction of the session. If the timeout length is not defined, it is automatically invalidated when the browser is closed.
Session can specify the period of existence, if the time limit is exceeded, the PHPSESSID value of this cookie in the corresponding session has a request will automatically lengthen the length of time, until more than the length of the request will be cleared through the recovery mechanism, but not fully guaranteed to be properly recycled. If the cookie file is still stored locally, it cannot be rebuilt because the session file for the corresponding PHPSESSID is no longer present.



3, PHP print time format for 2014-2-1 13:22:22 the day before



echo Date ("Y-m-d h:i:s", " -1day");



4. The difference between echo (), print (), Print_r (), printf ()



echo can output multiple values at once, which is a PHP statement with no return value



Print is a function that has a return value to print a value of a simple type



Print_r is a function that can print the values of variables of complex types, such as arrays, objects, etc.



printf originates from the C language and can output formatted strings



5. Separating HTML and PHP templates



Smarty,Dwoo, Savant, Tinybutstrong



6. Version Control tool



SVN, Git,CVS, VSS



7, how to implement the flip string



echo strrev($a);



8. How to optimize MySQL database

























































PHP interview 01


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.