From: Sascha Schumann Date: Fri, 27 Oct 2000 09:43:06 +0000 (+0000) Subject: Allow users to specify whether they want to replace existing header fields. X-Git-Tag: php-4.0.4RC3~508 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9b2a1110a6cc64290b53a484e41f11b3047a5355;p=php Allow users to specify whether they want to replace existing header fields. --- diff --git a/ext/standard/head.c b/ext/standard/head.c index 72c457a219..77169cca4b 100644 --- a/ext/standard/head.c +++ b/ext/standard/head.c @@ -59,17 +59,25 @@ PHP_RINIT_FUNCTION(head) /* Implementation of the language Header() function */ -/* {{{ proto void header(string header) +/* {{{ proto void header(string header[, bool replace]) Send a raw HTTP header */ PHP_FUNCTION(Header) { - pval **arg1; - - if (zend_get_parameters_ex(1, &arg1) == FAILURE) { + pval **arg1, **arg2; + zend_bool replace = 1; + + if (ZEND_NUM_ARGS() < 1 || ZEND_NUM_ARGS() > 2 + || zend_get_parameters_ex(ZEND_NUM_ARGS(), &arg1, &arg2) == FAILURE) { WRONG_PARAM_COUNT; } - convert_to_string_ex(arg1); - sapi_add_header(Z_STRVAL_PP(arg1), Z_STRLEN_PP(arg1), 1); + switch (ZEND_NUM_ARGS()) { + case 2: + convert_to_boolean_ex(arg2); + replace = Z_BVAL_PP(arg2); + case 1: + convert_to_string_ex(arg1); + } + sapi_add_header_ex(Z_STRVAL_PP(arg1), Z_STRLEN_PP(arg1), 1, replace); } /* }}} */