Skip to main content

The Dummies Guide to Php.ini Configuration File of PHP

Welcome to PHPBash | Helping You to Become an Expert in PHP Programming. In this PHP Tutorial for beginners and professionals, I will cover details about The Dummies Guide to Php.ini Configuration File of PHP. The configuration file (php.ini) of PHP is read when PHP starts up. In case of web server module versions of PHP, this happens only once when the web server is started. For the CGI and CLI versions, it happens on every invocation.

The Dummies Guide to Php.ini Configuration File of PHP Tutorial 

This PHP tutorial covers all the topics of php.ini File Configuration of PHP like

        1. What is php.in file?

        2. What are PHP Directives and their types? 

        3. Important settings or common parameters of the php.ini file

Let's start PHP tutorial with questions, What is php.in file?

What is php.in file?

At the time of PHP installation, php.ini is a special file provided as a default configuration file. PHP's configuration file php.in is important file which is responsible for controlling what user can do and can't do with website. The configuration file (php.ini) of PHP is read when PHP starts up.

PHP comes packaged with two "ini" files. One that is recommended to be used in production environments and one that is recommended to be used in development environments. For example, if those versions are named as php.ini_dist and php.ini_recommended. If you are using XAMPP then the two versions of php.in will be php.ini-development and php.ini-production.

In case of web server module versions of PHP, this happens only once when the web server is started. For the CGI and CLI versions, it happens on every invocation. php.ini file consist set of directives with their values. These directives of configuration file tells web server about behaviour of PHP. 

PHP php.ini configuration file
PHP php.ini Configuration File

In case you need to change the behaviour of PHP, then php.in configuration file can be accessed and modified.    

IMPORTANT: If you modify php.in file, then you must Restart your Web Server for taking effect. 

LOCATION: php.ini file can be found inside the PHP Directory. In case you are using XAMPP, the php.ini configuration file can be found in "xampp/php".

What are PHP Directives and their types? 

Basically, Directives are variables used to configure PHP or PHP extensions. As described, These directives of configuration file tells web server about behaviour of PHP.  Directive names are *case sensitive*. For Example, foo=bar is different from FOO=bar.

Directives are specified using the following syntax: 

directive = value

The value can be a string, a number, a PHP constant (e.g. E_ALL or M_PI), one of the INI constants (On, Off, True, False, Yes, No and None) or an expression (e.g. E_ALL & ~E_NOTICE), a quoted string ("bar"), or a reference to a previously set variable or directive (e.g. ${foo})

The php.ini file Consist two types of directives. They are

1. Boolean/Flag directive – These directives are treated like flags that can be set or unset by using boolean values, like, on or off, 1 or 0, true or false. Boolean flags can be turned on using the values 1, On, True or Yes.They can be turned off using the values 0, Off, False or No.

2. Value Directive – It contains values with respect to the name of the directive. 

Important settings or common parameters of the php.ini file

The following directives describe various php.in Configuration settings and their values.

1. display_errors = off 
This setting will not allow showing errors while running PHP project in the specified host.
2. error_reporting = E_ALL & ~E_NOTICE:
This setting has default values as E_ALL and ~E_NOTICE which shows all errors except notices.
3. max_execution_time = 30 
Maximum execution time is set to seconds for any script to limit the time in production servers.
4. short_open_tags = Off 
To use XML functions, we have to set this option as off.
5. variables_order = EGPCS
This setting is done to set the order of variables as Environment, GET, POST, COOKIE, SERVER. The developer can change the order as per the need also.
6. auto-prepend-file = [filepath] 
This setting is done when we need to automatically include() it at the beginning of every PHP file.
7. auto-append-file = [filepath] 
This setting is done when we need to automatically include() it at the end of every PHP file.
8. include_path = [DIR] 
This setting is done when we need to require files from the specified directories. Multiple directories are set using colons.
9. ignore_user_abort = [On/Off]
This settings control what will happen when the user click any stop button. The default value is on this setting doesn’t work on CGI mode it works on only module mode.
10. file_uploads = [on/off] 
This flag is set to ON if file uploads are included in the PHP code.
11. mysql.default_host = hostname 
This setting is done to connect to MySQL default server if no other server host is mentioned.
12. mysql.default_user = username 
This setting is done to connect MySQL default username, if no other name is mentioned.
13. mysql.default_password = password
This setting is done to connect MySQL default password if no other password is mentioned.
14.upload_max_filesize=value
This setting is for the maximum allowed size for uploaded files in the scripts.
15. upload_tmp_dir = [DIR] 
Don’t uncomment this setting.
16. post_max_size =value
This setting is for the maximum allowed size of POST data that PHP will accept.
17. register_argc_argv = Off 
This directive determines whether PHP registers $argv & $argc each time it runs. $argv contains an array of all the arguments passed to PHP when a script is invoked. $argc contains an integer representing the number of arguments that were passed when the script was invoked.
18. register_globals = on 
its default setting to ON which tells that the contents of EGPCS (Environment, GET, POST, Cookie, Server) variables are registered as global variables. But due to a security risk, the user has to ensure if it set to OFF for all scripts.
19. display_startup_errors = Off
The display of errors which occur during PHP's startup sequence are handled separately from display_errors.
20. log_errors = On
Besides displaying errors, PHP can also log errors to locations such as a server-specific log, STDERR, or a location specified by the error_log directive.
21. log_errors_max_len = 1024
Set maximum length of log_errors. In error_log information about the source is added. The default is 1024 and 0 allows to not apply any maximum length at all.
22. ignore_repeated_errors = Off
Do not log repeated messages. Repeated errors must occur in same file on same line unless ignore_repeated_source is set true.
23. html_errors = On
When PHP displays or logs an error, it has the capability of formatting the error message as HTML for easier reading. This directive controls whether the error message is formatted as HTML or not.
24. default_mimetype = "text/html"
PHP's built-in default media type is set to text/html.
25. default_charset = "UTF-8"
PHP's default character set is set to UTF-8.
26. file_uploads = On
Whether to allow HTTP file uploads.
27. allow_url_fopen = On
Whether to allow the treatment of URLs (like http:// or ftp://) as files.
28. allow_url_include = Off
Whether to allow include/require to open URLs (like http:// or ftp://) as files.
29. date.timezone 
Defines the default timezone used by the date functions
30. session.use_cookies = 1
Whether to use cookies OR not.
31. session.name = PHPSESSID
Name of the session (used as cookie name).
32. session.cookie_lifetime = 0
Lifetime in seconds of cookie or, if 0, until browser is restarted.
33. session.cache_expire = 180
Document expires after n minutes.
34. engine = On
Enable the PHP scripting language engine under Apache.
35. short_open_tag = Off
This directive determines whether or not PHP will recognize code between <? and ?> tags as PHP source which should be processed as such. It is generally recommended that <?php and ?> should be used and that this feature should be disabled, as enabling it may result in issues when generating XML documents.
36. precision = 14
The number of significant digits displayed in floating point numbers.
37. max_input_vars = 1000
How many GET/POST/COOKIE input variables may be accepted.
38. memory_limit = 128M 
Maximum amount of memory a script may consume (128MB)

These are some important directives available in php.ini configuration file. As mention earlier, if modify any directive value, do not forgot to restart your server in order to take effect.

I hope this PHP tutorial might have given a much better idea about "The Dummies Guide to Php.ini Configuration File of PHP". If you have any doubt/query related to PHP or Web Technologies, Please let me know in Comment Section. Please share it with your friends. 

 Sharing is caring ❤️

Thank you for Visiting PHPBash | Helping You to Become an Expert in PHP Programming Keep Visiting for more Interesting concepts of Php language and web technologies from basics to advanced. 

As well we will also share some ready-to-use, useful code snippets for beginners to kick start their web development project. 

Want to Develop Website / Web Application or any Academic Project?

Do you want to build a modern, lightweight, responsive website and launch quickly? 

 I help to create the best websites / web applications and will be available for freelance work. contact: phpgems28@gmail.com

 

Comments

You may also like

PHP Constants

W elcome to PHPBash. In this PHP Tutorial, we will learn about Basics of PHP Constants.  In our Previous Tutorial , we learn about different concepts related to PHP variables. A constant is a name or an identifier with a fixed or permanent value. In Programming, Both constants and variables are used for storing data or values and act as container. Constants are more like variables with one difference that, Constants can not be modified/Changed during execution of program.  PHP Constants In this, PHP tutorial covers all the topics of Basics of PHP Constants  like         1.  PHP Constants         2.  Using the PHP define() method.         3.  Using the PHP const keyword.         4.  PHP 7 Constant Arrays         5.  PHP Global Constants         6.  PHP constant() Function          7. PHP Class constant array Now let's start  this tutorial with understanding P HP Constants and their use .  PHP Constants A constant is an identifier whose value cannot be changed or modified during the

PHP 7 Data Types: Scalar, Compound and Special

W elcome to PHPBash. In this PHP Tutorial, we will learn about Basics of PHP Data Types.  In our  Previous Tutorial , we learn about different concepts related to PHP variables.  Data types define what kind of data or values a variable will hold. With help of data types, computer can understand the type of data stored in variable and as per its type, memory will be allocated. so data types are very important and crucial concept in any programming language.  In PHP 7, there are total 10 different data type s. They are divided in to Scalar Types, Compound Types and Special Types. As PHP is loosely typed, there is no need to specify data type while declaring variables. PHP Handles typecasting or PHP Juggling automatically. You can read more about it, in this tutorial. In this, PHP tutorial covers all the topics of Basics of  PHP 7 Data Types  like 1.  PHP 7 Data Types and their Sub Types Now let's start  this tutorial with understanding  PHP 7 Data Types and  their  Sub Types. PHP 7

PHP echo and print Statements | PHP Echo Vs Print

Welcome to PHPBash. In this PHP Tutorial for Beginners , we will learn about PHP echo and print Statement. PHP print return 1 value where as PHP echo do not return any value. These both statements are used for printing output in PHP. The PHP echo or PHP print statement can be used for printing variables, strings, escaping characters etc.  PHP echo and print Statements | PHP Echo Vs Print  This PHP tutorial covers all the topics of Basics of PHP Variable like         1.  PHP Echo Statement         2.  PHP Echo Statement Example         3.  PHP  print   Statement         4.  PHP  print  Statement Example          5.  PHP Echo Vs Print  Now let's start  this tutorial with understanding  PHP Echo Statement with its Examples. In PHP, The output is displayed using either print or echo statements. For printing data, In PHP we can used print or echo statement. There is very small difference between print and echo statement. The print statement return value 1 where as echo do not return any

Basics of Php Syntax

Welcome to PHPBash | Helping You to Become an Expert in PHP Programming. In this PHP Tutorial for beginners and professionals, we will learn details about Precious Tips To Help You Get Better At Basics of PHP Syntax, Including PHP script in HTML and Executing PHP Script. As well  PHP case sensitivity, PHP tags and their types ,  Comments in PHP,  Whitespace in PHP &  PHP Block Concept. Basics of Php Syntax This PHP tutorial covers all the topics of Basics of PHP Syntax like           1. Basic PHP Syntax         2. PHP Case Sensitivity         3. Types of PHP Tags         4. Comments in PHP         5. White Spaces in PHP          6. Blocks in PHP          7. PHP Expressions and Statements          8. Executing/Running PHP Script in Windows Command Prompt(cmd) Now let's start  this tutorial with understanding Basic PHP Syntax. Basic PHP Syntax   PHP is very popular and most widely used and the reason is that,PHP is  simple to learn and use.   The code of PHP is executed on server

PHP Programming Fundamentals - Introduction to PHP

Welcome to PHPBash | Helping You to Become an Expert in PHP Programming. In this PHP Tutorial for beginners and professionals, I will provides in-depth knowledge of Introduction of PHP scripting language.  PHP Programming Fundamentals - Introduction to PHP  This PHP tutorial covers all the topics of PHP Introduction such as          1. What is PHP?         2. Basic Uses of PHP         3. Characteristics of PHP         4. Prerequisite to Start with PHP         5. What PHP File can contain?         6. Syntax of PHP Code          7.  What you will need to Work with PHP?  Let's start PHP tutorial with basic question, What is PHP? What is PHP? PHP Stands for PHP: hypertext Preprocessor. PHP is Open source general-purpose High Level  object-oriented  Scripting Language. It is used for web application development and can also be embedded into hypertext markup language (HTML).  Many Web site like Yahoo, Wikipedia,  Facebook,  Tumblr,  Wordpress,  MailChimp,  Flickr. etc, are developed usin

PHP Programming Tutorials for Beginners | PHP Variables Types

Welcome to PHPBash | Helping You to Become an Expert in PHP Programming. In this PHP Tutorial for beginners and professionals, we will learn about PHP Variables, PHP Variables Type s,  PHP Global Variables,  php variable scope,  static variable in php.  As well  Rules for Variable declaration. PHP Programming Tutorials for Beginners | PHP Variables Types This PHP tutorial covers all the topics of Basics of PHP Variable like         1.  PHP Variables         2.  Rules for Variable declaration         3. Creating (Declaring) PHP Variable and Assigning value         4. PHP Variable Scope & Lifetime         5. PHP Static Variables         6. Type Casting and Type Juggling in PHP         7.  PHP Variable Case Sensitiveness          8. Destroying PHP Variables using unset()          9. PHP Programming Examples/Scripts on PHP Variable concept Now let's start  this tutorial with understanding PHP Variables. PHP Variables In computer programming, Variables are act as containers for stor

How to Beginning with your First PHP Program?

Welcome to PHPBash | Helping You to Become an Expert in PHP Programming. In this PHP Tutorial for beginners and professionals, I will Cover, How to Write First PHP Program or Script?, How to Execute PHP Program in XAMPP?,What PHP File contains? etc. To Run Your PHP Script, You must be ready with PHP Environment like XAMPP.  If you have not Installed XAMPP till now, You can Visit latest tutorial on  Installation of PHP with XAMPP in Windows 7/ Windows 10  from our blog. By Following instructions given in tutorial, you will be able to download and install XAMPP on Windows 7 / Windows 10. How to Beginning with your First PHP Program? This PHP tutorial covers all the topics of PHP Introduction such as          1. What is PHP Script/ PHP Program?         2. What PHP file Contains?         3. Editors for Writing PHP Program         4. Creating First PHP Program         5. Executing PHP Program in XAMPP      Lets start this PHP tutorial with question What is PHP Script/ PHP Program? What is P

PHP Comment Style Guide and Coding Standards

W elcome to PHPBash. In this PHP Tutorial, we will learn about Basics PHP Comments.  In our  Previous Tutorial , we learn about basics of PHP syntax as well fundamentals of comments. Basically, PHP Comments are part of PHP Program which is not executed by PHP  parser while Executing PHP Program. PHP Comments can be Single line or multiline.  PHP Comment Style Guide and PHP Coding Standards In this, PHP tutorial covers all the topics of Basics of  PHP Comments styles and Coding Standard  like 1.  What are Comments in PHP Programming Language?  2. Need of PHP Comments 3. Types of PHP Comments 4. PHP Comment Styling 5. PHP Comments Standards with Best Practices 6.PHP Comments Example with Valid and Invalid Examples Now let's start  this tutorial with understanding  What are Comments in PHP Programming Language? What are Comments in PHP Programming Language?  In PHP, Comments are part of PHP program or script which is not Interpreted by PHP Parser while Executing PHP Script or PHP prog

Installation of PHP with XAMPP in Windows 7/ Windows 10

Welcome to PHPBash | Helping You to Become an Expert in PHP Programming. In this PHP Tutorial for beginners and professionals, I will provides in-depth knowledge of Installation of PHP with XAMPP in Windows 7/ Windows 10. XAMPP can be used to install and configure PHP on Windows 7 / Windows 10. Installation of PHP with XAMPP in Windows 7/ Windows 10 This PHP tutorial covers all the topics of Installation of PHP with XAMPP in Windows 7/ Windows 10 such as          1. PHP Installation           2.  What is  XAMPP?         3. Alternative to XAMPP         4. Download XAMPP         5.  Installation of XAMPP in Windows 7/ Windows 10          Lets start PHP tutorial with PHP Installation . PHP Installation As described in our previous post, to install PHP we require three components that are PHP Parser, Web Server and Database Server. Collectively it is called as AMP Software Stack( Apache, MySql, PHP). We can download each component separately from their official websites. After download, w