News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Lorna Mitchell:
PHP 5.6 and the Splat Operator
March 17, 2014 @ 09:05:36

Lorna Mitchell has a new post to her site looking at a feature of the upcoming PHP 5.6 release, the splat operator (three ellipsis...).

We have a couple of new features coming in to PHP 5.6 with names that sound much less exciting than the features they actually represent: "variadic functions" sound positively academic, and "argument unpacking" isn't exactly catchy. However they both use a new operator in PHP which looks like an elipsis (three dots ...) and is referred to as either the splat operator or the scatter operator. I included them in a recent version of my "Upgrading PHP" talk so I thought I'd share the examples here too in case anyone is interested.

She includes an example of it being used in a variadic function, one that lets you define an optional number of parameters without having to resort to func_get_args. She also talks about "argument unpacking" or the passing in of an array of values with the splat to have it handled like a string. An example with the mail function is included.

0 comments voice your opinion now!
php56 splat operator variadic function argument unpacking

Link: http://www.lornajane.net/posts/2014/php-5-6-and-the-splat-operator

blog comments powered by Disqus

Similar Posts

Dhiraj Patra's Blog: Caching PHP Programs with PEAR

Rails for PHP Developers: Three New Articles Posted (Scope, Variables & RegEx)

Ben Ramsey: Introducing Array_column() in PHP 5.5

PHPit.net: A beginners introduction to PHP\'s file functions

Fabien Potencier's Blog: On PHP 5.3, Lambda Functions, and Closures


Community Events

Don't see your event here?
Let us know!


series laravel api podcast video laravel5 unittest extension voicesoftheelephpant release framework library community psr7 language wordpress opinion introduction development interview

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework