Skip to content

http_response_code must emit a warning if headers were already flushed #10742

Description

@mvorisek

Description

The following code:

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions