Do you know your PHP.INI file

Hello, Today we are going to learn about that what is the php.ini file in the Opencart and how we can change the existing configuration of the server with the help of this file. First of all, we will see what this file is and why we use this.

So php.ini file also known as “PHP configuration file” is the default configuration file which acquires running applications on the server that require PHP. This file is basically used to manage or Customize the variables such as upload sizes, file timeouts, and resource limits which are treated as Configuration variables.

This file always looked up by the server and it will load the all the other desired and required settings whenever PHP server starts up running. Remember if you are making changes in this file and want that your changes in the php.ini file will affect on your server settings then you just need to restart your apache server to apply the changes. And always remember that if you are going to make any changes in the existing php.ini file then it’s a good idea to copy the original file in some location on your system. This can be useful for the future reference or to easily restore the original file if necessary.

Syntax Used inside the file PHP.INI

variable_name = "value";  

For example

max_execution_time = 36000;

Keys or variable names are case sensitive but not the keyword values. In this file Booleans are be represented by 1/0, Yes/No, On/Off, or True/False. The lines which are started with a semicolon (;) ignored as these lines are treated as comment lines in this file.

Below are some common variables which are used in the PHP.INI file


register_globals: This is an internal PHP setting which will give access to the all array elements form $_REQUEST variables as register variables. For example, if we have HTML form containing two input fields email and password then when we submit the form than normally we access the variable email like

$email = $_POST['email']; //for accessing email
$password = $_POST['password'];//for accessing password from the post

but if register_globals is on then you can access the this with $email && $password as below

// at the very beginning of the script we can use variables like .
$get_email = $email;
$get_password = $password;
//In other words, this expression 
if($email === $_POST['email']) {
  return true;
 } else {
  return false;
// this will return true.

Warning: This feature is DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 5.4.0.

memory Limit

memory_limit: This variable has the value Max amount of server memory allowed to consume that is used to open a single PHP script.

memory_limit = 64M; // value in Mega Bytes

When script exceeds the memory allowed, the error output looks something like this:

Fatal error: Allowed memory size of x bytes exhausted (tried to allocate x+y
 bytes) in /path/to/php/your/running/script

or like this:

PHP Fatal error: Out of memory (allocated x) (tried to allocate x+y bytes)
 in /path/to/php/your/running/script

Upload Max Size && Post Size

This are used to control file size limit to users to the maximum upload file size for PHP scripts. Although if we want to make a change as per our need we can make it by these two variables change the upload_max_filesizeand post_max_size directives.

upload_max_filesize = 50M;
post_max_size = 51M;

Important: Always remember that if you want that file uploads to work perfectly, the post_max_size directive should be a little larger than the upload_max_filesize

Magic Quotes GPC

magic_quotes_gpc: This is A Magic Quotes process which is used to escapes incoming data to the PHP script automatically. But this is not the preferred way to code with magic quotes on, instead do it is better to escape the data at runtime, so this one is having the value off.

magic_quotes_gpc = off;

Warning: This feature is DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 5.4.0.


mysql.connect_timeout: This is to set maximum execution time limit for sql query of that you script can take.By default which is 30 seconds but we can adjust this y writing as beklow.

mysql.connect_timeout = 60; // values in the seconds

So here in the above i have mentioned some directives used in the PHP.INI file used in the OPENCART and Almost others CMS too.

Hope you have get the idea of the PHP.INI file. For any query comment in the below.

Happy Learning!!.

. . .


Add Your Comment

Be the first to comment.

Hire Us!
Brief us about your requirements and we'll get back to you.
Woo! Hooy!
We have just recieved your project brief and our expert will contact you shortly.
Send Again