PHP 8.5.0 Alpha 2 available for testing

Voting

: seven minus four?
(Example: nine)

The Note You're Voting On

boan dot web at outlook dot com
7 years ago
Quote:

"The declaration can be made to accept NULL values if the default value of the parameter is set to NULL."

But you can do this (PHP 7.1+):

<?php
function foo(?string $bar) {
//...
}

foo(); // Fatal error
foo(null); // Okay
foo('Hello world'); // Okay
?>

<< Back to user notes page

To Top