All Posts Tagged ‘php7.1


Void return types coming in PHP 7.1!

Leave a reply

As we all know the fact that we will have the ability to declare the return types from PHP 7 onwards, there might also be situations where you may not want to return anything, and therefore, an RFC regarding void return types was initiated, which requested the implementation of the void return type for methods or functions which will indicate that there is nothing to be returned by the function or method.

You could declare the return type as void for a function or method this way:

function returnNothing(): void {
    //perform operations

After a vote between some PHP internal members, this idea received 37 positive votes against 7 negative, and therefore, was decided as approved for PHP 7.1 as you can see in this message here.