Wordpress Parse Error Syntax Error
If you’ve ever updated a plugin or a theme into your WordPress website, chances are you’ve problem seen the parse error syntax error unexpected end in WordPress message. This is a common error because it only takes one character to cause it.

The following errors suddenly generated?
parse error: syntax error, unexpected t_string wordpress,parse error syntax error unexpected end of file in wordpress,parse error: syntax error, unexpected t_function wordpress,parse error syntax error unexpected text t_string wordpress,parse error syntax error unexpected if t_if wordpress,wordpress parse error syntax error unexpected expecting or ‘;’
As the parse error locked you out of the admin area of your site, and nothing can be done. Fortunately, the error message indicates which part of the code causes the issue which makes it easier to fix. Thus, this article will show you a way to fix the syntax error and restore your website’s function without needing to log in through wp-admin.
Fixing the Parse Error Syntax Error in WordPress
There is one ways to find the parse error if it doesn’t display for you or you’re not sure where it’s coming from. Here’s a look at both methods.
The step is to enable the WordPress error log. Go to your wp-config file using FTP or cPanel. Search for a line of code that looks like this:
define( 'WP_DEBUG', false );
change false to true.
define( 'WP_DEBUG', true );
Load the website. This will display the error and you now have a place to start troubleshooting.
What Causes the Parse Error Syntax Error in WordPress?
The cause of your error will be different than the one shown below, but each error shares similar parts when broken down:
Parse error: syntax error, unexpected '?' in /home/public_html/wp-content/themes/oceanwp/inc/third/class-gutenberg.php on line 313
This tells you there’s a syntax error on your site. Syntax is “the arrangement of words and phrases to create well-formed sentences in a language.”
When a parse error or syntax error occurs, it means something didn’t occur in the order it was supposed to, and that’s where we get into the second part of this error.
The second part of the parse error will say things like “unexpected $end,” “unexpected ‘.’,” etc. This tells you exactly what the problem is. Unexpected $end means you didn’t close something properly. Maybe you forget to add a parenthesis or forgot to close a bracket.
If you get something along the lines of “unexpected ‘?’,” this means you added something you shouldn’t have, a period in this case.
The next part of the error tells you exactly where the problem is located. If you’ve never accessed your site’s files outside of the Editor in the WordPress admin area, you may find yourself getting lost at this point.
Just make sure you make note of this part as it’s telling you the exact file path of where the problem is located.
It’s difficult to see when you only edit files in the WordPress Editor or general text editors, but all of the lines in your files are numbered. That’s what the end of this error is about. It tells you the exact line the error is occurring on, which saves you from having to go through every little bit of code yourself.
Accessing Your Site’s Files via FTP or CPanel
When you can’t edit your files through the WordPress Editor, your best bet is to use an FTP client. An FTP client gives you access to your site’s files through an FTP server. It’s similar to how you access your site’s files through your host in cPanel.
I’m going to reference the error in the previous error as an example. The last part of the file path tells you which file contains the error. This is class-gutenberg.php in the example I gave above.
The rest of the file path tells you exactly where the file is located. If you go backward in the example above, you can see the class-gutenberg.php file is located in the Oceanwp theme’s folder, which is located in the main Themes folder, which is located in the wp-content folder, which is located under “inc” then “third” directory.
The root directory is public_html for most sites, so open that first in FileZilla. Use your own error to locate the file that contains the parse error.
Double-click the file once you find it to download it to your computer.
The easiest way to open a PHP file is to open it using the default text editor on your computer. If you’re having trouble finding the exact line the error is referring to, download a text editor meant for programmers and open the file in that. Go to the line 313 as in the example I gave above. Then just remove the additional “?” or whatever the unexpected is. Save the file and upload it back.
Conclusion
The parse error syntax error unexpected end in WordPress is a common error for anyone handling code. It’s not difficult to fix, but it can sometimes take time to track it down. The steps are simple:
If you’ve added code, start there.If you’ve installed a plugin or theme, deactivate it.When you can’t find the problem, replace the suspected files.When all else fails, restore a backup.
Following a few troubleshooting steps will help get your site running smoothly as fast as possible. If you are experiencing any other issues with your WordPress site or just want a checkup on your configuration, we’d love to help!
The post WordPress Parse error syntax error appeared first on Wordpress Tip Guide Support Solution.
Artikel ini hanyalah simpanan cache dari url asal penulis yang berkebarangkalian sudah terlalu lama atau sudah dibuang :
https://www.jonloh.com/wordpress-parse-error-syntax-error/