Re: Function proposal

From: Date: Mon, 16 May 2005 18:02:30 +0000
Subject: Re: Function proposal
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-16258@lists.php.net to get a copy of this message
> > > Yes I know that this is a small function and yes I know it can be copy-paste > > > with every new project you do but from the first day I've been using PHP > > > until today this function follows me everywhere and I now that everyone is > > > using it one way or the other for debugging...... > > ... > > > > The proper place to ask for new features is at > > http://bugs.php.net/. Click > > "report a bug" and choose "Feature/Change Request" as the "Type > > of bug". > > But don't bother - this was requested before and denied. > If you really-really want it on your own build, just apply this short patch. Index: ext/standard/basic_functions.c =================================================================== RCS file: /repository/php-src/ext/standard/basic_functions.c,v retrieving revision 1.713 diff -u -r1.713 basic_functions.c --- ext/standard/basic_functions.c 2 May 2005 12:12:04 -0000 1.713 +++ ext/standard/basic_functions.c 16 May 2005 18:00:25 -0000 @@ -2762,23 +2762,29 @@ /* }}} */ -/* {{{ proto mixed print_r(mixed var [, bool return]) +/* {{{ proto mixed print_r(mixed var [, bool return[, bool pretags]]) Prints out or returns information about the specified variable */ PHP_FUNCTION(print_r) { zval *var; - zend_bool i = 0; + zend_bool i = 0, pretags = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|b", &var, &i) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|bb", &var, &i, &pretags) == FAILURE) { RETURN_FALSE; } if (i) { php_start_ob_buffer (NULL, 0, 1 TSRMLS_CC); } + if (pretags) { + php_printf("<pre>\n"); + } zend_print_zval_r(var, 0 TSRMLS_CC); + if (pretags) { + php_printf("\n</pre>\n"); + } if (i) { php_ob_get_buffer (return_value TSRMLS_CC); php_end_ob_buffer (0, 0 TSRMLS_CC);

« previous php.internals (#16258) next »