Last Updated on: 26th October 2017, 10:00 am
PHP code is managed by your servers PHP settings
WordPress and WooCommerce PHP code can fail due to your servers PHP configuration. Some plugin’s PHP code require certain configuration values to be active, while some hosting providers may configure your servers PHP environment in a way that impairs execution.
Developers test their code using their configured local environments. Their server configuration often differs from what your hosting providers deems necessary. If you run into a problem situation where blame is being directed at your hosting provider, chances are that it is not the hardware, but the software (PHP, MySQL) version or configuration. While I am an advocate of solid hosting, many issues can be resolved by checking configuration settings alone.
How to check your servers PHP settings
Your PHP environment is configured using a
.ini file. It is usually called
php.ini oftentimes a version number is included such as
PHP itself provides a function which sole purpose is to output information about the present PHP configuration. Copy and paste the code visible under example 1 and open the file in your browser will give you all relevant information.
You can also use one of the many WordPress plugins to display this information. Me personally I like using WP-ServerInfo.
How to edit PHP settings
A frequent example from Woo support is to increase the script runtime for PHP. For this you need to edit the value:
- Open the
php.inidirectly, look for the value and change it via a text editor. Sometimes your hosting provider grants you access via the admin panel or FTP. You can also ask your hosting provider to change the value for you.
- Open your
wp-config.phpand use it to overwrite the value:
@ini_set( 'max_execution_time', 1234 );
- If your server runs on Apache you can use the
.htaccessfile to try and overwrite the file like so:
php_value max_execution_time 1234
- I also like using a plugin for this: PHP Settings.
Track your changes manually
Editing your PHP configuration is not something you can restore via a WordPress backup. This happens on your server directly so do keep tabs on what you do so you can revert the changes, if you edit something that you need to undo.