Complete the code to enable strict types in PHP.
<?php [1] function add(int $a, int $b): int { return $a + $b; }
The declare(strict_types=1); directive enables strict type checking in PHP.
Complete the code to correctly declare strict types at the top of the PHP file.
<?php
[1]
// Your code here
The correct syntax to enable strict types is declare(strict_types=1);.
Fix the error in the strict types declaration.
<?php [1] function multiply(int $x, int $y): int { return $x * $y; }
The strict_types directive must be set to 1 to enable strict typing. Other values or missing values cause errors.
Fill both blanks to correctly declare strict types and define a function with strict typing.
<?php [1] function divide(int $a, int $b): float { return $a [2] $b; }
Strict types are declared with declare(strict_types=1);. The division operator is /.
Fill all three blanks to declare strict types, define a function, and return the sum of two integers.
<?php [1] function sum([2] $x, [3] $y): int { return $x + $y; }
Strict types are declared with declare(strict_types=1);. The function parameters are typed as int to match the return type.