Skip to content

Code with PHP.

Start coding with PHP, from your first script to a complete Laravel app. Follow free, hands-on tutorials with examples you can run.

Halftone pin-up illustration of a programmer in red cat-eye glasses at a vintage computer

Pick your next project.

Start from scratch, build a full app, or see what’s new in PHP.

Try it.
Break it.

Guess what PHP prints, then open the answer to see why.

Find examples and exercises

Strict equality

<?php
$count = "3";
echo $count === 3 ? "same" : "different";
Reveal the answer

PHP prints different. Strict equality compares both type and value. The string "3" and the integer 3 are different types.

Array mapping

<?php
$prices = [3, 5];
echo implode(", ", array_map(fn ($n) => $n * 2, $prices));
Reveal the answer

PHP prints 6, 10. array_map() doubles each price in a new array. implode() joins those values with a comma and a space.

Null coalescing

<?php
$name = "";
echo ($name ?? "Guest") === "" ? "blank" : "Guest";
Reveal the answer

PHP prints blank. The ?? operator falls back only for null or an undefined value. An empty string is still a string.

Good code.
Better company.

Share a project, ask for a hand, or help shape the next lesson.