note 92428 added to function.file-get-contents

From: Date: Thu, 23 Jul 2009 18:55:11 +0000
Subject: note 92428 added to function.file-get-contents
Groups: php.notes 
Request: Send a blank email to php-notes+get-158660@lists.php.net to get a copy of this message
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; } ---- Server IP: 209.41.74.194 Probable Submitter: 64.244.66.2 ---- Manual Page -- http://www.php.net/manual/en/function.file-get-contents.php Edit -- https://master.php.net/note/edit/92428 Del: integrated -- https://master.php.net/note/delete/92428/integrated Del: useless -- https://master.php.net/note/delete/92428/useless Del: bad code -- https://master.php.net/note/delete/92428/bad+code Del: spam -- https://master.php.net/note/delete/92428/spam Del: non-english -- https://master.php.net/note/delete/92428/non-english Del: in docs -- https://master.php.net/note/delete/92428/in+docs Del: other reasons-- https://master.php.net/note/delete/92428 Reject -- https://master.php.net/note/reject/92428 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#158660) next »