php
rango PHP并发IO编程之路nginx + fpm 工作机制
字符串处理: 注意编码, 比如遇到中文的处理情况
php最常见的bug就是 undefined index, 所以使用数组涉及到索引时一定要注意
大文件一定要使用 文件指针 来操作
模板引擎: 需要消耗服务器资源来编译(blade vs twig)
设计模式: 实现了面向对象的语言都可以应用设计模式; 设计模式实际是特定场景下的更加优良的解决方案
php 代码修改没有立即生效:可能是开启了 opcache 缓存导致;遇到类似情况,都有可能是缓存导致的
# php 信息查看php -v # 版本php -m # 查看 cli 下的扩展php-fpm -m # 查看 php-fpm 开启的扩展php --ini # 查看 ini 文件的位置php -i # 查看php的信息,配合 grep 使用php -r # 执行一段 php 代码php -S localhost:8000 # 开启 php 内置 web server# 安装扩展pecl install xxx # 可以使用 pecl search xxx 先查看phpize # 编译安装yum insta php-xxx # 如果用包管理安装的 php,部分扩展已经加入到包管理中# config; max_execution_time = 0 # execution timeset_time_limit(0);display_errors = Onphp -i|grep upload # 文件上传# php-fpmphp-fpm # 启动 php-fpmpkill php-fpmuser = www # /etc/php-fpm.d/www.confgroup = www那些年使用过的 php 函数
phpinfo() // 查看系统环境ini_set() // 运行时设置环境var_dump() // 调试神器error_reporting()# 进制转换decbin() / decoct() / dechex()bin2hex() / bindec()octdec()hexdec()base_convert()ord() / chr() // ASCII# 空值判断, 一定要小心空数组if()empty()isset()unset()# arrayarray_values() // 注意会重建索引array_diff() // 只比较一维的值sort()/count()array_rand()# 位操作相关pack() / unpack()gmp_and() / gmp_or() / gmp_xor() / gmp_testbit() / gmp_clrbit()# 程序执行 函数die / exit / var_dump()``shell_exec()exec()system()# 包含文件requireincluderequire_onceinclude_once# date&timetime(); // 返回当前时间戳date('Y-m-d H:i:s', $timestamp); // 格式化显示一个时间戳strtotime('-1 day', $timestamp); // 计算天数一定要使用这个# filesystemunlink/chmod/chown // 大部分函数名都和linux命令一样file()file_get_contents() / file_put_contents()fgetcsv() / fputcsv()# 编码iconv($str, 'utf8', 'gbk//ignore) // 大部分情况能解决问题, 且比 mb_* 效率高mb_convert_encoding($str, 'gbk')# url 相关json_decode($str, true) // 默认 false, 返回为 stdClass, true 为 arrayjson_decode(json_encode($stdClass), true) // stdClass -> arrayhttp_build_query()parse_url()pathinfo()# 错误 & 异常set_error_handler()Exception 类# GD 库 & 图像处理# otherinstanceofmt_rand()trim()
ext & package
Swoole:重新定义PHP:通过官方的文档,学习更多服务器编程的知识