note 92428 rejected from function.file-get-contents by danbrown

From: Date: Thu, 23 Jul 2009 18:56:33 +0000
Subject: note 92428 rejected from function.file-get-contents by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-158661@lists.php.net to get a copy of this message
Note Submitter: ryan at genius dot com ---- The default value of the maxlen param is wrong. It is set to PHP_STREAM_COPY_ALL, not -1. passing -1 will trigger an error. From the C code: /* {{{ proto string file_get_contents(string filename [, bool use_include_path [, resource context [, long offset [, long maxlen]]]]) Read the entire file into a string */ PHP_FUNCTION(file_get_contents) { char *filename; int filename_len; char *contents; zend_bool use_include_path = 0; php_stream *stream; int len, newlen; long offset = -1; long maxlen = PHP_STREAM_COPY_ALL; zval *zcontext = NULL; php_stream_context *context = NULL; /* Parse arguments */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|br!ll", &filename, &filename_len, &use_include_path, &zcontext, &offset, &maxlen) == FAILURE) { return; } if (ZEND_NUM_ARGS() == 5 && maxlen < 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "length must be greater than or equal to zero"); RETURN_FALSE; }

« previous php.notes (#158661) next »