1.2.597. Invalid Octal In String

Any octal sequence inside a string can’t be go 377. Those will be a fatal error at parsing time.

The check is applied to the string, starting with PHP 7.1. In PHP 7.0 and older, those sequences were silently adapted (modulo/% 400).

<?php

// A valid octal in a PHP string
echo "\100"; // @

// Emit a warning in PHP 7.1
//Octal escape sequence overflow \500 is greater than \377
echo "\500"; // @

// Silent conversion
echo "\478"; // 8

?>

See also Integers.

1.2.597.1. Suggestions

  • Use a double slash to avoid the sequence to be an octal sequence

  • Use a function call, such as decoct() to convert larger number to octal notation

1.2.597.2. Specs

Short name

Type/OctalInString

Rulesets

All, CompatibilityPHP71, Inventory

Exakat since

0.9.1

PHP Version

With PHP 7.1 and older

Severity

Major

Time To Fix

Quick (30 mins)

Precision

Very high

Available in

Entreprise Edition, Exakat Cloud