0% found this document useful (0 votes)
9 views

php-ini-file-configuration-

The document provides an overview of the php.ini file, which is a crucial configuration file for PHP that dictates the behavior of PHP scripts on a web server. It details various settings and directives within the file, such as memory limits, error reporting, and file upload sizes, and emphasizes the importance of restarting the web server after making changes. Additionally, it explains how to locate the php.ini file and mentions the existence of alternative versions for different environments.

Uploaded by

infopolish6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

php-ini-file-configuration-

The document provides an overview of the php.ini file, which is a crucial configuration file for PHP that dictates the behavior of PHP scripts on a web server. It details various settings and directives within the file, such as memory limits, error reporting, and file upload sizes, and emphasizes the importance of restarting the web server after making changes. Additionally, it explains how to locate the php.ini file and mentions the existence of alternative versions for different environments.

Uploaded by

infopolish6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Courses Tutorials DSA Data Science Web Tech Sign In

PHP Tutorial PHP Exercises PHP Array PHP String PHP Calendar PHP Filesystem PHP Math PHP Programs PHP Array Programs PHP String Programs PHP Interview Questions PHP GMP

PHP php.ini File Configuration


Last Updated : 19 Jul, 2024

At the time of PHP installation, php.ini is a special file provided as a default


configuration file. It’s a very essential configuration file that controls, what a user can or
cannot do with the website. Each time PHP is initialized, the php.ini file is read by the
system. Sometimes you need to change the behavior of PHP at runtime, then this
configuration file is used.

All the settings related to registering global variables, uploading maximum size,
displaying log errors, resource limits, the maximum time to execute a PHP script, and
others are written in a file as a set of directives that helps in declaring changes.

Note: Whenever some changes are performed in the file, you need to restart our web
server.

It helps in the easy administration of web server using these configuration files. We can
also write our own custom configuration files.

To check the file path use the below example:

<?php
echo phpinfo();
?>

Note: Keys in the file are case-sensitive, keyword values are not spaces and lines
starting with a semicolon are ignored. The file is well-commented. The Boolean values
are represented by On/Off, 1/0, True/False, Yes/No.

The file contains a set of directives with a set of respective values assigned to it. The
values can be string, a number, a PHP constant, INI constants, an expression, a quoted
string or a reference to a previously set variable. Expression in the INI file is limited to
bitwise operators or parentheses. Settings with a particular hostname will work under
that particular host only.

Environment variables of php.ini file:

memory_limit: This setting is done to show the maximum amount of memory a script
consumes.

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

enable_safe_mode = on Its default setting to ON whenever PHP is compiled. Safe


mode is most relevant to CGI use.
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.
upload_max_filesize This setting is for the maximum allowed size for uploaded files
in the scripts.
upload_tmp_dir = [DIR] Don’t uncomment this setting.
post_max_size This setting is for the maximum allowed size of POST data that PHP
will accept.
display_errors = off This setting will not allow showing errors while running PHP
project in the specified host.
error_reporting = E_ALL & ~E_NOTICE: This setting has default values as E_ALL and
~E_NOTICE which shows all errors except notices.
error_prepend_string = [“”] This setting allow you to make different color of
messages.
max_execution_time = 30 Maximum execution time is set to seconds for any script to
limit the time in production servers.
short_open_tags = Off To use XML functions, we have to set this option as off.
Skip to content
session.save-handler = files You don’t need to change anything in this setting.
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.
warn_plus_overloading = Off This setting issues a warning if + used with strings in a
form of value.
gpc_order = GPC This setting has been GPC Deprecated.
magic_quotes_gpc = on This setting is done in case of many forms are used which
submits to themselves or others and display form values.
magic_quotes_runtime = Off If magic_quotes_sybase is set to On, this must be Off,
this setting escape quotes.
magic_quotes_sybase = Off If this setting is set to off it should be off, this setting
escape quotes.
auto-prepend-file = [filepath] This setting is done when we need to automatically
include() it at the beginning of every PHP file.
auto-append-file = [filepath] This setting is done when we need to automatically
include() it at the end of every PHP file.
include_path = [DIR] This setting is done when we need to require files from the
specified directories. Multiple directories are set using colons.
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.
doc_root = [DIR] This setting is done if we want to apply PHP to a portion of our
website.
file_uploads = [on/off] This flag is set to ON if file uploads are included in the PHP
code.
mysql.default_host = hostname This setting is done to connect to MySQL default
server if no other server host is mentioned.
mysql.default_user = username This setting is done to connect MySQL default
username, if no other name is mentioned.
mysql.default_password = password This setting is done to connect MySQL default
password if no other password is mentioned.

Configuration of php.ini file

Whenever we install PHP, we can locate the configuration file inside the PHP folder. If
using xampp, we can find the configuration file in one or many versions, inside the path
‘\xampp\php’.

Note: Other versions of this file are php.ini-development and php.ini-production. The
most preferred one is php.ini-development file.

Comment More info Advertise with us Next Article


Enumerations in PHP

Similar Reads
PHP php.ini File Configuration
At the time of PHP installation, php.ini is a special file provided as a default configuration file. It's a very essential
configuration file that controls, what a user can or cannot do with the website. Each time PHP is initialized, the…

5 min read

Enumerations in PHP
Enumeration (or enum) is mainly used to assign names to integral constants, the names make a program easy to
read and maintain. In PHP, enumeration datatypes can be implemented using and extending abstract classes.…

3 min read

How to Import config.php File in a PHP Script?


The include() function in PHP copies the code from the specified file into the file that uses the include statement. It
directs the preprocessor to insert the content of the specified file into the current program. The name of the file to…

2 min read

Installation and Configuration Symfony Framework


Skip to content
Symfony is an open-source PHP web application framework with MVC architecture. It is a set of reusable PHP
components/libraries. It is basically designed for developers who need an elegant and simple toolkit to create we…

2 min read
How to convert XML file into array in PHP?
Given an XML document and the task is to convert an XML file into PHP array. To convert the XML document into
PHP array, some PHP functions are used which are listed below: file_get_contents() function: The…

2 min read

PHP Infix to Postfix Converter


Converting infix expressions to postfix notation (also known as Reverse Polish Notation) is a common task in
computer science, especially in the context of parsing and evaluating expressions. In infix notation, the operator is…

3 min read

PHP Postfix to Infix Converter


Converting postfix (also known as Reverse Polish Notation) expressions to infix notation is a common task in
computer science, especially in the context of parsing and evaluating expressions. In postfix notation, the operator…

2 min read

How to post data using file_get_contents in PHP ?


The file_get_contents() function in PHP is used to read the contents of a file and make HTTP requests using GET
and get HTTP responses using POST methods. The HTTP POST request can be made using the $context…

3 min read

How to Zip a directory in PHP?


ZIP is an archive file format that supports lossless data compression. A ZIP file may contain one or more files or
directories that may have been compressed. The PHP ZipArchive class can be used to zipping and unzipping. It…

2 min read

Error handling in PHP


Prerequisite: Types of Error PHP is used for web development. Error handling in PHP is almost similar to error
handling in all programming languages. The default error handling in PHP will give file name line number and…

3 min read

Function overloading and Overriding in PHP


Function overloading and overriding is the OOPs feature in PHP. In function overloading, more than one function
can have same method signature but different number of arguments. But in case of function overriding, more than…

3 min read

What are User-defined Functions and Built-in Functions in PHP?


In PHP, User-defined functions are created by programmers to meet specific requirements, while PHP built-in
functions are provided by PHP to perform common tasks without the need for manual implementation. Both type…

2 min read

Complex Numbers in PHP


In the mathematical computations, complex numbers play a crucial role, especially in fields like engineering and
physics. A complex number is a combination of a real part and an imaginary part, often expressed as a + bi, where…

2 min read

How to create optional arguments in PHP ?


Arguments that do not stop the function from working even though there is nothing passed to it are known as
optional arguments. Arguments whose presence is completely optional, their value will be taken by the program i…

2 min read

PHP | Magic Constants


Magic constants: Magic constants are the predefined constants in PHP which is used on the basis of their use.
These constants are created by various extensions. There are nine magic constant in the PHP and all of the…

3 min read

How to write comments in PHP ?


Comments are non-executable lines of text in the code that are ignored by the PHP interpreter. Comments are an
essential part of any programming language. It help developers to understand the code, provide explanations, an…

1 min read

How to include() all PHP files from a directory ?


Given list of PHP files in a directory and the task is to include all files from a directory. In order to include all PHP
files from directory at once need a foreach-loop. Example: This example contains four PHP files (file1.php,…

1 min read

How to open a PDF files in web browser using


Skip toPHP?
content
Opening a PDF file in a web browser using PHP involves serving the PDF directly to the client’s browser. This is
achieved by setting the appropriate HTTP headers (Content-Type and Content-Disposition) in PHP, which instruct…

2 min read
How to delete a file using PHP ?
To delete a file by using PHP is very easy. Deleting a file means completely erase a file from a directory so that the
file is no longer exist. PHP has an unlink() function that allows to delete a file. The PHP unlink() function takes tw…

2 min read

Company Languages DSA Data Science & ML Web Technologies Python Tutorial
About Us Python Data Structures Data Science With HTML Python Programming
Corporate & Communications Address: Legal Java Algorithms Python CSS Examples
A-143, 7th Floor, Sovereign Corporate Privacy Policy C++ DSA for Beginners Data Science For JavaScript Python Projects
Tower, Sector- 136, Noida, Uttar Pradesh In Media PHP Basic DSA Problems Beginner TypeScript Python Tkinter
(201305)
Contact Us GoLang DSA Roadmap Machine Learning ReactJS Web Scraping
Registered Address: Advertise with us SQL Top 100 DSA Interview ML Maths NextJS OpenCV Tutorial
K 061, Tower K, Gulshan Vivante GFG Corporate Solution R Language Problems Data Visualisation Bootstrap Python Interview
Apartment, Sector 137, Noida, Gautam Placement Training Android Tutorial DSA Roadmap by Pandas Web Design Question
Buddh Nagar, Uttar Pradesh, 201305 Program Tutorials Archive Sandeep Jain NumPy Django
GeeksforGeeks All Cheat Sheets NLP
Community Deep Learning

Computer Science DevOps System Design Inteview School Subjects GeeksforGeeks


Operating Systems Git High Level Design Preparation Mathematics Videos
Computer Network Linux Low Level Design Competitive Physics DSA
Database Management AWS UML Diagrams Programming Chemistry Python
Advertise with us System Docker Interview Guide Top DS or Algo for CP Biology Java
Software Engineering Kubernetes Design Patterns Company-Wise Social Science C++
Digital Logic Design Azure OOAD Recruitment Process English Grammar Web Development
Engineering Maths GCP System Design Company-Wise Commerce Data Science
Software Development DevOps Roadmap Bootcamp Preparation World GK CS Subjects
Software Testing Interview Questions Aptitude Preparation
Puzzles

@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved

You might also like