PHP 5.6: Major Features

PHP 5.6 is the last major 5.x release before the PHP 7 engine leap: variadic functions (function foo(...$parts)), argument unpacking in calls (foo(...$args)), an ** exponentiation operator, use function / use const alongside classes in namespaces, constant expressions (including for default property values), ... in trait use blocks, and phpdbg for debugging. Default UTF-8 handling improves for several string functions when configured. Migration focus: operator precedence with **, unpacking edge cases, and tightening around TLS, json_decode, and extensions as you approach PHP 7.

Use migration56 as the hub for sub-pages.

Table of Contents


Variadic parameters

function sum($first, ...$rest)
{
    return $first + array_sum($rest);
}

Replaces many func_get_args() patterns with readable signatures.

Argument unpacking

$args = [1, 2, 3];
echo sprintf('%d-%d-%d', ...$args);

Works with user-defined functions and many internals—verify edge cases with references and by-name expectations in your codebase.

Exponentiation **

Right-associative: 2 ** 3 ** 2 is 2 ** (3 ** 2). Audit math expressions that mixed pow() and inline operators.

use function / use const

namespace App;

use function SomeLib\helper;
use const SomeLib\VERSION;

Keeps namespace imports explicit for functions/constants, not only classes.

Constant expressions

Class constants and static default property values may use compile-time expressions (including other constants, literals, and allowed operators)—reduces magic numbers when bootstrapping config objects.

phpdbg & misc

phpdbg is an interactive debugger SAPI—useful for stepping through CLI scripts. ... in traits can pull in methods from multiple traits with explicit conflict resolution similar to classes.

Practical recipes

Replace call_user_func_array noise

Where you built arrays only to forward arguments, prefer ...$params.

Safe exponentiation

Prefer ** for readability in new code; keep pow() when you need a float-specific path on older branches.

Backward incompatible changes

Highlights (migration56 incompatible):

  • ** precedence vs unary operators—parenthesize legacy expressions when porting.
  • json_decode() failures: true/false/null become JSON_ERROR_SYNTAX in stricter cases—audit APIs that relied on loose acceptance.
  • Mcrypt, GD, OpenSSL: several signature and cipher behaviors tightened—retest encryption and thumbnail pipelines.
  • foreach on properties: subtle changes when mixing by-reference and property visibility—exercise unit tests around ORM-like objects.
  • TLS peer verification defaults trend stricter across PHP + OpenSSL versions—your “works on 5.5” curl code may need explicit options.

Deprecated

  • $HTTP_RAW_POST_DATA—use php://input.
  • iconv / mbstring settings: some ini defaults deprecated or realigned—see migration56 deprecated.

Other notes

  • hash() and friends gained hash_equals() in 5.6—use for timing-safe string compares of MACs.
  • SSL/TLS hostname verification improvements—plan for certificate chains and SNI in outbound HTTP clients.

Closing thoughts

PHP 5.6 closes the 5.x story: you get modern call syntax without waiting for PHP 7. After stabilizing here, plan the big jump to PHP 7.0+ for scalar types, Throwable, and massive performance gains—this guide series continues at the 7.0 article.