php interview (1)

1. Use PHP to get the current time and print it, the print format: 2020-5-6 22:05:23

echo date('Y-n-d,H:i:s')

2. What are the functions of string to array, array to string, string interception, string replacement, and string search?

explode()
implode()
substr()
str_replace()、preg_replace()
preg_match()、preg_match_all()

3. Explain the meaning of the PHP class: protected, public, private, interface, abstract, final, static

       protected

       public

       private

       interface interface

       abstract abstract

       final final class and method

       static static methods and properties

4. Write the data result of the following code

$date = '08/26/2003'; changes to 2003/08/26

echo preg_replace('/(\d+)\/(\d+)\/(\d+)/','$3/$1/$2',$date);

5. From the login table, select the sql statement whose name field contains all the information of the first 10 results of admin

select * from login where name like '%admin%' limit 10 order by id

6. Explain left join, right join, inner join, index

   Left join: lift join

select user.name,post.info from user left join post on user.id = post.user_id limit 0,10 

   Right join: right join

select user.name,post.info from post right join user on user.id = post.user_id limit 0,10 

   Inner join: inner join

select user.name,post.info from user inner join post on user.id = post.user_id limit 0,10 

   Index: index

alert table user add index in_name(name)
alert table user drop index in_name

7. Briefly describe the realization principle of unlimited classification in the forum

https://blog.csdn.net/qq_43737121/article/details/108668282

8. Write a function that is as efficient as possible to extract the file extension from a standard URL

For example: http://www.test.cccom.cn/abc/de/fg.php needs to take out php or .php

9. Explanation: MVC

    Application completed by model, view, controller

    The model sends out the function to be realized to the controller, and the controller accepts the organization function and passes it to the view;

10. Describe the solution for a large-traffic and high-concurrency website

       (1) dns load balancing

       (2) Load balancer

       (3) Cluster server

       (4) Web server selection (nginx instead of apache)

       (5) Static cache (tp, smarty)

       (6) File data cache (tp)

       (7) Memory data cache (memcache, redis)

       (8) Index the database

       (9) Disk array technology

11. How to prevent sql injection

       (1) The form is submitted with post as much as possible, and the form judges to control the get, because get is faster than post

       (2)$_SERVER[HTTP_REFERER] Determine the source of the submitter

       (3) Open addslasges, add \ at the head of',",\

       (4) The password must be set to md5 encryption

       (5) The security of the server itself (web+mysql)

12. Prevent hotlinking

       (1) Prevention on the server: Apache and nginx do rewrite based on the source to make judgments to prevent hotlinking

       (2) Code prevention: $_SERVER[HTTP_REFERER]

13. The security of landing design

       (1) Verification code

       (2) U shield   

       (3) Dynamic password card

       (4) Limit the number of logins

       (5) Use the numeric keyboard

       (6) Password cannot be pasted

14. Which php frameworks have been used and describe their advantages and disadvantages

       https://blog.csdn.net/qq_41718455/article/details/81511678

15. Have used those version control tools

      git

Guess you like

Origin blog.csdn.net/qq_43737121/article/details/113922034