← BACK
PHP / Syntax

Improve Large Number Readability with Numeric Literal Separators

Punyapal Shah • • 1 min read
edit this tip →

Use underscores (_) as visual numeric literal separators in PHP code to improve number readability.

Reading large numbers like 1000000000 requires counting zeroes manually. PHP allows underscores as visual separators inside numeric literals without affecting value evaluation.

// Hard to read
$bytes = 1073741824;

// Clean and readable with numeric separators
$bytes = 1_073_741_824; // 1 GB
$price = 1_999_99;       // 1999.99 in cents
  • Underscores serve purely as visual code separators and are ignored at runtime
  • Works with integers, floats, binary (0b1010_0001), and hex (0xFF_00_FF)
  • Prevents misreading large numbers during code reviews

Related Tips

View all tips →

// Got a tip in mind? Contributions are always welcome