1--TEST-- 2Test fscanf() function: usage variations - return type without third argument 3--FILE-- 4<?php 5 6/* 7 Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] ); 8 Description: Parses input from a file according to a format 9*/ 10 11/* test fscanf() for its return type */ 12 13$file_path = dirname(__FILE__); 14 15echo "*** Testing fscanf(): for its return type without third argument ***\n"; 16 17// create a file 18$filename = "$file_path/fscanf_variation1.tmp"; 19$file_handle = fopen($filename, "w"); 20if($file_handle == false) 21 exit("Error:failed to open file $filename"); 22@fwrite($file_handle, "hello_world "); 23@fwrite($file_handle, 12345); 24fclose($file_handle); 25 26// open file for reading 27$file_handle = fopen($filename, "r"); 28// capturing the return value from fscanf() called without third argument 29$return_value = fscanf($file_handle, "%s"); 30var_dump( is_array($return_value), $return_value); // return type is an array 31fclose($file_handle); 32 33echo "\n*** Done ***"; 34?> 35--CLEAN-- 36<?php 37$file_path = dirname(__FILE__); 38$filename = "$file_path/fscanf_variation1.tmp"; 39unlink($filename); 40?> 41--EXPECT-- 42*** Testing fscanf(): for its return type without third argument *** 43bool(true) 44array(1) { 45 [0]=> 46 string(11) "hello_world" 47} 48 49*** Done *** 50