The ini_get Function
The ini_get
function returns the value of the specified PHP configuration directive.
It takes the name of the setting as a parameter and returns its current value
as a string. If the setting does not exist, the function returns false
.
Syntax
ini_get(string $varname): string|false
Example
Get the value of the 'upload_max_filesize'
setting:
<?php
$res = ini_get('upload_max_filesize');
echo $res;
?>
Code execution result:
'2M'
Example
Try to get the value of a non-existent setting:
<?php
$res = ini_get('nonexistent_setting');
var_dump($res);
?>
Code execution result:
false
Example
Get several configuration values:
<?php
$max_execution = ini_get('max_execution_time');
$memory_limit = ini_get('memory_limit');
echo "Max execution time: $max_execution\n";
echo "Memory limit: $memory_limit";
?>
Code execution result:
'Max execution time: 30
Memory limit: 128M'
See Also
-
the
ini_set
function,
which sets the value of a configuration setting -
the
ini_get_all
function,
which returns all available configuration settings