syntax error, unexpected token “<<”

Description

This error might be related to the left bitshift operator, although it is often related to a git diff leftover. Here, a merge conflict was left in the code, and the first and erroneous characters are <<.

There are other possibilities of error with that operator, although they are less common.

Example

<?php

<<<<<<< HEAD
    $a = 2 * $b;
=======
    $a = 3 * $b + 1;
>>>>>>> e0ce25cd1fe156c2f50def834532e489b923dcef

?>

Solutions

  • Remove the diff from the code, as it doesn’t compile.

  • Fix the merge conflict.