Backed enum “Fruit” is created

You have created a backed enum “Fruit” as follows in PHP.

<?php

enum Fruit: string

case Apple = ‘A’;

case Lemon = ‘L’;

case Orange = ‘O’;

case Tomato = ‘T’;

}

?>

In the given context, what will happen if a variable is assigned as a reference to the backed case Lemon?

Options
  1. The value property of Lemon is enforced to be read-only
  2. The following error is thrown:
  3. Error: Cannot acquire reference to property Fruit::$value
  4. The value L is printed
  5. A ValueError is thrown

Related Posts