Question from the PHP8 test

PHP code that throws an error.

Hard

What will this code display?

<?php

class Foo
{
    private ?string $bar;

    public function setBar(?string $secondLine): void
    {
        $this->bar = $secondLine;
    }

    public function getBar(): ?string
    {
        return $this->bar;
    }
}

$foo = new Foo();
echo $foo->getBar() ?? 'john doe';
Author: W3D TeamStatus: PublishedQuestion passed 1160 times
Edit
7
Community EvaluationsNo one has reviewed this question yet, be the first!