├── README.md └── love_china.py /README.md: -------------------------------------------------------------------------------- 1 | 最近面试了不少公司,正好把记得的问题做个总结。 2 | 3 | 本文 [github](https://github.com/sushengbuhuo/php-interview-2018) 会持续更新 4 | 5 | 本文[sf](https://segmentfault.com/a/1190000015651120) 6 | 7 | 欢迎关注公众号:苏生不惑 每周更新文章,一个有趣又有用的公众号 8 | 9 | ![关注](https://mmbiz.qpic.cn/mmbiz_jpg/sZeVtjGD4lFg1Ijxp4V5UfVuOkP90u1H3Ifm02J5ibEdoTsvpavaSGO2tGBrH2fxUibI8uiclUo0QrFguhfjnialbw/640?wx_fmt=jpeg&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1) 10 | 11 | # 简历 12 | 13 | 关于简历怎么写,知乎上有很多对应问题,可以自行搜索,这里推荐几个简历相关的 repo 14 | 15 | [程序员写简历时,常用的例句范式]( https://github.com/resumejob/awesome-resume) 16 | 17 | [简历常用例句 ](https://github.com/resumejob/awesome-resume) 18 | 19 | [程序员简历模板](https://github.com/geekcompany/ResumeSample ) 20 | 21 | [在线简历]( http://cv.ftqq.com/#) 22 | 23 | [md简历](https://resume.mdnice.com/) 24 | 25 | # 笔试题 26 | 27 | ### 写一个email的正则 28 | ```js 29 | $mail = 'test@sina.com'; //邮箱地址 30 | $pattern = "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,})$/"; 31 | preg_match($pattern, $mail, $matches); 32 | //验证可以使用 filter_var($email, FILTER_VALIDATE_EMAIL) 33 | ``` 34 | ### 关系比较 35 | [参考官网](http://php.net/manual/zh/types.comparisons.php) 36 | 37 | ![clipboard.png](https://segmentfault.com/img/bVbdOqw?w=835&h=497) 38 | 39 | ### echo (int)((0.1+0.7)*10);//7 40 | 看似有穷的小数, 在计算机的二进制表示里却是无穷的 http://www.cnblogs.com/datang6777/p/7049159.html 41 | echo serialize(0.1+0.7); //d:0.79999999999999993; 42 | 43 | ### 熟悉的linux命令 44 | ps cat tail top awk 45 | 46 | ### javascript跨域如何实现 47 | jsonp 和 cors 48 | 49 | ### 熟悉的5种设计模式及用单例模式建立一个数据库连接 50 | 单例 工厂 策略 适配器 观察者 51 | ```js 52 | link = mysql_connect($host, $username, $password); 63 | $this->query("SET NAMES 'utf8'", $this->link); 64 | //echo mysql_errno($this->link) . ": " . mysql_error($link). "n"; 65 | //var_dump($this->link); 66 | return $this->link; 67 | } 68 | private function __clone() 69 | { 70 | } 71 | public static function get_class_nmdb($host, $username, $password) 72 | { 73 | //$connector = new nmdb($host, $username, $password); 74 | //return $connector; 75 | 76 | if (FALSE == (self::$_instance instanceof self)) { 77 | self::$_instance = new self($host, $username, $password); 78 | } 79 | return self::$_instance; 80 | } 81 | // 连接数据表 82 | public function select_db($database) 83 | { 84 | $this->result = mysql_select_db($database); 85 | return $this->result; 86 | } 87 | // 执行SQL语句 88 | public function query($query) 89 | { 90 | return $this->result = mysql_query($query, $this->link); 91 | } 92 | // 将结果集保存为数组 93 | public function fetch_array($fetch_array) 94 | { 95 | return $this->result = mysql_fetch_array($fetch_array, MYSQL_ASSOC); 96 | } 97 | // 获得记录数目 98 | public function num_rows($query) 99 | { 100 | return $this->result = mysql_num_rows($query); 101 | } 102 | // 关闭数据库连接 103 | public function close() 104 | { 105 | return $this->result = mysql_close($this->link); 106 | } 107 | } 108 | $connector = DBHelper::get_class_nmdb($host, $username, $password); 109 | $connector -> select_db($database); 110 | ?> 111 | ``` 112 | ### 冒泡排序 大数在前 小数在后 113 | ```js 114 | $arr=[5,2,8,1,9]; 115 | $len=count($arr); 116 | for($k=1;$k<$len;$k++) 117 | { 118 | for($j=0;$j<$len-$k;$j++){ 119 | if($arr[$j]<$arr[$j+1]){ 120 | list($arr[$j+1],$arr[$j])=[$arr[$j],$arr[$j+1]]; 121 | 122 | } 123 | } 124 | } 125 | print_r($arr); 126 | ``` 127 | ### 如何实现单点登录 128 | 利用 jwt 实现 session 共享,具体使用 jwt 参考 http://blog.leapoahead.com/2015/09/07/user-authentication-with-jwt/ 129 | ### 出现性能瓶颈如何快速定位解决 130 | 服务器负载 慢日志 xhprof 慢sql 131 | ### 熟悉的 nosql 和 sql 有什么区别(优势,劣势) 132 | Memcache,Redis 都是内存数据库 133 | redis是一个开源的支持多种数据类型的key=>value的存储数据库。支持字符串、列表、集合、有序集合、哈希五种类型 134 | memcache 只支持简单的key/value数据结构,不像Redis可以支持丰富的数据类型。 135 | 无法进行持久化,数据不能备份,只能用于缓存使用,且重启后数据全部丢失 136 | 137 | ### 如何保证代码质量 138 | 高质量代码三要素:可读性,可维护性,可变更性 代码质量评价:低耦合,高内聚 https://segmentfault.com/a/1190000004355331 139 | 140 | ### 学习PHP的渠道 看过的PHP书,了解的PHP开源项目 141 | php.net sf google 142 | 《Modern PHP》《PHP核心技术和最佳实践》《PHP the right way》 143 | laravel carbon querylist等 144 | 145 | ### mysql innodb 有哪些索引类型 分别在什么场景下使用 146 | 索引的本质还是提升查询数据库的速度,减少服务器I/O开销 147 | 主键 唯一 普通 联合 148 | 149 | ### 对一个链表顺序反转 150 | 151 | ### 实现PHP5中的 var_dump 函数 152 | ```js 153 | function mydump() { 154 | $args = func_num_args(); 155 | for($i = 0;$i < $args; $i ++) { 156 | $param = func_get_arg($i); 157 | switch(gettype($param)) { 158 | case 'NULL' : 159 | echo 'NULL'; 160 | break; 161 | case 'boolean' : 162 | echo ($param ? 'bool(true)' : 'bool(false)'); 163 | break; 164 | case 'integer' : 165 | echo "int($param)"; 166 | break; 167 | case 'double' : 168 | echo "float($param)"; 169 | break; 170 | case 'string' : 171 | dumpString($param); 172 | break; 173 | case 'array' : 174 | dumpArr($param); 175 | break; 176 | case 'object' : 177 | dumpObj($param); 178 | break; 179 | case 'resource' : 180 | echo 'resource'; 181 | break; 182 | default : 183 | echo 'UNKNOWN TYPE'; 184 | break; 185 | } 186 | } 187 | } 188 | 189 | 190 | function dumpString($param) { 191 | $str = sprintf("string(%d) %s",strlen($param),$param); 192 | echo $str; 193 | } 194 | 195 | function dumpArr($param) { 196 | $len = count($param); 197 | echo "array($len) {\r\n"; 198 | foreach($param as $key=>$val) { 199 | if(is_array($val)) { 200 | dumpArr($val); 201 | } else { 202 | echo sprintf('["%s"] => %s(%s)',$key,gettype($val),$val); 203 | } 204 | } 205 | echo "}\r\n"; 206 | } 207 | 208 | function dumpObj($param) { 209 | $className = get_class($param); 210 | $reflect = new ReflectionClass($param); 211 | $prop = $reflect->getDefaultProperties(); 212 | echo sprintf("Object %s #1(%d) {\r\n",$className,count($prop)); 213 | foreach($prop as $key=>$val) { 214 | echo "[\"$key\"] => "; 215 | mydump($val); 216 | } 217 | echo "}"; 218 | } 219 | 220 | class MyClass 221 | { 222 | protected $_name; 223 | function test() 224 | { 225 | echo "hello"; 226 | } 227 | } 228 | 229 | $str = "test"; 230 | mydump(new MyClass(),$str); 231 | echo "\r\n"; 232 | $arr2 = array( 233 | "1" => "Ddaddad", 234 | "one" => array("two" => "Dddd" ), 235 | "three" => 1 236 | ); 237 | mydump($arr2); 238 | mydump(1,true,null); 239 | ``` 240 | ### 如何设计一个微博 241 | 用户可以关注他人 可以发布微博 可以查看关注人的微博 可以评论微博 242 | 243 | 用户表 关注表 微博表 评论表 244 | 245 | ### 获取上周一和周日的日期 246 | `echo date('Y-m-d',strtotime('monday last week'));` 247 | `echo date('Y-m-d', strtotime('-' . (6+date('w')) . ' days'));` 248 | `echo date('Y-m-d',strtotime('sunday last week'));` 249 | ### 对数组实现去除空元素 排重 按值从大到小排序 重新建立数字索引 250 | `array_values(rsort(array_unique(array_filter($arr))))` 251 | ### 对二维数组按照 title+pubscore 去重 252 | ```js 253 | function unique_by_key($arr, $key1,$key2) { 254 | $tmp_key = []; 255 | foreach ($arr as $key => $item) { 256 | if ( in_array($item[$key1].$item[$key2], $tmp_key) ) { 257 | unset($arr[$key]); 258 | } else { 259 | $tmp_key[] = $item[$key1].$item[$key2]; 260 | } 261 | } 262 | return $arr; 263 | } 264 | //使用示例: 265 | $arr = array( 266 | array('id' => 1, 'title' => 'a','pubscore'=>1), 267 | array('id' => 2, 'title' => 'a','pubscore'=>1), 268 | array('id' => 3, 'title' => 'b','pubscore'=>2), 269 | array('id' => 4, 'title' => 'c','pubscore'=>3), 270 | array('id' => 5, 'title' => 'd','pubscore'=>3), 271 | ); 272 | print_r(unique_by_key($arr,'title','num')); 273 | 274 | ``` 275 | ### 写一个正则 匹配新闻标题不能为数字,纯字母,不能包含 彩票/广告/启示 276 | 277 | ### linux 压缩 解压缩命令 278 | `tar -cvf jpg.tar *.jpg` 279 | `tar -xvf jpg.tar` 280 | ### linux下后台执行 test.php 将结果输出到test.log 281 | `php test.php & >test.log` 282 | ### 写一个shell命令 实现找出所有包含 spread的进程,杀死这些进程并记录日志,日志包含杀死进程名称和杀死进程的时间 283 | `ps -ef |grep spread |grep -v grep |awk '{print $2}'|xargs kill -9` 284 | `kill -9 $(ps -ef | grep spread| grep -v grep | awk '{print $2}')` 285 | ### 一个json 转化输出有层级的文本 286 | 参考 https://segmentfault.com/a/1190000008265618 287 | ### 排行榜统计 sql 288 | 订单表有如下字段 289 | id 自增id 290 | user_id 购买者id 291 | product_id 商品id 292 | time 购买时间 293 | price 订单总价 294 | 找出销量大于1000的商品,按销量倒序 和 找出消费最多的10个用户 295 | 296 | `select product_id,count(*) s from orders group by product_id order by s having s>1000;` 297 | 298 | `select user_id,sum(price) s from orders group by user_id order by s desc limit 10;` 299 | 300 | ### 列出你知道的魔术方法 ,并说明他们的用途 301 | 302 | [参考手册](http://php.net/manual/zh/language.oop5.magic.php) 303 | 304 | ### 写出你知道的http头部属性 注意大小写 并说明用途 305 | ```js 306 | Accept 指定客户端能够接收的内容类型 Accept: text/plain, text/html 307 | Accept-Charset 浏览器可以接受的字符编码集。 Accept-Charset: iso-8859-5 308 | Accept-Encoding 指定浏览器可以支持的web服务器返回内容压缩编码类型。 Accept-Encoding: compress, gzip 309 | Accept-Language 浏览器可接受的语言 Accept-Language: en,zh 310 | Accept-Ranges 可以请求网页实体的一个或者多个子范围字段 Accept-Ranges: bytes 311 | Authorization HTTP授权的授权证书 Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ== 312 | Cache-Control 指定请求和响应遵循的缓存机制 Cache-Control: no-cache 313 | Connection 表示是否需要持久连接。(HTTP 1.1默认进行持久连接) Connection: close 314 | Cookie HTTP请求发送时,会把保存在该请求域名下的所有cookie值一起发送给web服务器。 Cookie: $Version=1; Skin=new; 315 | Content-Length 请求的内容长度 Content-Length: 348 316 | Content-Type 请求的与实体对应的MIME信息 Content-Type: application/x-www-form-urlencoded 317 | Date 请求发送的日期和时间 Date: Tue, 15 Nov 2010 08:12:31 GMT 318 | Expect 请求的特定的服务器行为 Expect: 100-continue 319 | From 发出请求的用户的Email From: user@email.com 320 | Host 指定请求的服务器的域名和端口号 Host: www.zcmhi.com 321 | If-Match 只有请求内容与实体相匹配才有效 If-Match: “737060cd8c284d8af7ad3082f209582d” 322 | If-Modified-Since 如果请求的部分在指定时间之后被修改则请求成功,未被修改则返回304代码 If-Modified-Since: Sat, 29 Oct 2010 19:43:31 GMT 323 | If-None-Match 如果内容未改变返回304代码,参数为服务器先前发送的Etag,与服务器回应的Etag比较判断是否改变 If-None-Match: “737060cd8c284d8af7ad3082f209582d” 324 | If-Range 如果实体未改变,服务器发送客户端丢失的部分,否则发送整个实体。参数也为Etag If-Range: “737060cd8c284d8af7ad3082f209582d” 325 | If-Unmodified-Since 只在实体在指定时间之后未被修改才请求成功 If-Unmodified-Since: Sat, 29 Oct 2010 19:43:31 GMT 326 | Max-Forwards 限制信息通过代理和网关传送的时间 Max-Forwards: 10 327 | Pragma 用来包含实现特定的指令 Pragma: no-cache 328 | Proxy-Authorization 连接到代理的授权证书 Proxy-Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ== 329 | Range 只请求实体的一部分,指定范围 Range: bytes=500-999 330 | Referer 先前网页的地址,当前请求网页紧随其后,即来路 Referer: http://www.zcmhi.com/archives/71.html 331 | TE 客户端愿意接受的传输编码,并通知服务器接受接受尾加头信息 TE: trailers,deflate;q=0.5 332 | Upgrade 向服务器指定某种传输协议以便服务器进行转换(如果支持) Upgrade: HTTP/2.0, SHTTP/1.3, IRC/6.9, RTA/x11 333 | User-Agent User-Agent的内容包含发出请求的用户信息 User-Agent: Mozilla/5.0 (Linux; X11) 334 | Via 通知中间网关或代理服务器地址,通信协议 Via: 1.0 fred, 1.1 nowhere.com (Apache/1.1) 335 | Warning 关于消息实体的警告信息 Warn: 199 Miscellaneous warning 336 | ``` 337 | ### 有一个文本文件,内容为ip 每行一个ip 格式为 338 | 1.2.3.4 339 | 4.5.6.7 340 | 2.3.4.5 341 | 1.2.3.4 342 | 写出 shell命令 统计 ip出现的次数 结果类似 343 | 1.2.3.4 2 344 | 4.5.6.7 1 345 | 2.3.4.5 1 346 | 347 | `awk '{arr[$1]++;}END{for(i in arr){print i , arr[i] }}' test.txt` 348 | ### __destruction() 和 __autoload()触发时机 349 | unset 和 加载一个为包含的文件 350 | ### 如何实现一个数组[1,2,3]连续复制3次变为[1,2,3,1,2,3,1,2,3] 351 | ```js 352 | $arr=[1,2,3]; 353 | print_r(f($arr,3)); 354 | function f($arr,$num){ 355 | return array_filter(explode(',',str_repeat(implode(',',$arr).',',$num))); 356 | } 357 | ``` 358 | 359 | ### 抽象类和接口的区别,分别在什么场景使用 360 | 抽象类可以实现的功能,接口也可以实现。 361 | 抽象类的接口的区别,不在于编程实现,而在于程序设计模式的不同。 362 | 一般来讲,抽象用于不同的事物,而接口用于事物的行为。 363 | 参考 https://segmentfault.com/a/1190000004699158 364 | 365 | ### 猴子选大王 366 | 一群猴子排成一圈,按1,2,...,n依次编号。然后从第1只开始数,数到第m只,把它踢出圈,从它后面再开始数,再数到第m只,在把它踢出去...,如此不停的进行下去,直到最后只剩下一只猴子为止,那只猴子就叫做大王。要求编程模拟此过程,输入m、n,输出最后那个大王的编号 367 | ```js 368 | echo monkey(10,4);//5 369 | function monkey($m,$n){ 370 | $arr=range(1,$m); 371 | $i=0; 372 | while(count($arr)>1){ 373 | if(($i+1)%$n==0){ 374 | unset($arr[$i]); 375 | }else{ 376 | $arr[]=$arr[$i]; 377 | unset($arr[$i]); 378 | } 379 | $i++; 380 | } 381 | return $arr[$i]; 382 | } 383 | ``` 384 | ### 写一个快速排序 385 | ```js 386 | function quickSort($arr) { 387 | $len = count($arr); 388 | if($len <= 1) { 389 | return $arr; 390 | } 391 | 392 | $base = $min = $max = []; 393 | 394 | $base_item = $arr[0]; 395 | 396 | for($i = 0; $i < $len ; $i++) { 397 | if($arr[$i] < $base_item) { 398 | $min[] = $arr[$i]; 399 | }elseif($arr[$i] > $base_item) { 400 | $max[] = $arr[$i]; 401 | }else { 402 | $base[] = $arr[$i]; 403 | } 404 | } 405 | 406 | $min = quickSort($min); 407 | $max = quickSort($max); 408 | return array_merge($min,$base,$max); 409 | } 410 | ``` 411 | ### 实现一个发红包功能,100元发给8人 412 | 413 | ### 实现斐波那契数列 414 | ```js 415 | 416 | function fib($n) { 417 | if($n <= 0) return 0; 418 | if ($n <= 2) return 1; 419 | return fib($n - 1) + fib($n - 2); 420 | } 421 | 422 | function fib2($n) { 423 | if ($n <= 2) return 1; 424 | $arr = [0,1,1]; 425 | for ($i = 3; $i <= $n; $i++) { 426 | $arr[$i] = $arr[$i - 1] + $arr[$i - 2]; 427 | } 428 | return $arr[$n]; 429 | } 430 | ``` 431 | ### 二分查找 432 | ```js 433 | function binSearch($arr,$search){ 434 | $height=count($arr)-1; 435 | $low=0; 436 | while($low<=$height){ 437 | $mid=floor(($low+$height)/2);//获取中间数 438 | if($arr[$mid]==$search){ 439 | return $mid; 440 | }elseif($arr[$mid]<$search){//当中间值小于所查值时,则$mid左边的值都小于$search,此时要将$mid赋值给$low 441 | $low=$mid+1; 442 | }elseif($arr[$mid]>$search){//中间值大于所查值,则$mid右边的所有值都大于$search,此时要将$mid赋值给$height 443 | $height=$mid-1; 444 | } 445 | } 446 | return "查找失败"; 447 | } 448 | ``` 449 | ### 二维数组转换成一维数组 450 | ```js 451 | $user = array( 452 | array('id' => 100, 'username' => 'a1'), 453 | array('id' => 101, 'username' => 'a2'), 454 | array('id' => 102, 'username' => 'a3'), 455 | array('id' => 103, 'username' => 'a4'), 456 | array('id' => 104, 'username' => 'a5'), 457 | ); 458 | $result = array_reduce($user, function ($result, $value) { 459 | return array_merge($result, array_values($value)); 460 | }, array()); 461 | /* 462 | Array 463 | ( 464 | [0] => 100 465 | [1] => a1 466 | [2] => 101 467 | [3] => a2 468 | [4] => 102 469 | [5] => a3 470 | [6] => 103 471 | [7] => a4 472 | [8] => 104 473 | [9] => a5 474 | ) 475 | */ 476 | $result = []; 477 | array_walk_recursive($user, function($value) use (&$result) { 478 | array_push($result, $value); 479 | }); 480 | $result = []; 481 | array_map(function ($value) use (&$result) { 482 | $result = array_merge($result, array_values($value)); 483 | }, $user); 484 | ``` 485 | ### 2次foreach 输出什么 486 | ```js 487 | //参考https://segmentfault.com/q/1010000008279730 488 | $arr = [1,2,3]; 489 | foreach($arr as &$v) { 490 | //nothing todo. 491 | } 492 | foreach($arr as $v) { 493 | //nothing todo. 494 | } 495 | var_export($arr); 496 | //output:array(0=>1,1=>2,2=>2) 497 | ``` 498 | # 面试题 499 | 500 | ### nginx 热启动 501 | nginx -s reload 502 | 503 | ### 读取1G大文件 504 | 使用游标或者yield生成器来获取数据库的数据 https://segmentfault.com/a/1190000012334856 505 | 506 | ### http https 区别 507 | HTTPS协议是由SSL+HTTP协议构建的可进行加密传输、身份认证的网络协议,要比http协议安全。 参考 https://www.itcodemonkey.com/article/4195.html 508 | 509 | ### redis 持久化 510 | aof rdb http://www.hoohack.me/2018/04/04/deep-learning-redis-durability 511 | https://juejin.im/entry/5b35ad87f265da597759804b/ 512 | ### 权限如何设计 513 | user用户表、role角色表、perm权限表、role-user用户角色关联表、role-perm角色权限关联表 514 | ### apache nginx 区别 515 | https://juejin.im/entry/5b34b2d7e51d4558ae19f2eb 516 | nginx从入门到实践 https://juejin.im/post/5a2600bdf265da432b4aaaba 517 | ### 数据库锁的了解 518 | 乐观锁(代码处理)与悲观锁( select for update) http://www.hollischuang.com/archives/934 519 | 520 | ### 2038 时间问题 521 | ```js 522 | //解决:DateTime 或者 使用64位操作系统 523 | 524 | $str_time = '2100-10-02'; 525 | function newStrToTime($str_time) { 526 | $result = strtotime($str_time); 527 | if(empty($result)) { 528 | $date = new DateTime($str_time); 529 | $result = $date->format('U'); 530 | } 531 | return $result; 532 | } 533 | ``` 534 | ### 谈谈最近微信支付 xxe 漏洞 535 | php 调用simplexml_load_string之前把外部引用实体关掉: 536 | libxml_disable_entity_loader(true); 537 | $data = json_decode(json_encode(simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true); 538 | 539 | ### 写个定时任务 540 | `*  *  *  *  *  command` 541 | 分 时 日 月 周 命令 542 | 工具 https://crontab-generator.org/ 543 | https://crontab.guru/ 544 | https://tool.lu/crontab/ 545 | https://atool.vip/crontab 546 | ### opcache了解 547 | 缓存字节码 548 | ### array_merge + 区别 549 | [参考](https://segmentfault.com/a/1190000014838713) 550 | ### 如何实现多继承 551 | 552 | trait的出现就是一种解决需要多继承场景的方式。 使用场景是如果多个类都要用到同样的属性或者方法,这个时候使用Traits可以方便的给类增加这些属性或方法,而不用每个类都去继承一个类,如果说继承类是竖向扩展一个类,那么Traits是横向扩展一个类,从而实现代码复用。 553 | 554 | [PHP中Trait详解及其应用]( https://segmentfault.com/a/1190000008009455 ) 555 | 556 | ### PHP 多线程 557 | https://www.cnblogs.com/kluan/p/5934228.html 558 | https://www.cnblogs.com/zhenbianshu/p/7978835.html 559 | ```js 560 | class Request extends Thread { 561 | public $url; 562 | public $response; 563 | public function __construct($url) { 564 | $this->url = $url; 565 | } 566 | public function run() { 567 | $this->response = file_get_contents($this->url); 568 | } 569 | } 570 | $ch = new Request("www.baidu.com"); 571 | $ch ->start(); 572 | ``` 573 | ### php执行流程 574 | 浏览器输入URL->Nginx(从配置文件中加载nginx的fast-cgi模块)->php-fpm(fastcgi的进程管理器) 575 | 先到php-fpm的master进程(负责监听端口,接收Nginx的请求,据子进程的状态将请求分配给子进程去处理)->worker进程负责处理请求 576 | worker 进程则一般有多个(具体数量根据实际需要配置),每个进程内部都嵌入了一个 PHP 解释器,是 PHP 代码真正执行的地方。 577 | master 进程做的事情是 PHP环境初始化、事件监听(重启/重载、关闭、分发请求)、子进程状态 578 | https://youngperson.github.io/blog/#/posts/16 579 | ### 如何优化 mysql 580 | ### 如何防 SQL 注入 581 | 1 表单尽量用 post 提交,核心用户验证都走 post,避开 get容易暴露客户数据 582 | 2 使用HTTP_REFERER 检查源文件是否来自本系统 583 | 3 开启addslashes在特殊符号前加\ 584 | 4 使用htmlspecialchars对字符串转实体 585 | 5 用户授权登录 586 | 6 使用PDO 587 | 588 | 数据库字段冗余,增添索引、优化sql、分库分表 主从分离 589 | ### 常用 git 命令 590 | git add git log git pull git push git remote git checkout 591 | ### php7常用新特性 592 | 比如标量类型声明、返回类型声明 593 | ### 自动加载如何实现的 594 | spl_autoload_register composer 595 | ### 用过哪些PHP扩展 596 | curl mb 597 | ### php 异步如何实现 598 | curl_multi_exec 599 | ### 了解的微服务 600 | 601 | ### redis 过期如何处理 602 | 惰性删除与定期删除 603 | ### explain 关注哪些 604 | type 字段 const、eq_reg、ref、range、index和ALL 605 | ### 对你最有挑战的项目是怎样的 606 | 607 | ### laravel 优势是什么 608 | # 非技术问题 609 | 为什么从上家公司离职? 610 | 未来三年的职业规划的怎样的? 611 | 你有什么问的? 612 | 613 | # 资源 614 | 615 | [PHP面试准备]( https://github.com/xianyunyh/PHP-Interview) 616 | 617 | [关于面试/谈Offer/程序员职场生涯等]( https://github.com/lietoumai/awesome-offer) 618 | 619 | [少写PHP "烂"代码](https://segmentfault.com/a/1190000015274515) 620 | 621 | [PHP工程师面试题目]( https://github.com/hookover/php-engineer-interview-questions) 622 | 623 | [PHPer 面试指南](https://github.com/todayqq/PHPerInterviewGuide ) 624 | 625 | [一个16年毕业生所经历的php面试](https://github.com/OMGZui/noteBook/blob/master/level.md) 626 | 627 | [找工作遇到的面试题目]( https://cloud.tencent.com/developer/article/1104156 ) 628 | 629 | [大话编程]( https://mp.weixin.qq.com/s/nCx7Jb5WRXGzkpsuth6LAw) 630 | 631 | https://mp.weixin.qq.com/s/13OJ8YAXLj3tqAC0aZ1e_Q 632 | 633 | [strace帮助你调试PHP代码]( https://www.jianshu.com/p/cbc716f8a932? ) 634 | 635 | [Resetful API 设计规范](https://godruoyi.com/posts/resetful-api-design-specifications ) 636 | 637 | [Java 基础知识、底层原理 面试]( https://github.com/crossoverJie/Java-Interview) 638 | 639 | [PHP基础数据结构专题系列目录地址](https://github.com/xx19941215/light-tips) 640 | 641 | [后端架构师技术图谱]( https://github.com/xingshaocheng/architect-awesome) 642 | 643 | [记一次面试,分享我整理的答案](https://laravel-china.org/articles/9143/write-an-interview-and-share-my-answers) 644 | 645 | [PHP 面试知识点汇总 ](https://github.com/eaglewu/php-interview-best-practices-in-china ) 646 | 647 | [平时积累 ](https://github.com/OMGZui/noteBook) 648 | 649 | [PHP 代码简洁之道](https://github.com/ryanmcdermott/clean-code-javascript ) 650 | 651 | [PHP PSR 标准规范]( https://www.twle.cn/l/yufei/phppsr/php-psr-index.html) 652 | 653 | [psr](https://laravel-china.org/docs/psr ) 654 | 655 | [PHP 开发知识结构 ](https://github.com/han8gui/PHPer) 656 | 657 | [PHP多进程系列笔记](https://mp.weixin.qq.com/s/af2my0IC4VIo1WNaCvZAaA) 658 | 659 | [Redis从入门到实践]( https://juejin.im/post/5a912b3f5188257a5c608729) 660 | 661 | [浅谈消息队列及常见的消息中间件](https://juejin.im/post/5b41fe36e51d45191252e79e) 662 | 663 | [《程序员练级攻略》推荐必读书籍清单 ](https://time.geekbang.org/column/article/10793) 664 | 665 | [redis开发设计规范及案例分析](https://mp.weixin.qq.com/s/vS8IMgBIrfGpZYNUwtXrPQ ) 666 | 667 | [MySQL运维:索引与查询性能优化](https://juejin.im/entry/5b444bf05188251a8d36d034) 668 | 669 | [从输入URL到页面展示到底发生了什么 ](https://juejin.im/entry/5b44155f6fb9a04f932fdf80) 670 | 671 | [数据结构与算法](https://mp.weixin.qq.com/s/FslsYpofN5vE20TEfJNwrw) 672 | 673 | [PHP面试:说说你理解的二叉树吧]( https://segmentfault.com/a/1190000015635928) 674 | 675 | [初中级PHP面试基础汇总 ](https://segmentfault.com/a/1190000015412706) 676 | 677 | https://segmentfault.com/a/1190000010250591 678 | 679 | [php 经典排序算法(解析)]( https://segmentfault.com/a/1190000011751912) 680 | 681 | [PHP面试之一:PHP基础知识点]( https://segmentfault.com/a/1190000011335262) 682 | 683 | [PHPer、Laravel 面试可能会遇到的问题及答案](https://github.com/todayqq/caseInterviewQuestions ) 684 | 685 | [PHPer 面试指南-扩展阅读资源整理](https://segmentfault.com/a/1190000012971148) 686 | 687 | [3年PHPer的面试总结]( http://coffeephp.com/articles/4) 688 | 689 | [PHP 无限级分类最佳实践](https://segmentfault.com/a/1190000008265618) 690 | 691 | [数据库面试题(开发者必看)]( https://segmentfault.com/a/1190000013517914) 692 | 693 | [10个值得深思的PHP面试问题](https://segmentfault.com/a/1190000005032279) 694 | 695 | [php 高并发](https://www.cnblogs.com/phpper/p/6716248.html) 696 | 697 | [SegmentFault 技术周刊 Vol.31 - 码农也要学算法](https://segmentfault.com/a/1190000010600318) 698 | 699 | [SegmentFault 技术周刊 Vol.6 - 面试那些事儿](https://segmentfault.com/a/1190000006950447) 700 | 701 | [笔试面试](https://segmentfault.com/a/1190000012770931) 702 | 703 | [PHP常见算法-面试篇 ](http://www.cnblogs.com/zswordsman/p/5824599.html) 704 | 705 | [PHPer 面试指南-扩展阅读资源整理](https://segmentfault.com/a/1190000012971148) 706 | 707 | [shell在手分析服务器日志不愁]( https://segmentfault.com/a/1190000009745139) 708 | 709 | [PHPer 面试可能会遇到的问题](https://github.com/justcodingnobb/fuck-php-interview) 710 | 711 | [程序员的自我修养](https://www.kancloud.cn/kancloud/a-programmer-prepares/78223) 712 | 713 | [小土刀的面试刷题笔记](https://wdxtub.com/interview/14520847747820.html) 714 | 715 | [笔试面试知识整理](https://github.com/HIT-Alibaba/interview) 716 | 717 | [MySQL 避坑宝典](https://github.com/XiaoMi/soar/blob/master/doc/heuristic.md) 718 | -------------------------------------------------------------------------------- /love_china.py: -------------------------------------------------------------------------------- 1 | #Python表白祖国 https://weibo.com/5780793700/I9lerpmzZ?type=comment#_rnd1570079816878 2 | from turtle import*#从海龟绘图( Turtle)模块中导入全部西数(星号*代表全部 3 | setup(600,400,0,0)#设定大小,四个参数依次为:宽度、高度、起始点x值、起始点y值 4 | bgcolor('red')#背景颜色设为红色('red') 5 | fi1lcolor('yellow') 6 | color('ye11ow')#线条及填充颜色设为黄色("ye1ow 7 | speed(10)#画笔运行速度 8 | #大五角星部分 9 | begin_fi11()#开始填充 10 | up()#提起(up)画笔,此时移动画笔,不会进行绘画 11 | goto(-280,100)#前任(goto)指定坐标(这里是280,100) 12 | down()#放下(down)画笔,此时移动画笔,直接进行绘画 13 | for i in range(5):#for循环语句,范围( range)设为5,意思是以下指令重复5次,用于画出五角星的五条边 14 | fd(150)# forwardd的简写,意为向前移动画笔150单位 15 | rt(144)# righte的简写,向右旋转144度(这两条指令重复5次) 16 | end_fill()#结東填充 17 | #四颗小五角星部分 18 | begin_fill()#开始填充 19 | up()#提起画笔 20 | goto(-100,180)#前住指定坐标 21 | heading(305)#设置朝向角度(这里是305度) 22 | down()#放下画笔 23 | for i in range(5):#for循环语句,同上 24 | fd(50)#向前50单位 25 | 1t(144)#1eft的简写,向左旋转144度 26 | end_fi11()#结東填充 27 | begin_fi11()其余三颗小五角星原理相同 28 | up() 29 | goto(-50,110) 30 | setheading (30) 31 | for i in range(5): 32 | fd(50) 33 | t(144 34 | end_fill() 35 | begin_fill() 36 | up() 37 | goto(-40,50) 38 | setheading (5) 39 | down () 40 | for i in range(5): 41 | fd(50) 42 | rt(144) 43 | end_fill() 44 | begin_fill() 45 | goto(-100,10) 46 | setheading (300) 47 | down () 48 | for i in range(5): 49 | fd(50) 50 | 1t(144) 51 | end_fill() 52 | --------------------------------------------------------------------------------