#9: Reading an Individual Setting

Sometimes phpinfo() can be overkill if you know what you're looking for. For example, you may just want to find out whether magic quotes is turned on or check an include path. Furthermore, phpinfo() won't help you if you're writing a script that behaves one way if a setting is enabled and another way if it's not.

To get the value of a particular configuration setting, use the ini_get() function as follows:

<?php
echo "The register_globals value is " . ini_get('register_globals');
?>

Give ini_get() a valid configuration parameter name, and it returns the current setting on the current server. The setting is returned as a regular value, so you can print it, assign it to a variable, and so on. However, there are two ...

Get Wicked Cool PHP now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.