PHP

PHP Tutorial

Write server-side code – syntax, strings, arrays, functions, forms, files and databases with PDO.

PHP runs on the web server and powers WordPress and countless websites. This track covers PHP 8 from the basics to handling forms safely, including files and talking to a MySQL database with PDO and prepared statements.

PHP code can't run inside your browser, so each example shows the exact output it prints. To run them yourself, install a local server such as XAMPP.

  1. 1 PHP IntroductionLearn what PHP is, how it runs on the server to build web pages, and write your first PHP script…
  2. 2 PHP Syntax and VariablesLearn the basic rules of PHP syntax – statements, semicolons, comments and case – and how to create and use…
  3. 3 PHP Data TypesUnderstand PHP data types – string, int, float, bool, array, null and object – and learn how to inspect, convert…
  4. 4 PHP StringsWork with text in PHP: single vs double quotes, joining strings, heredoc, and the most useful string functions in PHP…
  5. 5 PHP OperatorsLearn PHP arithmetic, assignment, comparison and logical operators, why === beats ==, and the handy ?? and ?-> operators.
  6. 6 PHP Conditions: if, else and matchMake decisions in PHP with if, elseif and else, and learn why the PHP 8 match expression is often cleaner…
  7. 7 PHP LoopsRepeat work with PHP loops: for, while, do-while and foreach, plus break, continue and building HTML lists from data.
  8. 8 PHP FunctionsWrite your own PHP functions with typed parameters and return types, default values, named arguments, variable scope and arrow functions.
  9. 9 PHP ArraysStore lists and records in PHP arrays: indexed, associative and multidimensional arrays, plus searching, sorting and the most useful array…
  10. 10 PHP Forms: GET and POSTHandle HTML form data safely in PHP: GET vs POST, reading $_GET and $_POST, validating input, escaping output and protecting…
  11. 11 PHP Include and FilesSplit PHP code into reusable files with require and include, then read and write text, JSON and CSV files safely.
  12. 12 PHP MySQL with PDOConnect PHP to MySQL or MariaDB with PDO, and read, insert and update data safely using prepared statements.