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

phpini_get(string $varname): string|false

Example

Get the value of the 'upload_max_filesize' setting:

php<?php
  $res = ini_get('upload_max_filesize');
  echo $res;
?>

Code execution result:

php'2M'

Example

Try to get the value of a non-existent setting:

php<?php
  $res = ini_get('nonexistent_setting');
  var_dump($res);
?>

Code execution result:

phpfalse

Example

Get several configuration values:

php<?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:

php'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