Access to the php.ini is trivial when you are the server administrator, however shared hosting environments will logically prevent you from modifying this file. All is not lost however; if you require certain directives to be set in a specific way in order for your website to run properly on a shared host, and your shared host is running PHP as an Apache module, then it's possible you could modify the desired PHP directives within an .htaccess file which resides in your website's root directory. For instance, if your shared host disables the use of short open tags you can override this setting and enable them by adding this line to your .htaccess file:
php_flag short_open_tag On
The php_flag directive is an Apache-specific configuration feature, so you won't be able to use this when working with other web servers such as Nginx. Further, this is used for setting PHP's Boolean directives; you'll want to use php_value to set those directives which aren't Boolean in nature, such as the include_path.
For reasons of security, not all PHP configuration directives can be changed in this way! Each directive is associated with a mode value which determines exactly where the directive can be modified. Four modes are supported, including:
PHP_INI_USER: The directive can be set within PHP scripts (more about this in the next section).
PHP_INI_PERDIR: The directive can be set in the php.ini file, in httpd.conf, and in .htaccess.
PHP_INI_SYSTEM: The directive can be set in php.ini and httpd.conf.
PHP_INI_ALL: The directive can bet set via any of the aforementioned outlets.
You can view a list of available PHP directives and their corresponding mode values here.
Modifying a Value Via a PHP Script
In the previous set of bullet points I mentioned it was possible to set a PHP directive from within a PHP script. You might wish to take this approach when the need arises to change a directive value which should be localized to one specific script. For instance suppose a particular script occasionally needed to run for longer than expected as it was responsible for generating a lengthy sales report. You can increase the default maximum PHP script execution time by setting the max_execution_time directive at the top of the script using the ini_set() function:
Although not the most exciting of topics, your understanding of PHP's approach to configuration will be a significant contributor to the overall success of future projects. Hopefully this brief introduction provides you with a solid foundation for performing further investigation!