This code works in every browser except Firefox and I can’t seem to find out why. I have tried to require all the way back to the root dir, but it still throws me the error:
“Fatal error: require(): Failed opening required
‘PHPMailer/src/PHPMailer.php’
(include_path=’.:/opt/cpanel/ea-php70/root/usr/share/pear’)”
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';
require 'PHPMailer/src/Exception.php';
2
Answers
Your browser has no influence over how paths work on your server.
Most simply, you do not have the correct path in your require statement.
However, I would recommend using composer and its autoload script to bring PHPMailer into your project.
Firefox should NOT be able to influence any of this.
Checking whether none of your browsers cache old/new version
Try:
If any of these steps help, it definitely isn’t Firefox’ issue.
Is it a simple page you open, or do you rely on GET or POST variables? Is there any chance other browsers have cached an older, working version, and only Firefox shows the current broken results? Try renaming the file to something you haven’t had there before and re-opening it, or the steps I listed on other browsers.
Checking whether you are editing the right file
When I get weird behavior like this, I usually try editing the file to show something different (like
echo "current file <br>";
at the beginning of the PHP file) first to see for sure I am opening the right file from everywhere and the changes to code take effect. I’ve had lots of such problems and it usually were switching underscore and dash, opening from production server instead of development one, etc. It’s a nightmare when your debugging can’t seem to work whatever you do and in the end you find out you didn’t do anything at all (to the file you were opening).Including absolute path
This won’t help with the “Why only Firefox” question, but you might want to use absolute path to be safe when including, or relative to your current folder.
Instead of
try
or
or
so the parser doesn’t look for the file in your include path (unless that is where your PHPMailer is located).
Also, I’d use
require_once
rather thanrequire
when loading libraries.