What does double question mark (??) operator mean in PHP [duplicate]

I was diving into Symfony framework (version 4) code and found this piece of code:

$env = $_SERVER['APP_ENV'] ?? 'dev';

I’m not sure what this actually does but I imagine that it expands to something like:

$env = $_SERVER['APP_ENV'] != null ? $_SERVER['APP_ENV'] : 'dev';

Or maybe:

$env = isset($_SERVER['APP_ENV']) ? $_SERVER['APP_ENV'] : 'dev';

Does someone have any precision about the subject?

3 Answers
3

Leave a Comment