PHP errors are frustrating problems on your WordPress site. If you do not fix it, then it slow down your frontend pages, freeze plugins, and affects on SEO rankings, and even take you out from your website.
If you have business website, then you must fix PHP errors quickly, to prevent your SEO rankings from down badly.
In this guide, we will tell you common PHP errors with its solutions.
Table of Contents
ToggleCommon PHP Errors
There are some common PHP errors that affect your website. Below, we tell you common PHP errors with their solutions.
1. Syntax Errors
- Example:
Parse error: syntax error, unexpected ‘}’
- Cause: This error occurs because of missing elements or typos like semicolons, brackets, or quotation marks.
- Solution: To resolve this error, you must check recent code edits in theme or plugin files and correct the syntax mistakes.
2. Deprecated Functions
- Example:
Deprecated: Function get_magic_quotes_gpc() is deprecated
- Cause: This error occurs because of outdated functions used in your code that do not supported in newer PHP versions currently.
- Solution: To fix this error, you should update your theme or plugins with the latest version. If you’re performing coding, then you should replace deprecated functions with the recommended options that are compatible to latest PHP standards.
3. Fatal Errors
- Example:
Fatal error: Call to undefined function function_name()
- Cause: Fatal errors are occurs when WordPress tries to call missing or undefined function. It cause if a required plugin or theme is deleted or deactivated. This error also occurs if you call a typo function in the code.
- Solution: To solve this error, you must check your error logs, find out the missing function and either reinstall or reactivate the required plugin or theme. Alternatively, you can also check your plugin or theme files to ensure that all dependencies are intact and loaded properly.
How to Resolve PHP Errors in WordPress
Once you know the causes of PHP errors on WordPress, you must know the solutions to fix them.
Here is step by step guide you should follow to resolve this error:
1. Enable Debugging in WordPress
To resolve the PHP error, you should enable WordPress debugging to dive deep into the cause of this issue.
Here how you can easily enable debugging:
How to enable debugging:
- Navigate to your website files via the hosting control panel or FTP.
- Now, Open the
wp-config.php
file in the root WordPress directory.
- Add or update these lines:
define( 'WP_DEBUG', true ); define( 'WP_DEBUG_LOG', true ); define( 'WP_DEBUG_DISPLAY', false );
- Next, Save the file.
- In this way, you are able to see PHP errors in
wp-content/debug.log
for review.
The above steps log PHP errors to a file called debug.log
in the wp-content
directory and allow you to review these errors to fix it.
2. Increase PHP Memory Limit
If your wordpress site is run out of memory, then also it cause PHP error. So, the easy solution to fix it by increasing the memory limit. It allows your WordPress site to run smoothly.
Let us tell you step by step guide to increase memory limit and fix this error:
How to increase PHP memory limit:
- Access Your Hosting Account:
- Go to cPanel and Log to your hosting account.
- Open File Manager and move to the public_html directory.
- Edit wp-config.php File:
- Now, you should find the wp-config.php file and right-click on it.
- Select on Edit option to open it.
- Update Memory Limit:
- To update the memory limit, look for the line that reads
define( 'WP_MEMORY_LIMIT', '32M' );
- Now, Change the value from
'32M'
to'256M'
:define( 'WP_MEMORY_LIMIT', '256M' );
- To update the memory limit, look for the line that reads
- Save and Exit:
- If you can’t locate the line, then you should insert it above the line that reads
/* That's all, stop editing! Happy publishing. */
- Tap on Save Changes after you make all changes and exit the file.
- If you can’t locate the line, then you should insert it above the line that reads
The above steps will increase the memory limit to 256MB. If you still face errors, then you can follow the next solutions in this guide.
3. Deactivate All Plugins
The another common cause of PHP errors is plugin conflicts. To check if this is an error, you should deactivate all plugins and check if the error occurs or not.
Here is how you can easily deactivate all plugins on the WordPress site:
How to deactivate plugins:
- Log into your WordPress dashboard.
- Move to Plugins → Installed Plugins.
- Select all plugins, and tap on on Deactivate button, then click on Apply to save changes.
If still this error occurs after deactivating all plugins, then you should reactivate all plugins one by one and find out a specific plugin that causes this error.
4. Switch to a Default Theme
If you do not find any plugins that cause PHP errors, then it may caused due to theme conflicts. So, you must switch to the default WordPress theme to check if the error occurs by the theme.
How to switch to the default theme:
- Move to Appearance → Themes.
- Activate a default theme (e.g., Twenty Twenty-One).
- Check if PHP error is fix.
If the error is resolved, then you should update your original theme or switch to the default theme or compatible themes.
5. Check for Syntax Errors
If syntax errors are the reasons behind PHP error, then you should check your code (e.g., in a custom theme or plugin) for missing braces, semicolons and parentheses.
- Find the error message in
debug.log
to locate the file and line number where the error arises.
- Cross-check the code in this file to fix any errors.
- If you’re not sure, then contact with your developer to get more support.
6. Update WordPress, Plugins, and Themes
Outdated themes, plugins, or WordPress can cause PHP errors and compatibility issues. So, ensure that everything is updated so your WordPress site works smoothly.
How to update WordPress, plugins, and themes:
- Move to Dashboard → Updates.
- Update WordPress, plugins, and themes to their latest versions.
7. Check File Permissions
PHP errors are also caused because of Incorrect file permissions. So, you should check that your WordPress files and folders have the correct permissions.
Correct file permissions for WordPress:
- Files should be set to
644
. - Folders should be set to
755
.
You can check and update these permissions by using FTP client like FileZilla or through cPanel file manager.
Checkout our detailed guide on Fix WordPress File and Folder Permissions — to get more information! 💡
8. Contact Your Hosting Provider
After trying all above solutions, if you face the PHP errors, then you must contact with your hosting provider. There are some limitations set by the hosting provider that cause this error.
What to ask your hosting provider:
- Ask the hosting provider to check the PHP error logs.
- Check that your server meets the PHP version requirements for the WordPress site (ideally PHP 8.0 or higher).
- Ask if they can change serve settings or increase the memory limit to fix this error.
9. Consult PHP Documentation
If you face complex PHP errors, then you should check the PHP’s official documentation or WordPress-specific PHP resources. The documentation gives you valuable insights about syntax and functional and resolve these technical errors.
FAQs about to Fix PHP Errors in WordPress
PHP errors can occur due to various reasons like outdated plugins, theme conflicts, memory issues, or incorrect code syntax.
PHP errors can slow down your website, break functionality, and even affect your SEO rankings, leading to poor user experience.
Fatal errors happen when WordPress calls a missing or undefined function. To resolve this, you can reinstall or reactivate the required plugin or theme.
You can increase the memory limit by editing the wp-config.php file and setting WP_MEMORY_LIMIT to a higher value (e.g., 256M).
Deactivate all plugins, and if the error disappears, reactivate them one by one to identify the problematic plugin.
Check and adjust the file permissions for WordPress files (644) and folders (755) using an FTP client like FileZilla or cPanel.
Final Word
Identify and resolve PHP errors on WordPress is important to maintain user experience, functionality and security. By follow above step by step guide, use plugins and tools, check correct file permissions, you can ensure that your site is error free and optimized. It gives you a secure and seamless user experience and maintains your site integrity.