What PHP Does
- Server-side scripting — embedded in HTML or standalone
- CLI execution — scripts, CLIs, cron jobs
- Built-in web server —
php -Sfor dev - Huge standard library — strings, arrays, HTTP, crypto, DB, JSON
- Frameworks — Laravel, Symfony, CodeIgniter, Phalcon, Yii
- CMS — WordPress, Drupal, Joomla, Magento
- ORM — Eloquent (Laravel), Doctrine (Symfony)
- Composer — Packagist is the largest PHP package registry
- JIT compiler — OPcache + JIT in PHP 8.0+
- Modern syntax — union types, enums, readonly, attributes, first-class callable
Architecture
Zend Engine interprets PHP bytecode. OPcache caches compiled bytecode between requests. PHP-FPM process manager serves requests behind Nginx or Apache. PHP 8 added a JIT tracing optimizer on top of OPcache for CPU-bound workloads.
Self-Hosting
# Production stack
# PHP-FPM + Nginx
apt install php8.3-fpm nginx
systemctl enable php8.3-fpm nginxKey Features
- Embedded in HTML or standalone
- JIT compiler (8.0+)
- Union and intersection types
- Enums (8.1+)
- Readonly properties (8.1+) and readonly classes (8.2+)
- Attributes (metadata annotations)
- First-class callable syntax
- Composer package ecosystem
- Laravel and Symfony frameworks
- WordPress and many CMS
Comparison
| Language | Use | Startup | Ecosystem |
|---|---|---|---|
| PHP | Web, CLI | Per-request | Huge (CMS) |
| Python | Web, ML, scripts | Per-request (uvicorn) | Huge |
| Ruby | Web, scripts | Per-request (Rails) | Large |
| Node.js | Web, CLI | Long-running | Huge |
| Go | Services | Long-running | Large |
常见问题 FAQ
Q: PHP 过时了吗? A: 没有。现代 PHP (8.x) 类型系统、性能、工具都和其他主流语言接近。WordPress 之类的 CMS 还是 PHP 主导。Laravel 生态非常健康。
Q: PHP vs Python web? A: PHP 在共享主机和 CMS 场景无可替代;Python 在 ML/数据 场景优势明显。Web 框架层面两者都很成熟(Laravel vs Django/FastAPI)。
Q: JIT 有多快? A: CPU-bound 提升明显(2-3x),web IO-bound 提升不大(因为每次请求重新编译一遍 bytecode)。OPcache 才是 web 性能的关键。
来源与致谢 Sources
- Docs: https://www.php.net/docs.php
- GitHub: https://github.com/php/php-src
- License: PHP License