#安装 epel-release 依赖:
yum install epel-release
#安装 DNF 包:
yum install dnf
sudo dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo dnf -y install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
sudo dnf -y install yum-utils
sudo dnf module reset php
sudo dnf module install php:remi-8.0 -y
sudo dnf install php -y
sudo yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo yum -y install yum-utils
sudo yum-config-manager --disable 'remi-php*'
sudo yum-config-manager --enable remi-php80
sudo yum -y install php php-{cli,fpm,mysqlnd,zip,devel,gd,mbstring,curl,xml,pear,bcmath,json}
http://windows.php.net/download
http://windows.php.net/downloads/
https://windows.php.net/downloads/releases/archives/php-5.4.45-Win32-VC9-x86.zip
Thread Safe 才有 php7apache2_4.dll
对应版本的 VC 运行库要安装
Experimental: PHP 5.6 and Apache 2.4.10 VC11 for 2K3/XP
https://visualstudio.microsoft.com/downloads/ => https://visualstudio.microsoft.com/zh-hans/downloads/
Other Tools and Frameworks > Microsoft Visual C++ Redistributable for Visual Studio 2019
https://aka.ms/vs/16/release/VC_redist.x64.exe
-
配置 Windows PATH 环境路径,例如 C:\php
-
命令行查看版本信息
php -v
C:\Users\Administrator>php -h
Usage: php [options] [-f] <file> [--] [args...]
php [options] -r <code> [--] [args...]
php [options] [-B <begin_code>] -R <code> [-E <end_code>] [--] [args...]
php [options] [-B <begin_code>] -F <file> [-E <end_code>] [--] [args...]
php [options] -S <addr>:<port> [-t docroot] [router]
php [options] -- [args...]
php [options] -a
-a Run as interactive shell
-c <path>|<file> Look for php.ini file in this directory
-n No configuration (ini) files will be used
-d foo[=bar] Define INI entry foo with value 'bar'
-e Generate extended information for debugger/profiler
-f <file> Parse and execute <file>.
-h This help
-i PHP information
-l Syntax check only (lint)
-m Show compiled in modules
-r <code> Run PHP <code> without using script tags <?..?>
-B <begin_code> Run PHP <begin_code> before processing input lines
-R <code> Run PHP <code> for every input line
-F <file> Parse and execute <file> for every input line
-E <end_code> Run PHP <end_code> after processing all input lines
-H Hide any passed arguments from external tools.
-S <addr>:<port> Run with built-in web server.
-t <docroot> Specify document root <docroot> for built-in web server.
-s Output HTML syntax highlighted source.
-v Version number
-w Output source with stripped comments and whitespace.
-z <file> Load Zend extension <file>.
args... Arguments passed to script. Use -- args when first argument
starts with - or script is read from stdin
--ini Show configuration file names
--rf <name> Show information about function <name>.
--rc <name> Show information about class <name>.
--re <name> Show information about extension <name>.
--rz <name> Show information about Zend extension <name>.
--ri <name> Show configuration for extension <name>.
# 内置Web Server
php -S localhost:8000 -t foo/ router.php
router.php
<?php
// router.php
if (preg_match('/\.(?:png|jpg|jpeg|gif)$/', $_SERVER["REQUEST_URI"]))
return false; // 直接返回请求的文件
else {
echo "<p>Welcome to PHP</p>";
}
K:\env\win\ProgramFiles\php-7.3.0>php-cgi -h
Usage: php [-q] [-h] [-s] [-v] [-i] [-f <file>]
php <file> [args...]
-a Run interactively
-b <address:port>|<port> Bind Path for external FASTCGI Server mode
-C Do not chdir to the script's directory
-c <path>|<file> Look for php.ini file in this directory
-n No php.ini file will be used
-d foo[=bar] Define INI entry foo with value 'bar'
-e Generate extended information for debugger/profiler
-f <file> Parse <file>. Implies `-q'
-h This help
-i PHP information
-l Syntax check only (lint)
-m Show compiled in modules
-q Quiet-mode. Suppress HTTP Header output.
-s Display colour syntax highlighted source.
-v Version number
-w Display source with stripped comments and whitespace.
-z <file> Load Zend extension <file>.
-T <count> Measure execution time of script repeated <count> times.
# 直接运行
start php-cgi.exe -b 127.0.0.1:9000 -c php\php.ini
# 使用 xxfpm
start D:/ProgramFiles/nginx-1.13.10/RunHiddenConsole.exe D:/ProgramFiles/nginx-1.13.10/xxfpm.exe "D:/ProgramFiles/php-7.2.3-nts-x64/php-cgi.exe" -n 2 -i 127.0.0.1 -p 9000
php.ini
-
搜索路径
SAPI 指定位置 PHPIniDir, -c
PHPRC 环境变量
注册表 [HKEY_LOCAL_MACHINE\SOFTWARE\PHP(x(.y(.z)))] IniFilePath
当前工作目录(对于 CLI)
?web 服务器(根)目录(对于 SAPI 模块)
Windows 目录
-
名称
php-SAPI.ini 会替代 php.ini
-
可以使用
环境变量
引用已存在的 .ini 变量 open_basedir = ${open_basedir} ":/new/dir"
user_ini.filename
user_ini.cache_ttl
- PHP_INI_ALL 可在任何地方设定
- PHP_INI_USER ini_set() 注册表 .user.ini
- PHP_INI_PERDIR 可在 php.ini httpd.conf .htaccess (.user.ini ?)
- PHP_INI_SYSTEM 可在 php.ini 或 httpd.conf
- .htaccess
php_value name value
php_flag name on|off
- httpd.conf 不会被 .htaccess 覆盖
php_admin_value name value|none
php_admin_flag name on|off
- 注册表 HKLM\SOFTWARE\PHP\Per Directory Values\c\inetpub\wwwroot
[Date]
date.timezone = PRC
对应的 php 函数
date_default_timezone_set()
扩展目录
extension_dir = "ext"
常用扩展
; 协议
extension=curl
extension=php_openssl.dll
; 文本和翻译
extension=php_gettext.dll
extension=php_intl.dll
extension=php_mbstring.dll
; 数据库
extension=php_mysqli.dll
extension=php_pdo_mysql.dll
[opcache]
zend_extension="K:\env\win\ProgramFiles(x86)\php-7.3.0RC1-nts\ext\php_opcache.dll"
; Determines if Zend OPCache is enabled
opcache.enable=1
; Determines if Zend OPCache is enabled for the CLI version of PHP
opcache.enable_cli=1
include_path = ".;c:\php\includes"
sys_temp_dir = "D:/env/tmp/sys"
enable_dl = Off
file_uploads = On
upload_tmp_dir = "D:/env/tmp/upload"
upload_max_filesize = 20M
max_file_uploads = 20
[Date]
date.timezone = PRC
[Session]
session.save_handler = files
session.save_path = "N;MODE;/path"
session.name = PHPSESSID
session.use_trans_sid = 0
session.use_cookies = 1
session.use_only_cookies = 1
; 值设置为 0 可以在客户端禁用 cookie 时用 sid
类型运算符 instanceof
42 ** 2 = 42 * 42
Trait
重载
__set
__get
__isset
__unset
__call
__callStatic
魔术方法
__sleep
__wakeup
__toString
__invoke
__set_state
__debugInfo
Closure
WinCache
- 清除数组的数字键名项
- 比较数组的键值
- 合并 JSON 格式数组,以文本存储
- \u 开头的
- DOMDocument::loadHTML 默认编码是 ISO-8859-1
// 转为实体
$dom->loadHTML(mb_convert_encoding($profile, 'HTML-ENTITIES', 'UTF-8'));
<!-- 需要声明 -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
PHP DOMDocument loadHTML出现乱码的解决方法
DOMDocument->loadHTML()处理中文的一点问题
选项列表
段列表
[HOST=]
[PATH=]
(核心配置)选项说明
最大执行时间、上传文件大小
- PHP5.6 不可以用list作为对象方法,PHP7可以
- PHP5.4 不可以 $class->object()::staticfunc(); 要 $obj = $class->object(); $obj::staticfunc(); object()是获取一个对象
- 一篇文章帮你了解 PHP 7.3 更新
- 【PHP】PHP 7.4 新特性
https://github.com/php-fig/fig-standards/blob/master/proposed/phpdoc-tags.md
Queries per second (QPS)
OOP
缓存技术、静态化设计
Web Service