ProgrammingBeginnerPHP

PHP Fundamentals

The language behind a large share of the web: tags and types, PHP's one-array data structure, functions and scope, the request lifecycle, files and errors, and PDO.

PHP is a language shaped by the web, and most of its oddities stop being odd once you know what it was built for. A request arrives, a script runs, and the process ends. There is nothing to keep in memory between requests, which is why PHP leans so hard on files, sessions and databases for anything that must persist. The second thing to know is that PHP has exactly one data structure, and it is called an array. It is an ordered hash map: it behaves like a JavaScript object with a length, like a Python dict that remembers insertion order, and like a list when you use it as one. Learning PHP is largely learning when to use which of those three faces. The third is that almost nothing is a type error, because almost everything is coerced. `$a == $b` asks the loosest possible question, and the answer is sometimes surprising. `===` asks the strict one. Choosing the right operator is most of what "learning PHP properly" means. The course moves from the language to the web: what a request actually is, why `$_POST` is untrusted input, how sessions carry state across requests, and how PDO with prepared statements is the difference between a working app and an injectable one.

4.3 (120) 620 students 114 min 12 lessons 160 XP on completion

What you will be able to do

  • Write syntactically valid PHP and predict exactly what a script prints
  • Use PHP's single array type for both lists and maps, and pick the right shape
  • Explain loose versus strict comparison, and say which one belongs in your code
  • Pass data between functions by value and by reference, and choose deliberately
  • Read request data defensively and escape it on the way out
  • Handle failures with exceptions rather than silent false returns
  • Use PDO with prepared statements so user input can never become SQL

Assessments

Dashboard