PHP 8.1: auto_detect_line_endings INI directive is deprecated

Version8.1
TypeDeprecation

File-handling functions such as file() and fgets() can automatically detect common line endings: \n (Line Feed / LF) and \r\n (Carriage-Return and Line-Feed / CRLF).

PHP also has an INI directive called auto_detect_line_endings, and this somewhat misleading INI directive enables PHP to also scan for \r line-endings, which were used by Classic Mac OS, which is unsupported since 2002.

Since PHP 8.1, PHP INI directive auto_detect_line_endings is deprecated. Setting it to true emits a PHP deprecation notice. This INI directive will be removed in PHP 9.0.

Regardless of the auto_detect_line_endings setting, PHP still can, and continue to, automatically detect common line endings: \n and \r\n.

In PHP 8.1 and later, setting the auto_detect_line_endings value to enable it (e.g. auto_detect_line_endings=On) either in a PHP INI file or in an ini_set call emits a deprecation notice.

auto_detect_line_endings=On
ini_set("auto_detect_line_endings", true);`
Deprecated: auto_detect_line_endings is deprecated ...

Backwards Compatibility Impact

Unless a PHP INI file or an explicit ini_set call enables the auto_detect_line_endings directive, this deprecation should not cause any issues in existing applications.

Note that auto_detect_line_endings directive only enables line-ending detection for \r characters, which are only used in legacy ("classic") Mac OS environments. It is not necessary to enable auto_detect_line_endings for PHP to detect standard \n and \r\n line-endings, which are common and used in Linux, Mac OS, and Windows systems.


RFC Implementation