Convert some warnings into ValueErrors in the standard file extension

Closes GH-5007
This commit is contained in:
George Peter Banyard 2019-12-11 21:57:57 +01:00
parent cb1b26ac9c
commit 9a76a2a032
26 changed files with 710 additions and 8214 deletions

View File

@ -351,8 +351,8 @@ PHP_FUNCTION(flock)
act = operation & 3;
if (act < 1 || act > 3) {
php_error_docref(NULL, E_WARNING, "Illegal operation argument");
RETURN_FALSE;
zend_value_error("Illegal operation argument");
RETURN_THROWS();
}
if (wouldblock) {
@ -745,8 +745,8 @@ PHP_FUNCTION(file)
ZEND_PARSE_PARAMETERS_END();
if (flags < 0 || flags > (PHP_FILE_USE_INCLUDE_PATH | PHP_FILE_IGNORE_NEW_LINES | PHP_FILE_SKIP_EMPTY_LINES | PHP_FILE_NO_DEFAULT_CONTEXT)) {
php_error_docref(NULL, E_WARNING, "'" ZEND_LONG_FMT "' flag is not supported", flags);
RETURN_FALSE;
zend_value_error("'" ZEND_LONG_FMT "' flag is not supported", flags);
RETURN_THROWS();
}
use_include_path = flags & PHP_FILE_USE_INCLUDE_PATH;
@ -1040,8 +1040,8 @@ PHPAPI PHP_FUNCTION(fgets)
efree(buf);
} else if (argc > 1) {
if (len <= 0) {
php_error_docref(NULL, E_WARNING, "Length parameter must be greater than 0");
RETURN_FALSE;
zend_value_error("Length parameter must be greater than 0");
RETURN_THROWS();
}
str = zend_string_alloc(len, 0);
@ -1495,8 +1495,8 @@ PHP_NAMED_FUNCTION(php_if_ftruncate)
ZEND_PARSE_PARAMETERS_END();
if (size < 0) {
php_error_docref(NULL, E_WARNING, "Negative size is not supported");
RETURN_FALSE;
zend_value_error("Negative size is not supported");
RETURN_THROWS();
}
PHP_STREAM_TO_ZVAL(stream, fp);
@ -1750,8 +1750,8 @@ PHPAPI PHP_FUNCTION(fread)
PHP_STREAM_TO_ZVAL(stream, res);
if (len <= 0) {
php_error_docref(NULL, E_WARNING, "Length parameter must be greater than 0");
RETURN_FALSE;
zend_value_error("Length parameter must be greater than 0");
RETURN_THROWS();
}
str = php_stream_read_to_str(stream, len);
@ -1829,8 +1829,8 @@ PHP_FUNCTION(fputcsv)
if (delimiter_str != NULL) {
/* Make sure that there is at least one character in string */
if (delimiter_str_len < 1) {
php_error_docref(NULL, E_WARNING, "delimiter must be a character");
RETURN_FALSE;
zend_value_error("delimiter must be a character");
RETURN_THROWS();
} else if (delimiter_str_len > 1) {
php_error_docref(NULL, E_NOTICE, "delimiter must be a single character");
}
@ -1841,8 +1841,8 @@ PHP_FUNCTION(fputcsv)
if (enclosure_str != NULL) {
if (enclosure_str_len < 1) {
php_error_docref(NULL, E_WARNING, "enclosure must be a character");
RETURN_FALSE;
zend_value_error("enclosure must be a character");
RETURN_THROWS();
} else if (enclosure_str_len > 1) {
php_error_docref(NULL, E_NOTICE, "enclosure must be a single character");
}
@ -1967,8 +1967,8 @@ PHP_FUNCTION(fgetcsv)
if (delimiter_str != NULL) {
/* Make sure that there is at least one character in string */
if (delimiter_str_len < 1) {
php_error_docref(NULL, E_WARNING, "delimiter must be a character");
RETURN_FALSE;
zend_value_error("delimiter must be a character");
RETURN_THROWS();
} else if (delimiter_str_len > 1) {
php_error_docref(NULL, E_NOTICE, "delimiter must be a single character");
}
@ -1979,8 +1979,8 @@ PHP_FUNCTION(fgetcsv)
if (enclosure_str != NULL) {
if (enclosure_str_len < 1) {
php_error_docref(NULL, E_WARNING, "enclosure must be a character");
RETURN_FALSE;
zend_value_error("enclosure must be a character");
RETURN_THROWS();
} else if (enclosure_str_len > 1) {
php_error_docref(NULL, E_NOTICE, "enclosure must be a single character");
}
@ -2004,8 +2004,8 @@ PHP_FUNCTION(fgetcsv)
if (len_zv != NULL && Z_TYPE_P(len_zv) != IS_NULL) {
len = zval_get_long(len_zv);
if (len < 0) {
php_error_docref(NULL, E_WARNING, "Length parameter may not be negative");
RETURN_FALSE;
zend_value_error("Length parameter may not be negative");
RETURN_THROWS();
} else if (len == 0) {
len = -1;
}

View File

@ -3,8 +3,11 @@ Bug #71882 (Negative ftruncate() on php://memory exhausts memory)
--FILE--
<?php
$fd = fopen("php://memory", "w+");
var_dump(ftruncate($fd, -1));
try {
var_dump(ftruncate($fd, -1));
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}
?>
--EXPECTF--
Warning: ftruncate(): Negative size is not supported in %s%ebug71882.php on line %d
bool(false)
--EXPECT--
Negative size is not supported

View File

@ -0,0 +1,2 @@
"water",fruit
This is line of text without csv fields
Can't render this file because it has a wrong number of fields in line 2.

View File

@ -0,0 +1,61 @@
--TEST--
Various fgetcsv() error conditions
--FILE--
<?php
$file_name = __DIR__ . '/fgetcsv_error_conditions.csv';
$file_handle = fopen($file_name, 'r');
$length = 1024;
$delimiter = ',';
$enclosure = '"';
echo 'fgetcsv() with negative length' . \PHP_EOL;
try {
var_dump( fgetcsv($file_handle, -10) );
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}
try {
var_dump( fgetcsv($file_handle, -10, $delimiter) );
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}
try {
var_dump( fgetcsv($file_handle, -10, $delimiter, $enclosure) );
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}
echo 'fgetcsv() with delimiter as NULL' . \PHP_EOL;
try {
var_dump( fgetcsv($file_handle, $length, NULL, $enclosure) );
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}
echo 'fgetcsv() with enclosure as NULL' . \PHP_EOL;
try {
var_dump( fgetcsv($file_handle, $length, $delimiter, NULL) );
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}
echo 'fgetcsv() with delimiter & enclosure as NULL' . \PHP_EOL;
try {
var_dump( fgetcsv($file_handle, $length, NULL, NULL) );
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}
?>
--EXPECT--
fgetcsv() with negative length
Length parameter may not be negative
Length parameter may not be negative
Length parameter may not be negative
fgetcsv() with delimiter as NULL
delimiter must be a character
fgetcsv() with enclosure as NULL
enclosure must be a character
fgetcsv() with delimiter & enclosure as NULL
delimiter must be a character

View File

@ -1,935 +0,0 @@
--TEST--
Test fgetcsv() : usage variations - with negative length value along with enclosure and delimiter
--FILE--
<?php
/*
Prototype: array fgetcsv ( resource $handle [, int $length [, string $delimiter [, string $enclosure]]] );
Description: Gets line from file pointer and parse for CSV fields
*/
/*
Testing fgetcsv() to read from a file when provided with negative length argument
along with delimiter and enclosure arguments
*/
echo "*** Testing fgetcsv() : with negative length value ***\n";
/* the array is with three elements in it. Each element should be read as
1st element is delimiter, 2nd element is enclosure
and 3rd element is csv fields
*/
$csv_lists = array (
array(',', '"', '"water",fruit'),
array(',', '"', '"water","fruit"'),
array(' ', '^', '^water^ ^fruit^'),
array(':', '&', '&water&:&fruit&'),
array('=', '=', '=water===fruit='),
array('-', '-', '-water--fruit-air'),
array('-', '-', '-water---fruit---air-'),
array(':', '&', '&""""&:&"&:,:":&,&:,,,,')
);
$filename = __DIR__ . '/fgetcsv_variation25.tmp';
@unlink($filename);
$file_modes = array ("r","rb", "rt", "r+", "r+b", "r+t",
"a+", "a+b", "a+t",
"w+", "w+b", "w+t",
"x+", "x+b", "x+t");
$loop_counter = 1;
foreach ($csv_lists as $csv_list) {
for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
// create the file and add the content with has csv fields
if ( strstr($file_modes[$mode_counter], "r") ) {
$file_handle = fopen($filename, "w");
} else {
$file_handle = fopen($filename, $file_modes[$mode_counter] );
}
if ( !$file_handle ) {
echo "Error: failed to create file $filename!\n";
exit();
}
$delimiter = $csv_list[0];
$enclosure = $csv_list[1];
$csv_field = $csv_list[2];
fwrite($file_handle, $csv_field . "\n");
// write another line of text and a blank line
// this will be used to test, if the fgetcsv() read more than a line and its
// working when only a blank line is read
fwrite($file_handle, "This is line of text without csv fields\n");
fwrite($file_handle, "\n"); // blank line
// close the file if the mode to be used is read mode and re-open using read mode
// else rewind the file pointer to beginning of the file
if ( strstr($file_modes[$mode_counter], "r" ) ) {
fclose($file_handle);
$file_handle = fopen($filename, $file_modes[$mode_counter]);
} else {
// rewind the file pointer to bof
rewind($file_handle);
}
echo "\n-- Testing fgetcsv() with file opened using $file_modes[$mode_counter] mode --\n";
// call fgetcsv() to parse csv fields
// use the right delimiter and enclosure with negative length
var_dump( fgetcsv($file_handle, -10, $delimiter, $enclosure) );
// check the file pointer position and if eof
var_dump( ftell($file_handle) );
var_dump( feof($file_handle) );
// close the file
fclose($file_handle);
//delete file
unlink($filename);
} //end of mode loop
} // end of foreach
echo "Done\n";
?>
--EXPECTF--
*** Testing fgetcsv() : with negative length value ***
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
Done

View File

@ -1,585 +0,0 @@
--TEST--
Test fgetcsv() : usage variations - reading files opened in write only mode (Bug #42036)
--FILE--
<?php
/*
Prototype: array fgetcsv ( resource $handle [, int $length [, string $delimiter [, string $enclosure]]] );
Description: Gets line from file pointer and parse for CSV fields
*/
/* Testing fgetcsv() to read from files opened in write only mode */
echo "*** Testing fgetcsv() : reading the files opened in write only mode ***\n";
/* the array is with three elements in it. Each element should be read as
1st element is delimiter, 2nd element is enclosure
and 3rd element is csv fields
*/
$csv_lists = array (
array(',', '"', '"water",fruit'),
array(',', '"', '"water","fruit"'),
array(' ', '^', '^water^ ^fruit^'),
array(':', '&', '&water&:&fruit&'),
array('=', '=', '=water===fruit='),
array('-', '-', '-water--fruit-air'),
array('-', '-', '-water---fruit---air-'),
array(':', '&', '&""""&:&"&:,:":&,&:,,,,')
);
$filename = __DIR__ . '/fgetcsv_variation26.tmp';
@unlink($filename);
$file_modes = array ("w", "wb", "wt",
"a", "ab", "at",
"x", "xb", "xt");
$loop_counter = 1;
foreach ($csv_lists as $csv_list) {
for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
// create the file and add the content with has csv fields
$file_handle = fopen($filename, $file_modes[$mode_counter] );
if ( !$file_handle ) {
echo "Error: failed to create file $filename!\n";
exit();
}
$delimiter = $csv_list[0];
$enclosure = $csv_list[1];
$csv_field = $csv_list[2];
fwrite($file_handle, $csv_field . "\n");
// write another line of text and a blank line
// this will be used to test, if the fgetcsv() read more than a line and its
// working when only a blank line is read
fwrite($file_handle, "This is line of text without csv fields\n");
fwrite($file_handle, "\n"); // blank line
// rewind the file pointer to bof
rewind($file_handle);
echo "\n-- Testing fgetcsv() with file opened using $file_modes[$mode_counter] mode --\n";
// call fgetcsv() to parse csv fields
// use the right delimiter and enclosure with max length
var_dump( fgetcsv($file_handle, 1024, $delimiter, $enclosure) );
// check the file pointer position and if eof
var_dump( ftell($file_handle) );
var_dump( feof($file_handle) );
// close the file
fclose($file_handle);
//delete file
unlink($filename);
} //end of mode loop
} // end of foreach
echo "Done\n";
?>
--EXPECTF--
*** Testing fgetcsv() : reading the files opened in write only mode ***
-- Testing fgetcsv() with file opened using w mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using wb mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using wt mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using ab mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using at mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using xb mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using xt mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using wb mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using wt mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using ab mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using at mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using xb mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using xt mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using wb mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using wt mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using ab mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using at mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using xb mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using xt mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using wb mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using wt mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using ab mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using at mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using xb mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using xt mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using wb mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using wt mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using ab mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using at mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using xb mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using xt mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using wb mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using wt mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using ab mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using at mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using xb mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using xt mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using wb mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using wt mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using ab mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using at mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using xb mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using xt mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using wb mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using wt mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using ab mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using at mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using xb mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using xt mode --
Notice: fgetcsv(): Read of 8192 bytes failed with errno=9 Bad file descriptor in %s on line %d
bool(false)
int(0)
bool(false)
Done

View File

@ -1,935 +0,0 @@
--TEST--
Test fgetcsv() : usage variations - with negative length value along with delimiter and no enclosure
--FILE--
<?php
/*
Prototype: array fgetcsv ( resource $handle [, int $length [, string $delimiter [, string $enclosure]]] );
Description: Gets line from file pointer and parse for CSV fields
*/
/*
Testing fgetcsv() to read from a file when provided with negative length argument
along with delimiter and no enclosure arguments
*/
echo "*** Testing fgetcsv() : with negative length value ***\n";
/* the array is with three elements in it. Each element should be read as
1st element is delimiter, 2nd element is enclosure
and 3rd element is csv fields
*/
$csv_lists = array (
array(',', '"', '"water",fruit'),
array(',', '"', '"water","fruit"'),
array(' ', '^', '^water^ ^fruit^'),
array(':', '&', '&water&:&fruit&'),
array('=', '=', '=water===fruit='),
array('-', '-', '-water--fruit-air'),
array('-', '-', '-water---fruit---air-'),
array(':', '&', '&""""&:&"&:,:":&,&:,,,,')
);
$filename = __DIR__ . '/fgetcsv_variation27.tmp';
@unlink($filename);
$file_modes = array ("r","rb", "rt", "r+", "r+b", "r+t",
"a+", "a+b", "a+t",
"w+", "w+b", "w+t",
"x+", "x+b", "x+t");
$loop_counter = 1;
foreach ($csv_lists as $csv_list) {
for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
// create the file and add the content with has csv fields
if ( strstr($file_modes[$mode_counter], "r") ) {
$file_handle = fopen($filename, "w");
} else {
$file_handle = fopen($filename, $file_modes[$mode_counter] );
}
if ( !$file_handle ) {
echo "Error: failed to create file $filename!\n";
exit();
}
$delimiter = $csv_list[0];
$enclosure = $csv_list[1];
$csv_field = $csv_list[2];
fwrite($file_handle, $csv_field . "\n");
// write another line of text and a blank line
// this will be used to test, if the fgetcsv() read more than a line and its
// working when only a blank line is read
fwrite($file_handle, "This is line of text without csv fields\n");
fwrite($file_handle, "\n"); // blank line
// close the file if the mode to be used is read mode and re-open using read mode
// else rewind the file pointer to beginning of the file
if ( strstr($file_modes[$mode_counter], "r" ) ) {
fclose($file_handle);
$file_handle = fopen($filename, $file_modes[$mode_counter]);
} else {
// rewind the file pointer to bof
rewind($file_handle);
}
echo "\n-- Testing fgetcsv() with file opened using $file_modes[$mode_counter] mode --\n";
// call fgetcsv() to parse csv fields
// use the right delimiter and enclosure with negative length
var_dump( fgetcsv($file_handle, -10, $delimiter) );
// check the file pointer position and if eof
var_dump( ftell($file_handle) );
var_dump( feof($file_handle) );
// close the file
fclose($file_handle);
//delete file
unlink($filename);
} //end of mode loop
} // end of foreach
echo "Done\n";
?>
--EXPECTF--
*** Testing fgetcsv() : with negative length value ***
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
Done

View File

@ -1,935 +0,0 @@
--TEST--
Test fgetcsv() : usage variations - with negative length value along with neither enclosure and nor delimiter
--FILE--
<?php
/*
Prototype: array fgetcsv ( resource $handle [, int $length [, string $delimiter [, string $enclosure]]] );
Description: Gets line from file pointer and parse for CSV fields
*/
/*
Testing fgetcsv() to read from a file when provided with negative length argument
along with neither delimiter nor enclosure argument
*/
echo "*** Testing fgetcsv() : with negative length value ***\n";
/* the array is with three elements in it. Each element should be read as
1st element is delimiter, 2nd element is enclosure
and 3rd element is csv fields
*/
$csv_lists = array (
array(',', '"', '"water",fruit'),
array(',', '"', '"water","fruit"'),
array(' ', '^', '^water^ ^fruit^'),
array(':', '&', '&water&:&fruit&'),
array('=', '=', '=water===fruit='),
array('-', '-', '-water--fruit-air'),
array('-', '-', '-water---fruit---air-'),
array(':', '&', '&""""&:&"&:,:":&,&:,,,,')
);
$filename = __DIR__ . '/fgetcsv_variation28.tmp';
@unlink($filename);
$file_modes = array ("r","rb", "rt", "r+", "r+b", "r+t",
"a+", "a+b", "a+t",
"w+", "w+b", "w+t",
"x+", "x+b", "x+t");
$loop_counter = 1;
foreach ($csv_lists as $csv_list) {
for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
// create the file and add the content with has csv fields
if ( strstr($file_modes[$mode_counter], "r") ) {
$file_handle = fopen($filename, "w");
} else {
$file_handle = fopen($filename, $file_modes[$mode_counter] );
}
if ( !$file_handle ) {
echo "Error: failed to create file $filename!\n";
exit();
}
$delimiter = $csv_list[0];
$enclosure = $csv_list[1];
$csv_field = $csv_list[2];
fwrite($file_handle, $csv_field . "\n");
// write another line of text and a blank line
// this will be used to test, if the fgetcsv() read more than a line and its
// working when only a blank line is read
fwrite($file_handle, "This is line of text without csv fields\n");
fwrite($file_handle, "\n"); // blank line
// close the file if the mode to be used is read mode and re-open using read mode
// else rewind the file pointer to beginning of the file
if ( strstr($file_modes[$mode_counter], "r" ) ) {
fclose($file_handle);
$file_handle = fopen($filename, $file_modes[$mode_counter]);
} else {
// rewind the file pointer to bof
rewind($file_handle);
}
echo "\n-- Testing fgetcsv() with file opened using $file_modes[$mode_counter] mode --\n";
// call fgetcsv() to parse csv fields
// use the right delimiter and enclosure with negative length
var_dump( fgetcsv($file_handle, -10) );
// check the file pointer position and if eof
var_dump( ftell($file_handle) );
var_dump( feof($file_handle) );
// close the file
fclose($file_handle);
//delete file
unlink($filename);
} //end of mode loop
} // end of foreach
echo "Done\n";
?>
--EXPECTF--
*** Testing fgetcsv() : with negative length value ***
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
bool(false)
int(0)
bool(false)
Done

View File

@ -1,933 +0,0 @@
--TEST--
Test fgetcsv() : usage variations - with delimiter as NULL
--FILE--
<?php
/*
Prototype: array fgetcsv ( resource $handle [, int $length [, string $delimiter [, string $enclosure]]] );
Description: Gets line from file pointer and parse for CSV fields
*/
/* Testing fgetcsv() to read from a file when provided with delimiter value as NULL */
echo "*** Testing fgetcsv() : with delimiter as NULL ***\n";
/* the array is with three elements in it. Each element should be read as
1st element is delimiter, 2nd element is enclosure
and 3rd element is csv fields
*/
$csv_lists = array (
array(',', '"', '"water",fruit'),
array(',', '"', '"water","fruit"'),
array(' ', '^', '^water^ ^fruit^'),
array(':', '&', '&water&:&fruit&'),
array('=', '=', '=water===fruit='),
array('-', '-', '-water--fruit-air'),
array('-', '-', '-water---fruit---air-'),
array(':', '&', '&""""&:&"&:,:":&,&:,,,,')
);
$filename = __DIR__ . '/fgetcsv_variation3.tmp';
@unlink($filename);
$file_modes = array ("r","rb", "rt", "r+", "r+b", "r+t",
"a+", "a+b", "a+t",
"w+", "w+b", "w+t",
"x+", "x+b", "x+t");
$loop_counter = 1;
foreach ($csv_lists as $csv_list) {
for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
// create the file and add the content with has csv fields
if ( strstr($file_modes[$mode_counter], "r") ) {
$file_handle = fopen($filename, "w");
} else {
$file_handle = fopen($filename, $file_modes[$mode_counter] );
}
if ( !$file_handle ) {
echo "Error: failed to create file $filename!\n";
exit();
}
$delimiter = $csv_list[0];
$enclosure = $csv_list[1];
$csv_field = $csv_list[2];
fwrite($file_handle, $csv_field . "\n");
// write another line of text and a blank line
// this will be used to test, if the fgetcsv() read more than a line and its
// working when only a blank line is read
fwrite($file_handle, "This is line of text without csv fields\n");
fwrite($file_handle, "\n"); // blank line
// close the file if the mode to be used is read mode and re-open using read mode
// else rewind the file pointer to beginning of the file
if ( strstr($file_modes[$mode_counter], "r" ) ) {
fclose($file_handle);
$file_handle = fopen($filename, $file_modes[$mode_counter]);
} else {
// rewind the file pointer to bof
rewind($file_handle);
}
echo "\n-- Testing fgetcsv() with file opened using $file_modes[$mode_counter] mode --\n";
// call fgetcsv() to parse csv fields
// use length as 0
fseek($file_handle, 0, SEEK_SET);
var_dump( fgetcsv($file_handle, 1024, NULL, $enclosure) );
// check the file pointer position and if eof
var_dump( ftell($file_handle) );
var_dump( feof($file_handle) );
// close the file
fclose($file_handle);
//delete file
unlink($filename);
} //end of mode loop
} // end of foreach
echo "Done\n";
?>
--EXPECTF--
*** Testing fgetcsv() : with delimiter as NULL ***
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
Done

View File

@ -1,932 +0,0 @@
--TEST--
Test fgetcsv() : usage variations - with enclosure as NULL
--FILE--
<?php
/*
Prototype: array fgetcsv ( resource $handle [, int $length [, string $delimiter [, string $enclosure]]] );
Description: Gets line from file pointer and parse for CSV fields
*/
/* Testing fgetcsv() to read from a file when provided with enclosure value as NULL */
echo "*** Testing fgetcsv() : with enclosure as NULL ***\n";
/* the array is with three elements in it. Each element should be read as
1st element is delimiter, 2nd element is enclosure
and 3rd element is csv fields
*/
$csv_lists = array (
array(',', '"', '"water",fruit'),
array(',', '"', '"water","fruit"'),
array(' ', '^', '^water^ ^fruit^'),
array(':', '&', '&water&:&fruit&'),
array('=', '=', '=water===fruit='),
array('-', '-', '-water--fruit-air'),
array('-', '-', '-water---fruit---air-'),
array(':', '&', '&""""&:&"&:,:":&,&:,,,,')
);
$filename = __DIR__ . '/fgetcsv_variation4.tmp';
@unlink($filename);
$file_modes = array ("r","rb", "rt", "r+", "r+b", "r+t",
"a+", "a+b", "a+t",
"w+", "w+b", "w+t",
"x+", "x+b", "x+t");
$loop_counter = 1;
foreach ($csv_lists as $csv_list) {
for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
// create the file and add the content with has csv fields
if ( strstr($file_modes[$mode_counter], "r") ) {
$file_handle = fopen($filename, "w");
} else {
$file_handle = fopen($filename, $file_modes[$mode_counter] );
}
if ( !$file_handle ) {
echo "Error: failed to create file $filename!\n";
exit();
}
$delimiter = $csv_list[0];
$enclosure = $csv_list[1];
$csv_field = $csv_list[2];
fwrite($file_handle, $csv_field . "\n");
// write another line of text and a blank line
// this will be used to test, if the fgetcsv() read more than a line and its
// working when only a blan line is read
fwrite($file_handle, "This is line of text without csv fields\n");
fwrite($file_handle, "\n"); // blank line
// close the file if the mode to be used is read mode and re-open using read mode
// else rewind the file pointer to beginning of the file
if ( strstr($file_modes[$mode_counter], "r" ) ) {
fclose($file_handle);
$file_handle = fopen($filename, $file_modes[$mode_counter]);
} else {
// rewind the file pointer to bof
rewind($file_handle);
}
echo "\n-- Testing fgetcsv() with file opened using $file_modes[$mode_counter] mode --\n";
// call fgetcsv() to parse csv fields
// use length as 0
fseek($file_handle, 0, SEEK_SET);
var_dump( fgetcsv($file_handle, 0, $delimiter, NULL) );
// check the file pointer position and if eof
var_dump( ftell($file_handle) );
var_dump( feof($file_handle) );
// close the file
fclose($file_handle);
//delete file
unlink($filename);
} //end of mode loop
} // end of foreach
echo "Done\n";
?>
--EXPECTF--
*** Testing fgetcsv() : with enclosure as NULL ***
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): enclosure must be a character in %s on line %d
bool(false)
int(0)
bool(false)
Done

View File

@ -1,934 +0,0 @@
--TEST--
Test fgetcsv() : usage variations - with delimiter & enclosure as NULL
--FILE--
<?php
/*
Prototype: array fgetcsv ( resource $handle [, int $length [, string $delimiter [, string $enclosure]]] );
Description: Gets line from file pointer and parse for CSV fields
*/
/*
Testing fgetcsv() to read from a file when provided with delimiter and
enclosure values both as NULL
*/
echo "*** Testing fgetcsv() : with delimiter & enclosure as NULL ***\n";
/* the array is with three elements in it. Each element should be read as
1st element is delimiter, 2nd element is enclosure
and 3rd element is csv fields
*/
$csv_lists = array (
array(',', '"', '"water",fruit'),
array(',', '"', '"water","fruit"'),
array(' ', '^', '^water^ ^fruit^'),
array(':', '&', '&water&:&fruit&'),
array('=', '=', '=water===fruit='),
array('-', '-', '-water--fruit-air'),
array('-', '-', '-water---fruit---air-'),
array(':', '&', '&""""&:&"&:,:":&,&:,,,,')
);
$filename = __DIR__ . '/fgetcsv_variation5.tmp';
@unlink($filename);
$file_modes = array ("r","rb", "rt", "r+", "r+b", "r+t",
"a+", "a+b", "a+t",
"w+", "w+b", "w+t",
"x+", "x+b", "x+t");
$loop_counter = 1;
foreach ($csv_lists as $csv_list) {
for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
// create the file and add the content with has csv fields
if ( strstr($file_modes[$mode_counter], "r") ) {
$file_handle = fopen($filename, "w");
} else {
$file_handle = fopen($filename, $file_modes[$mode_counter] );
}
if ( !$file_handle ) {
echo "Error: failed to create file $filename!\n";
exit();
}
$delimiter = $csv_list[0];
$enclosure = $csv_list[1];
$csv_field = $csv_list[2];
fwrite($file_handle, $csv_field . "\n");
// write another line of text and a blank line
// this will be used to test, if the fgetcsv() read more than a line and its
// working when only a blank line is read
fwrite($file_handle, "This is line of text without csv fields\n");
fwrite($file_handle, "\n"); // blank line
// close the file if the mode to be used is read mode and re-open using read mode
// else rewind the file pointer to beginning of the file
if ( strstr($file_modes[$mode_counter], "r" ) ) {
fclose($file_handle);
$file_handle = fopen($filename, $file_modes[$mode_counter]);
} else {
// rewind the file pointer to bof
rewind($file_handle);
}
echo "\n-- Testing fgetcsv() with file opened using $file_modes[$mode_counter] mode --\n";
// call fgetcsv() to parse csv fields
fseek($file_handle, 0, SEEK_SET);
var_dump( fgetcsv($file_handle, 1024, NULL, NULL) );
// check the file pointer position and if eof
var_dump( ftell($file_handle) );
var_dump( feof($file_handle) );
// close the file
fclose($file_handle);
//delete file
unlink($filename);
} //end of mode loop
} // end of foreach
echo "Done\n";
?>
--EXPECTF--
*** Testing fgetcsv() : with delimiter & enclosure as NULL ***
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rb mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using rt mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using r+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using a+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using w+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+ mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+b mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
-- Testing fgetcsv() with file opened using x+t mode --
Warning: fgetcsv(): delimiter must be a character in %s on line %d
bool(false)
int(0)
bool(false)
Done

View File

@ -14,22 +14,25 @@ $fp = fopen(__FILE__, "r");
// invalid length argument
echo "-- Testing fgets() with invalid length arguments --\n";
$len = 0;
var_dump( fgets($fp, $len) );
try {
var_dump( fgets($fp, $len) );
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}
$len = -10;
var_dump( fgets($fp, $len) );
try {
var_dump( fgets($fp, $len) );
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}
$len = 1;
var_dump( fgets($fp, $len) ); // return length - 1 always, expect false
echo "Done\n";
?>
--EXPECTF--
--EXPECT--
*** Testing error conditions ***
-- Testing fgets() with invalid length arguments --
Warning: fgets(): Length parameter must be greater than 0 in %s on line %d
Length parameter must be greater than 0
Length parameter must be greater than 0
bool(false)
Warning: fgets(): Length parameter must be greater than 0 in %s on line %d
bool(false)
bool(false)
Done

View File

@ -9,13 +9,17 @@ fwrite($fd, "Line 1\nLine 2\nLine 3");
fclose($fd);
for ($flags = 0; $flags <= 32; $flags++) {
var_dump(file($filepath, $flags));
try {
var_dump(file($filepath, $flags));
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}
}
unlink($filepath);
?>
--EXPECTF--
--EXPECT--
array(3) {
[0]=>
string(7) "Line 1
@ -232,30 +236,12 @@ array(3) {
[2]=>
string(6) "Line 3"
}
Warning: file(): '24' flag is not supported in %s on line %d
bool(false)
Warning: file(): '25' flag is not supported in %s on line %d
bool(false)
Warning: file(): '26' flag is not supported in %s on line %d
bool(false)
Warning: file(): '27' flag is not supported in %s on line %d
bool(false)
Warning: file(): '28' flag is not supported in %s on line %d
bool(false)
Warning: file(): '29' flag is not supported in %s on line %d
bool(false)
Warning: file(): '30' flag is not supported in %s on line %d
bool(false)
Warning: file(): '31' flag is not supported in %s on line %d
bool(false)
Warning: file(): '32' flag is not supported in %s on line %d
bool(false)
'24' flag is not supported
'25' flag is not supported
'26' flag is not supported
'27' flag is not supported
'28' flag is not supported
'29' flag is not supported
'30' flag is not supported
'31' flag is not supported
'32' flag is not supported

View File

@ -1,72 +0,0 @@
--TEST--
Test filesize() function: usage variations - file size after truncate
--SKIPIF--
<?php
if (substr(PHP_OS, 0, 3) != 'WIN') {
die('skip only valid for Windows');
}
--FILE--
<?php
/*
Prototype : int filesize ( string $filename );
Description : Returns the size of the file in bytes, or FALSE
(and generates an error of level E_WARNING) in case of an error.
*/
$file_path = __DIR__;
echo "*** Testing filesize(): usage variations ***\n";
$filename = $file_path."/filesize_variation3.tmp";
$file_handle = fopen($filename, "w");
fwrite($file_handle, str_repeat("Hello,World ", 1000) ); // create file of size 12000 bytes
fclose($file_handle);
echo "-- Testing filesize() after truncating the file to a new length --\n";
// truncate the file created earlier in subdir, the size of the file is 12000bytes
// truncate the same file, in the loop , each time with the decrement in size by 1200 bytes,
// until -1200bytes size
for($size = filesize($filename); $size>=-1200; $size-=1200) {
$file_handle = fopen($filename, "r+");
var_dump( ftruncate($file_handle, $size) );
fclose($file_handle);
var_dump( filesize($filename) );
clearstatcache();
}
echo "*** Done ***\n";
?>
--CLEAN--
<?php
$file_path = __DIR__;
unlink($file_path."/filesize_variation3.tmp");
?>
--EXPECTF--
*** Testing filesize(): usage variations ***
-- Testing filesize() after truncating the file to a new length --
bool(true)
int(12000)
bool(true)
int(10800)
bool(true)
int(9600)
bool(true)
int(8400)
bool(true)
int(7200)
bool(true)
int(6000)
bool(true)
int(4800)
bool(true)
int(3600)
bool(true)
int(2400)
bool(true)
int(1200)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
*** Done ***

View File

@ -1,10 +1,5 @@
--TEST--
Test filesize() function: usage variations - file size after truncate
--SKIPIF--
<?php
if (substr(PHP_OS, 0, 3) == 'WIN') {
die('skip only valid for Linux');
}
--FILE--
<?php
/*
@ -26,21 +21,24 @@ echo "-- Testing filesize() after truncating the file to a new length --\n";
// truncate the same file, in the loop , each time with the decrement in size by 1200 bytes,
// until -1200bytes size
for($size = filesize($filename); $size>=-1200; $size-=1200) {
$file_handle = fopen($filename, "r+");
var_dump( ftruncate($file_handle, $size) );
fclose($file_handle);
var_dump( filesize($filename) );
clearstatcache();
$file_handle = fopen($filename, "r+");
try {
var_dump( ftruncate($file_handle, $size) );
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}
fclose($file_handle);
var_dump( filesize($filename) );
clearstatcache();
}
echo "*** Done ***\n";
?>
--CLEAN--
<?php
$file_path = __DIR__;
unlink($file_path."/filesize_variation3.tmp");
?>
--EXPECTF--
--EXPECT--
*** Testing filesize(): usage variations ***
-- Testing filesize() after truncating the file to a new length --
bool(true)
@ -65,8 +63,5 @@ bool(true)
int(1200)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
*** Done ***

View File

@ -32,16 +32,20 @@ var_dump(flock($fp, LOCK_UN, $would));
var_dump($would);
var_dump(flock($fp, -1));
var_dump(flock($fp, 0));
echo "Done\n";
try {
var_dump(flock($fp, 0));
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}
?>
--CLEAN--
<?php
$file = __DIR__."/flock.dat";
unlink($file);
?>
--EXPECTF--
--EXPECT--
flock(): supplied resource is not a valid stream resource
bool(true)
bool(true)
@ -56,7 +60,4 @@ int(0)
bool(true)
int(0)
bool(true)
Warning: flock(): Illegal operation argument in %s on line %d
bool(false)
Done
Illegal operation argument

View File

@ -30,13 +30,13 @@ $operations = array(
$i = 0;
foreach($operations as $operation) {
echo "\n--- Iteration $i ---";
try {
var_dump(flock($fp, $operation));
} catch (TypeError $e) {
echo "\n", $e->getMessage(), "\n";
}
$i++;
echo "--- Iteration $i ---" . \PHP_EOL;
try {
var_dump(flock($fp, $operation));
} catch (\TypeError|\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}
$i++;
}
@ -54,37 +54,24 @@ try {
$file = __DIR__."/flock_error.tmp";
unlink($file);
?>
--EXPECTF--
--EXPECT--
*** Testing error conditions ***
--- Iteration 0 ---
Warning: flock(): Illegal operation argument in %s on line %d
bool(false)
Illegal operation argument
--- Iteration 1 ---
Warning: flock(): Illegal operation argument in %s on line %d
bool(false)
Illegal operation argument
--- Iteration 2 ---
Warning: flock(): Illegal operation argument in %s on line %d
bool(false)
Illegal operation argument
--- Iteration 3 ---
Warning: flock(): Illegal operation argument in %s on line %d
bool(false)
Illegal operation argument
--- Iteration 4 ---
flock() expects parameter 2 to be int, array given
--- Iteration 5 ---
flock() expects parameter 2 to be int, array given
--- Iteration 6 ---
flock() expects parameter 2 to be int, string given
--- Iteration 7 ---
flock() expects parameter 2 to be int, string given
--- Iteration 8 ---
flock() expects parameter 2 to be int, string given
flock(): supplied resource is not a valid stream resource

View File

@ -55,7 +55,11 @@ foreach ($csv_lists as $csv_list) {
$csv_field = $csv_list[2];
// write to a file in csv format
var_dump( fputcsv($file_handle, $csv_field, NULL, $enclosure) );
try {
var_dump( fputcsv($file_handle, $csv_field, NULL, $enclosure) );
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}
// check the file pointer position and eof
var_dump( ftell($file_handle) );
var_dump( feof($file_handle) );
@ -72,869 +76,653 @@ foreach ($csv_lists as $csv_list) {
echo "Done\n";
?>
--EXPECTF--
--EXPECT--
*** Testing fputcsv() : with delimiter as NULL ***
-- file opened in r+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""

View File

@ -55,7 +55,11 @@ foreach ($csv_lists as $csv_list) {
$csv_field = $csv_list[2];
// write to a file in csv format
var_dump( fputcsv($file_handle, $csv_field, $delimiter, NULL) );
try {
var_dump( fputcsv($file_handle, $csv_field, $delimiter, NULL) );
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}
// check the file pointer position and eof
var_dump( ftell($file_handle) );
var_dump( feof($file_handle) );
@ -72,869 +76,653 @@ foreach ($csv_lists as $csv_list) {
echo "Done\n";
?>
--EXPECTF--
--EXPECT--
*** Testing fputcsv() : with enclosure as NULL ***
-- file opened in r+ --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+b --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+t --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+ --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+b --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+t --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+ --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+b --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+t --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+ --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+b --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+t --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+ --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+b --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+t --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+ --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+b --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+t --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+ --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+b --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+t --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+ --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+b --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+t --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+ --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+b --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+t --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+ --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+b --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+t --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+ --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+b --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+t --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+ --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+b --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+t --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+ --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+b --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+t --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+ --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+b --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+t --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+ --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+b --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+t --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+ --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+b --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+t --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+ --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+b --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+t --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+ --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+b --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+t --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+ --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+b --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+t --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+ --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+b --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+t --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+ --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+b --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+t --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+ --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+b --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+t --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+ --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+b --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+t --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+ --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+b --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+t --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+ --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+b --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+t --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+ --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+b --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+t --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+ --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+b --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+t --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+ --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+b --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+t --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+ --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+b --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+t --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+ --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+b --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+t --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+ --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+b --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+t --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+ --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+b --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+t --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+ --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+b --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+t --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+ --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+b --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+t --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+ --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+b --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+t --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+ --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+b --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+t --
Warning: fputcsv(): enclosure must be a character in %s on line %d
bool(false)
enclosure must be a character
int(0)
bool(false)
string(0) ""

View File

@ -55,7 +55,11 @@ foreach ($csv_lists as $csv_list) {
$csv_field = $csv_list[2];
// write to a file in csv format
var_dump( fputcsv($file_handle, $csv_field, NULL, NULL) );
try {
var_dump( fputcsv($file_handle, $csv_field, NULL, NULL) );
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}
// check the file pointer position and eof
var_dump( ftell($file_handle) );
var_dump( feof($file_handle) );
@ -72,869 +76,653 @@ foreach ($csv_lists as $csv_list) {
echo "Done\n";
?>
--EXPECTF--
--EXPECT--
*** Testing fputcsv() : with delimiter and enclosure as NULL ***
-- file opened in r+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in r+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in a+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in w+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+ --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+b --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""
-- file opened in x+t --
Warning: fputcsv(): delimiter must be a character in %s on line %d
bool(false)
delimiter must be a character
int(0)
bool(false)
string(0) ""

View File

@ -17,18 +17,21 @@ $file_handle = fopen($filename, "r");
// invalid length argument
echo "-- Testing fread() with invalid length arguments --\n";
$len = 0;
var_dump( fread($file_handle, $len) );
$len = -10;
var_dump( fread($file_handle, $len) );
try {
var_dump( fread($file_handle, $len) );
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}
echo "Done\n";
--EXPECTF--
$len = -10;
try {
var_dump( fread($file_handle, $len) );
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}
--EXPECT--
*** Testing error conditions ***
-- Testing fread() with invalid length arguments --
Warning: fread(): Length parameter must be greater than 0 in %s on line %d
bool(false)
Warning: fread(): Length parameter must be greater than 0 in %s on line %d
bool(false)
Done
Length parameter must be greater than 0
Length parameter must be greater than 0

View File

@ -1,558 +0,0 @@
--TEST--
Test ftruncate() function : usage variations - truncate file to negative size
--SKIPIF--
<?php
if (substr(PHP_OS, 0, 3) != 'WIN') {
die('skip.. only valid for Windows');
}
?>
--FILE--
<?php
/*
Prototype: bool ftruncate ( resource $handle, int $size );
Description: Truncates a file to a given length
*/
// include common file related test functions
include ("file.inc");
echo "*** Testing ftruncate() : usage variations ***\n";
/* test ftruncate with file opened in different modes */
$file_modes = array("r", "rb", "rt", "r+", "r+b", "r+t",
"w", "wb", "wt", "w+", "w+b", "w+t",
"x", "xb", "xt", "x+", "x+b", "x+t",
"a", "ab", "at", "a+", "a+b", "a+t");
$file_content_types = array("numeric","text_with_new_line");
foreach($file_content_types as $file_content_type) {
echo "\n-- Testing ftruncate() with file having data of type ". $file_content_type ." --\n";
for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
echo "-- Testing ftruncate() with file opening using $file_modes[$mode_counter] mode --\n";
// create 1 file with some contents
$filename = __DIR__."/ftruncate_variation4.tmp";
if( strstr($file_modes[$mode_counter], "x") || strstr($file_modes[$mode_counter], "w") ) {
// fopen the file using the $file_modes
$file_handle = fopen($filename, $file_modes[$mode_counter]);
fill_file($file_handle, $file_content_type, 1024);
} else {
create_files ( __DIR__, 1, $file_content_type, 0755, 1, "w", "ftruncate_variation", 4);
// fopen the file using the $file_modes
$file_handle = fopen($filename, $file_modes[$mode_counter]);
}
if (!$file_handle) {
echo "Error: failed to open file $filename!\n";
exit();
}
rewind($file_handle); // file pointer to 0
echo "-- Testing ftruncate(): try truncating file to a negative size --\n";
/* try to truncate it to a negative size, size should not change*/
$new_size = -1000;
var_dump( filesize($filename) ); // current filesize
var_dump( ftell($file_handle) );
var_dump( ftruncate($file_handle, $new_size) ); // truncate it
var_dump( ftell($file_handle) );
var_dump( feof($file_handle) );
fclose($file_handle);
clearstatcache(); // clear previous size value in cache
var_dump( filesize($filename) ); // new file size = actual size, no change
//delete all files created
delete_file( $filename );
}//end of inner for loop
}//end of outer foreach loop
echo "Done\n";
?>
--EXPECTF--
*** Testing ftruncate() : usage variations ***
-- Testing ftruncate() with file having data of type numeric --
-- Testing ftruncate() with file opening using r mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1024)
-- Testing ftruncate() with file opening using rb mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1024)
-- Testing ftruncate() with file opening using rt mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1024)
-- Testing ftruncate() with file opening using r+ mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1024)
-- Testing ftruncate() with file opening using r+b mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1024)
-- Testing ftruncate() with file opening using r+t mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1024)
-- Testing ftruncate() with file opening using w mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1024)
-- Testing ftruncate() with file opening using wb mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1024)
-- Testing ftruncate() with file opening using wt mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1024)
-- Testing ftruncate() with file opening using w+ mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1024)
-- Testing ftruncate() with file opening using w+b mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1024)
-- Testing ftruncate() with file opening using w+t mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1024)
-- Testing ftruncate() with file opening using x mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1024)
-- Testing ftruncate() with file opening using xb mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1024)
-- Testing ftruncate() with file opening using xt mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1024)
-- Testing ftruncate() with file opening using x+ mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1024)
-- Testing ftruncate() with file opening using x+b mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1024)
-- Testing ftruncate() with file opening using x+t mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1024)
-- Testing ftruncate() with file opening using a mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1024)
-- Testing ftruncate() with file opening using ab mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1024)
-- Testing ftruncate() with file opening using at mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1024)
-- Testing ftruncate() with file opening using a+ mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1024)
-- Testing ftruncate() with file opening using a+b mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1024)
-- Testing ftruncate() with file opening using a+t mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1024)
-- Testing ftruncate() with file having data of type text_with_new_line --
-- Testing ftruncate() with file opening using r mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1024)
-- Testing ftruncate() with file opening using rb mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1024)
-- Testing ftruncate() with file opening using rt mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1024)
-- Testing ftruncate() with file opening using r+ mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1024)
-- Testing ftruncate() with file opening using r+b mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1024)
-- Testing ftruncate() with file opening using r+t mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1024)
-- Testing ftruncate() with file opening using w mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1024)
-- Testing ftruncate() with file opening using wb mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1024)
-- Testing ftruncate() with file opening using wt mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1137)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1137)
-- Testing ftruncate() with file opening using w+ mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1024)
-- Testing ftruncate() with file opening using w+b mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1024)
-- Testing ftruncate() with file opening using w+t mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1137)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1137)
-- Testing ftruncate() with file opening using x mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1024)
-- Testing ftruncate() with file opening using xb mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1024)
-- Testing ftruncate() with file opening using xt mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1137)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1137)
-- Testing ftruncate() with file opening using x+ mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1024)
-- Testing ftruncate() with file opening using x+b mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1024)
-- Testing ftruncate() with file opening using x+t mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1137)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1137)
-- Testing ftruncate() with file opening using a mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1024)
-- Testing ftruncate() with file opening using ab mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1024)
-- Testing ftruncate() with file opening using at mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1024)
-- Testing ftruncate() with file opening using a+ mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1024)
-- Testing ftruncate() with file opening using a+b mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1024)
-- Testing ftruncate() with file opening using a+t mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
int(0)
bool(false)
int(1024)
Done

View File

@ -1,11 +1,5 @@
--TEST--
Test ftruncate() function : usage variations - truncate file to negative size
--SKIPIF--
<?php
if (substr(PHP_OS, 0, 3) == 'WIN') {
die('skip.. Not valid for Windows');
}
?>
--FILE--
<?php
/*
@ -27,532 +21,442 @@ $file_modes = array("r", "rb", "rt", "r+", "r+b", "r+t",
$file_content_types = array("numeric","text_with_new_line");
foreach($file_content_types as $file_content_type) {
echo "\n-- Testing ftruncate() with file having data of type ". $file_content_type ." --\n";
echo "\n-- Testing ftruncate() with file having data of type ". $file_content_type ." --\n";
for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
echo "-- Testing ftruncate() with file opening using $file_modes[$mode_counter] mode --\n";
for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
echo "-- Testing ftruncate() with file opening using $file_modes[$mode_counter] mode --\n";
// create 1 file with some contents
$filename = __DIR__."/ftruncate_variation4.tmp";
if( strstr($file_modes[$mode_counter], "x") || strstr($file_modes[$mode_counter], "w") ) {
// fopen the file using the $file_modes
$file_handle = fopen($filename, $file_modes[$mode_counter]);
fill_file($file_handle, $file_content_type, 1024);
} else {
create_files ( __DIR__, 1, $file_content_type, 0755, 1, "w", "ftruncate_variation", 4);
// fopen the file using the $file_modes
$file_handle = fopen($filename, $file_modes[$mode_counter]);
}
if (!$file_handle) {
echo "Error: failed to open file $filename!\n";
exit();
}
// create 1 file with some contents
$filename = __DIR__."/ftruncate_variation4.tmp";
if( strstr($file_modes[$mode_counter], "x") || strstr($file_modes[$mode_counter], "w") ) {
// fopen the file using the $file_modes
$file_handle = fopen($filename, $file_modes[$mode_counter]);
fill_file($file_handle, $file_content_type, 1024);
} else {
create_files ( __DIR__, 1, $file_content_type, 0755, 1, "w", "ftruncate_variation", 4);
// fopen the file using the $file_modes
$file_handle = fopen($filename, $file_modes[$mode_counter]);
}
if (!$file_handle) {
echo "Error: failed to open file $filename!\n";
exit();
}
rewind($file_handle); // file pointer to 0
rewind($file_handle); // file pointer to 0
echo "-- Testing ftruncate(): try truncating file to a negative size --\n";
/* try to truncate it to a negative size, size should not change*/
echo "-- Testing ftruncate(): try truncating file to a negative size --\n";
/* try to truncate it to a negative size, size should not change*/
$new_size = -1000;
var_dump( filesize($filename) ); // current filesize
var_dump( ftell($file_handle) );
var_dump( ftruncate($file_handle, $new_size) ); // truncate it
var_dump( ftell($file_handle) );
var_dump( feof($file_handle) );
fclose($file_handle);
clearstatcache(); // clear previous size value in cache
var_dump( filesize($filename) ); // new file size = actual size, no change
$new_size = -1000;
$file_size = filesize($filename); // current filesize
var_dump($file_size === 1024 || $file_size === 1137); // 1137 is for Windows with 't' mode
var_dump( ftell($file_handle) );
try {
var_dump( ftruncate($file_handle, $new_size) ); // truncate it
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}
var_dump( ftell($file_handle) );
var_dump( feof($file_handle) );
fclose($file_handle);
clearstatcache(); // clear previous size value in cache
$file_size = filesize($filename); // new file size = actual size, no change
var_dump($file_size === 1024 || $file_size === 1137); // 1137 is for Windows with 't' mode
//delete all files created
delete_file( $filename );
}//end of inner for loop
//delete all files created
delete_file( $filename );
}//end of inner for loop
}//end of outer foreach loop
echo "Done\n";
?>
--EXPECTF--
--EXPECT--
*** Testing ftruncate() : usage variations ***
-- Testing ftruncate() with file having data of type numeric --
-- Testing ftruncate() with file opening using r mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using rb mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using rt mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using r+ mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using r+b mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using r+t mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using w mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using wb mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using wt mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using w+ mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using w+b mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using w+t mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using x mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using xb mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using xt mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using x+ mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using x+b mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using x+t mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using a mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using ab mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using at mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using a+ mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using a+b mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using a+t mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file having data of type text_with_new_line --
-- Testing ftruncate() with file opening using r mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using rb mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using rt mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using r+ mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using r+b mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using r+t mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using w mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using wb mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using wt mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using w+ mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using w+b mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using w+t mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using x mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using xb mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using xt mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using x+ mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using x+b mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using x+t mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using a mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using ab mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using at mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using a+ mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using a+b mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
-- Testing ftruncate() with file opening using a+t mode --
-- Testing ftruncate(): try truncating file to a negative size --
int(1024)
bool(true)
int(0)
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
int(0)
bool(false)
int(1024)
bool(true)
Done

View File

@ -38,7 +38,11 @@ $fd3 = fopen("test3://foo","r");
test("stream_truncate not implemented", $fd2, 0);
test("stream_truncate size 0", $fd, 0);
test("stream_truncate size 10", $fd, 10);
test("stream_truncate negative size", $fd, -1);
try {
test("stream_truncate negative size", $fd, -1);
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}
test("stream_truncate bad return", $fd3, 0);
--EXPECTF--
bool(true)
@ -55,9 +59,7 @@ bool(true)
truncation with new_size=10
bool(true)
------ stream_truncate negative size: -------
Warning: ftruncate(): Negative size is not supported in %s on line %d
bool(false)
Negative size is not supported
------ stream_truncate bad return: -------
truncation with new_size=0

View File

@ -11,20 +11,24 @@ if (!extension_loaded("zlib")) {
$f = __DIR__."/004.txt.gz";
$h = gzopen($f, 'r');
var_dump(gzread($h, 10));
var_dump(gzread($h, 0));
try {
var_dump(gzread($h, 0));
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}
var_dump(gzread($h, 5));
var_dump(gzread($h, -1));
try {
var_dump(gzread($h, -1));
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}
var_dump(gzread($h, 8));
gzclose($h);
?>
--EXPECTF--
--EXPECT--
string(10) "When you'r"
Warning: gzread(): Length parameter must be greater than 0 in %s on line %d
bool(false)
Length parameter must be greater than 0
string(5) "e tau"
Warning: gzread(): Length parameter must be greater than 0 in %s on line %d
bool(false)
Length parameter must be greater than 0
string(8) "ght thro"