UPDATED

Type Declarations in PHP 7 | return

Type declarations simply means specifying which type of variable is being set instead of allowing PHP to set this automatically


Written By

0 contributions

112 Views 2
 
 Tags    #tech(6)  

Return type declarations

Array

function getTotal(float $a, float $b) : array {
    return [];
}

boolean

function getTotal(float $a, float $b) : bool {
    return 1 == 1;
}

Integer

function sum(int $a, int $b) : int {
    return $a + $b;
}