There are a number of WordPress errors that are present on your site that often manage to make it unusable:

"Parse error: syntax error, unexpected ..."
"Notice: Use of undefined constant ..."
"Parse error: unexpected ..."

All you did was add some code to adjust the look of your site slightly. So, what really happened?

Fortunately, these errors can be easily resolved by correcting the code you added. Read on to find out more about correcting these errors.

What is an analysis error?

In the context of PHP, parsing is what happens when your code is being converted from a series of characters to the final result that the visiteurs will see on your site.

These errors occur when the PHP code cannot start or finish being parsed for some reason. It could be that the file or the database data is unavailable, damaged or your version of PHP is not compatible with WordPress, file permissions are not set correctly, your server ran out of PHP memory or there is a structural error in the code.

In WordPress, the latter is usually what you can meet the most and there are three main types:

  • Syntax error  - There are issues with semicolons or braces or quotes that were used. Either their lack or misuse.
  • Unexpected error  - You forgot to include a character like an opening or closing support or other possible characters.
  • Constant "Undefined" error  – A character is missing in a table, when SEO of a variable or other possible scenarios.

Keep in mind that these three types of parsing errors have a lot of different variations depending on the specific error in the code.

How to correct analysis errors

The parsing error might sound scary, but it is one of the simpler mistakes to fix. Somewhere in the code you just added there is an item that you need to fix to make the error go away.

If you just added some code yourself or if you installed a plugin or theme before the error appeared, this is where you need to start looking. Removing the snippet, plugin, or theme should fix the issue or you can go ahead and fix the error yourself.

There is a great way to refine the search and know exactly where you need to explore the code to correct the error.

Here are the structures of the parsing errors that you are more likely to encounter:

“Parse error: syntax error, unexpected in path / to / php-file.php on line [number]“

“Notice: Use of undefined constant - assumed '' in path / to / php-file.php on line [number]“

Unexpected errors may have variations, but they generally look like this:

"Parse error: unexpected in path / to / php-file.php on line [number]"

Keep in mind that for errors on undefined constants, the named constant may actually be a string that was not correctly used.

Likewise, Unexpected parsing errors may enumerate a string instead of a character.

In each of these examples, we number Indicates the line where the error is, but sometimes it's number are not always correct.

The file indicated in the error message indicates the origin of the file, and the line number gives you a clue as to where to look for the error. It's either on this line or a bit ahead.

The term " character "or " Constant string In these examples give you an idea of ​​what to look for in the given row number. This is what needs to be corrected, where it relates to what needs to be corrected.

Now that you know where you are looking for, you can connect to your site using your favorite FTP client to locate the file and either edit it directly in your FTP client, or you can download it to your computer, edit it, and then download it. 'send back to your site.

How to avoid these mistakes

Avoiding these mistakes is as easy as correcting them if you are at least a little familiar with PHP. You can check your code for syntax errors automatically by placing it in a PHP code validator.

Here are some free validators that you can use:

Here are some tips of the most common syntax errors that you can check first:

Make sure there is only one opening of the PHP tag ( ).

Search for forgetting cases of PHP tag closing

If you add the code, make sure it is included before a closing tag and not after

That's all for this tutorial, I hope it will allow you to fix the analysis errors on WordPress. Feel free to share it with your friends on your favorite social networks.