1--TEST--
2Test http_response_code basic functionality
3--CREDITS--
4Gabriel Caruso (carusogabriel@php.net)
5--SKIPIF--
6<?php
7if (getenv('SKIP_REPEAT')) {
8    /* The http_response_code leaks across repeats. Technically that's a bug, but it's something
9     * that only affects the CLI repeat option, where the response code is not meaningful in the
10     * first place. Other SAPIs will properly reset the response code for each request. */
11    die('skip Not repeatable');
12}
13?>
14--FILE--
15<?php
16var_dump(
17    // Get the current default response code
18    http_response_code(),
19    // Set a response code
20    http_response_code(201),
21    // Get the new response code
22    http_response_code()
23);
24echo "Now we've sent the headers\n";
25var_dump(
26    // This should fail
27    http_response_code(500)
28);
29?>
30--EXPECTF--
31bool(false)
32bool(true)
33int(201)
34Now we've sent the headers
35
36Warning: http_response_code(): Cannot set response code - headers already sent (output started at %s:%d) in %s on line %d
37bool(false)
38