Post Format

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.

Posted by

Hassan Althaf is a self taught programmer who has taught him self how to code by learning various languages from the internet.

Leave a Reply

Required fields are marked *.