New Features in PHP 5.6 Available For You at WebHostFace

Who said PHP 5.6? We’re happy to announce that the latest version of the widely-used scripting language is available for our customers.

PHP has emerged as a procedural programming language but it has long since proven to have one of the most flexible syntaxes for object-oriented programming.

Some of the recent changes extend this flexibility even further. Others include new functions like extended OpenSSL functionality, on-the-fly adding of passwords for Zip archives, and a new interactive debugger (PHPdbg).

Here are the most notable of them:

Constants

Another core functionality that has been extended are constants. It is now possible to use math operators or add other constants in their values. For example, you can now include the following expressions in your PHP script when running v5.6:

const ONE = .02 + .05;
const TWO = ONE * 2;
const THREE = TWO + 1;

Changes to memory usage and uploads

Up until now you couldn’t upload files larger than 2GB with PHP scripts. Now it is possible to extend this maximum upload file size beyond those numbers.

In addition to this, the POST data requires two or three times less memory usage than with its predecessor.

Variadic functions and argument unpacking

The ‘‘ operator is some of the new things in PHP 5.6 syntax. For those who program in Ruby, this may be known as the splat operator.

We can now assign all the entries of an array as parameters to functions and methods. This is called a variadic function because we can now give them a changeable number of attributes.

Here’s a simple example:

function add(...$numbers) { return array_sum ($numbers); }

This is far more flexible than using a predefined number of variables like pre-PHP 5.6:

function add ($x, $y, $z) { return $x + $y + $z;
# in this case we give the function only three arguments }

We can also use the ‘‘ operator for the opposite – to pass the values of an array to a function with the same number of arguments as the array values. This is called argument unpacking.

Let’s say we have the following array:

$numbers = array [ 1, 5, 7 ]; function add ($x, $y, $z) { echo $x + $y + $z; }

This syntax would work in PHP 5.6:

add ( ...$numbers ); add (...[1, 5, 7]);

In 5.5 and previous this would return an error. In PHP 5.6 the entries of the array $numbers will be used as arguments for the function.

Add password to zip archives:

You can use this new functionality to increase the security of the zip archives you can generate with your scripts.

You can use the following method:

ZipArchive::setPassword('password-string');

Our DevOps team has succeeded in crafting and implementing our own custom PHP tools. You can find and try them out in your cPanel under the “WebHostFace PHP Tools” section.

We want to remind you that versions 5.3 and lower will not receive any major support from the PHP team anymore. Changing the version you are using to a supported one is highly advisable. This will improve your website’s security since this way the PHP version you are using will get the needed bug fixes.

You can always contact us if you are having any issues with switching to a newer PHP version. Our technical support team is available 24/7.

Which programming language do you like using, are you excited about the new PHP 5.6? Do tell us in the comments below!

Exit mobile version