PHP Intro
PHP is a server-side scripting language designed for the web. A request hits your server, PHP runs, the browser receives HTML.
Where PHP fits
| Use case | Examples |
|---|---|
| Web frameworks | Laravel, Symfony, CodeIgniter, Slim |
| CMS & e-commerce | WordPress, Drupal, Magento, Joomla |
| Command-line scripts | php script.php works fine |
| APIs & microservices | FastRoute, OpenSwoole, ReactPHP |
How a PHP request works
- Browser asks for
/page.php. - Apache / Nginx routes the request to PHP.
- PHP executes the file, building HTML as it goes.
- The HTML — never the PHP source — goes back to the browser.
The PHP you're learning
This tutorial targets PHP 8.x. Modern features include:
- Strict typing — typed properties, typed parameters, return types.
- Constructor property promotion —
public function __construct(public string $name) {}. matchexpressions and structural enums.- Named arguments —
greet(name: 'Ada'). - Readonly properties (8.1+),
readonlyclasses (8.2+). - First-class callable syntax —
$fn = strtoupper(...);.
Tip: PHP 7 hit end-of-life in 2022; PHP 5 was retired in 2018. If a tutorial uses
mysql_query or ereg, it's from another era — skip it.Example
Example
<?php // PHP runs on the server, before HTML reaches the browser. echo 'Hello from PHP ' . PHP_VERSION;Try it Yourself »
Exercise
PHP runs primarily on the…
Six letters — opposite of "browser".
Discussion
Loading…