<<< Previous question <<< Question ID#0506.md >>> Next question >>>
What is the result of the following code?
function foo(string $a, ?string $b) : ?int {
return $b ? $a <=> $b : null;
}
echo foo('PHP', 7);
- A) 1
- B) A type error because function should return int but instade return string;
- C) 0
- D) A syntax error because ?string and ?int does not exist in PHP7
Answer
Answer: A