1.2.661. Malformed Octal

Those numbers starts with a 0, so they are using the PHP octal convention. Therefore, one can’t use 8 or 9 figures in those numbers, as they don’t belong to the octal base. The resulting number will be truncated at the first erroneous figure. For example, 090 is actually 0, and 02689 is actually 22.

Also, note that very large octal, usually with more than 21 figures, will be turned into a real number and undergo a reduction in precision.

<?php

// A long way to write 0 in PHP 5
$a = 0890;

// A fatal error since PHP 7

?>

1.2.661.1. Suggestions

  • Fix the octal

  • Use another base to represent the number

1.2.661.2. Specs

Short name

Type/MalformedOctal

Rulesets

All, CompatibilityPHP53, CompatibilityPHP54, CompatibilityPHP55, CompatibilityPHP56

Exakat since

0.8.4

PHP Version

With PHP 7.0 and older

Severity

Minor

Time To Fix

Instant (5 mins)

Precision

Very high

Features

octal

Available in

Entreprise Edition, Exakat Cloud