syntax error, unexpected string content

Description

This error appears when a single quote string is not properly closed. In the example, there is an opening single quote, but not a closing one. PHP tries to use the rest of the code as a literal string, and ends up without tokens to wrap up the code legally.

Example

<?php

{ $a = '1+2; }

Solutions

  • Close the string with a single quote.

  • Close the string with a double quote.