Function return type in PHP 7 and void return type in PHP 7.1

One of the beautifull feature of programming languages came out in PHP 7 that now we also can have function return type in PHP like we have in other languages like Java, C, C# etc..
So PHP 7 adds support for return type declarations.
Now we can force a function to return a specific type of data.

In PHP 7 we have following function return types:
int : Integer data type.

float : Float data type.

array : Array data type.

bool : Boolean data type.

string: String data type.

Class/Interface name : Name of the class.

self : Instance of the same class. This can only be used if function is created under any class.

callable : Valid PHP callable.

 ...  Read More

Share This: