Home / Code typing practice / PHP

Free code typing practice

PHP Typing Practice

Free PHP typing practice: type real PHP with $variables, -> and => arrows, arrays and PDO queries. Build speed for Laravel, WordPress and Symfony code.

PHP puts a dollar sign in front of every variable, uses -> for methods and => in arrays, and mixes single and double quotes. That's a lot of number-row reaches per line.

The snippets cover output escaping, array_map with arrow functions, a controller method, foreach loops and PDO prepared statements, the PHP of Laravel, Symfony and WordPress.

PHP code you will type

Each session picks from these, in random order. Line breaks are shown as single spaces.

<?php echo htmlspecialchars($user['name'], ENT_QUOTES); ?>
$total = array_sum(array_map(fn($i) => $i['price'] * $i['qty'], $items));
public function show(int $id): Response { return $this->json($this->repo->find($id)); }
foreach ($rows as $key => $row) { echo "{$key}: {$row}" . PHP_EOL; }
$stmt = $pdo->prepare('SELECT * FROM users WHERE id = ?'); $stmt->execute([$id]);

Symbols to watch

$->=>[ ]'";<?php

Not sure which finger to use? See the programming symbols finger chart.

Tips for typing PHP faster

  • $ is Shift and 4: left index finger with the right Shift. You'll type it on almost every word.
  • Type $this-> as one chunk; it's the most common sequence in object-oriented PHP.
  • Keep -> (minus, Shift and full stop) and => (equals, Shift and full stop) distinct in your head.

Frequently asked questions

Why is PHP good typing practice?

Every variable starts with $, and arrows -> and => are everywhere, so PHP trains the number row and right-hand symbols hard.

Will PHP practice help with Laravel?

Yes. Laravel code is PHP with lots of arrays, arrows and closures, exactly what these snippets cover.

Practise typing other languages

All code typing practice