# New features in PHP 5.6

## New features in PHP 5.6

There are some very exciting features  in PHP 5.6 release. In this article we will look into new features introduced in PHP 5.6.

Before PHP 5.6 upload limit was less then 2 GB but in PHP 5.6 uploads over 2GB are supported.

Varidaic functions are the functions that can take any number of arguments. Previously func_get_args was used when we have to pass arbitrary number of arguments.

### Versions before PHP 5.6

function sum()
{
return array_sum(func_get_args());
}



echo sum(1, 4, 12, 20);

echo sum(1, 4, 12);

### PHP 5.6

function sum(...$nums) { return array_sum($nums);
}



echo sum(1, 4, 12, 20);

echo sum(1, 4, 12);

Look at the function defination

function sum(...$nums) Three dots (…) are used before the variable $nums

This variable will accept arguments.

## Constant Scalar Expressions

Before PHP 5.6 while declaring a constant we cannot use expressions for assigning a value to constant. but in PHP 5.6 we can now have basic arithmetic and logical structures in constant declarations, functions arguments, class properties etc.

Like:

const ONE = 1;
const TWO = ONE * 2;
const THREE = TWO + 1;


## PHPDBG bundled with PHP

phpdbg provides an interactive environment to debug PHP and is implemented as distributed as SAPI module, Just as a CLI interface.

## Importing Namespaced Functions

Before PHP 5.6 to import namespaced  functions using  use statement

namespace foo\bar {
function baz() {
return 'foo.bar.baz';
}
}

namespace {
use foo\bar as b;
var_dump(b\baz());
}

FBut now from PHP 5.6, we  can use  use function and use const statements to import a  function or constant from a namespace.

namespace {
use function foo\bar as foo_bar;
use const foo\BAZ as FOO_BAZ;
var_dump(foo_bar());
var_dump(FOO_BAZ);
}

In next article we will explore more features introduced in PHP 5.6.  If you need a brief introduction about PHP then you can read this post.

Tags:,