All Collections
Website development
How to fix an "Unexpected T_STRING" error?
How to fix an "Unexpected T_STRING" error?
Fixing "Parse error: syntax error Unexpected T_STRING error"
Updated over a week ago

This type of error (syntax error) usually happens because of a typo in your code, such as a missing apostrophe/quotation mark/a missing or extra space, or code that has been commented out incorrectly.

To fix it, in the File Manager:

  1. Open the file mentioned in the error

  2. Find the line, where the issue occurs (it is mentioned in the error message as well)

  3. Find the syntax mistake and fix it


For example, for this error message:

Parse error: syntax error, unexpected '<', 
expecting end of file in /home/u123456789/public_html/test.php
on line 7

We have the following information:

  • The error happened in the test.php file, located in the public_html - that's the file which we'll open and fix

  • "on line 7" shows, on which line the error occurred. You will also see the ❌ sign in File Manager, and the same error message if you hover on it:

What you need to do to fix the issue, is to find the missing syntax element. In the example above, we opened the PHP code part (with <?) but never closed it (with ?>) - that's why < symbol is unexpected for the File Manager.

After you add the missing code, your PHP file should work again:


Did this answer your question?