Verification: a143cc29221c9be0

Php 7 function return type


Default Weak Mode

By default PHP uses the Weak mode. The documentation explains it in the following way:

In the default weak mode, returned values will be coerced to the correct type if they are not already of that type

For example, see the following example where the function returns a string, even though the defined return type is int

function myInt() : int {
    return "1";

echo gettype(myInt());
// Output is "integer"