{"id":1596,"date":"2019-02-08T10:35:53","date_gmt":"2019-02-08T10:35:53","guid":{"rendered":"https:\/\/blog.hostinger.io\/support\/2019\/02\/08\/1583196-how-to-fix-the-unexpected-t_string-error-at-hostinger\/"},"modified":"2026-08-11T09:14:48","modified_gmt":"2026-08-11T09:14:48","slug":"1583196-how-to-fix-the-unexpected-t_string-error-at-hostinger","status":"publish","type":"post","link":"https:\/\/www.hostinger.com\/support\/1583196-how-to-fix-the-unexpected-t_string-error-at-hostinger\/","title":{"rendered":"How to fix the &#8220;Unexpected T_STRING&#8221; error at Hostinger"},"content":{"rendered":"<p>Fix the &ldquo;Unexpected T_STRING&rdquo; error at Hostinger &mdash; a PHP syntax error, usually caused by a typo such as a missing apostrophe, quotation mark, extra\/missing space, or incorrectly commented-out code.<\/p><h2 id=\"h-find-and-fix-the-syntax-error\">Find and fix the syntax error<\/h2><p class=\"no-margin\">The error message will contain useful information, such as the filename and line where it occurs. To fix it, open the file using the <b><a class=\"intercom-content-link\" href=\"https:\/\/www.hostinger.com\/support\/7949267-how-to-use-the-file-editor-at-hostinger\/\" target=\"_blank\" rel=\"noopener\">File Editor<\/a>, <\/b>go to the line mentioned in the error message, and edit the line according to the error message, such as adding any missing syntax element.<\/p><p id=\"h_5f11c76ecf\"><strong>Example<\/strong><\/p><p class=\"no-margin\">From this error message:<\/p><pre><code>Parse error: syntax error, unexpected '&lt;', \r\nexpecting end of file in \/home\/u123456789\/public_html\/test.php \r\non line 7<\/code><\/pre><p class=\"no-margin\">The following information can be extracted:<\/p><ul>\n<li>\n<p class=\"no-margin\">The error happened in the <b>test.php<\/b> file, located in the <b>public_html<\/b> directory &ndash; this is the file that needs to be edited and its location<\/p>\n<\/li>\n<li>\n<p class=\"no-margin\">The error occurred on <b>line 7<\/b> of the file. The File Editor will also display an &#10060; sign, and the same error message if you hover over it:<\/p>\n<\/li>\n<\/ul><div class=\"intercom-container intercom-align-center\"><img decoding=\"async\" src=\"\/support\/wp-content\/uploads\/sites\/55\/2019\/02\/2dd558dc-0ec5-4a0b-bc63-cda462835077.jpg\" alt=\"Code editor showing PHP syntax error, unexpected '\" data-media-id=\"5498\"><\/div><p class=\"no-margin\">On this file, the PHP code was opened by writing <b>&lt;?<\/b> but it was not closed, therefore missing a <b>?&gt;<\/b><\/p><p class=\"no-margin\">This is why the <b>&lt; <\/b>symbol in the next line is unexpected.<\/p><p class=\"no-margin\">After you add the missing code, your file should work:<\/p><div class=\"intercom-container intercom-align-center\"><img decoding=\"async\" src=\"\/support\/wp-content\/uploads\/sites\/55\/2019\/02\/9065f4f3-8bd2-4602-92af-cfe633259b2a.jpg\" alt=\"Browser displaying a test.php page with &ldquo;Hello, world!&rdquo; text and the address bar visible\" data-media-id=\"5500\"><\/div><p><strong>NOTES<\/strong><\/p><ul>\n<li class=\"no-margin\">If you encounter difficulties fixing the syntax errors, you can <b><a class=\"intercom-content-link\" href=\"https:\/\/www.hostinger.com\/support\/4283700-how-to-restore-backups-at-hostinger\/\" target=\"_blank\" rel=\"noopener\">restore your website<\/a> <\/b>to a previously working state.<\/li>\n<li>If you&rsquo;re encountering a different kind of server error, see <a href=\"https:\/\/www.hostinger.com\/support\/4714113-troubleshooting-5xx-errors-at-hostinger\/\">troubleshooting 5xx errors at Hostinger.<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Fixing &#8220;Parse error: syntax error Unexpected T_STRING error&#8221;<\/p>\n","protected":false},"author":581,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"include_on_kodee":true,"footnotes":""},"categories":[230],"tags":[],"class_list":["post-1596","post","type-post","status-publish","format-standard","hentry","category-php-advanced"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/support\/1583196-how-to-fix-the-unexpected-t_string-error-at-hostinger\/","default":1},{"locale":"es-ES","link":"https:\/\/www.hostinger.com\/es\/support\/1583196-como-solucionar-el-error-unexpected-t_string-en-hostinger\/","default":0},{"locale":"fr-FR","link":"https:\/\/www.hostinger.com\/fr\/support\/1583196-comment-corriger-une-erreur-unexpected-t_string\/","default":0},{"locale":"id-ID","link":"https:\/\/www.hostinger.com\/id\/support\/1583196-bagaimana-cara-mengatasi-error-unexpected-t_string-di-hostinger\/","default":0},{"locale":"uk-UA","link":"https:\/\/www.hostinger.com\/ua\/support\/1583196----unexpected-t_string--hostinger\/","default":0}],"include_on_kodee":true,"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/1596","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/users\/581"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/comments?post=1596"}],"version-history":[{"count":3,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/1596\/revisions"}],"predecessor-version":[{"id":15280,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/1596\/revisions\/15280"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/media?parent=1596"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/categories?post=1596"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/tags?post=1596"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}