syntax error, unexpected token “extends”, expecting identifier

Description

The extends keyword may only be used after a class name, an interface name, or the parenthesis of an anonymous class.

Example

<?php

// this is missing the name of the class
class  extends B {}

// this is missing the name of the interface
interface  extends B {}

?>

Solutions

  • Add a name to the class.

  • Add a name to the interface.

  • Add set of parenthesis to the class to make it anonymous.