haphpiness

These are things in PHP which make me genuinely_happy();

Numeric Literal Separators — 1_000_000

PHP 7.4 lets you insert underscores anywhere in numeric literals. The compiler ignores them; your eyes don't have to count digits.

// Before: count the zeros
$population     = 8000000000;
$diskSize       = 1099511627776;
$maxUpload      = 10485760;

// After: immediately readable
$population     = 8_000_000_000;       // 8 billion
$diskSize       = 1_099_511_627_776;   // 1 TiB in bytes
$maxUpload      = 10_485_760;          // 10 MiB

Works in every numeric context — integers, floats, hex, octal, binary, and scientific notation:

// Hex colour / bitmask constants become self-documenting
const PERMISSION_READ    = 0b0000_0001;
const PERMISSION_WRITE   = 0b0000_0010;
const PERMISSION_EXECUTE = 0b0000_0100;
const PERMISSION_ALL     = 0b0000_0111;

// RGB hex values
$red    = 0xFF_00_00;
$green  = 0x00_FF_00;
$blue   = 0x00_00_FF;
$white  = 0xFF_FF_FF;

// Financial precision
$price      = 1_299.99;
$taxRate    = 0.07_5;       // 7.5%
$threshold  = 1_000_000.00; // one million

Underscores can go between any two digits, so you can group by your domain's conventions: thousands in decimal, bytes in binary, nibbles in hex. The runtime value is identical — this is purely a readability aid.

Significance: Readability

Misreading a number's magnitude is a real bug category. Off-by-a-power-of-ten errors in timeouts, file size limits, and financial calculations have real consequences. Numeric separators make the magnitude visible at a glance, in the same way that formatting a number for display would.