PHP is a server-side scripting language built for the web: a script runs per request, reads input, talks to a database and returns HTML or data. It powers a very large share of existing sites and content management systems. Modern PHP is a typed, object-oriented language with a mature package ecosystem, quite unlike its early reputation.
Key concepts
- Request lifecycle: each request starts a fresh script, with superglobals holding input and no state carried over by default.
- Dynamic typing with type declarations: values convert freely, but declared types make code safer.
- Classes, interfaces and traits: the object model of current PHP, with namespaces and autoloading.
- Arrays: one flexible structure serves as list and dictionary.
- Database access: prepared statements through a database abstraction layer.
- Composer and frameworks: packages and frameworks provide routing, templating and structure.
Vocabulary
- Superglobal: built-in variables such as the request data and the session.
- Session: server-side state tied to a visitor by a cookie.
- Autoloading: classes load when first used, from a naming convention.
- Template: a file mixing markup with small bits of code to render output.
What to study, in order
- Basic syntax, arrays and functions, running scripts from the command line.
- Handle a form: read input, validate it, escape output, and store it with prepared statements.
- Classes, namespaces and Composer; split code into reusable pieces.
- Sessions, authentication and the common security pitfalls such as injection and cross-site scripting.
- A framework's routing, templates and testing.
- Deploy to a server and read its error logs.