diff options
-rw-r--r-- | ext/standard/basic_functions.c | 3 | ||||
-rw-r--r-- | ext/standard/head.c | 17 |
2 files changed, 16 insertions, 4 deletions
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index e6591af85a..916ffbcea6 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -94,6 +94,7 @@ php_basic_globals basic_globals; #include "php_fopen_wrappers.h" +static unsigned char first_and_second__args_force_ref[] = { 2, BYREF_FORCE, BYREF_FORCE }; static unsigned char second_and_third_args_force_ref[] = { 3, BYREF_NONE, BYREF_FORCE, BYREF_FORCE }; static unsigned char second_args_force_ref[] = { 2, BYREF_NONE, BYREF_FORCE }; static unsigned char third_and_fourth_args_force_ref[] = { 4, BYREF_NONE, BYREF_NONE, BYREF_FORCE, BYREF_FORCE }; @@ -540,7 +541,7 @@ function_entry basic_functions[] = { PHP_FE(ini_restore, NULL) PHP_FE(setcookie, NULL) - PHP_FE(header, NULL) + PHP_FE(header, first_and_second__args_force_ref) PHP_FE(headers_sent, NULL) PHP_FE(connection_aborted, NULL) diff --git a/ext/standard/head.c b/ext/standard/head.c index a6672239aa..0766261a7b 100644 --- a/ext/standard/head.c +++ b/ext/standard/head.c @@ -161,13 +161,24 @@ PHP_FUNCTION(setcookie) /* }}} */ -/* {{{ proto int headers_sent(void) +/* {{{ proto bool headers_sent([string &$file [, int &$line]]) Returns true if headers have already been sent, false otherwise */ PHP_FUNCTION(headers_sent) { - if (ZEND_NUM_ARGS() != 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "No parameters expected, %d given", ZEND_NUM_ARGS()); + zval *arg1, *arg2; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|zz", &arg1, &arg2) == FAILURE) return; + + + switch(ZEND_NUM_ARGS()) { + case 2: + zval_dtor(arg2); + ZVAL_LONG(arg2, php_get_output_start_lineno(TSRMLS_C)); + case 1: + zval_dtor(arg1); + ZVAL_STRING(arg1, php_get_output_start_filename(TSRMLS_C), 1); + break; } if (SG(headers_sent)) { |