php pen questions Summary

Regular expression to validate mailbox

!preg_match(“/^[0-9a-zA-Z-]+@[0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+){1,3}$/”,$email)

By value and pass by reference difference

Passed by value: function within the scope of any change in value will be ignored outside the function
passed by reference: function within the scope of any change in the external value of the function can also be modified to reflect these
advantages and disadvantages: when passing by value, php must be copied value. Especially for large strings and objects, it will be a lot of operating costs. Passed by reference is no need to copy the value, it is good for improved performance.

SESSION difference with the COOKIE

1, http stateless protocol, can not distinguish whether the user is requesting up a different page from the same site, the same can not be seen as a user with a user
2, SESSION is stored on the server side, COOKIE stored in the client. Session safer, cookie can be modified by some means, unsafe. Session rely on cookie delivery.
After disabling cookie, session is not working. Shortcoming Session: Saves the server side, are read from the server each reading, the server resources are consumed. Session stored in a database or file server, the default stored in a file, the file path specified by the configuration file session.save_path php. Session files are public.

To achieve the interception of non-Chinese garbled string method.

mb_substr ( 'ab desired noon', 2)

PHP how to determine whether a string is a legitimate mode of date

date('Y-m-d H:i:s',strtotime($data)) == $data

Data filtering

So the general form submission when the strip_tags can remove html tags
htmlentities This function converts all special characters containing the corresponding "html entities", such as currency symbol euro British pound, the copyright symbol and other
htmlspecialchars just put some special characters escaped , & " '<>

Cache coherency problem

Cache update routines:
Failure: An application to start taking data cache, do not get, fetch data from the database, after the success, into the cache.
Hit: application access to data from the cache, taken after return.
Update: put data into the database, after the success, let cache invalidation.

Guess you like

Origin blog.51cto.com/13990437/2404084