Read and fix common PHP errors
PHP prints or logs an error when it can't run your code. Every message names a file and a line number, which is where to look. See Read your site's error log to find the log.
Read one error
PHP Fatal error: Uncaught Error: Call to undefined function mb_strlen()
in /home/nsbakery/public_html/wp-content/plugins/menu-pro/menu.php:41
Stack trace:
#0 /home/nsbakery/public_html/wp-content/plugins/menu-pro/loader.php(12): menu_render()
| Part | Meaning |
|---|---|
Fatal error |
Severity. Fatal stops the page. Warning and Notice don't |
Call to undefined function mb_strlen() |
What went wrong |
/wp-content/plugins/menu-pro/ |
The plugin that failed. This is the culprit |
menu.php:41 |
File and line |
Stack trace |
The path of calls that led there. Read it from the bottom if you need to |
The folder name inside wp-content/plugins or wp-content/themes tells you which plugin or theme to blame.
Symptom, cause, fix
| Message | Meaning | Fix |
|---|---|---|
Allowed memory size of 134217728 bytes exhausted |
Script used more memory than allowed | Raise the limit. See Raise the WordPress memory limit |
Maximum execution time of 30 seconds exceeded |
Script ran too long | Raise Time limit per request under Performance → Choose PHP for each site → PHP settings (see Change PHP settings), or break up the job |
Call to undefined function ... |
A PHP extension is off, or code needs another version | Turn on the extension under Performance → Extensions. See Change PHP version and extensions |
Parse error: syntax error, unexpected ... |
A typo in a PHP file, often after editing by hand | Fix the line named, or restore the file |
Cannot redeclare function_name() |
Two plugins or files define the same function | Deactivate one. See Find a plugin causing problems |
Class 'X' not found |
A required file is missing or an update was incomplete | Reinstall the plugin or theme |
Warning: Cannot modify header information - headers already sent |
Output happened before the page started, often a space or blank line before <?php in wp-config.php or a theme file |
Remove blank lines and spaces before <?php and after the closing ?> |
Deprecated: ... |
Code uses a feature being removed | Not an error. Update the plugin or theme |
Notice: Undefined variable or Undefined index |
Sloppy code | Not an error. Safe to ignore, tell the plugin author |
Uncaught TypeError |
Plugin is not compatible with this PHP version | Update the plugin, or use an older PHP version while you wait |
Failed to open stream: No such file or directory |
A file the code needs isn't there | Reinstall, or check that you didn't delete a folder |
Failed to open stream: Permission denied |
Wrong permissions | See Fix file and folder permissions |
mysqli_connect(): (HY000/1045) Access denied for user |
Database username or password wrong | See Fix "Error establishing a database connection" |
Warning, notice, deprecated, fatal
| Level | Stops the page? | Do you need to act? |
|---|---|---|
| Fatal error | Yes | Yes |
| Parse error | Yes | Yes |
| Warning | No, usually | If it breaks something, yes |
| Notice | No | Usually not |
| Deprecated | No | Plan an update |
After a PHP version change
New PHP versions are stricter. If errors appear after a change:
- Switch back under Account → Hosting → your site → Performance → Choose PHP for each site. See PHP version and OPcache for speed.
- Update plugins, themes, and WordPress.
- Try the new version again.
Show the error on the page for yourself
In WordPress, don't show errors to visitors. Log them. See Turn on WordPress debug logging.
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
Errors then go to wp-content/debug.log. Turn debug off when you're done and delete the log, since it can hold sensitive paths.
Fix a parse error you caused
- Open the file in Files → File manager and go to the line the error names.
- Check the line above too. A missing semicolon or bracket shows up on the next line.
- If you can't find it, restore the file from backup. See Restore files from a backup.
Still stuck?
Send the full error text, the file name, and what you changed. See What to include when you ask for help.
Still stuck? Ask us and we'll walk you through it.