Home  >  Article  >  Backend Development  >  PHP interview summary sharing

PHP interview summary sharing

小云云
小云云Original
2018-05-15 14:08:082610browse

This article mainly shares the PHP interview summary with you, hoping to help everyone.

Related recommendations: "2019 PHP Interview Questions Summary (Collection)"

1:变量的传值与引用。
2:变量的类型转换和判断类型方法。
3:php运算符优先级,一般是写出运算符的运算结果。
4:PHP中函数传参,闭包,判断输出的echo,print是不是函数等。
5:PHP数组,数组函数,数组遍历,预定义数组(面试必出)。
6:PHP面向对象,魔术方法,封装、继承、多态。设计模式,包括(单利、工厂、迭代器、装饰、命令、策略)。
7:正则表达式,每个标号含义,邮箱、网址、标签匹配,正则函数(面试必出)。
8:PHP异常处理(级别,错误日志,控制错误输出)(面试必出)。
9:PHP时间函数,日期计算函数。
10:文件系统,记录日志、目录、文件的遍历、上传、多方法得到文件扩展名、文件引用方式、引用函数区别。(面试必出)。
11:会话控制,主要说原理。session与cookie在分布式应用中出现问题的解决方案。
12:PHP模板引擎,常用模板引擎特点,MVC好与不好的地方。
13:PHP安全处理,过滤函数。
14:XML的使用。
15:PHP字符串的处理,包括转义(安全)、编码、截取、定位、与数组间的转换、处理函数等。(面试必出)。
16:Socket编程,各种协议,head头,curl参数含义。
17:网络状态码含义,常用(204,304, 404, 504,502)。
18:Apache配置文件,PHP配置文件,各个含义字段的含义。
19:网络各种攻击的名词含义(SQL攻击、XSS、CSRF、DDos),防止措施。
20:url的处理函数,得到url指定的部分。

Mysql Basics

1:基础sql语句书写(一般让写关联和子查询语句)
2:索引的创建,优缺点,最左原则
3:存储引擎,常用的几个,优缺点,差别,原理(面试必出)4:sql注入的处理方法
5:mysql处理函数(PHP中封装的)
6:PDO的使用方法,为什么使用
7:mysql的优化,表拆分等
8:事务处理,sql语句的处理效率等
9:数据表字段的类型,同类型间的区别,改如何选取,int(10)与int(11)的区别等。
10:数据库索引使用的那种数据结构,画出数据结构

Linux

1:常用命令的使用,vim编辑器的使用。
2:进程,cpu等信息的查看命令。
3:文件内查看命令(主要涉及统计信息)。
4:Shell的使用,命令操作。
5:awk的用法
6:shell杀掉所有的php-fpm进程

NoSql

1:Redis的应用场景,结合微博业务说出他的具体应用。
2:Redis与MC支持数据的不同点,两者都支持哪些数据结构的存储,写越多越好。
3:Redis持久化存储的原理,与Mysql的应用区别。怎样保持持久化数据与内存数据同步的关系(Redis同步机制)
4:Redis与MC在并发状态下的性能比较。
5:MC的内存管理机制,当一个数据需要存储的时候怎样分配内存空间
6:Redis的内存管理机制,与MC有哪些不同点。

Development Environment

1:PHP7中的新特性与废弃的特性
2:为什么要使用PHP7,PHP7快在哪里
3:PHP7中对异常和错误的理解

Version Control

1:git的使用命令,例如:写出版本回退命令。
2:git与svn的区别。
3:如何进行多分支开发,包括多人开发协同,分段测试,上线。

Here is a map of knowledge points to help you remember:

PHP interview summary sharing

PHP part

1. The role of HTTP Keep-Alive

2. What are the common PHP array functions? (The role of array_merge, in_array)

3. The difference between several output functions echo, print(), print_r(), sprintf(), and var_dump() in PHP

4. Directly exchange the values ​​of two existing variables without using new variables

5. heredoc

6. Write a function to solve the problem of multiple threads reading and writing a file at the same time.

7. Disable cookie session usage plan, set session expiration method, corresponding function

8. What are the characteristics of json format data

9. PHP obtains file content method, corresponding function

10. PHP magic methods and magic constants

11. How to obtain the client’s IP address in PHP

12. Write a function that can traverse files All files and folders under the folder.

13. There is a document called mail.log. The content is a number of email addresses, separated by newlines with ‘\n’. Select the address of sina.com.

14. What are the PHP caching technologies? Is tp a partial or complete cache?

15. The functions and differences between strlen() and mb_strlen

16. Write a function, Remove the extension from a standard URL as efficiently as possible

17. Which functions and parameters are affected by turning off safe mod in php.ini? Write at least 6?

18. Joseph Ring Problem

19. The difference between Isset(), empty() and is_null

20. Find the relative paths of two files

21. Advantages and disadvantages of MVC

22. The connection and difference between Session and cookie (operation mechanism), solution to session sharing problem

23. Regular expression

24 , Write a function to get the header information

MySQL part

1. Select * from table where (ID = 10) or (ID = 32) or (ID = 22) Let the result be 10 , 32, 22 are retrieved in the order?

Linux part

1. What is the Core file and what is it used for?

2. In addition to file mapping, is there any other way to share memory?

3. Please explain the purpose of the following 10 shell commands

4. What are the attributes of Linux files? (Ten in total)

5. Linux query command

Server part

1. Comparison of the advantages and disadvantages of Apache and Nginx

2. Cgi and fastcgi The difference

3. The difference between Select, poll and epoll

4. The difference between Memcache and Redis

--------------- --------------------------PHP part-------------------------- ----------

#php I summarized the part based on frequently asked questions in interviews. The following questions have a high rate of appearance in interviews. The problem is relatively basic

1. The role of HTTP Keep-Alive

Function: Keep-Alive: Make the connection from the client to the server continue to be valid when a subsequent request to the server occurs. , the Keep-Alive function avoids establishing or re-establishing connections. Web servers basically support HTTP Keep-Alive.

Disadvantages: This feature is often useful for websites that serve static content. However, for heavily loaded sites, while there are certain benefits to keeping open connections for clients, it also affects performance because resources that could have been freed are still occupied during processing pauses. When the web server and application server are running on the same machine, the Keep-Alive function has a particularly prominent impact on resource utilization.

Solution: Keep-Alive: timeout=5, max=100
timeout: expiration time 5 seconds (corresponding to the parameters in httpd.conf: KeepAliveTimeout), max is a maximum of one hundred requests, mandatory Disconnect. That is, if there is a new connection within the timeout period, max will automatically decrease by 1 until it reaches 0, and it will be forcibly disconnected.

2. What are the common array functions in PHP? (The role of array_merge, in_array)

What are the array functions starting with array_ in PHP and how to use them (at least 6)

1. Array traversal function

1 list();  //不是真正的函数,而是PHP的语言结构,用于给一组变量赋值,仅能用于索引数组2 each();  //返回数组当前元素的键值对,并将指针移动到下一个元素位置3 while(); //可配合list或each使用:while(list($key, $value) = each($arr)){each $key, $value; }

2. Array internal pointer control

1 current();  //读取指针位置的内容2 key();      //读取当前指针指向内容的索引值3 next();     //将数组中的内部指针指向下一单元4 prev();     //将数组内部指针倒回一位5 end();      //将数组内部指针指向最后一个元素6 reset();    //将目前指针指向第一个索引位置

3. Array key value operation function

PHP interview summary sharing

1 array_values($arr);       //获得数组的值2 array_keys($arr);         //获得数组的键名3 array_flip($arr);         //数组中的值与键名互换(如果有重复前面的会被后面的覆盖)4 array_search('PHP',$arr); //检索给定的值,加true则是严格类型检查5 array_reverse($arr);      //将数组中的元素翻转(前后顺序)6 in_array("apple", $arr);  //在数组中检索apple7 array_key_exists("apple", $arr); // 检索给定的键名是否存在数组中8 array_count_values($arr);        // 统计数组中所有值出现的次数
9 array_unique($arr);              // 删除数组中重复的值

PHP interview summary sharing

4. Array callback function

1 array_filter(); //使用回调函数过滤数组中的元素,如果回调返回true则当前的元素被包含到返回数组中2 array_walk();   //回调函数处理数组,自定义函数要有两个参数,本函数第三个参数可以作为回调第三个参数返回3 array_map();    //可以处理多个数组,每个数组的长度应该相同,传入数组的个数和回调函数参数个数应该一致

2. Array segmentation and filling

1 array_slice($arr, 0, 3);    //将数组中的一段取出,此函数忽略键名(数组的分段)2 array_splice($arr, 0, 3,array("black","maroon"));    //将数组中的一段取出,返回的序列从原数组中删除3 array_chunk($arr, 3, TRUE);   //将一个数组分割成多个,TRUE为保留原数组的键名(分割多个数组)

4 , arrays and stacks, queues

1 array_push($arr, "apple", "pear");    //将一个或多个元素压入数组栈的末尾(入栈),返回入栈元素的个数2 array_pop($arr);    // 将数组栈的最后一个元素弹出(出栈)3 array_shift($arr);   //数组中第一个元素移出并返回(长度减1,其他元素向前移动一位,数字键名改为从零计数,文字键名不变)4 array_unshift($arr,"a",array(1,2));  //在数组的开头插入一个或多个元素

6. Sorting of arrays

PHP interview summary sharing

1 sort($arr);      //由小到大,忽略键名2 rsort($arr);     //由大到小,忽略键名
3 asort($arr);     //由小到大,保留键名4 arsort($arr);    //由大到小,保留键名
5 ksort($arr);     //按照键名正序排序6 krsort($arr);    //按照键名逆序排序

PHP interview summary sharing

7. Calculation of arrays

PHP interview summary sharing

1 array_sum($arr);   //对数组内部的所有元素做求和运算(数组元素的求和)2 array_merge($arr1, $arr2); //合并两个或多个(相同字符串键名,后面覆盖前面,相同的数字键名,后面的附加到后面)3  4 array_diff($arr1, $arr2);       //返回差集结果数组   array_diff_assoc($arr1, $arr2, $arr3);  //返回差集结果数组,键名也做比较5 array_intersect($arr1, $arr2);  //返回交集结果数组    array_intersect_assoc($arr1, $arr2);   //返回交集结果数组,键名也做比较

PHP interview summary sharing

八、其他的数组函数

1 array_unique($arr);   //移除数组中重复的值,新的数组中会保留原始的键名2 shuffle($arr);        // 将数组的顺序打乱

 3、PHP中几个输出函数echo,print(),print_r(),sprintf(),var_dump()的区别

1:echo:是语句不是函数,没有返回值,可输出多个变量值,不需要圆括号。不能输出数组和对象,只能打印简单类型(如int,string)。

2:print:是语句不是函数,有返回值 1 ,只能输出一个变量,不需要圆括号。不能输出数组和对象,只能打印简单类型(如int,string)。

3:print_r:是函数,可以打印复合类型,例如:stirng、int、float、array、object等,输出array时会用结构表示,而且可以通过print_r($str,true)来使print_r不输出而返回print_r处理后的值

4:printf:是函数,把文字格式化以后输出(参看C语言)

5:sprintf:是函数,跟printf相似,但不打印,而是返回格式化后的文字(该函数把格式化的字符串写写入一个变量中,而不是输出来),其    他的与printf一样。 

例如:  

1 $str = "Hello";    
2 $number = 123; 
3 $txt = sprintf("%s world. Day number %u",$str,$number);4 //输出: Hello world. Day number 123

6:var_dump():函数,输出变量的内容、类型或字符串的内容、类型、长度。常用来调试。

可以通过function_exists('函数名称')进行测试

1 var_dump(function_exists('print'));  //bool(false)2 3 var_dump(function_exists('echo'));  //bool(false)4 5 var_dump(function_exists('print_r')); //bool(true)

4、不用新变量直接交换现有两个变量的值

PHP interview summary sharing

 1 1:  3     list($a, $b) = array($b, $a); 4 2: 
 5     $a = $a . $b; 5     $b = strlen( $b ); 6     $b = substr( $a, 0, (strlen($a) – $b ) ); 7     $a = substr( $a, strlen($b) ); 8  9 3:(必须用一个两个字符串都都不能出现的字符做为分隔符)10     $a = $b.','.$a ;11     $a = explode(',', $a);12     $b = $a[1];13     $a = $a[0];14 15 4:这个是当两个数都是数字的时候:16     $a = $a + $b;17     $b = $a – $b;18     $a = $a – $b;19 20 5:借助数组21     $a = array($a,$b);22     $b = $a[0];23     $a = $a[1];

PHP interview summary sharing

5、heredoc

Heredoc在正规的PHP文档中和技术书籍中一般没有详细讲述。他是一种Perl风格的字符串输出技术。使用heredoc技术可以实现界面与代码的准分离,比如phpwind模板。

heredoc的语法是用”

规则如下:

1、以

2、位于开始标记和结束标记之间的变量可以被正常解析,但是函数则不可以。在heredoc中,变量不需要用连接符 . 或 , 来拼接,比如:

1 $a=2;2 $b= <p>3、heredoc常用在输出包含大量HTML语法文档的时候。他要比传统的echo输出精炼很多,如下所示:</p><p><img src="https://img.php.cn/upload/article/000/054/025/277f1538a44b804d1a78c0539aac6687-0.gif" alt="PHP interview summary sharing"></p><pre class="brush:php;toolbar:false"> 1 function getHtml() 2 { 3     echo ""; 4     echo "<title>Title</title>"; 5     echo "Content"; 6     echo "; 7 } 8  9 function getHtml()10 {11 echo 13       <title>Title</title>14       Content15       

The above is the detailed content of PHP interview summary sharing. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn