Viewing PHP settings


Default PHP settings may be viewed either as a standalone page or within an application using phpinfo() or ini_get().

Default Environment Settings

To view your default environment settings, create a file named phpinfo.php inside your document root. Inside this file, include the following line:

<?php phpinfo(); ?>

Access the URL phpinfo.php from your web browser, e.g. if your domain were, to view the settings.

Example phpinfo() response

Example phpinfo() response

Application Settings

phpinfo() in a standalone script will show you the default settings for your hosting environment. Web applications like WordPress, Drupal, and Joomla! will automatically adjust settings on-the-fly with recommended settings as necessary (error_reporting, display_errors, upload_max_filesize, etc.). It’s recommended to refer either to the settings panel in the web application (see vendor’s instructions) or if it is unavailable and absolutely necessary, use ini_get() or phpinfo() at the bottom of the script, usually index.php:

/** some application code ... */

<?php print "memory_limit setting: "; ini_get('memory_limit'); ?>

<?php phpinfo(); ?>

Explanation: In the above example, 2 methods of accessing PHP settings are used: ini_get() to get a specific single value (memory_limit in this case – note this can’t be changed except by support ticket in the control panel) and phpinfo() once again to dump the entire PHP environment. These scriptlets are inserted at the end of the file after the closing PHP delimiter, ?>.

Sometimes there is no PHP at the end of a script, but rather HTML. In those cases, ini_get() or phpinfo() should be injected before the closing </body> tag:

<!--- some html ... -->
<span>Thanks for coming!</span>
<?php print "memory_limit setting: "; ini_get('memory_limit'); ?>
<?php phpinfo(); ?>

See Also

Leave a Reply