Complete the code to print a simple message using modern PHP syntax.
<?php
echo [1];
?>In PHP, strings must be enclosed in quotes. Double quotes allow variable parsing and are commonly used for strings.
Complete the code to declare a typed property in a PHP class.
<?php class User { [1] string $name; } ?>
In modern PHP, properties are declared with visibility keywords like public, private, or protected. Here, public is used to allow access from outside the class.
Fix the error in the function declaration using modern PHP return type syntax.
<?php function getCount(): [1] { return 5; } ?>
The function returns an integer value 5, so the return type should be 'int'.
Fill both blanks to create a typed array property with default empty array in a PHP class.
<?php class Product { private array [1] = [2]; } ?>
The property name is '$tags' and the default value for an empty array is '[]' in modern PHP.
Fill all three blanks to create a typed function with nullable parameter and return type in modern PHP.
<?php function findUser([1] ?int $id): ?[2] { if ($id === null) { return null; } return new [3](); } ?>
The function parameter is a nullable int, so no visibility keyword is needed here. The return type is nullable User, and the function returns a new User object.