07-02-2016, 03:50 PM
Environment errors occur when a system that’s external to a PHP script causes a problem. For example, your MySQL server might have been down at the point at which your PHP script tried to connect to it. Perhaps you specified an incorrect path to a file you wanted to open, so PHP was unable to find the file.
These errors also occur when we take a PHP script that has been written on one system, and execute it on another system with a different environment. The problem may simply be that the underlying directory structure or domain name of the Web server is different. It’s common to deal with these types of issues by creating a central configuration script that stores all these environment variables. PHP also has a number of settings in php.ini that can cause a script to fail on another system where the settings are different. I’ll be looking at these in “How do I write portable PHP code?”; there’s also summary information in Appendix A.
These errors also occur when we take a PHP script that has been written on one system, and execute it on another system with a different environment. The problem may simply be that the underlying directory structure or domain name of the Web server is different. It’s common to deal with these types of issues by creating a central configuration script that stores all these environment variables. PHP also has a number of settings in php.ini that can cause a script to fail on another system where the settings are different. I’ll be looking at these in “How do I write portable PHP code?”; there’s also summary information in Appendix A.