Programming languages
PHP
A server-side web language: it powers WordPress, Laravel and a large part of the internet.
What it is
Rasmus Lerdorf created PHP in 1995 as a set of scripts for his own homepage. Today it is a full language with classes, types, attributes and a JIT.
The execution model is simple: every request starts from a clean state, so horizontal scaling is predictable. Packages come from Packagist via Composer.
Modern PHP (8.x) has optional strict typing, enums, readonly properties and named arguments. The best known frameworks are Laravel and Symfony. WordPress, Drupal and Magento are also PHP.
Use it when
- Websites and web apps, especially on Laravel or Symfony.
- Working with WordPress, WooCommerce, Magento and other PHP systems.
- Cheap, widespread hosting: PHP is supported almost everywhere.
Avoid it when
- Long-running processes, websockets and high-concurrency real-time: Node.js, Go or Elixir fit better.
- Non-web tasks: desktop, systems programming, ML.
Key concepts
- Composer
- The dependency manager, with PSR-4 class autoloading.
- PHP-FPM
- A process pool that runs PHP behind nginx or Apache.
- Request lifecycle
- Each request runs from scratch and shares no state with the previous one.
- PSR
- Community standards (PHP-FIG): code style, autoloading, interfaces.
- Enums and types
- PHP 8 has enums, union types, readonly and constructor promotion.
Example
Interview questions
1. How does == differ from === in PHP?
==compares with type juggling, while===also requires the same type. PHP 8 made==stricter for strings and numbers, but===is still safer.2. What are Composer and PSR-4?
Composer manages dependencies. PSR-4 is an autoloading standard that maps namespaces to directories, so you do not
requireevery class.3. How does PHP keep state between requests?
It does not by itself. State lives in sessions (files, Redis), a database or a cache. Every request starts from zero.
4. What is new in PHP 8?
JIT, union types, named arguments, attributes,
match, the nullsafe operator?->, constructor promotion, and in 8.1 enums and readonly.
Related technologies
- LaravelA popular PHP framework with expressive syntax, the Eloquent ORM, queues and a rich ecosystem.
- MySQLOne of the most widespread relational databases, the foundation of many web projects and the LAMP stack.
- nginxnginx is a fast web server and reverse proxy that also works as a load balancer and HTTP cache.
Logos belong to their owners and are used for identification only. Icons: Simple Icons (CC0), Devicon (MIT).