How to fix WordPress Parse errors • WordPress Help

In this article we will see what they are and how to solve the errors of Parse (Unespected, Undefined Constant and Syntax) from WordPress but let it be clear in advance that almost always the fault will be yours, then do not get mad.

What are mistakes Parse ?

In PHP, an error parse is basically when a code does not finish executing, it returns an unexpected response, something slows the execution and returns an error of the code.

There are several types of errors parse :

  • Syntax error – They are usually due to problems with hyphens, brackets or quotes used in the code. Either they are missing or the ones included are not correct. A very common mistake is to include typographical quotes instead of normal, to use a text editor instead of a code editor.
  • Unexpected error – It is when you forget to include an opening or closing character in brackets, quotes , etc.
  • Undefined constant error – It is usually due to a missing character in a array that refers to variables.

When errors appear Parse ?

As I warned you at the beginning of the article, are almost always due to the fact that you have added some type of code on your website with some of the errors noted above.

They can also be due to a poorly programmed plugin or theme of course.

But come on, that the most common is when you copy and paste codes here or there and for some reason you're missing something from same or some character is wrongly copied.

Structure and you Error Parse

So that you learn to distinguish them and identify what causes them here is the basic structure of the code errors I mentioned earlier and how they will be displayed in your WordPress when they occur.

It is important that you notice the details that I highlight, to identify where the specific error is in each case.

Structure type of Syntax errors

"Parse error: syntax error, unexpected character in path / to / php-file.php on line number "

Structure type of errors of Undefined constant [19659017] "Notice: Use of undefined constant constant string – assumed ' constant string ' in path / to / file-php.php on line number "

Structure type of errors Unexpected

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

Help notes in identifying the problem

  • In the errors of undefined constant the so-called constant string may be a string, since PHP sometimes refers to unidentified elements as constant strings
  • Errors in unexpected may display a list of characters instead of a single character.
  • The number refers to the line number of code in the affected file, and it will be replaced by real numbers (18, 514, 994, etc), and sometimes these lines may not be exact and you have to look for the error on your own.
  • The file indicated in the error message is where the problem persists, and the line number gives you a clue as to where to start looking for the problem. It is usually on that line a little earlier.
  • The names of the character or of the constant string of the error structure will give you an idea of ​​what to look for in the number of line indicated (or earlier).

Errors Parse most common

There are many possible errors, and the structure will be the best indicator of where the error occurred, but I would always recommend it first look for some of this too:

  • Make sure there is only one <? php opening and only one ?> closing per file
    • Search them in the middle of the file , surely in codes copied from blogs
    • Search for added code after closing tag ?>
    • Search for added code before opening tag <? php
    • ]

  • Search for broken functions because of others.
  • Search for empty lines after the closing tag ?>
  • Whenever you add new codes, for example to your file functions.php add it at the end, and always before the label close ?> if any.

How do I avoid mistakes Parse ?

Ideally, you should learn PHP, since knowledge of a language is what most helps you to detect at first sight errors in your code .

It is not difficult, I am of letters and little by little, with desire, in a self-taught way, I am defending myself, and I can identify many errors at first glance (and I'm also wrong, of course)

But, you can always / must check your codes before applying them to a website or converting them into a plugin . Here are some tools that can help you:

How do I fix the errors Parse ?

If you have taken note of the structure of the errors we have seen above, you know what to look for and where.

You only have go to the file in which they were caused and identify the line / character / constant that generates it and modify it .

Access via FTP or the file panel of your hosting, whatever you prefer, and edit the file with a code editor (important).

These programs will help you quickly identify problems, as it includes line numbering and color code syntax, which It helps to detect errors.

My recommended ones are these:

My advice is that delete the complete code fragment that causes the error, check its syntax and fix the problems before returning to insert it . If you do not know how to fix it, ask for help, right here, or in the forums .

Do not forget: If you copied the code from another website, notify the author, and if the error is in a plugin or theme warns the developer, so that they fix it and it does not happen to others.

Final note

The worst enemy of code errors are nerves so if you come across some error Parse in WordPress remembers that they are easy to identify, and to solve .

To little that you follow the indications of this article you will be able to solve them in few minutes, and of course you will have learned something.

Loading …

That may also help you: