PHP

A server-side language for building websites and web apps.

PHP runs on the server and is used by a large share of websites, including everything built on WordPress. Modern PHP (8.x) is fast and supports type declarations, and it remains a common skill in web development jobs.

  • Beginner
  • 8 lessons
Not started yet
Start lesson 1

Lessons

  1. Hello, PHPWrite your first PHP script and a page that mixes HTML with PHP code in <?php ?> tags. The server runs the code, and the browser only sees the result.
  2. Types, Conditions & LoopsLearn PHP's basic types, conditions and loops. Pay attention to the difference between == and ===, which is a common source of bugs.
  3. ArraysPHP uses one collection type, the array, for both ordered lists and key-value maps. Learn to create, loop over and transform arrays.
  4. Functions & Type DeclarationsLearn to write functions with typed parameters, return types, defaults and named arguments. Type declarations make PHP report mistakes as errors instead of silently converting values.
  5. Classes & Modern OOPLearn to write classes in modern PHP, with constructor property promotion, readonly properties, interfaces and enums.
  6. Composer & the EcosystemLearn to use Composer, PHP's package manager and autoloader, and get an overview of the main frameworks. Almost every modern PHP project uses Composer.
  7. Handling Web RequestsLearn to handle a form submission: read the input, save it to a database and print HTML safely. Frameworks do this for you, but it helps to see the plain version first.
  8. PHP CheatsheetModern PHP 8 syntax, arrays, and classes on one page.

Install it on your own computer

PHP comes with a built-in development web server, so you do not need Apache or nginx while learning.

Bash
winget install PHP.PHP.8.3
# Or grab a zip from https://windows.php.net

php --version

# Run a file:
php hello.php

# Start the built-in dev server in a folder:
php -S localhost:8000

What people build with PHP

Learn the basics first, then pick up these tools when a project needs them.

Practical uses

  • Build server-rendered websites
  • Create APIs and business applications
  • Develop content-management systems
  • Run ecommerce and publishing platforms

Projects to try

  1. Contact form
  2. Personal blog
  3. Laravel appointment system
  4. Small ecommerce backend

Common tools and packages

LaravelSymfonyComposerPHPUnitPestDoctrinePHPStanMonolog

Well-known software

WordPressWikipediaLaravelDrupalMagentoNextcloud