Scalar type declarations in PHP 7 ?

In PHP 7, introduced Scalar type declarations, has been . Scalar type declaration has two options −

coercive – coercive is default mode and need not to be specified.

strict – strict mode has to explicitly hinted.

It support gollowing types for function parameters,

int,float,bool,string,interfaces,array,
callable.

Scalar type declaration : Coercive mode
<?php

function sum(int …$ints) {
return array_sum($ints);
}
print(sum(2, ‘4’, 6.1));

?>

Output : 12
 

Scalar type declaration : Strict mode
<?php

declare(strict_types=1);
function sum(int …$ints) {
return array_sum($ints);
}
print(sum(2, ‘4’, 6.1));

?>

Output :
 PHP Fatal error: Uncaught TypeError: Argument 2 passed to sum() must be of the type integer, string given, called in……