PHP warnings showing on your website: odd lines with file paths in them
Last reviewed
Your pages show odd "Warning:" lines with file paths in them.
A PHP warning showing on a website is a line of text such as "Warning: ... on line 42" that the server prints into the page when some code misbehaves. Notices and "Deprecated" lines are milder versions of the same thing. The page usually still works, but it looks broken and reveals where your files live on the server. The fix is switching off on-screen errors, then repairing the code behind them.
Why PHP warnings on your pages costs you customers
To a visitor, a block of code-like text above your header looks like a site nobody is minding, and some will pick a business whose page looks cared for. The messages also print the full folder path to your files on the server, a small gift to anyone probing for weak spots. And a warning is often an early sign of an outdated plugin that a later update will break outright.
What usually causes PHP warnings on your pages
- Your host moved the site to a newer PHP version, and older plugin or theme code now trips warnings or deprecation notices
- A plugin or theme update brought in code that clashes with your PHP version or with another plugin
- Error display, a PHP setting called display_errors, is switched on for the live site, often left over from a developer's testing
- WP_DEBUG was set to true in wp-config.php to chase a problem and never set back
- A move to new hosting brought PHP settings that show errors on screen by default
How to check for PHP warnings on your pages yourself
- Open your homepage and main service pages in a private window, and read the top and bottom of each page closely. Look for the words Warning, Notice or Deprecated followed by a file path.
- If a page looks fine, right-click it and choose "View page source", then search the source for the word Warning. A message hidden behind other content still shows up there.
- On WordPress, open Tools, then Site Health. The Info tab lists the PHP version your site runs on, and the Status tab tells you if WordPress itself is set to show errors to visitors.
- Note the folder name inside the file path of each message, such as a name after /plugins/ or /themes/. It usually tells you which add-on is at fault.
How to fix PHP warnings on your pages
- Your developer or host turns off on-screen errors for the live site but keeps them recorded: display_errors = Off and log_errors = On in php.ini, or in a .user.ini file in the site's main folder on hosting that reads one. Many hosting control panels offer the same two switches on a PHP settings page.
- On WordPress, your developer sets WP_DEBUG_DISPLAY to false in wp-config.php and points WP_DEBUG_LOG at a file outside the public web folder, rather than the default wp-content/debug.log, which many servers will hand to anyone who asks for it. These two settings only act while WP_DEBUG is true. With WP_DEBUG false, the server setting from the first step is what hides the messages.
- Your developer reads the log, finds the plugin, theme or custom file named in each warning, and updates it, since a newer release often fixes the clash.
- If no fix exists, your developer checks whether that plugin or theme supports your PHP version, then replaces it with a maintained alternative, or asks the host to run the version it was built for while a replacement is found.
- You reload the affected pages to confirm the messages are gone, and your developer tries future PHP upgrades and plugin updates on a staging copy before they reach the live site.
How Prsona catches PHP warnings on your pages
Prsona reads the pages it visits on each scan and reports a PHP warning printed into a page, naming the page where it appeared. It is listed in your dashboard with the date it was first seen, even when the rest of that page looks normal.
Prsona looks for PHP warnings on your pages as part of broken page detection.
See whether any page on your site is printing PHP messages for visitors to read.
Questions about PHP warnings on your pages
Are PHP warnings on my site dangerous?
Usually not in themselves. A warning means some code did something unexpected but carried on, so the page still loads. The risks are that it looks unprofessional, that the message reveals file paths on your server, and that it can be the first sign of code a future update will break. Treat it as a job for this month.
Will turning off error display fix the problem?
It hides the symptom, which is the right first step, but the faulty code is still there. With logging switched on, the same messages keep collecting in a log file your developer can read. Use that log to update or replace whatever causes them, otherwise the next PHP or plugin upgrade may turn a warning into a page that will not load.