[php-src] Issue #21947: The flag 'JSON_UNESCAPED_LINE_TERMINATORS' seems to be useless

[email protected] (JoeHorn)
Newsgroups php.bugs
Message-ID <[email protected]>
Issue: https://github.com/php/php-src/issues/21947
Author: JoeHorn

### Description

The following code:

```php
<?php
$strs = [
  'str1' => "Line1\nLine2",
  'str2' => "Line1\r\nLine2",
  'str3' => 'Line1' . PHP_EOL . 'Line2',
];
foreach ($strs as $k => $v) {
  echo "** {$k} **" . PHP_EOL . $v . PHP_EOL . PHP_EOL;
}

echo '** json_encoded **' . PHP_EOL . json_encode(
  $strs,
  JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_LINE_TERMINATORS
) . PHP_EOL . PHP_EOL;
```

Resulted in this output:
```
** str1 **
Line1
Line2

** str2 **
Line1
Line2

** str3 **
Line1
Line2

** json_encoded **
{"str1":"Line1\nLine2","str2":"Line1\r\nLine2","str3":"Line1\nLine2"}
```

But I expected this output instead:
```
** str1 **
Line1
Line2

** str2 **
Line1
Line2

** str3 **
Line1
Line2

** json_encoded **
{"str1":"Line1
Line2","str2":"Line1
Line2","str3":"Line1
Line2"}
```


### PHP Version

```plain
PHP 8.3.6 (cli) (built: Mar 20 2026 02:32:55) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.6, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.6, Copyright (c), by Zend Technologies
```

### Operating System

Ubuntu 24.04
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.