[php-src] Issue #10742: `http_response_code` must emit a warning if headers were already flushed
| From: | mvorisek | Date: | Wed, 01 Mar 2023 15:37:34 +0000 |
| Subject: | [php-src] Issue #10742: `http_response_code` must emit a warning if headers were already flushed | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-243829@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/10742
Author: mvorisek
### Description
The following code:
```php
<?php
echo 'x';
ob_end_flush();
flush();
// header('test: test');
http_response_code(301);
```
Resulted in this output:
```
x
```
But I expected this output instead:
```
x
Warning: Cannot modify response code - headers already sent by (output started at ....php:12) in
...
```
I would expect about the same warning as
header() emit. In the repro above, I have
verified header(string) emits a warning, but http_response_code(number)
currently does not.
### PHP Version
any
### Operating System
any