parse_ini_file

FunctionParams and return types changed in PHP 8.0

Parse a configuration file.

PHP 5
PHP 7
PHP 8.0
Improved
PHP 8.1
PHP 8.2-8.3
PHP 8.4
PHP 8.5
PHP 8.6

parse_ini_file Function synopsis

parse_ini_file(
    string $filename,
    bool $process_sections = false,
    int $scanner_mode = INI_SCANNER_NORMAL
  ): array|false

Parameters

$filename

Typestring

The filename of the ini file being parsed. If a relative path is used, it is evaluated relative to the current working directory, then the include_path.

$process_sections

OptionalTypeboolDefault valuefalse

By setting the $process_sections parameter to true, you get a multidimensional array, with the section names and settings included. The default for $process_sections is false

$scanner_mode

OptionalTypeintDefault valueINI_SCANNER_NORMAL

Can either be INI_SCANNER_NORMAL (default) or INI_SCANNER_RAW. If INI_SCANNER_RAW is supplied, then option values will not be parsed.

Return value

Typearray|false

The settings are returned as an associative array on success, and false on failure.

Changes to the parse_ini_file Function

PHP 8.0

  • Return type added: array|false
  • Parameter type added for parameter #1 ($filename): string
  • Parameter type added for parameter #2 ($process_sections): bool
  • Parameter default value added for position #2 ($process_sections): false
  • Parameter type added for parameter #3 ($scanner_mode): int
  • Parameter default value added for position #3 ($scanner_mode): INI_SCANNER_NORMAL
  parse_ini_file(
-     $filename,
+     string $filename,
-     $process_sections,
+     bool $process_sections = false,
-     $scanner_mode
+     int $scanner_mode = INI_SCANNER_NORMAL
-   )
+   ): array|false

parse_ini_file Function Availability

PHP VersionAvailability
PHP 8.6Upcoming Release Yes
PHP 8.5Supported (Latest) Yes
PHP 8.4Supported Yes
PHP 8.3Security-Fixes Only Yes
PHP 8.2Security-Fixes Only Yes
PHP 8.1Unsupported Yes
PHP 8.0Unsupported Yes
PHP 7.4Unsupported Yes
PHP 7.3Unsupported Yes
PHP 7.2Unsupported Yes
PHP 7.1Unsupported Yes
PHP 7.0Unsupported Yes
PHP 5.6Unsupported Yes
PHP 5.5Unsupported Yes
PHP 5.4Unsupported Yes
PHP 5.3Unsupported Yes