]> granicus.if.org Git - php/commitdiff
New testcaes for file/strings/general_functions
authorZoe Slattery <zoe@php.net>
Fri, 25 May 2007 13:44:23 +0000 (13:44 +0000)
committerZoe Slattery <zoe@php.net>
Fri, 25 May 2007 13:44:23 +0000 (13:44 +0000)
24 files changed:
ext/standard/tests/file/fgetc_basic.phpt [new file with mode: 0644]
ext/standard/tests/file/fgetc_error.phpt [new file with mode: 0644]
ext/standard/tests/file/file.inc [new file with mode: 0644]
ext/standard/tests/file/fileinode_basic.phpt [new file with mode: 0644]
ext/standard/tests/file/fileinode_error.phpt [new file with mode: 0644]
ext/standard/tests/file/fileinode_variation.phpt [new file with mode: 0644]
ext/standard/tests/file/filetype_basic.phpt [new file with mode: 0644]
ext/standard/tests/file/filetype_error.phpt [new file with mode: 0644]
ext/standard/tests/file/filetype_variation.phpt [new file with mode: 0644]
ext/standard/tests/file/flock_basic.phpt [new file with mode: 0644]
ext/standard/tests/file/flock_error.phpt [new file with mode: 0644]
ext/standard/tests/file/flock_variation.phpt [new file with mode: 0644]
ext/standard/tests/file/fnmatch_basic.phpt [new file with mode: 0644]
ext/standard/tests/file/fnmatch_error.phpt [new file with mode: 0644]
ext/standard/tests/file/fnmatch_variation.phpt [new file with mode: 0644]
ext/standard/tests/file/fpassthru_basic.phpt [new file with mode: 0644]
ext/standard/tests/file/fpassthru_error.phpt [new file with mode: 0644]
ext/standard/tests/file/fpassthru_variation.phpt [new file with mode: 0644]
ext/standard/tests/general_functions/intval.phpt [new file with mode: 0644]
ext/standard/tests/general_functions/var_export.phpt [new file with mode: 0644]
ext/standard/tests/strings/dirname_basic.phpt [new file with mode: 0644]
ext/standard/tests/strings/dirname_error.phpt [new file with mode: 0644]
ext/standard/tests/strings/dirname_variation.phpt [new file with mode: 0644]
ext/standard/tests/strings/explode1.phpt [new file with mode: 0644]

diff --git a/ext/standard/tests/file/fgetc_basic.phpt b/ext/standard/tests/file/fgetc_basic.phpt
new file mode 100644 (file)
index 0000000..fca3a31
--- /dev/null
@@ -0,0 +1,543 @@
+--TEST--
+Test fgetc() function : basic functionality
+--FILE--
+<?php
+/*
+ Prototype: string fgetc ( resource $handle );
+ Description: Gets character from file pointer
+*/
+// include the header for common test function 
+include ("file.inc");
+
+echo "*** Testing fgetc() : basic operations ***\n";
+/* read charecter from different files which are opened in different modes */
+$file_modes = array( "r", "rb", "rt", "r+", "r+b", "r+t");
+
+/* create file with following type of contents */
+$file_content_types = array("numeric", "text", "text_with_new_line");
+
+for($outerloop_counter = 0; $outerloop_counter < count($file_content_types); $outerloop_counter++) {
+  echo "--- Outerloop iteration ";
+  echo $outerloop_counter + 1;
+  echo " ---\n";
+  // create file file 
+  create_files(dirname(__FILE__), 1, $file_content_types[$outerloop_counter]);
+  //open the file in different modes and check the working of fgetc
+  for($innerloop_counter = 0; $innerloop_counter < count($file_modes); $innerloop_counter++) {
+    echo "-- Innerloop iteration ";
+    echo $innerloop_counter + 1;
+    echo " of Outerloop Iteration ";
+    echo $outerloop_counter + 1;
+    echo " --\n";
+     
+    // open the file using the $file_modes
+    $filename = dirname(__FILE__)."/file1.tmp"; // file name that is created by create_files
+    echo "-- Testing fgetc() : file opened using $file_modes[$innerloop_counter] mode --\n";
+    $file_handle = fopen($filename, $file_modes[$innerloop_counter]);
+    if ( !$file_handle ) {
+      echo "Error: failed to open file $filename!";
+      exit();
+    }
+
+    // perform the read file atleast 6 char and check 
+    for( $counter = 1; $counter <= 6; $counter++ ) {
+      // read data from the file and check, file pointer position, feof etc
+      var_dump( fgetc($file_handle) ); // read a char
+      var_dump( ftell($file_handle) ); // file pointer position
+      var_dump( feof($file_handle) );  // is it eof()
+      var_dump($file_handle); // dump the $file_handle to see if any thing got modifed 
+    } // end of for
+    
+    // close the file 
+    fclose ( $file_handle);
+
+  } // end of innerloop for
+  
+  // delete the file
+  delete_files(dirname(__FILE__), 1);
+
+} // end of outerloop for
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fgetc() : basic operations ***
+--- Outerloop iteration 1 ---
+-- Innerloop iteration 1 of Outerloop Iteration 1 --
+-- Testing fgetc() : file opened using r mode --
+string(1) "2"
+int(1)
+bool(false)
+resource(8) of type (stream)
+string(1) "2"
+int(2)
+bool(false)
+resource(8) of type (stream)
+string(1) "2"
+int(3)
+bool(false)
+resource(8) of type (stream)
+string(1) "2"
+int(4)
+bool(false)
+resource(8) of type (stream)
+string(1) "2"
+int(5)
+bool(false)
+resource(8) of type (stream)
+string(1) "2"
+int(6)
+bool(false)
+resource(8) of type (stream)
+-- Innerloop iteration 2 of Outerloop Iteration 1 --
+-- Testing fgetc() : file opened using rb mode --
+string(1) "2"
+int(1)
+bool(false)
+resource(9) of type (stream)
+string(1) "2"
+int(2)
+bool(false)
+resource(9) of type (stream)
+string(1) "2"
+int(3)
+bool(false)
+resource(9) of type (stream)
+string(1) "2"
+int(4)
+bool(false)
+resource(9) of type (stream)
+string(1) "2"
+int(5)
+bool(false)
+resource(9) of type (stream)
+string(1) "2"
+int(6)
+bool(false)
+resource(9) of type (stream)
+-- Innerloop iteration 3 of Outerloop Iteration 1 --
+-- Testing fgetc() : file opened using rt mode --
+string(1) "2"
+int(1)
+bool(false)
+resource(10) of type (stream)
+string(1) "2"
+int(2)
+bool(false)
+resource(10) of type (stream)
+string(1) "2"
+int(3)
+bool(false)
+resource(10) of type (stream)
+string(1) "2"
+int(4)
+bool(false)
+resource(10) of type (stream)
+string(1) "2"
+int(5)
+bool(false)
+resource(10) of type (stream)
+string(1) "2"
+int(6)
+bool(false)
+resource(10) of type (stream)
+-- Innerloop iteration 4 of Outerloop Iteration 1 --
+-- Testing fgetc() : file opened using r+ mode --
+string(1) "2"
+int(1)
+bool(false)
+resource(11) of type (stream)
+string(1) "2"
+int(2)
+bool(false)
+resource(11) of type (stream)
+string(1) "2"
+int(3)
+bool(false)
+resource(11) of type (stream)
+string(1) "2"
+int(4)
+bool(false)
+resource(11) of type (stream)
+string(1) "2"
+int(5)
+bool(false)
+resource(11) of type (stream)
+string(1) "2"
+int(6)
+bool(false)
+resource(11) of type (stream)
+-- Innerloop iteration 5 of Outerloop Iteration 1 --
+-- Testing fgetc() : file opened using r+b mode --
+string(1) "2"
+int(1)
+bool(false)
+resource(12) of type (stream)
+string(1) "2"
+int(2)
+bool(false)
+resource(12) of type (stream)
+string(1) "2"
+int(3)
+bool(false)
+resource(12) of type (stream)
+string(1) "2"
+int(4)
+bool(false)
+resource(12) of type (stream)
+string(1) "2"
+int(5)
+bool(false)
+resource(12) of type (stream)
+string(1) "2"
+int(6)
+bool(false)
+resource(12) of type (stream)
+-- Innerloop iteration 6 of Outerloop Iteration 1 --
+-- Testing fgetc() : file opened using r+t mode --
+string(1) "2"
+int(1)
+bool(false)
+resource(13) of type (stream)
+string(1) "2"
+int(2)
+bool(false)
+resource(13) of type (stream)
+string(1) "2"
+int(3)
+bool(false)
+resource(13) of type (stream)
+string(1) "2"
+int(4)
+bool(false)
+resource(13) of type (stream)
+string(1) "2"
+int(5)
+bool(false)
+resource(13) of type (stream)
+string(1) "2"
+int(6)
+bool(false)
+resource(13) of type (stream)
+--- Outerloop iteration 2 ---
+-- Innerloop iteration 1 of Outerloop Iteration 2 --
+-- Testing fgetc() : file opened using r mode --
+string(1) "t"
+int(1)
+bool(false)
+resource(16) of type (stream)
+string(1) "e"
+int(2)
+bool(false)
+resource(16) of type (stream)
+string(1) "x"
+int(3)
+bool(false)
+resource(16) of type (stream)
+string(1) "t"
+int(4)
+bool(false)
+resource(16) of type (stream)
+string(1) " "
+int(5)
+bool(false)
+resource(16) of type (stream)
+string(1) "t"
+int(6)
+bool(false)
+resource(16) of type (stream)
+-- Innerloop iteration 2 of Outerloop Iteration 2 --
+-- Testing fgetc() : file opened using rb mode --
+string(1) "t"
+int(1)
+bool(false)
+resource(17) of type (stream)
+string(1) "e"
+int(2)
+bool(false)
+resource(17) of type (stream)
+string(1) "x"
+int(3)
+bool(false)
+resource(17) of type (stream)
+string(1) "t"
+int(4)
+bool(false)
+resource(17) of type (stream)
+string(1) " "
+int(5)
+bool(false)
+resource(17) of type (stream)
+string(1) "t"
+int(6)
+bool(false)
+resource(17) of type (stream)
+-- Innerloop iteration 3 of Outerloop Iteration 2 --
+-- Testing fgetc() : file opened using rt mode --
+string(1) "t"
+int(1)
+bool(false)
+resource(18) of type (stream)
+string(1) "e"
+int(2)
+bool(false)
+resource(18) of type (stream)
+string(1) "x"
+int(3)
+bool(false)
+resource(18) of type (stream)
+string(1) "t"
+int(4)
+bool(false)
+resource(18) of type (stream)
+string(1) " "
+int(5)
+bool(false)
+resource(18) of type (stream)
+string(1) "t"
+int(6)
+bool(false)
+resource(18) of type (stream)
+-- Innerloop iteration 4 of Outerloop Iteration 2 --
+-- Testing fgetc() : file opened using r+ mode --
+string(1) "t"
+int(1)
+bool(false)
+resource(19) of type (stream)
+string(1) "e"
+int(2)
+bool(false)
+resource(19) of type (stream)
+string(1) "x"
+int(3)
+bool(false)
+resource(19) of type (stream)
+string(1) "t"
+int(4)
+bool(false)
+resource(19) of type (stream)
+string(1) " "
+int(5)
+bool(false)
+resource(19) of type (stream)
+string(1) "t"
+int(6)
+bool(false)
+resource(19) of type (stream)
+-- Innerloop iteration 5 of Outerloop Iteration 2 --
+-- Testing fgetc() : file opened using r+b mode --
+string(1) "t"
+int(1)
+bool(false)
+resource(20) of type (stream)
+string(1) "e"
+int(2)
+bool(false)
+resource(20) of type (stream)
+string(1) "x"
+int(3)
+bool(false)
+resource(20) of type (stream)
+string(1) "t"
+int(4)
+bool(false)
+resource(20) of type (stream)
+string(1) " "
+int(5)
+bool(false)
+resource(20) of type (stream)
+string(1) "t"
+int(6)
+bool(false)
+resource(20) of type (stream)
+-- Innerloop iteration 6 of Outerloop Iteration 2 --
+-- Testing fgetc() : file opened using r+t mode --
+string(1) "t"
+int(1)
+bool(false)
+resource(21) of type (stream)
+string(1) "e"
+int(2)
+bool(false)
+resource(21) of type (stream)
+string(1) "x"
+int(3)
+bool(false)
+resource(21) of type (stream)
+string(1) "t"
+int(4)
+bool(false)
+resource(21) of type (stream)
+string(1) " "
+int(5)
+bool(false)
+resource(21) of type (stream)
+string(1) "t"
+int(6)
+bool(false)
+resource(21) of type (stream)
+--- Outerloop iteration 3 ---
+-- Innerloop iteration 1 of Outerloop Iteration 3 --
+-- Testing fgetc() : file opened using r mode --
+string(1) "l"
+int(1)
+bool(false)
+resource(24) of type (stream)
+string(1) "i"
+int(2)
+bool(false)
+resource(24) of type (stream)
+string(1) "n"
+int(3)
+bool(false)
+resource(24) of type (stream)
+string(1) "e"
+int(4)
+bool(false)
+resource(24) of type (stream)
+string(1) "
+"
+int(5)
+bool(false)
+resource(24) of type (stream)
+string(1) "l"
+int(6)
+bool(false)
+resource(24) of type (stream)
+-- Innerloop iteration 2 of Outerloop Iteration 3 --
+-- Testing fgetc() : file opened using rb mode --
+string(1) "l"
+int(1)
+bool(false)
+resource(25) of type (stream)
+string(1) "i"
+int(2)
+bool(false)
+resource(25) of type (stream)
+string(1) "n"
+int(3)
+bool(false)
+resource(25) of type (stream)
+string(1) "e"
+int(4)
+bool(false)
+resource(25) of type (stream)
+string(1) "
+"
+int(5)
+bool(false)
+resource(25) of type (stream)
+string(1) "l"
+int(6)
+bool(false)
+resource(25) of type (stream)
+-- Innerloop iteration 3 of Outerloop Iteration 3 --
+-- Testing fgetc() : file opened using rt mode --
+string(1) "l"
+int(1)
+bool(false)
+resource(26) of type (stream)
+string(1) "i"
+int(2)
+bool(false)
+resource(26) of type (stream)
+string(1) "n"
+int(3)
+bool(false)
+resource(26) of type (stream)
+string(1) "e"
+int(4)
+bool(false)
+resource(26) of type (stream)
+string(1) "
+"
+int(5)
+bool(false)
+resource(26) of type (stream)
+string(1) "l"
+int(6)
+bool(false)
+resource(26) of type (stream)
+-- Innerloop iteration 4 of Outerloop Iteration 3 --
+-- Testing fgetc() : file opened using r+ mode --
+string(1) "l"
+int(1)
+bool(false)
+resource(27) of type (stream)
+string(1) "i"
+int(2)
+bool(false)
+resource(27) of type (stream)
+string(1) "n"
+int(3)
+bool(false)
+resource(27) of type (stream)
+string(1) "e"
+int(4)
+bool(false)
+resource(27) of type (stream)
+string(1) "
+"
+int(5)
+bool(false)
+resource(27) of type (stream)
+string(1) "l"
+int(6)
+bool(false)
+resource(27) of type (stream)
+-- Innerloop iteration 5 of Outerloop Iteration 3 --
+-- Testing fgetc() : file opened using r+b mode --
+string(1) "l"
+int(1)
+bool(false)
+resource(28) of type (stream)
+string(1) "i"
+int(2)
+bool(false)
+resource(28) of type (stream)
+string(1) "n"
+int(3)
+bool(false)
+resource(28) of type (stream)
+string(1) "e"
+int(4)
+bool(false)
+resource(28) of type (stream)
+string(1) "
+"
+int(5)
+bool(false)
+resource(28) of type (stream)
+string(1) "l"
+int(6)
+bool(false)
+resource(28) of type (stream)
+-- Innerloop iteration 6 of Outerloop Iteration 3 --
+-- Testing fgetc() : file opened using r+t mode --
+string(1) "l"
+int(1)
+bool(false)
+resource(29) of type (stream)
+string(1) "i"
+int(2)
+bool(false)
+resource(29) of type (stream)
+string(1) "n"
+int(3)
+bool(false)
+resource(29) of type (stream)
+string(1) "e"
+int(4)
+bool(false)
+resource(29) of type (stream)
+string(1) "
+"
+int(5)
+bool(false)
+resource(29) of type (stream)
+string(1) "l"
+int(6)
+bool(false)
+resource(29) of type (stream)
+Done
\ No newline at end of file
diff --git a/ext/standard/tests/file/fgetc_error.phpt b/ext/standard/tests/file/fgetc_error.phpt
new file mode 100644 (file)
index 0000000..b771c3a
--- /dev/null
@@ -0,0 +1,73 @@
+--TEST--
+Test fgetc() function : error conditions
+--FILE--
+<?php
+/*
+ Prototype: string fgetc ( resource $handle );
+ Description: Gets character from file pointer
+*/
+
+echo "*** Testing error conditions ***\n";
+// zero argument
+echo "-- Testing fgetc() with zero argument --\n";
+var_dump( fgetc() );
+
+// more than expected no. of args
+echo "-- Testing fgetc() with more than expected number of arguments --\n";
+$fp = fopen(__FILE__, "r");
+var_dump( fgetc($fp, $fp) );
+fclose($fp);
+
+// test invalid arguments : non-resources
+echo "-- Testing fgetc() with invalid arguments --\n";
+$invalid_args = array (
+  "string",
+  10,
+  10.5,
+  true,
+  array(1,2,3),
+  new stdclass,
+);
+/* loop to test fgetc() with different invalid type of args */
+for($loop_counter = 1; $loop_counter <= count($invalid_args); $loop_counter++) {
+  echo "-- Iteration $loop_counter --\n";
+  var_dump( fgetc($invalid_args[$loop_counter - 1]) );
+}
+
+echo "Done\n";
+--EXPECTF--
+*** Testing error conditions ***
+-- Testing fgetc() with zero argument --
+
+Warning: Wrong parameter count for fgetc() in %s on line %d
+NULL
+-- Testing fgetc() with more than expected number of arguments --
+
+Warning: Wrong parameter count for fgetc() in %s on line %d
+NULL
+-- Testing fgetc() with invalid arguments --
+-- Iteration 1 --
+
+Warning: fgetc(): supplied argument is not a valid stream resource in %s on line %d
+bool(false)
+-- Iteration 2 --
+
+Warning: fgetc(): supplied argument is not a valid stream resource in %s on line %d
+bool(false)
+-- Iteration 3 --
+
+Warning: fgetc(): supplied argument is not a valid stream resource in %s on line %d
+bool(false)
+-- Iteration 4 --
+
+Warning: fgetc(): supplied argument is not a valid stream resource in %s on line %d
+bool(false)
+-- Iteration 5 --
+
+Warning: fgetc(): supplied argument is not a valid stream resource in %s on line %s
+bool(false)
+-- Iteration 6 --
+
+Warning: fgetc(): supplied argument is not a valid stream resource in %s on line %d
+bool(false)
+Done
diff --git a/ext/standard/tests/file/file.inc b/ext/standard/tests/file/file.inc
new file mode 100644 (file)
index 0000000..ea8bf04
--- /dev/null
@@ -0,0 +1,472 @@
+<?php
+/* Header file for common file test functions 
+     Following functions are provided :
+       create_files() : create files with specified contents 
+       delete_files() : delete files
+       create_links() : crate links of different types
+       delete_links() : delete links 
+       fill_files()   : fill file with specified contents 
+       change_file_perms : Change permission of files 
+
+*/ 
+
+define('file_not_found', 2, 1);
+
+/* 
+ Function: bool create_file(string $filename, string $mode = "w");
+ Description: creates a new file using fopen() call 
+   $filename = Name of the file 
+   $mode = Mode as specified in fopen call, read documentation of fopen() call for more info
+
+ Returns: 
+   true on success, false otherwise
+*/
+function create_file($filename, $mode = "w") {
+  $file_handle = fopen ($filename, $mode);
+  if ( $file_handle == false )
+    return false;
+  fclose($file_handle);
+  return true;
+}
+
+/*
+ Function : bool fill_file(resource $file_handle, string $fill_type, string $file_size);
+ Description: Fills the file with data as specified with requested size.
+   $file_handle = file handle, opened with write options,
+   $fill_type: 
+       "text" = fills with string of size $file_size
+       "numeric" = fills with numeric value of size $file_size
+       "empty" = no fill operation performed, returns true
+       "text_with_new_line" = similar to "text" fill type but writes with new line
+       "alphanumeric" = fills with alphnumeric values 
+ Returns: true on success, false on failure & invalid fill type
+*/
+
+function fill_file($file_handle, $fill_type, $file_size) {
+   
+  if ( $fill_type == "empty" ) {
+    // no fill required, return true
+    return true;
+  } if ( $fill_type == "text" ) {
+    $data = "text ";
+    $size_divider = strlen($data); 
+    $add_value = strlen($data);
+  } else if ( $fill_type == "text_with_new_line" ) {
+    $data = "line\nline of text\n";
+    $size_divider = strlen($data);
+    $add_value = strlen($data);
+  } else if ( $fill_type == "alphanumeric" ) {
+    $data = "ab12 ";
+    $size_divider = strlen($data);
+    $add_value = strlen($data);
+  } else if ( $fill_type == "numeric" ) {
+    $data = 2;
+    $size_divider = 1;
+    $add_value = 0;
+  } else { 
+    // invalid fill type;
+    return false;
+  }
+
+  // write in terms of a chunk of 1 K to avoid memory size overflow
+  $size = $file_size;
+  $chunk_size = 1024;
+  if ( $size > $chunk_size ) {
+    $loop_count = 1;
+    do {
+      $loop_count ++; 
+      if ( $size <= $chunk_size ) {
+        $chunk_size = $size;
+      }
+      $num_values = str_repeat($data, ($chunk_size/$size_divider) + $add_value );
+      $bytes_written = fwrite($file_handle, $num_values, $chunk_size);
+      if ( $bytes_written != $chunk_size ) {
+            return false;
+      }
+      $size -= $chunk_size;
+    } while ( $size > 0 );
+  } else {
+    $num_values = str_repeat($data, ($chunk_size/$size_divider) + $add_value );
+    $bytes_written = fwrite($file_handle, $num_values, $file_size);
+    if ( $bytes_written != $chunk_size ) {
+      return false;
+    }
+  }
+  
+  // successful, return true
+  return true;
+}
+
+/*
+ Function: int change_file_perms(string $file_path, int $count = 1, int $perms = 0755, 
+                                 string $name_prefix = "file", 
+                                 string $name_suffix = 1, $file_extension = ".tmp");
+ Description: changes file permission for given file(s).
+   $file_path = dir path where file exists
+   $count = no. of files, default is 1
+   $perms = new permission of the file, similar to $mode args of chmod() call
+   $name_prefix = common name prefix, default is "file"
+   $name_suffix = suffix to end the common name given in name_prefix to create
+      a unique name. default is 1. 
+   $file_extension = default is .tmp
+ Returns:
+   Integer, Count of total files permission changed.
+*/
+function change_file_perms($file_path,
+                           $count = 1, 
+                           $perms = 0755, 
+                           $name_prefix = "file", 
+                           $name_suffix = 1, 
+                           $file_extension = ".tmp" ) 
+{
+  $changed = 0;
+
+  if( $count <= 0 ) 
+    return $changed;
+
+  if ( $name_suffix <= 0)
+    $name_suffix = 1;
+
+  for($loop_counter = 1; $loop_counter <= $count; $loop_counter++) {
+    $filename = $file_path."/".$name_prefix.$name_suffix.$file_extension;
+    if( chmod($filename, $perms) )
+      $changed++;
+    $name_suffix++;
+  } 
+  return $changed;
+}
+
+/* 
+ Function: array create_files( string $file_path,
+                               int $count = 1,
+                               string $content_type = "numeric", 
+                               int $permission = 0755, 
+                               int $size = 1,
+                               string $mode = "w", 
+                               string $name_prefix = "file", 
+                               int $name_suffix = 1,
+                               string $flag = "kilobytes"
+                               string $file_extension = ".tmp"
+                             );
+ Description: Creates given number of files with specified mode and 
+   permissions. File is filled with content of size specified.
+   $file_path = dir where files will be created
+   $name_prefix = prefix to be used for names, name is suffix with a 
+     unqiue numeric value to make the file name unique, default = file
+   $name_suffix = suffix to be used for the name, default = 1
+   $count = total no. of files to be created, default = 1
+   $mode = file open mode as specified in fopen() call. Do not use 
+     modes used for only reading the file. Default = "w"
+   $permission = An octal number, This should be similar to $mode 
+     specified in chmod() call. 
+   $content_type = Specify type of the content to fill in the file. 
+     "numeric" = fill file with numeric vlaues
+     "text" = fill file with regular text
+     "empty" = empty file
+     "text_with_new_line" = similar to text fill type, but writes with new line char
+     "alphanumeric" = fill file with alpha numeric text
+     If imporper $content type is specified, file is created as empty
+   $size = size of the fill in terms of kilobyte, i.e size of the file.
+           if $flag is specified as "byte", then then given size is taken in bytes
+   $flag = specifiy if size has to be treated as no of total bytes or 
+           multiple of KB.
+     "kilobytes" = take size in terms of multiple of KB
+     "byte" = take size in terms of bytes 
+   $file_extension = default is .tmp
+
+ Returns:
+   An array with following key value pair:
+     created => total file created
+     filled => total files filled 
+     perms_changed => total files permission changed
+*/
+function create_files( $file_path,
+                       $count = 1,
+                       $content_type = "numeric",
+                       $permission = 0755,
+                       $size = 1,
+                       $mode = "w",
+                       $name_prefix = "file",
+                       $name_suffix = 1,
+                       $flag = "kilobytes",
+                       $file_extension = ".tmp"
+                     )
+{
+  $return_value = array('created' => 0, 'filled' => 0, 'perms_changed' => 0);
+
+  //ensure that suffix is a +ve integer
+  if ($name_suffix <= 0) {
+    $name_suffix = 1;
+  }
+
+  // check for proper size
+  if ( $size == 0 )
+    return $return_value;
+
+  // prepare the size based on flag 
+  $file_size = $size;
+  if ( $flag == "kilobytes" ) {
+    $file_size = $file_size * 1024;
+  }
+
+  $tmp_name_suffix = $name_suffix;
+  // create the files with specified mode and permission
+  for($file_created_count = 1; $file_created_count <= $count; $file_created_count ++) {
+    $filename = $file_path."/".$name_prefix.$tmp_name_suffix.$file_extension;
+
+    $status = create_file($filename, $mode);
+
+    $tmp_name_suffix++;
+
+    if ($status == true) {
+      $return_value['created']++;
+    }
+    else {
+      return $return_value;
+    }
+  }
+
+  if ( $content_type == "empty" ) {
+    $return_value['filled'] = $count;
+    return $return_value;
+  }
+
+  // fill the file with specifiec type of data and size
+  $tmp_name_suffix = $name_suffix;
+  for($loop_counter = 1; $loop_counter <= $count; $loop_counter ++) {
+    $filename = $file_path."/".$name_prefix.$tmp_name_suffix.$file_extension;
+    $file_handle = fopen($filename, $mode);
+    if($file_handle == false) {
+      fclose($file_handle);
+      return $return_value;
+    } // end of if
+    // call fill_file() to fill the file 
+    if( fill_file($file_handle, $content_type, $file_size) )
+      $return_value['filled']++;
+    
+    fclose($file_handle);
+
+    $tmp_name_suffix++;
+  } // end of for
+
+  // change all file's permissions
+  $return_value['perms_changed'] = change_file_perms($file_path, $count, $permission, $name_prefix, 
+                                                     $name_suffix, $file_extension);
+  
+  return $return_value;
+}
+
+
+/*
+ Function: function create_links( $file_path,
+                      $filename,
+                       $link_count = 1,
+                       $link_type = "soft",
+                       $link_size = 1024,
+                       $link_name_prefix = "link",
+                       $link_name_suffix = 1,
+                       $link_file_content = "text",
+                       $link_perms = 0755,
+                       $link_file_extension = ".tmp"
+                     );
+
+ Description: Creates given number of links with specified mode and
+   permissions.Link is filled with content of size specified.
+   $file_path = location of the file and where links need to be created
+   $link_name_prefix = prefix to be used for names, name is suffix with a
+     unique numeric value to make the file name unique, default = link
+   $link_name_suffix = suffix to be used for the name, default = 1
+   $link_count = total no. of links to be created to given file, default = 1
+   $link_perms = An octal number, This should be similar to $mode
+     specified in chmod() call.
+   $link_file_content = Type of the content to fill in the file.
+     numeric = fill file with numeric vlaues
+     text = fill file with regular text
+     text_with_new_line = same as text but new lines are written
+     alphanumeric = fill with alphanumeric text
+     If imporper $content type is specified, file is created as empty
+   $size = size of the fill in terms of kilobyte, i.e size of the file.
+   $link_type = type of the link to be created 
+      "soft" = soft link 
+      "hard" = hard link
+   $filename = file used to create a link on
+
+ Returns:
+   An array with following key value pair:
+     created => total file created
+     filled => total files filled, always returned as 1
+     perms_changed => total files permission changed
+*/
+function create_links( $file_path,
+                      $filename,
+                       $link_count = 1,
+                       $link_type = "soft",
+                       $link_size = 1024,
+                       $link_name_prefix = "link",
+                       $link_name_suffix = 1,
+                       $link_file_content = "text",
+                       $link_perms = 0755,
+                       $link_file_extension = ".tmp"
+                     )
+{
+  $return_value = array('created' => 0, 'filled' => 0, 'perms_changed' => 0);
+  $tmp_name_suffix = $link_name_suffix;
+  $src_filename = $file_path."/".$filename;
+  switch( $link_type ) {
+    default :
+    case "soft" :  // create a soft link
+      for($link_created_count = 1; $link_created_count <= $link_count; $link_created_count++) {
+        $linkname = $file_path."/".$link_name_prefix.$tmp_name_suffix.$link_file_extension;
+        $status = symlink( $src_filename, $linkname);
+        $tmp_name_suffix++;
+        if ($status) {
+          $return_value['created']++;
+        }
+        else {
+          $return_value;
+        }
+      }
+      break;
+
+    case "hard" :  // create a hard link
+      for($link_created_count = 1; $link_created_count <= $link_count; $link_created_count++) {
+        $linkname = $file_path."/".$link_name_prefix.$tmp_name_suffix.$link_file_extension;
+        $status = link($src_filename, $linkname);
+        $tmp_name_suffix++;
+        if ($status) {
+          $return_value['created']++;
+        }
+        else {
+          $return_value;
+        }
+      }
+      break;
+  }
+  
+  if ( $link_file_content == "empty" ) {
+    $return_value['filled'] = 1;
+    return $return_value;
+  }
+  
+  // fill the file with specific type of data and size
+  $tmp_name_suffix = $link_name_suffix;
+  $linkname = $file_path."/".$link_name_prefix.$tmp_name_suffix.$link_file_extension;
+  $file_handle = fopen($linkname, "w");
+  if($file_handle == false) {
+    return $return_value;
+  } // end of if
+  // call fill_file() to fill the file 
+  if( fill_file($file_handle, $link_file_content, $link_size) )
+    $return_value['filled']++;
+
+  // close the link
+  fclose($file_handle);
+
+  // change the permission of the link file, only if hard link.
+  // this is not applicable to soft links
+  if( $link_type == "hard" ) { 
+    $return_value['perms_changed'] = change_file_perms($file_path, 
+                                                        $link_count, 
+                                                        $link_perms, 
+                                                        $link_name_prefix, 
+                                                        $link_name_suffix,
+                                                        $link_file_extension );
+  }
+
+  return $return_value;
+}
+
+/* 
+ Function: bool delete_file(string $filename);
+ Description: delete a given file if exists 
+ Returns: true on success  
+          false on failure
+          file_not_found if file doesn't exist
+*/
+function delete_file($filename) {
+  // check if file exists
+  if ( file_exists($filename) ) {
+    if ( unlink($filename) )
+      return true;
+    else
+      return false;
+  }
+  return file_not_found;
+}
+
+/*
+ Function: array delete_files(string $file_path, int $count = 1, string $name_prefix = "file", 
+                              int name_suffix = 1, $file_extension = ".tmp" );
+ Description: Deletes given number of files if exists.
+   $file_path = location of the files
+   $name_prefix = prefix for the filename, rest of the name is incremental(increment by 1 only)
+     numeric starting from suffix upto count
+   $count = number of files to be deleted
+   $name_suffix = first numeric suffix in the name
+ Returns: An array with following key/value pair
+   deleted = Number of files deleted.
+   notfound = Count of non existing file
+   failed = Count of failed to delete
+*/
+function delete_files($file_path,
+                      $count = 1, 
+                      $name_prefix = "file", 
+                      $name_suffix = 1, 
+                      $file_extension = ".tmp") 
+{
+  $return_value = array ('deleted' => 0, 'notfound' => 0, 'failed' => 0);
+
+  if ( $name_suffix < 1 )
+    $name_suffix = 1; 
+  for($loop_counter = 1; $loop_counter <= $count; $loop_counter++) {
+    $filename = $file_path."/".$name_prefix.$name_suffix.$file_extension;
+    $name_suffix++;
+    $status = delete_file($filename);
+    if($status == true) {
+      $return_value['deleted']++;
+    } else if($status == file_not_found) {
+      $return_value['notfound']++;
+    } else {
+      $return_value['failed']++;
+    }
+    
+  } // end of for
+  return $return_value;
+}
+
+/*
+ Function: array delete_links( $file_path, 
+                               $link_file_count, 
+                               $link_name_prefix, 
+                               $link_name_suffix, 
+                               $link_file_extension );
+ Description: Deletes given number of links if exists. Uses delete_files() function
+   $file_path = location of link files 
+   $link_file_count = Number of link files 
+   $link_name_prefix = prefix for the linkname, rest of the name is incremental(increment by 1 only)
+     numeric starting from $link_name_suffix upto count
+   $link_name_suffix = first numeric suffix in the name
+
+ Returns: An array with following key/value pair
+   deleted = Number of links deleted.
+   notfound = Count of non existing link
+   failed = Count of failed to delete
+*/
+function delete_links($file_path,
+                      $link_file_count = 1, 
+                      $link_name_prefix = "link", 
+                      $link_name_suffix = 1, 
+                      $link_file_extension = ".tmp") 
+{
+   // call the delete files to delete links 
+   $return_value = delete_files( $file_path, 
+                                 $link_file_count, 
+                                 $link_name_prefix, 
+                                 $link_name_suffix, 
+                                 $link_file_extension );
+   return $return_value;
+}
+
+
diff --git a/ext/standard/tests/file/fileinode_basic.phpt b/ext/standard/tests/file/fileinode_basic.phpt
new file mode 100644 (file)
index 0000000..27b7dbd
--- /dev/null
@@ -0,0 +1,37 @@
+--TEST--
+Test fileinode() function: Basic functionality
+--FILE--
+<?php
+/* 
+Prototype: int fileinode ( string $filename );
+Description: Returns the inode number of the file, or FALSE in case of an error.
+*/
+
+echo "*** Testing fileinode() with file, directory ***\n";
+
+/* Getting inode of created file */
+$file_path = dirname(__FILE__);
+fopen("$file_path/inode.tmp", "w");
+print( fileinode("$file_path/inode.tmp") )."\n";
+
+/* Getting inode of current file */
+print( fileinode(__FILE__) )."\n";
+
+/* Getting inode of directories */
+print( fileinode(".") )."\n";
+print( fileinode("./..") )."\n";
+
+echo "\n*** Done ***";
+--CLEAN--
+<?php
+unlink (dirname(__FILE__)."/inode.tmp");
+?>
+
+--EXPECTF--
+*** Testing fileinode() with file, directory ***
+%d
+%d
+%d
+%d
+
+*** Done ***
diff --git a/ext/standard/tests/file/fileinode_error.phpt b/ext/standard/tests/file/fileinode_error.phpt
new file mode 100644 (file)
index 0000000..4730d06
--- /dev/null
@@ -0,0 +1,41 @@
+--TEST--
+Test fileinode() function: Error conditions
+--FILE--
+<?php
+/* 
+Prototype: int fileinode ( string $filename );
+Description: Returns the inode number of the file, or FALSE in case of an error.
+*/
+
+echo "*** Testing error conditions of fileinode() ***";
+
+/* Non-existing file or dir */
+var_dump( fileinode("/no/such/file/dir") );
+
+/* Invalid arguments */
+var_dump( fileinode("string") );
+var_dump( fileinode(100) );
+
+/* No.of argumetns less than expected */
+var_dump( fileinode() );
+
+/* No.of argumetns greater than expected */
+var_dump( fileinode(__FILE__, "string") );
+
+echo "\n*** Done ***";
+
+--EXPECTF--
+*** Testing error conditions of fileinode() ***
+Warning: fileinode(): stat failed for /no/such/file/dir in %s on line %d
+bool(false)
+
+Warning: fileinode(): stat failed for string in %s on line %d
+bool(false)
+
+Warning: Wrong parameter count for fileinode() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for fileinode() in %s on line %d
+NULL
+
+*** Done ***
diff --git a/ext/standard/tests/file/fileinode_variation.phpt b/ext/standard/tests/file/fileinode_variation.phpt
new file mode 100644 (file)
index 0000000..7a27964
--- /dev/null
@@ -0,0 +1,96 @@
+--TEST--
+Test fileinode() function: Variations
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+    die('skip no fnmatch() on Windows');
+}
+--FILE--
+<?php
+/* 
+Prototype: int fileinode ( string $filename );
+Description: Returns the inode number of the file, or FALSE in case of an error.
+*/
+
+include "file.inc";
+
+echo "*** Testing fileinode() with files, links and directories ***\n";
+
+echo "-- Testing with files --\n";
+create_files( dirname(__FILE__), 2);
+
+print( fileinode( dirname(__FILE__)."/file1.tmp") )."\n";
+print( fileinode( dirname(__FILE__)."/file2.tmp") )."\n";
+clearstatcache();
+
+echo "-- Testing with links: hard link --\n";
+link( dirname(__FILE__)."/file1.tmp", dirname(__FILE__)."/link1.tmp");  // Creating an hard link
+print( fileinode( dirname(__FILE__)."/file1.tmp") )."\n";
+clearstatcache();
+print( fileinode( dirname(__FILE__)."/link1.tmp") )."\n";
+clearstatcache();
+
+echo "-- Testing with links: soft link --\n";
+symlink( dirname(__FILE__)."/file2.tmp", dirname(__FILE__)."/link2.tmp");  // Creating a soft link
+print( fileinode( dirname(__FILE__)."/file2.tmp") )."\n";
+clearstatcache();
+print( fileinode( dirname(__FILE__)."/link2.tmp") )."\n";
+
+delete_files( dirname(__FILE__), 2, "link");
+
+echo "-- Testing after copying a file --\n";
+copy( dirname(__FILE__)."/file1.tmp", dirname(__FILE__)."/file1_new.tmp");
+print( fileinode( dirname(__FILE__)."/file1.tmp") )."\n";
+clearstatcache();
+print( fileinode( dirname(__FILE__)."/file1_new.tmp") )."\n";
+
+unlink( dirname(__FILE__)."/file1_new.tmp");
+
+delete_files( dirname(__FILE__), 2);
+
+
+echo "-- Testing after renaming the file --\n";
+$file_path = dirname(__FILE__);
+fopen("$file_path/old.txt", "w");
+print( fileinode("$file_path/old.txt") )."\n";
+clearstatcache();
+
+rename("$file_path/old.txt", "$file_path/new.txt");
+print( fileinode("$file_path/new.txt") )."\n";
+
+unlink("$file_path/new.txt");
+
+echo "-- Testing with directories --\n";
+mkdir("$file_path/dir");
+print( fileinode("$file_path/dir") )."\n";
+clearstatcache();
+
+mkdir("$file_path/dir/subdir");
+print( fileinode("$file_path/dir/subdir") );
+
+rmdir("$file_path/dir/subdir");
+rmdir("$file_path/dir");
+
+echo "\n*** Done ***";
+
+--EXPECTF--
+*** Testing fileinode() with files, links and directories ***
+-- Testing with files --
+%d
+%d
+-- Testing with links: hard link --
+%d
+%d
+-- Testing with links: soft link --
+%d
+%d
+-- Testing after copying a file --
+%d
+%d
+-- Testing after renaming the file --
+%d
+%d
+-- Testing with directories --
+%d
+%d
+*** Done ***
diff --git a/ext/standard/tests/file/filetype_basic.phpt b/ext/standard/tests/file/filetype_basic.phpt
new file mode 100644 (file)
index 0000000..4a6d3b2
--- /dev/null
@@ -0,0 +1,22 @@
+--TEST--
+Test filetype() function: Basic functionality
+--FILE--
+<?php
+/*
+Prototype: string filetype ( string $filename );
+Description: Returns the type of the file. Possible values are fifo, char,
+             dir, block, link, file, and unknown. 
+*/
+
+echo "*** Testing filetype() with files and dirs ***\n";
+
+print( filetype(__FILE__) )."\n";
+print( filetype(".") )."\n";
+
+echo "*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing filetype() with files and dirs ***
+file
+dir
+*** Done ***
diff --git a/ext/standard/tests/file/filetype_error.phpt b/ext/standard/tests/file/filetype_error.phpt
new file mode 100644 (file)
index 0000000..9b4d71f
--- /dev/null
@@ -0,0 +1,39 @@
+--TEST--
+Test filetype() function: Error conditions
+--FILE--
+<?php
+/*
+Prototype: string filetype ( string $filename );
+Description: Returns the type of the file. Possible values are fifo, char,
+             dir, block, link, file, and unknown. 
+*/
+
+echo "\n*** Testing error conditions ***";
+/* non-existing file or dir */
+print( filetype("/no/such/file/dir") );
+
+/* unknown type */
+print( filetype("string") );
+print( filetype(100) );
+
+/* No.of args less than expected */
+print( filetype() );
+
+/* No.of args greater than expected */
+print( filetype("file", "file") );
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing error conditions ***
+Warning: filetype(): Lstat failed for /no/such/file/dir in %s on line %d
+
+Warning: filetype(): Lstat failed for string in %s on line %d
+
+Warning: filetype(): Lstat failed for 100 in %s on line %d
+
+Warning: Wrong parameter count for filetype() in %s on line %d
+
+Warning: Wrong parameter count for filetype() in %s on line %d
+
+*** Done ***
diff --git a/ext/standard/tests/file/filetype_variation.phpt b/ext/standard/tests/file/filetype_variation.phpt
new file mode 100644 (file)
index 0000000..bc9e1a1
--- /dev/null
@@ -0,0 +1,69 @@
+--TEST--
+Test filetype() function: Variations
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+    die('skip no fnmatch() on Windows');
+}
+--FILE--
+<?php
+/*
+Prototype: string filetype ( string $filename );
+Description: Returns the type of the file. Possible values are fifo, char,
+             dir, block, link, file, and unknown. 
+*/
+
+include "file.inc";
+
+echo "*** Testing filetype() with various types ***\n";
+
+create_files( dirname(__FILE__), 2);
+
+echo "-- Checking with files --\n";
+print( filetype( dirname(__FILE__)."/file1.tmp") )."\n";
+print( filetype( dirname(__FILE__)."/file2.tmp") )."\n";
+clearstatcache();
+
+echo "-- Checking with links: hardlink --\n";
+link( dirname(__FILE__)."/file1.tmp", dirname(__FILE__)."/link1.tmp");
+print( filetype( dirname(__FILE__)."/link1.tmp" ) )."\n";
+
+echo "-- Checking with links: symlink --\n";
+symlink( dirname(__FILE__)."/file2.tmp", dirname(__FILE__)."/link2.tmp");
+print( filetype( dirname(__FILE__)."/link2.tmp") )."\n";
+
+delete_files( dirname(__FILE__), 2, "link");
+
+delete_files( dirname(__FILE__), 2, "file");
+
+$file_path = dirname(__FILE__);
+echo "-- Checking with directory --\n";
+mkdir("$file_path/temp");
+print( filetype("$file_path/temp") )."\n";
+rmdir( "$file_path/temp" );
+
+echo "-- Checking with fifo --\n";
+posix_mkfifo( dirname(__FILE__)."/file3.tmp", 0755);
+print( filetype( dirname(__FILE__)."/file3.tmp") )."\n";
+delete_files( dirname(__FILE__), 1, "file", 3);
+
+/* Checking with block in file */
+/* To test this PEAR package should be installed */
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing filetype() with various types ***
+-- Checking with files --
+file
+file
+-- Checking with links: hardlink --
+file
+-- Checking with links: symlink --
+link
+-- Checking with directory --
+dir
+-- Checking with fifo --
+fifo
+
+*** Done ***
diff --git a/ext/standard/tests/file/flock_basic.phpt b/ext/standard/tests/file/flock_basic.phpt
new file mode 100644 (file)
index 0000000..d218cee
--- /dev/null
@@ -0,0 +1,44 @@
+--TEST--
+Test flock() function: Basic functionality
+--FILE--
+<?php
+/* 
+Prototype: bool flock(resource $handle, int $operation [, int &$wouldblock]);
+Description: PHP supports a portable way of locking complete files 
+  in an advisory way
+*/
+
+echo "*** Testing flock() fun with file and dir ***\n"; 
+$file_path = dirname(__FILE__);
+
+$file_handle = fopen("$file_path/lock.tmp", "w");
+var_dump(flock($file_handle, LOCK_SH|LOCK_NB));
+var_dump(flock($file_handle, LOCK_UN));
+var_dump(flock($file_handle, LOCK_EX));
+var_dump(flock($file_handle, LOCK_UN));
+fclose($file_handle);
+unlink("$file_path/lock.tmp");
+
+mkdir("$file_path/dir");
+$dir_handle = opendir("$file_path/dir");
+var_dump(flock($dir_handle, LOCK_SH|LOCK_NB));
+var_dump(flock($dir_handle, LOCK_UN));
+var_dump(flock($dir_handle, LOCK_EX));
+var_dump(flock($dir_handle, LOCK_UN));
+closedir($dir_handle);
+rmdir("$file_path/dir");
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--    
+*** Testing flock() fun with file and dir ***
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+*** Done ***
diff --git a/ext/standard/tests/file/flock_error.phpt b/ext/standard/tests/file/flock_error.phpt
new file mode 100644 (file)
index 0000000..077e543
--- /dev/null
@@ -0,0 +1,112 @@
+--TEST--
+Test flock() function: Error conditions
+--FILE--
+<?php
+/* 
+Prototype: bool flock(resource $handle, int $operation [, int &$wouldblock]);
+Description: PHP supports a portable way of locking complete files 
+  in an advisory way
+*/
+
+echo "*** Testing error conditions ***\n";
+
+$file = dirname(__FILE__)."/flock.tmp";
+$fp = fopen($file, "w");
+
+/* array of operatons */
+$operations = array(
+  0,
+  LOCK_NB,
+  FALSE,
+  NULL,
+  array(1,2,3),
+  array(),
+  "string",
+  "",
+  "\0" 
+);
+
+$i = 0;
+foreach($operations as $operation) {
+  echo "\n--- Iteration $i ---";
+  var_dump(flock($fp, $operation));
+  $i++;
+}
+
+
+/* Invalid arguments */
+$fp = fopen($file, "w");
+fclose($fp);
+var_dump(flock($fp, LOCK_SH|LOCK_NB));
+
+var_dump(flock("", "", $var));
+
+/* No.of args leass than expected */
+var_dump(flock());
+var_dump(flock($fp));
+
+/* No.of args greater than expected */
+var_dump(flock($fp, "", $var, ""));
+
+echo "\n*** Done ***\n";
+?>
+--CLEAN--
+<?php
+$file = dirname(__FILE__)."/flock.tmp";
+unlink($file);
+?>
+--EXPECTF--    
+*** Testing error conditions ***
+
+--- Iteration 0 ---
+Warning: flock(): Illegal operation argument in %s on line %d
+bool(false)
+
+--- Iteration 1 ---
+Warning: flock(): Illegal operation argument in %s on line %d
+bool(false)
+
+--- Iteration 2 ---
+Warning: flock(): Illegal operation argument in %s on line %d
+bool(false)
+
+--- Iteration 3 ---
+Warning: flock(): Illegal operation argument in %s on line %d
+bool(false)
+
+--- Iteration 4 ---
+Warning: flock() expects parameter 2 to be long, array given in %s on line %d
+NULL
+
+--- Iteration 5 ---
+Warning: flock() expects parameter 2 to be long, array given in %s on line %d
+NULL
+
+--- Iteration 6 ---
+Warning: flock() expects parameter 2 to be long, string given in %s on line %d
+NULL
+
+--- Iteration 7 ---
+Warning: flock() expects parameter 2 to be long, string given in %s on line %d
+NULL
+
+--- Iteration 8 ---
+Warning: flock() expects parameter 2 to be long, string given in %s on line %d
+NULL
+
+Warning: flock(): 6 is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: flock() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Warning: flock() expects at least 2 parameters, 0 given in %s on line %d
+NULL
+
+Warning: flock() expects at least 2 parameters, 1 given in %s on line %d
+NULL
+
+Warning: flock() expects at most 3 parameters, 4 given in %s on line %d
+NULL
+
+*** Done ***
diff --git a/ext/standard/tests/file/flock_variation.phpt b/ext/standard/tests/file/flock_variation.phpt
new file mode 100644 (file)
index 0000000..d34f78f
--- /dev/null
@@ -0,0 +1,328 @@
+--TEST--
+Test flock() function: Variations
+--FILE--
+<?php
+/* 
+Prototype: bool flock(resource $handle, int $operation [, int &$wouldblock]);
+Description: PHP supports a portable way of locking complete files 
+  in an advisory way
+*/
+
+echo "*** Testing flock() fun with the various operation and 
+            wouldblock values                                ***\n";
+$file = dirname(__FILE__)."/flock.tmp";
+$fp = fopen($file, "w");
+
+/* array of operatons */
+$operations = array(
+  LOCK_SH,
+  LOCK_EX,
+  LOCK_SH|LOCK_NB,
+  LOCK_EX|LOCK_NB,
+  LOCK_SH|LOCK_EX,
+  LOCK_UN,
+  1, 
+  2,
+  2.234,
+  TRUE
+);
+
+/* array of wouldblocks */
+$wouldblocks = array(
+  0,
+  1,
+  2,
+  1.234,
+  TRUE,
+  FALSE,
+  NULL,
+  array(1,2,3),
+  array(),
+  "string",
+  "",
+  "\0"
+);
+
+$i = 0;
+foreach($operations as $operation) {
+  echo "--- Outer iteration $i ---\n";
+  var_dump(flock($fp, $operation));
+  $j = 0;
+  foreach($wouldblocks as $wouldblock) {
+    echo "-- Inner iteration $j in $i --\n";
+    var_dump(flock($fp, $operation, $wouldblock));
+    $j++;
+  }
+  $i++;
+}
+
+fclose($fp);
+@unlink($file);
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--    
+*** Testing flock() fun with the various operation and 
+            wouldblock values                                ***
+--- Outer iteration 0 ---
+bool(true)
+-- Inner iteration 0 in 0 --
+bool(true)
+-- Inner iteration 1 in 0 --
+bool(true)
+-- Inner iteration 2 in 0 --
+bool(true)
+-- Inner iteration 3 in 0 --
+bool(true)
+-- Inner iteration 4 in 0 --
+bool(true)
+-- Inner iteration 5 in 0 --
+bool(true)
+-- Inner iteration 6 in 0 --
+bool(true)
+-- Inner iteration 7 in 0 --
+bool(true)
+-- Inner iteration 8 in 0 --
+bool(true)
+-- Inner iteration 9 in 0 --
+bool(true)
+-- Inner iteration 10 in 0 --
+bool(true)
+-- Inner iteration 11 in 0 --
+bool(true)
+--- Outer iteration 1 ---
+bool(true)
+-- Inner iteration 0 in 1 --
+bool(true)
+-- Inner iteration 1 in 1 --
+bool(true)
+-- Inner iteration 2 in 1 --
+bool(true)
+-- Inner iteration 3 in 1 --
+bool(true)
+-- Inner iteration 4 in 1 --
+bool(true)
+-- Inner iteration 5 in 1 --
+bool(true)
+-- Inner iteration 6 in 1 --
+bool(true)
+-- Inner iteration 7 in 1 --
+bool(true)
+-- Inner iteration 8 in 1 --
+bool(true)
+-- Inner iteration 9 in 1 --
+bool(true)
+-- Inner iteration 10 in 1 --
+bool(true)
+-- Inner iteration 11 in 1 --
+bool(true)
+--- Outer iteration 2 ---
+bool(true)
+-- Inner iteration 0 in 2 --
+bool(true)
+-- Inner iteration 1 in 2 --
+bool(true)
+-- Inner iteration 2 in 2 --
+bool(true)
+-- Inner iteration 3 in 2 --
+bool(true)
+-- Inner iteration 4 in 2 --
+bool(true)
+-- Inner iteration 5 in 2 --
+bool(true)
+-- Inner iteration 6 in 2 --
+bool(true)
+-- Inner iteration 7 in 2 --
+bool(true)
+-- Inner iteration 8 in 2 --
+bool(true)
+-- Inner iteration 9 in 2 --
+bool(true)
+-- Inner iteration 10 in 2 --
+bool(true)
+-- Inner iteration 11 in 2 --
+bool(true)
+--- Outer iteration 3 ---
+bool(true)
+-- Inner iteration 0 in 3 --
+bool(true)
+-- Inner iteration 1 in 3 --
+bool(true)
+-- Inner iteration 2 in 3 --
+bool(true)
+-- Inner iteration 3 in 3 --
+bool(true)
+-- Inner iteration 4 in 3 --
+bool(true)
+-- Inner iteration 5 in 3 --
+bool(true)
+-- Inner iteration 6 in 3 --
+bool(true)
+-- Inner iteration 7 in 3 --
+bool(true)
+-- Inner iteration 8 in 3 --
+bool(true)
+-- Inner iteration 9 in 3 --
+bool(true)
+-- Inner iteration 10 in 3 --
+bool(true)
+-- Inner iteration 11 in 3 --
+bool(true)
+--- Outer iteration 4 ---
+bool(true)
+-- Inner iteration 0 in 4 --
+bool(true)
+-- Inner iteration 1 in 4 --
+bool(true)
+-- Inner iteration 2 in 4 --
+bool(true)
+-- Inner iteration 3 in 4 --
+bool(true)
+-- Inner iteration 4 in 4 --
+bool(true)
+-- Inner iteration 5 in 4 --
+bool(true)
+-- Inner iteration 6 in 4 --
+bool(true)
+-- Inner iteration 7 in 4 --
+bool(true)
+-- Inner iteration 8 in 4 --
+bool(true)
+-- Inner iteration 9 in 4 --
+bool(true)
+-- Inner iteration 10 in 4 --
+bool(true)
+-- Inner iteration 11 in 4 --
+bool(true)
+--- Outer iteration 5 ---
+bool(true)
+-- Inner iteration 0 in 5 --
+bool(true)
+-- Inner iteration 1 in 5 --
+bool(true)
+-- Inner iteration 2 in 5 --
+bool(true)
+-- Inner iteration 3 in 5 --
+bool(true)
+-- Inner iteration 4 in 5 --
+bool(true)
+-- Inner iteration 5 in 5 --
+bool(true)
+-- Inner iteration 6 in 5 --
+bool(true)
+-- Inner iteration 7 in 5 --
+bool(true)
+-- Inner iteration 8 in 5 --
+bool(true)
+-- Inner iteration 9 in 5 --
+bool(true)
+-- Inner iteration 10 in 5 --
+bool(true)
+-- Inner iteration 11 in 5 --
+bool(true)
+--- Outer iteration 6 ---
+bool(true)
+-- Inner iteration 0 in 6 --
+bool(true)
+-- Inner iteration 1 in 6 --
+bool(true)
+-- Inner iteration 2 in 6 --
+bool(true)
+-- Inner iteration 3 in 6 --
+bool(true)
+-- Inner iteration 4 in 6 --
+bool(true)
+-- Inner iteration 5 in 6 --
+bool(true)
+-- Inner iteration 6 in 6 --
+bool(true)
+-- Inner iteration 7 in 6 --
+bool(true)
+-- Inner iteration 8 in 6 --
+bool(true)
+-- Inner iteration 9 in 6 --
+bool(true)
+-- Inner iteration 10 in 6 --
+bool(true)
+-- Inner iteration 11 in 6 --
+bool(true)
+--- Outer iteration 7 ---
+bool(true)
+-- Inner iteration 0 in 7 --
+bool(true)
+-- Inner iteration 1 in 7 --
+bool(true)
+-- Inner iteration 2 in 7 --
+bool(true)
+-- Inner iteration 3 in 7 --
+bool(true)
+-- Inner iteration 4 in 7 --
+bool(true)
+-- Inner iteration 5 in 7 --
+bool(true)
+-- Inner iteration 6 in 7 --
+bool(true)
+-- Inner iteration 7 in 7 --
+bool(true)
+-- Inner iteration 8 in 7 --
+bool(true)
+-- Inner iteration 9 in 7 --
+bool(true)
+-- Inner iteration 10 in 7 --
+bool(true)
+-- Inner iteration 11 in 7 --
+bool(true)
+--- Outer iteration 8 ---
+bool(true)
+-- Inner iteration 0 in 8 --
+bool(true)
+-- Inner iteration 1 in 8 --
+bool(true)
+-- Inner iteration 2 in 8 --
+bool(true)
+-- Inner iteration 3 in 8 --
+bool(true)
+-- Inner iteration 4 in 8 --
+bool(true)
+-- Inner iteration 5 in 8 --
+bool(true)
+-- Inner iteration 6 in 8 --
+bool(true)
+-- Inner iteration 7 in 8 --
+bool(true)
+-- Inner iteration 8 in 8 --
+bool(true)
+-- Inner iteration 9 in 8 --
+bool(true)
+-- Inner iteration 10 in 8 --
+bool(true)
+-- Inner iteration 11 in 8 --
+bool(true)
+--- Outer iteration 9 ---
+bool(true)
+-- Inner iteration 0 in 9 --
+bool(true)
+-- Inner iteration 1 in 9 --
+bool(true)
+-- Inner iteration 2 in 9 --
+bool(true)
+-- Inner iteration 3 in 9 --
+bool(true)
+-- Inner iteration 4 in 9 --
+bool(true)
+-- Inner iteration 5 in 9 --
+bool(true)
+-- Inner iteration 6 in 9 --
+bool(true)
+-- Inner iteration 7 in 9 --
+bool(true)
+-- Inner iteration 8 in 9 --
+bool(true)
+-- Inner iteration 9 in 9 --
+bool(true)
+-- Inner iteration 10 in 9 --
+bool(true)
+-- Inner iteration 11 in 9 --
+bool(true)
+
+*** Done ***
diff --git a/ext/standard/tests/file/fnmatch_basic.phpt b/ext/standard/tests/file/fnmatch_basic.phpt
new file mode 100644 (file)
index 0000000..cc68924
--- /dev/null
@@ -0,0 +1,49 @@
+--TEST--
+Test fnmatch() function: Basic functionality
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+    die('skip no fnmatch() on Windows');
+}
+--FILE--
+<?php
+/* Prototype: bool fnmatch ( string $pattern, string $string [, int $flags] )
+   Description: fnmatch() checks if the passed string would match
+     the given shell wildcard pattern.
+*/
+
+echo "*** Testing fnmatch() with file ***\n";
+$file = basename(__FILE__);
+
+var_dump( fnmatch("*.php", $file) );
+var_dump( fnmatch("*.p*p", $file) );
+var_dump( fnmatch("*.p*", $file) );
+var_dump( fnmatch("*", $file) );
+var_dump( fnmatch("**", $file) );
+var_dump( fnmatch("*.phpt", $file) );
+
+echo "*** Testing fnmatch() with other than file ***\n";
+var_dump( fnmatch(100, 100) );
+var_dump( fnmatch("string", "string") );
+var_dump( fnmatch(TRUE, TRUE) );
+var_dump( fnmatch(FALSE, FALSE) );
+var_dump( fnmatch(NULL, NULL) );
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing fnmatch() with file ***
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(false)
+*** Testing fnmatch() with other than file ***
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+
+*** Done ***
diff --git a/ext/standard/tests/file/fnmatch_error.phpt b/ext/standard/tests/file/fnmatch_error.phpt
new file mode 100644 (file)
index 0000000..2bbff23
--- /dev/null
@@ -0,0 +1,57 @@
+--TEST--
+Test fnmatch() function: Error conditions
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+    die('skip no fnmatch() on Windows');
+}
+--FILE--
+<?php
+/* Prototype: bool fnmatch ( string $pattern, string $string [, int $flags] )
+   Description: fnmatch() checks if the passed string would match 
+     the given shell wildcard pattern. 
+*/
+
+echo "*** Testing error conditions for fnmatch() ***";
+
+/* Invalid arguments */
+var_dump( fnmatch(array(), array()) );
+
+$file_handle = fopen(__FILE__, "r");
+var_dump( fnmatch($file_handle, $file_handle) );
+fclose( $file_handle );
+
+$std_obj = new stdClass();
+var_dump( fnmatch($std_obj, $std_obj) );
+
+
+/* No.of arguments less than expected */
+var_dump( fnmatch("match.txt") );
+var_dump( fnmatch("") );
+
+/* No.of arguments greater than expected */
+var_dump( fnmatch("match.txt", "match.txt", TRUE, 100) );
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing error conditions for fnmatch() ***
+Warning: fnmatch() expects parameter 1 to be string, array given in %s on line %d
+NULL
+
+Warning: fnmatch() expects parameter 1 to be string, resource given in %s on line %d
+NULL
+
+Warning: fnmatch() expects parameter 1 to be string, object given in %s on line %d
+NULL
+
+Warning: fnmatch() expects at least 2 parameters, 1 given in %s on line %d
+NULL
+
+Warning: fnmatch() expects at least 2 parameters, 1 given in %s on line %d
+NULL
+
+Warning: fnmatch() expects at most 3 parameters, 4 given in %s on line %d
+NULL
+
+*** Done ***
diff --git a/ext/standard/tests/file/fnmatch_variation.phpt b/ext/standard/tests/file/fnmatch_variation.phpt
new file mode 100644 (file)
index 0000000..c3a3bdd
--- /dev/null
@@ -0,0 +1,402 @@
+--TEST--
+Test fnmatch() function: Variations
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+    die('skip no fnmatch() on Windows');
+}
+--FILE--
+<?php
+/* Prototype: bool fnmatch ( string $pattern, string $string [, int $flags] )
+   Description: fnmatch() checks if the passed string would match 
+     the given shell wildcard pattern. 
+*/
+
+echo "*** Testing fnmatch() with file and various patterns ***\n";
+$file_name = dirname(__FILE__)."/match.tmp";
+
+fopen($file_name, "w");
+
+$pattern_arr = array(
+0 => "*.tmp",
+1 => "match*",
+2 => "mat*",
+3 => "mat*tmp",
+4 => "m*t",
+5 => "ma[pt]ch*",
+6 => "*.t*",
+7 => "***.tmp",
+8 => "match**",
+9 => "*.t*p",
+10 => "",
+11 => "match",
+12 => ".tmp",
+13 => "?match",
+14 => "match?tmp",
+15 => "?tmp",
+16 => "match?",
+17 => "?match?",
+18 => "match.tmp",
+19 => "/match.tmp",
+20 => "/match.tmp/", 
+21 => 'match.tmp',
+22 => 'match.tmp\0',
+23 => "match.tmp\0",
+24 => "match\0.tmp",
+25 => chr(109).chr(97)."tch.tmp",
+26 => chr(109).chr(97).chr(116).chr(99).chr(104).".tmp",
+27 => chr(109).chr(97).chr(116).chr(99).chr(104).chr(46).chr(116).chr(120).chr(116),
+28 => chr(109).chr(97).chr(116).chr(99).chr(104).".".chr(116).chr(120).chr(116),
+29 => "MATCH.TMP",
+30 => "MATCH*",
+31 => $file_name 
+);
+
+for( $i = 0; $i<count($pattern_arr); $i++ ) {
+  echo "-- Iteration $i --\n";
+  var_dump( fnmatch($pattern_arr[$i], $file_name) );
+}
+unlink($file_name);
+
+
+echo "\n*** Testing fnmatch() with other types other than files ***";
+
+/* defining a common function */
+function match( $pattern, $string ) {
+  for( $i = 0; $i<count($pattern); $i++ ) {
+    echo "-- Iteration $i --\n";
+    for( $j = 0; $j<count($string); $j++ ) {
+    var_dump( fnmatch($pattern[$i], $string[$j]) );
+    }
+  }
+}
+
+echo "\n--- With Integers ---\n";
+$int_arr = array(
+  16,
+  16.00,
+  020,
+  020.00,
+  0xF,
+  0xF0000
+);
+match($int_arr, $int_arr);
+
+echo "\n--- With Strings ---\n";
+$str_arr = array(
+  "string",
+  "string\0",
+  'string',
+  "str\0ing",
+  "stringstring"
+);
+match($str_arr, $str_arr);
+
+echo "\n--- With booleans ---\n";
+$bool_arr = array(
+  TRUE,
+  true,
+  1,
+  10,
+  FALSE,
+  false,
+  0,
+  "",
+  "string"
+);
+match($bool_arr, $bool_arr);
+
+echo "\n--- With NULL ---\n";
+$null_arr = array(
+  NULL,
+  null,
+  "",
+  "\0",
+  "string",
+  0
+);
+match($null_arr, $null_arr);
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing fnmatch() with file and various patterns ***
+-- Iteration 0 --
+bool(true)
+-- Iteration 1 --
+bool(false)
+-- Iteration 2 --
+bool(false)
+-- Iteration 3 --
+bool(false)
+-- Iteration 4 --
+bool(false)
+-- Iteration 5 --
+bool(false)
+-- Iteration 6 --
+bool(true)
+-- Iteration 7 --
+bool(true)
+-- Iteration 8 --
+bool(false)
+-- Iteration 9 --
+bool(true)
+-- Iteration 10 --
+bool(false)
+-- Iteration 11 --
+bool(false)
+-- Iteration 12 --
+bool(false)
+-- Iteration 13 --
+bool(false)
+-- Iteration 14 --
+bool(false)
+-- Iteration 15 --
+bool(false)
+-- Iteration 16 --
+bool(false)
+-- Iteration 17 --
+bool(false)
+-- Iteration 18 --
+bool(false)
+-- Iteration 19 --
+bool(false)
+-- Iteration 20 --
+bool(false)
+-- Iteration 21 --
+bool(false)
+-- Iteration 22 --
+bool(false)
+-- Iteration 23 --
+bool(false)
+-- Iteration 24 --
+bool(false)
+-- Iteration 25 --
+bool(false)
+-- Iteration 26 --
+bool(false)
+-- Iteration 27 --
+bool(false)
+-- Iteration 28 --
+bool(false)
+-- Iteration 29 --
+bool(false)
+-- Iteration 30 --
+bool(false)
+-- Iteration 31 --
+bool(true)
+
+*** Testing fnmatch() with other types other than files ***
+--- With Integers ---
+-- Iteration 0 --
+bool(true)
+bool(true)
+bool(true)
+bool(false)
+bool(false)
+bool(false)
+-- Iteration 1 --
+bool(true)
+bool(true)
+bool(true)
+bool(false)
+bool(false)
+bool(false)
+-- Iteration 2 --
+bool(true)
+bool(true)
+bool(true)
+bool(false)
+bool(false)
+bool(false)
+-- Iteration 3 --
+bool(false)
+bool(false)
+bool(false)
+bool(true)
+bool(false)
+bool(false)
+-- Iteration 4 --
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(true)
+bool(false)
+-- Iteration 5 --
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(true)
+
+--- With Strings ---
+-- Iteration 0 --
+bool(true)
+bool(true)
+bool(true)
+bool(false)
+bool(false)
+-- Iteration 1 --
+bool(true)
+bool(true)
+bool(true)
+bool(false)
+bool(false)
+-- Iteration 2 --
+bool(true)
+bool(true)
+bool(true)
+bool(false)
+bool(false)
+-- Iteration 3 --
+bool(false)
+bool(false)
+bool(false)
+bool(true)
+bool(false)
+-- Iteration 4 --
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(true)
+
+--- With booleans ---
+-- Iteration 0 --
+bool(true)
+bool(true)
+bool(true)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+-- Iteration 1 --
+bool(true)
+bool(true)
+bool(true)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+-- Iteration 2 --
+bool(true)
+bool(true)
+bool(true)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+-- Iteration 3 --
+bool(false)
+bool(false)
+bool(false)
+bool(true)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+-- Iteration 4 --
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+bool(false)
+-- Iteration 5 --
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+bool(false)
+-- Iteration 6 --
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(true)
+bool(false)
+bool(false)
+-- Iteration 7 --
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+bool(false)
+-- Iteration 8 --
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(true)
+
+--- With NULL ---
+-- Iteration 0 --
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(false)
+bool(false)
+-- Iteration 1 --
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(false)
+bool(false)
+-- Iteration 2 --
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(false)
+bool(false)
+-- Iteration 3 --
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(false)
+bool(false)
+-- Iteration 4 --
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(true)
+bool(false)
+-- Iteration 5 --
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(true)
+
+*** Done ***
diff --git a/ext/standard/tests/file/fpassthru_basic.phpt b/ext/standard/tests/file/fpassthru_basic.phpt
new file mode 100644 (file)
index 0000000..a6e6612
--- /dev/null
@@ -0,0 +1,126 @@
+--TEST--
+Test fpassthru() function: Basic functionality
+--FILE--
+<?php
+/* 
+Prototype: int fpassthru ( resource $handle );
+Description: Reads to EOF on the given file pointer from the current position
+  and writes the results to the output buffer.
+*/
+
+$file_name = dirname(__FILE__)."/passthru.tmp";
+$write_handle = fopen($file_name, "w");
+
+$string = "Hello, world\n, abcdefg\tadsdsfdf\n8u2394723947\t$%$%#$%#$%#^#%^ 
+          Hello, world\n, abcdefg\tadsdsfdf\n8u2394723947\t$%$%#$%#$%#^#%^\n";
+
+fwrite($write_handle, $string);
+fclose($write_handle);
+
+$read_handle = fopen($file_name, "r");
+
+echo "*** Test basic functionality of fpassthru() function ***\n";
+echo "\n-- Before seek operation --\n";
+var_dump( fpassthru($read_handle) );
+
+echo "\n-- After seeking position to 0 --\n";
+fseek($read_handle, 0);
+var_dump( fpassthru($read_handle) );
+
+echo "\n-- After seeking position to 3 --\n";
+fseek($read_handle, 3);
+var_dump( fpassthru($read_handle) );
+
+echo "\n-- After seeking position to 13 --\n";
+fseek($read_handle, 13);
+var_dump( fpassthru($read_handle) );
+
+echo "\n-- After seeking position to 14 --\n";
+fseek($read_handle, 14);
+var_dump( fpassthru($read_handle) );
+
+echo "\n-- After seeking position to 23 --\n";
+fseek($read_handle, 23);
+var_dump( fpassthru($read_handle) );
+
+echo "\n-- After seeking position to 34 --\n";
+fseek($read_handle, 34);
+var_dump( fpassthru($read_handle) );
+
+echo "\n-- After seeking position to 1000 --\n";
+fseek($read_handle, 1000);
+var_dump( fpassthru($read_handle) );
+
+fclose($read_handle);
+
+echo "*** Done ***\n";
+
+?>
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/passthru.tmp");
+?>
+--EXPECTF--
+*** Test basic functionality of fpassthru() function ***
+
+-- Before seek operation --
+Hello, world
+, abcdefg      adsdsfdf
+8u2394723947   $%$%#$%#$%#^#%^ 
+          Hello, world
+, abcdefg      adsdsfdf
+8u2394723947   $%$%#$%#$%#^#%^
+int(133)
+
+-- After seeking position to 0 --
+Hello, world
+, abcdefg      adsdsfdf
+8u2394723947   $%$%#$%#$%#^#%^ 
+          Hello, world
+, abcdefg      adsdsfdf
+8u2394723947   $%$%#$%#$%#^#%^
+int(133)
+
+-- After seeking position to 3 --
+lo, world
+, abcdefg      adsdsfdf
+8u2394723947   $%$%#$%#$%#^#%^ 
+          Hello, world
+, abcdefg      adsdsfdf
+8u2394723947   $%$%#$%#$%#^#%^
+int(130)
+
+-- After seeking position to 13 --
+, abcdefg      adsdsfdf
+8u2394723947   $%$%#$%#$%#^#%^ 
+          Hello, world
+, abcdefg      adsdsfdf
+8u2394723947   $%$%#$%#$%#^#%^
+int(120)
+
+-- After seeking position to 14 --
+ abcdefg       adsdsfdf
+8u2394723947   $%$%#$%#$%#^#%^ 
+          Hello, world
+, abcdefg      adsdsfdf
+8u2394723947   $%$%#$%#$%#^#%^
+int(119)
+
+-- After seeking position to 23 --
+adsdsfdf
+8u2394723947   $%$%#$%#$%#^#%^ 
+          Hello, world
+, abcdefg      adsdsfdf
+8u2394723947   $%$%#$%#$%#^#%^
+int(110)
+
+-- After seeking position to 34 --
+2394723947     $%$%#$%#$%#^#%^ 
+          Hello, world
+, abcdefg      adsdsfdf
+8u2394723947   $%$%#$%#$%#^#%^
+int(99)
+
+-- After seeking position to 1000 --
+int(0)
+*** Done ***
\ No newline at end of file
diff --git a/ext/standard/tests/file/fpassthru_error.phpt b/ext/standard/tests/file/fpassthru_error.phpt
new file mode 100644 (file)
index 0000000..68e2e46
--- /dev/null
@@ -0,0 +1,40 @@
+--TEST--
+Test fpassthru() function: Error conditions
+--FILE--
+<?php
+/* 
+Prototype: int fpassthru ( resource $handle );
+Description: Reads to EOF on the given file pointer from the current position
+  and writes the results to the output buffer.
+*/
+
+echo "*** Test error conditions of fpassthru() function ***\n";
+
+/* Non-existing file resource */
+$no_file = fread("/no/such/file", "r");
+var_dump( fpassthru($no_file) );
+
+/* No.of args less than expected */
+var_dump( fpassthru() );
+
+/* No.of args greaer than expected */
+var_dump( fpassthru("", "") );
+
+echo "\n*** Done ***\n";
+
+?>
+--EXPECTF--
+*** Test error conditions of fpassthru() function ***
+
+Warning: fread(): supplied argument is not a valid stream resource in %s on line %d
+
+Warning: fpassthru(): supplied argument is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: Wrong parameter count for fpassthru() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for fpassthru() in %s on line %d
+NULL
+
+*** Done ***
diff --git a/ext/standard/tests/file/fpassthru_variation.phpt b/ext/standard/tests/file/fpassthru_variation.phpt
new file mode 100644 (file)
index 0000000..56a039e
--- /dev/null
@@ -0,0 +1,114 @@
+--TEST--
+Test fpassthru() function: Variations
+--FILE--
+<?php
+/* 
+Prototype: int fpassthru ( resource $handle );
+Description: Reads to EOF on the given file pointer from the current position
+  and writes the results to the output buffer.
+*/
+
+echo "*** Testing fpassthru() function with files ***\n\n";
+
+echo "--- Testing with different offsets ---\n";
+
+$file_name = dirname(__FILE__)."/passthru.tmp";
+$file_write = fopen($file_name, "w");
+fwrite($file_write, "1234567890abcdefghijklmnopqrstuvwxyz");
+fclose($file_write);
+
+$file_read = fopen($file_name, "r");
+
+$offset_arr = array(
+  /* Positive offsets */
+  0,
+  1, 
+  5,
+  10,
+  20,
+  30,
+  35,
+  36,
+  70,
+  /* Negative offsets, the file pointer should be at the end of file 
+  to get data */
+  -1, 
+  -5, 
+  -10,
+  -20,
+  -35,
+  -36,
+  -70
+);
+
+for( $i=0; $i<count($offset_arr); $i++ ) {
+  echo "-- Iteration $i --\n";
+  if( $offset_arr[$i] >= 0 ) {
+    fseek($file_read, $offset_arr[$i], SEEK_SET);
+    var_dump(fpassthru($file_read) );
+    rewind( $file_read );
+  }else
+    { 
+      fseek($file_read, $offset_arr[$i], SEEK_END);
+      var_dump( fpassthru($file_read) );
+      rewind( $file_read );
+    } 
+} 
+
+fclose($file_read);  // closing the handle
+
+echo "\n--- Testing with binary mode file ---\n";
+/* Opening the file in binary read mode */
+$file_read = fopen($file_name, "rb");
+
+fseek($file_read, 12, SEEK_SET);
+var_dump(fpassthru($file_read) );
+rewind( $file_read );
+fclose($file_read);
+
+unlink($file_name);
+
+echo "\n*** Done ***\n";
+
+?>
+--EXPECTF--
+*** Testing fpassthru() function with files ***
+
+--- Testing with different offsets ---
+-- Iteration 0 --
+1234567890abcdefghijklmnopqrstuvwxyzint(36)
+-- Iteration 1 --
+234567890abcdefghijklmnopqrstuvwxyzint(35)
+-- Iteration 2 --
+67890abcdefghijklmnopqrstuvwxyzint(31)
+-- Iteration 3 --
+abcdefghijklmnopqrstuvwxyzint(26)
+-- Iteration 4 --
+klmnopqrstuvwxyzint(16)
+-- Iteration 5 --
+uvwxyzint(6)
+-- Iteration 6 --
+zint(1)
+-- Iteration 7 --
+int(0)
+-- Iteration 8 --
+int(0)
+-- Iteration 9 --
+zint(1)
+-- Iteration 10 --
+vwxyzint(5)
+-- Iteration 11 --
+qrstuvwxyzint(10)
+-- Iteration 12 --
+ghijklmnopqrstuvwxyzint(20)
+-- Iteration 13 --
+234567890abcdefghijklmnopqrstuvwxyzint(35)
+-- Iteration 14 --
+1234567890abcdefghijklmnopqrstuvwxyzint(36)
+-- Iteration 15 --
+1234567890abcdefghijklmnopqrstuvwxyzint(36)
+
+--- Testing with binary mode file ---
+cdefghijklmnopqrstuvwxyzint(24)
+
+*** Done ***
diff --git a/ext/standard/tests/general_functions/intval.phpt b/ext/standard/tests/general_functions/intval.phpt
new file mode 100644 (file)
index 0000000..74d3a70
--- /dev/null
@@ -0,0 +1,302 @@
+--TEST--
+Test intval() function.
+--FILE--
+<?php
+/* Prototype: int intval( mixed $var [.int $base] );
+ * Description: Returns the integer value of var, using the specified base for the conversion(the default is base 10).
+ */
+
+echo "*** Testing intval() with valid integer values ***\n";
+// different valid  integer vlaues 
+$valid_ints = array(
+                '0',
+                '1',
+                '-1',
+                '-2147483648', // max negative integer value
+                '-2147483647', 
+                2147483647,  // max positive integer value
+                2147483640,
+                0x123B,      // integer as hexadecimal
+                '0x12ab',
+                '0Xfff',
+                '0XFA',
+                -0x80000000, // max negative integer as hexadecimal
+                '0x7fffffff',  // max postive integer as hexadecimal
+                0x7FFFFFFF,  // max postive integer as hexadecimal
+                '0123',        // integer as octal
+                01912,       // should be quivalent to octal 1
+                -020000000000, // max negative integer as octal
+                017777777777,  // max positive integer as octal
+               );
+
+/* loop to check that intval() recognizes different 
+   integer values, expected output:integer value in decimal notation for valid integer */
+
+echo "\n***Output with default base value ie 10 ***\n";
+foreach ($valid_ints as $value ) {
+   var_dump( intval($value) );
+}
+
+
+echo "\n***Output with base value of 10( explicitly passed as argument) ***\n";
+foreach ($valid_ints as $value ) {
+   var_dump( intval($value, 10) );
+}
+
+echo "\n***Output with base value  of 16 ***\n";
+foreach ($valid_ints as $value ) {
+   var_dump( intval($value, 16) );
+}
+
+echo "\n***Output with base value of 8 ***\n";
+foreach ($valid_ints as $value ) {
+   var_dump( intval($value, 8) );
+}
+
+echo "\n*** Testing intval() on non integer types ***\n";
+
+// get a resource type variable
+$fp = fopen (__FILE__, "r");
+fclose($fp);
+$dfp = opendir ( dirname(__FILE__) );
+closedir($dfp);
+
+// unset variable
+
+$unset_var = 10;
+unset ($unset_var);
+
+// other types in a array
+$not_int_types = array (
+  /* float values */
+  '-2147483649', // float value
+  '2147483648',  // float value
+  '-0x80000001', // float value, beyond max negative int
+  '0x800000001', // float value, beyond max positive int
+  '020000000001', // float value, beyond max positive int
+  '-020000000001', // float value, beyond max negative int
+  0.0,
+  -0.1,
+  1.0,
+  1e5,
+  -1e6,
+  1E8,
+  -1E9,
+  10.0000000000000000005,
+  10.5e+5,
+
+  /* resources */
+  $fp,
+  $dfp,
+
+  /* arrays */
+  array(),
+  array(0),
+  array(1),
+  array(NULL),
+  array(null),
+  array("string"),
+  array(true),
+  array(TRUE),
+  array(false),
+  array(FALSE),
+  array(1,2,3,4),
+  array(1 => "One", "two" => 2),
+
+  /* strings */
+  "",
+  '',
+  "0",
+  '0',
+  "1",
+  '1',
+  "\x01",
+  '\x01',
+  "\01",
+  '\01',
+  'string',
+  "string",
+  "true",
+  "FALSE",
+  'false',
+  'TRUE',
+  "NULL",
+  'null',
+
+  /* booleans */
+  true,
+  false,
+  TRUE,
+  FALSE,
+
+  /* undefined and unset vars */
+  @$unset_var,
+  @$undefined_var
+);
+
+
+/* loop through the $not_int_types to see working of 
+   intval() on non integer types, expected output: integer value in decimal notation for valid integers */
+foreach ($not_int_types as $type ) {
+   var_dump( intval($type) );
+}
+
+echo "\n*** Testing error conditions ***\n";
+//Zero argument
+var_dump( intval() );
+
+//arguments more than expected 
+var_dump( intval(TRUE, FALSE, TRUE) );
+echo "\n--- Done ---\n";
+
+
+?>
+--EXPECTF--
+*** Testing intval() with valid integer values ***
+
+***Output with default base value ie 10 ***
+int(0)
+int(1)
+int(-1)
+int(-2147483648)
+int(-2147483647)
+int(2147483647)
+int(2147483640)
+int(4667)
+int(0)
+int(0)
+int(0)
+int(-2147483648)
+int(0)
+int(2147483647)
+int(123)
+int(1)
+int(-2147483648)
+int(2147483647)
+
+***Output with base value of 10( explicitly passed as argument) ***
+int(0)
+int(1)
+int(-1)
+int(-2147483648)
+int(-2147483647)
+int(2147483647)
+int(2147483640)
+int(4667)
+int(0)
+int(0)
+int(0)
+int(-2147483648)
+int(0)
+int(2147483647)
+int(123)
+int(1)
+int(-2147483648)
+int(2147483647)
+
+***Output with base value  of 16 ***
+int(0)
+int(1)
+int(-1)
+int(-2147483648)
+int(-2147483648)
+int(2147483647)
+int(2147483640)
+int(4667)
+int(4779)
+int(4095)
+int(250)
+int(-2147483648)
+int(2147483647)
+int(2147483647)
+int(291)
+int(1)
+int(-2147483648)
+int(2147483647)
+
+***Output with base value of 8 ***
+int(0)
+int(1)
+int(-1)
+int(-9020)
+int(-9020)
+int(2147483647)
+int(2147483640)
+int(4667)
+int(0)
+int(0)
+int(0)
+int(-2147483648)
+int(0)
+int(2147483647)
+int(83)
+int(1)
+int(-2147483648)
+int(2147483647)
+
+*** Testing intval() on non integer types ***
+int(-2147483648)
+int(2147483647)
+int(0)
+int(0)
+int(2147483647)
+int(-2147483648)
+int(0)
+int(0)
+int(1)
+int(100000)
+int(-1000000)
+int(100000000)
+int(-1000000000)
+int(10)
+int(1050000)
+int(5)
+int(6)
+int(0)
+int(1)
+int(1)
+int(1)
+int(1)
+int(1)
+int(1)
+int(1)
+int(1)
+int(1)
+int(1)
+int(1)
+int(0)
+int(0)
+int(0)
+int(0)
+int(1)
+int(1)
+int(0)
+int(0)
+int(0)
+int(0)
+int(0)
+int(0)
+int(0)
+int(0)
+int(0)
+int(0)
+int(0)
+int(0)
+int(1)
+int(0)
+int(1)
+int(0)
+int(0)
+int(0)
+
+*** Testing error conditions ***
+
+Warning: Wrong parameter count for intval() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for intval() in %s on line %d
+NULL
+
+--- Done ---
diff --git a/ext/standard/tests/general_functions/var_export.phpt b/ext/standard/tests/general_functions/var_export.phpt
new file mode 100644 (file)
index 0000000..0f14657
--- /dev/null
@@ -0,0 +1,1052 @@
+--TEST--
+Test var_export() function
+--FILE--
+<?php
+/* Prototype: mixed var_export( mixed expression [, bool return]);
+ * Description: Returns the variable representation when the return parameter is used and evaluates to TRUE. Otherwise, this function will return NULL.
+
+*/
+
+echo "*** Testing var_export() with integer values ***\n";
+// different integer vlaues 
+$valid_ints = array(
+                '0',
+                '1',
+                '-1',
+                '-2147483648', // max negative integer value
+                '-2147483647', 
+                2147483647,  // max positive integer value
+                2147483640,
+                0x123B,      // integer as hexadecimal
+                '0x12ab',
+                '0Xfff',
+                '0XFA',
+                -0x80000000, // max negative integer as hexadecimal
+                '0x7fffffff',  // max postive integer as hexadecimal
+                0x7FFFFFFF,  // max postive integer as hexadecimal
+                '0123',        // integer as octal
+                01912,       // should be quivalent to octal 1
+                -020000000000, // max negative integer as octal
+                017777777777,  // max positive integer as octal
+               );
+$counter = 1;
+/* Loop to check for above integer values with var_export() */
+echo "\n*** Output for integer values ***\n";
+foreach($valid_ints as $int_value) {
+echo "\nIteration ".$counter."\n";
+var_export( $int_value );
+echo "\n";
+var_export( $int_value, FALSE);
+echo "\n";
+var_dump( var_export( $int_value, TRUE) );
+echo "\n";
+$counter++;
+}
+
+echo "*** Testing var_export() with valid boolean values ***\n";
+// different valid  boolean vlaues 
+$valid_bool = array(
+                   1,
+                   TRUE,
+                true, 
+                0,
+                   FALSE,
+                   false
+               );
+$counter = 1;
+/* Loop to check for above boolean values with var_export() */
+echo "\n*** Output for boolean values ***\n";
+foreach($valid_bool as $bool_value) {
+echo "\nIteration ".$counter."\n";
+var_export( $bool_value );
+echo "\n";
+var_export( $bool_value, FALSE);
+echo "\n";
+var_dump( var_export( $bool_value, TRUE) );
+echo "\n";
+$counter++;
+}
+
+echo "*** Testing var_export() with valid float values ***\n";
+// different valid  float vlaues 
+$valid_floats = array(
+  -2147483649, // float value
+  2147483648,  // float value
+  -0x80000001, // float value, beyond max negative int
+  0x800000001, // float value, beyond max positive int
+  020000000001, // float value, beyond max positive int
+  -020000000001, // float value, beyond max negative int
+  0.0,
+  -0.1,
+  10.0000000000000000005,
+  10.5e+5,
+  1e5,
+  1e-5,
+  1e+5,
+  1E5,
+  1E+5,
+  1E-5,
+  .5e+7,
+  .6e-19,
+  .05E+44,
+  .0034E-30
+);
+$counter = 1;
+/* Loop to check for above float values with var_export() */
+echo "\n*** Output for float values ***\n";
+foreach($valid_bool as $float_value) {
+echo "\nIteration ".$counter."\n";
+var_export( $float_value );
+echo "\n";
+var_export( $float_value, FALSE);
+echo "\n";
+var_dump( var_export( $float_value, TRUE) );
+echo "\n";
+$counter++;
+}
+
+echo "*** Testing var_export() with valid strings ***\n";
+// different valid  string 
+$valid_strings = array(
+            "",
+            " ",
+            '',
+            ' ',
+            "string",
+            'string',
+            "NULL",
+            'null',
+            "FALSE",
+            'false',
+            "\x0b",
+            "\0",
+            '\0',
+            '\060',
+            "\070"
+          );
+$counter = 1;
+/* Loop to check for above strings with var_export() */
+echo "\n*** Output for strings ***\n";
+foreach($valid_strings as $str) {
+echo "\nIteration ".$counter."\n";
+var_export( $str );
+echo "\n";
+var_export( $str, FALSE);
+echo "\n";
+var_dump( var_export( $str, TRUE) );
+echo "\n";
+$counter++;
+}
+
+echo "*** Testing var_export() with valid arrays ***\n";
+// different valid  arrays 
+$valid_arrays = array(
+           array(),
+           array(NULL),
+           array(null),
+           array(true),
+           array(""),
+           array(''),
+           array(array(), array()),
+           array(array(1, 2), array('a', 'b')),
+           array(1 => 'One'),
+           array("test" => "is_array"),
+           array(0),
+           array(-1),
+           array(10.5, 5.6),
+           array("string", "test"),
+           array('string', 'test')
+          );
+$counter = 1;
+/* Loop to check for above arrays with var_export() */
+echo "\n*** Output for arrays ***\n";
+foreach($valid_arrays as $arr) {
+echo "\nIteration ".$counter."\n";
+var_export( $arr );
+echo "\n";
+var_export( $arr, FALSE);
+echo "\n";
+var_dump( var_export( $arr, TRUE) );
+echo "\n";
+$counter++;
+}
+
+echo "*** Testing var_export() with valid objects ***\n";
+
+// class with no members
+class foo
+{
+// no members 
+}
+
+// abstract class
+abstract class abstractClass
+{
+  abstract protected function getClassName();
+  public function printClassName () {
+    echo $this->getClassName() . "\n";
+  }
+}
+// implement abstract class
+class concreteClass extends abstractClass
+{
+  protected function getClassName() {
+    return "concreteClass";
+  }
+}
+
+// interface class 
+interface iValue
+{
+   public function setVal ($name, $val); 
+   public function dumpVal ();
+}
+// implement the interface
+class Value implements iValue
+{
+  private $vars = array ();
+  
+  public function setVal ( $name, $val ) {
+    $this->vars[$name] = $val;
+  }
+  
+  public function dumpVal () {
+    var_export ( $vars );
+  }
+}
+
+// a gereral class 
+class myClass 
+{
+  var $foo_object;
+  public $public_var;
+  public $public_var1;
+  private $private_var;
+  protected $protected_var;
+
+  function myClass ( ) {
+    $this->foo_object = new foo();
+    $this->public_var = 10;
+    $this->public_var1 = new foo();
+    $this->private_var = new foo();
+    $this->proected_var = new foo();
+  }  
+}
+
+// create a object of each class defined above
+$myClass_object = new myClass();
+$foo_object = new foo();
+$Value_object = new Value();
+$concreteClass_object = new concreteClass();
+
+$valid_objects = array(
+                  new stdclass,
+                  new foo,
+                  new concreteClass,
+                  new Value,
+                  new myClass,
+                  $myClass_object,
+                  $myClass_object->foo_object,
+                  $myClass_object->public_var1,
+                  $foo_object,
+                  $Value_object,
+                  $concreteClass_object
+                 ); 
+ $counter = 1;
+/* Loop to check for above objects with var_export() */
+echo "\n*** Output for objects ***\n";
+foreach($valid_objects as $obj) {
+echo "\nIteration ".$counter."\n";
+var_export( $obj );
+echo "\n";
+var_export( $obj, FALSE);
+echo "\n";
+var_dump( var_export( $obj, TRUE) );
+echo "\n";
+$counter++;
+}
+                 
+echo "*** Testing var_export() with valid null values ***\n";
+// different valid  null vlaues 
+$unset_var = array();
+unset ($unset_var); // now a null
+$null_var = NULL;
+
+$valid_nulls = array(
+                NULL,
+                null,
+                $null_var,
+               );
+ $counter = 1;
+/* Loop to check for above null values with var_export() */
+echo "\n*** Output for null values ***\n";
+foreach($valid_nulls as $null_value) {
+echo "\nIteration ".$counter."\n";
+var_export( $null_value );
+echo "\n";
+var_export( $null_value, FALSE);
+echo "\n";
+var_dump( var_export( $null_value, true) );
+echo "\n";
+$counter++;
+}
+
+echo "\n*** Testing error conditions ***\n";
+//Zero argument
+var_export( var_export() );
+
+//arguments more than expected 
+var_export( var_export(TRUE, FALSE, TRUE) );
+echo "\n\nDone";
+
+
+?>
+--EXPECTF--
+*** Testing var_export() with integer values ***
+
+*** Output for integer values ***
+
+Iteration 1
+'0'
+'0'
+string(3) "'0'"
+
+
+Iteration 2
+'1'
+'1'
+string(3) "'1'"
+
+
+Iteration 3
+'-1'
+'-1'
+string(4) "'-1'"
+
+
+Iteration 4
+'-2147483648'
+'-2147483648'
+string(13) "'-2147483648'"
+
+
+Iteration 5
+'-2147483647'
+'-2147483647'
+string(13) "'-2147483647'"
+
+
+Iteration 6
+2147483647
+2147483647
+string(10) "2147483647"
+
+
+Iteration 7
+2147483640
+2147483640
+string(10) "2147483640"
+
+
+Iteration 8
+4667
+4667
+string(4) "4667"
+
+
+Iteration 9
+'0x12ab'
+'0x12ab'
+string(8) "'0x12ab'"
+
+
+Iteration 10
+'0Xfff'
+'0Xfff'
+string(7) "'0Xfff'"
+
+
+Iteration 11
+'0XFA'
+'0XFA'
+string(6) "'0XFA'"
+
+
+Iteration 12
+-2147483648
+-2147483648
+string(11) "-2147483648"
+
+
+Iteration 13
+'0x7fffffff'
+'0x7fffffff'
+string(12) "'0x7fffffff'"
+
+
+Iteration 14
+2147483647
+2147483647
+string(10) "2147483647"
+
+
+Iteration 15
+'0123'
+'0123'
+string(6) "'0123'"
+
+
+Iteration 16
+1
+1
+string(1) "1"
+
+
+Iteration 17
+-2147483648
+-2147483648
+string(11) "-2147483648"
+
+
+Iteration 18
+2147483647
+2147483647
+string(10) "2147483647"
+
+*** Testing var_export() with valid boolean values ***
+
+*** Output for boolean values ***
+
+Iteration 1
+1
+1
+string(1) "1"
+
+
+Iteration 2
+true
+true
+string(4) "true"
+
+
+Iteration 3
+true
+true
+string(4) "true"
+
+
+Iteration 4
+0
+0
+string(1) "0"
+
+
+Iteration 5
+false
+false
+string(5) "false"
+
+
+Iteration 6
+false
+false
+string(5) "false"
+
+*** Testing var_export() with valid float values ***
+
+*** Output for float values ***
+
+Iteration 1
+1
+1
+string(1) "1"
+
+
+Iteration 2
+true
+true
+string(4) "true"
+
+
+Iteration 3
+true
+true
+string(4) "true"
+
+
+Iteration 4
+0
+0
+string(1) "0"
+
+
+Iteration 5
+false
+false
+string(5) "false"
+
+
+Iteration 6
+false
+false
+string(5) "false"
+
+*** Testing var_export() with valid strings ***
+
+*** Output for strings ***
+
+Iteration 1
+''
+''
+string(2) "''"
+
+
+Iteration 2
+' '
+' '
+string(3) "' '"
+
+
+Iteration 3
+''
+''
+string(2) "''"
+
+
+Iteration 4
+' '
+' '
+string(3) "' '"
+
+
+Iteration 5
+'string'
+'string'
+string(8) "'string'"
+
+
+Iteration 6
+'string'
+'string'
+string(8) "'string'"
+
+
+Iteration 7
+'NULL'
+'NULL'
+string(6) "'NULL'"
+
+
+Iteration 8
+'null'
+'null'
+string(6) "'null'"
+
+
+Iteration 9
+'FALSE'
+'FALSE'
+string(7) "'FALSE'"
+
+
+Iteration 10
+'false'
+'false'
+string(7) "'false'"
+
+
+Iteration 11
+'\v'
+'\v'
+string(3) "'\v'"
+
+
+Iteration 12
+'\000'
+'\000'
+string(6) "'\000'"
+
+
+Iteration 13
+'\\0'
+'\\0'
+string(5) "'\\0'"
+
+
+Iteration 14
+'\\060'
+'\\060'
+string(7) "'\\060'"
+
+
+Iteration 15
+'8'
+'8'
+string(3) "'8'"
+
+*** Testing var_export() with valid arrays ***
+
+*** Output for arrays ***
+
+Iteration 1
+array (
+)
+array (
+)
+string(9) "array (
+)"
+
+
+Iteration 2
+array (
+  0 => NULL,
+)
+array (
+  0 => NULL,
+)
+string(22) "array (
+  0 => NULL,
+)"
+
+
+Iteration 3
+array (
+  0 => NULL,
+)
+array (
+  0 => NULL,
+)
+string(22) "array (
+  0 => NULL,
+)"
+
+
+Iteration 4
+array (
+  0 => true,
+)
+array (
+  0 => true,
+)
+string(22) "array (
+  0 => true,
+)"
+
+
+Iteration 5
+array (
+  0 => '',
+)
+array (
+  0 => '',
+)
+string(20) "array (
+  0 => '',
+)"
+
+
+Iteration 6
+array (
+  0 => '',
+)
+array (
+  0 => '',
+)
+string(20) "array (
+  0 => '',
+)"
+
+
+Iteration 7
+array (
+  0 => 
+  array (
+  ),
+  1 => 
+  array (
+  ),
+)
+array (
+  0 => 
+  array (
+  ),
+  1 => 
+  array (
+  ),
+)
+string(55) "array (
+  0 => 
+  array (
+  ),
+  1 => 
+  array (
+  ),
+)"
+
+
+Iteration 8
+array (
+  0 => 
+  array (
+    0 => 1,
+    1 => 2,
+  ),
+  1 => 
+  array (
+    0 => 'a',
+    1 => 'b',
+  ),
+)
+array (
+  0 => 
+  array (
+    0 => 1,
+    1 => 2,
+  ),
+  1 => 
+  array (
+    0 => 'a',
+    1 => 'b',
+  ),
+)
+string(107) "array (
+  0 => 
+  array (
+    0 => 1,
+    1 => 2,
+  ),
+  1 => 
+  array (
+    0 => 'a',
+    1 => 'b',
+  ),
+)"
+
+
+Iteration 9
+array (
+  1 => 'One',
+)
+array (
+  1 => 'One',
+)
+string(23) "array (
+  1 => 'One',
+)"
+
+
+Iteration 10
+array (
+  'test' => 'is_array',
+)
+array (
+  'test' => 'is_array',
+)
+string(33) "array (
+  'test' => 'is_array',
+)"
+
+
+Iteration 11
+array (
+  0 => 0,
+)
+array (
+  0 => 0,
+)
+string(19) "array (
+  0 => 0,
+)"
+
+
+Iteration 12
+array (
+  0 => -1,
+)
+array (
+  0 => -1,
+)
+string(20) "array (
+  0 => -1,
+)"
+
+
+Iteration 13
+array (
+  0 => 10.5,
+  1 => 5.6,
+)
+array (
+  0 => 10.5,
+  1 => 5.6,
+)
+string(34) "array (
+  0 => 10.5,
+  1 => 5.6,
+)"
+
+
+Iteration 14
+array (
+  0 => 'string',
+  1 => 'test',
+)
+array (
+  0 => 'string',
+  1 => 'test',
+)
+string(41) "array (
+  0 => 'string',
+  1 => 'test',
+)"
+
+
+Iteration 15
+array (
+  0 => 'string',
+  1 => 'test',
+)
+array (
+  0 => 'string',
+  1 => 'test',
+)
+string(41) "array (
+  0 => 'string',
+  1 => 'test',
+)"
+
+*** Testing var_export() with valid objects ***
+
+*** Output for objects ***
+
+Iteration 1
+stdClass::__set_state(array(
+))
+stdClass::__set_state(array(
+))
+string(31) "stdClass::__set_state(array(
+))"
+
+
+Iteration 2
+foo::__set_state(array(
+))
+foo::__set_state(array(
+))
+string(26) "foo::__set_state(array(
+))"
+
+
+Iteration 3
+concreteClass::__set_state(array(
+))
+concreteClass::__set_state(array(
+))
+string(36) "concreteClass::__set_state(array(
+))"
+
+
+Iteration 4
+Value::__set_state(array(
+   'vars' => 
+  array (
+  ),
+))
+Value::__set_state(array(
+   'vars' => 
+  array (
+  ),
+))
+string(57) "Value::__set_state(array(
+   'vars' => 
+  array (
+  ),
+))"
+
+
+Iteration 5
+myClass::__set_state(array(
+   'foo_object' => 
+  foo::__set_state(array(
+  )),
+   'public_var' => 10,
+   'public_var1' => 
+  foo::__set_state(array(
+  )),
+   'private_var' => 
+  foo::__set_state(array(
+  )),
+   'protected_var' => NULL,
+   'proected_var' => 
+  foo::__set_state(array(
+  )),
+))
+myClass::__set_state(array(
+   'foo_object' => 
+  foo::__set_state(array(
+  )),
+   'public_var' => 10,
+   'public_var1' => 
+  foo::__set_state(array(
+  )),
+   'private_var' => 
+  foo::__set_state(array(
+  )),
+   'protected_var' => NULL,
+   'proected_var' => 
+  foo::__set_state(array(
+  )),
+))
+string(293) "myClass::__set_state(array(
+   'foo_object' => 
+  foo::__set_state(array(
+  )),
+   'public_var' => 10,
+   'public_var1' => 
+  foo::__set_state(array(
+  )),
+   'private_var' => 
+  foo::__set_state(array(
+  )),
+   'protected_var' => NULL,
+   'proected_var' => 
+  foo::__set_state(array(
+  )),
+))"
+
+
+Iteration 6
+myClass::__set_state(array(
+   'foo_object' => 
+  foo::__set_state(array(
+  )),
+   'public_var' => 10,
+   'public_var1' => 
+  foo::__set_state(array(
+  )),
+   'private_var' => 
+  foo::__set_state(array(
+  )),
+   'protected_var' => NULL,
+   'proected_var' => 
+  foo::__set_state(array(
+  )),
+))
+myClass::__set_state(array(
+   'foo_object' => 
+  foo::__set_state(array(
+  )),
+   'public_var' => 10,
+   'public_var1' => 
+  foo::__set_state(array(
+  )),
+   'private_var' => 
+  foo::__set_state(array(
+  )),
+   'protected_var' => NULL,
+   'proected_var' => 
+  foo::__set_state(array(
+  )),
+))
+string(293) "myClass::__set_state(array(
+   'foo_object' => 
+  foo::__set_state(array(
+  )),
+   'public_var' => 10,
+   'public_var1' => 
+  foo::__set_state(array(
+  )),
+   'private_var' => 
+  foo::__set_state(array(
+  )),
+   'protected_var' => NULL,
+   'proected_var' => 
+  foo::__set_state(array(
+  )),
+))"
+
+
+Iteration 7
+foo::__set_state(array(
+))
+foo::__set_state(array(
+))
+string(26) "foo::__set_state(array(
+))"
+
+
+Iteration 8
+foo::__set_state(array(
+))
+foo::__set_state(array(
+))
+string(26) "foo::__set_state(array(
+))"
+
+
+Iteration 9
+foo::__set_state(array(
+))
+foo::__set_state(array(
+))
+string(26) "foo::__set_state(array(
+))"
+
+
+Iteration 10
+Value::__set_state(array(
+   'vars' => 
+  array (
+  ),
+))
+Value::__set_state(array(
+   'vars' => 
+  array (
+  ),
+))
+string(57) "Value::__set_state(array(
+   'vars' => 
+  array (
+  ),
+))"
+
+
+Iteration 11
+concreteClass::__set_state(array(
+))
+concreteClass::__set_state(array(
+))
+string(36) "concreteClass::__set_state(array(
+))"
+
+*** Testing var_export() with valid null values ***
+
+*** Output for null values ***
+
+Iteration 1
+NULL
+NULL
+string(4) "NULL"
+
+
+Iteration 2
+NULL
+NULL
+string(4) "NULL"
+
+
+Iteration 3
+NULL
+NULL
+string(4) "NULL"
+
+
+*** Testing error conditions ***
+
+Warning: var_export() expects at least 1 parameter, 0 given in %s on line %d
+NULL
+Warning: var_export() expects at most 2 parameters, 3 given in %s on line %d
+NULL
+
+Done
diff --git a/ext/standard/tests/strings/dirname_basic.phpt b/ext/standard/tests/strings/dirname_basic.phpt
new file mode 100644 (file)
index 0000000..2b5e4d4
--- /dev/null
@@ -0,0 +1,153 @@
+--TEST--
+Test dirname() function : basic funtionality
+--FILE--
+<?php
+/* Prototype: string dirname ( string $path );
+   Description: Returns directory name component of path.
+*/
+$file_paths = array (
+  /* simple paths */
+  "bar",
+  "/foo/bar",
+  "foo/bar",
+  "/bar",
+  "bar/",
+  "/bar/",
+  "/foo/bar/",
+  "foo/bar/",
+  "/bar/",
+  
+  /* path with only files and trailing slashes*/
+  "/foo/bar.gz",
+  "foo/bar.gz",
+  "bar.gz",
+  "bar.gz/",
+  "/bar.gz",  
+  "/bar.gz/",
+  "/foo/bar.gz/",
+  "foo/bar.gz/",
+  "/bar.gz/",  
+  /* path with file extension and trailing slashes */
+  "/.gz",
+  ".gz",
+  "/foo/.gz",
+  ".gz/",
+  "/foo/.gz/",
+  "foo/.gz/",
+
+  /* paths with binary value to check if the function is binary safe*/
+  "foo".chr(0)."bar",
+  "/foo".chr(0)."bar/",
+  "/foo".chr(0)."bar",
+  "foo".chr(0)."bar/",
+  "/foo".chr(0)."bar/t.gz"
+);
+
+function check_dirname( $paths ) {
+   $loop_counter = 0;
+   $noOfPaths = count($paths);
+   for( ; $loop_counter < $noOfPaths; $loop_counter++ ) {
+     echo "\n--Iteration ";
+     echo $loop_counter + 1; 
+     echo " --\n";
+     var_dump( dirname($paths[$loop_counter]) );
+   }
+}
+
+echo "*** Testing basic operations ***\n";
+check_dirname( $file_paths );
+
+echo "Done\n";
+?>
+
+--EXPECTREGEX--
+\*\*\* Testing basic operations \*\*\*
+
+--Iteration 1 --
+string\(1\) "."
+
+--Iteration 2 --
+string\(4\) "(\\|\/)foo"
+
+--Iteration 3 --
+string\(3\) "foo"
+
+--Iteration 4 --
+string\(1\) "(\\|\/)"
+
+--Iteration 5 --
+string\(1\) "."
+
+--Iteration 6 --
+string\(1\) "(\\|\/)"
+
+--Iteration 7 --
+string\(4\) "(\\|\/)foo"
+
+--Iteration 8 --
+string\(3\) "foo"
+
+--Iteration 9 --
+string\(1\) "(\\|\/)"
+
+--Iteration 10 --
+string\(4\) "(\\|\/)foo"
+
+--Iteration 11 --
+string\(3\) "foo"
+
+--Iteration 12 --
+string\(1\) "."
+
+--Iteration 13 --
+string\(1\) "."
+
+--Iteration 14 --
+string\(1\) "(\\|\/)"
+
+--Iteration 15 --
+string\(1\) "(\\|\/)"
+
+--Iteration 16 --
+string\(4\) "(\\|\/)foo"
+
+--Iteration 17 --
+string\(3\) "foo"
+
+--Iteration 18 --
+string\(1\) "(\\|\/)"
+
+--Iteration 19 --
+string\(1\) "(\\|\/)"
+
+--Iteration 20 --
+string\(1\) "."
+
+--Iteration 21 --
+string\(4\) "(\\|\/)foo"
+
+--Iteration 22 --
+string\(1\) "."
+
+--Iteration 23 --
+string\(4\) "(\\|\/)foo"
+
+--Iteration 24 --
+string\(3\) "foo"
+
+--Iteration 25 --
+string\(1\) "."
+
+--Iteration 26 --
+string\(1\) "(\\|\/)"
+
+--Iteration 27 --
+string\(1\) "(\\|\/)"
+
+--Iteration 28 --
+string\(1\) "."
+
+--Iteration 29 --
+string\(8\) "(\\|\/)foo\x00bar"
+Done
diff --git a/ext/standard/tests/strings/dirname_error.phpt b/ext/standard/tests/strings/dirname_error.phpt
new file mode 100644 (file)
index 0000000..3671695
--- /dev/null
@@ -0,0 +1,25 @@
+--TEST--
+Test dirname() function : error conditions
+--FILE--
+<?php
+/* Prototype: string dirname ( string $path );
+   Description: Returns directory name component of path.
+*/
+echo "*** Testing error conditions ***\n";
+// zero arguments 
+var_dump( dirname() );
+
+// more than expected no. of arguments
+var_dump( dirname("/var/tmp/bar.gz", ".gz") );
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing error conditions ***
+
+Warning: Wrong parameter count for dirname() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for dirname() in %s on line %d
+NULL
+Done
diff --git a/ext/standard/tests/strings/dirname_variation.phpt b/ext/standard/tests/strings/dirname_variation.phpt
new file mode 100644 (file)
index 0000000..da66f0f
--- /dev/null
@@ -0,0 +1,143 @@
+--TEST--
+Test dirname() function : usage variations
+--FILE--
+<?php
+/* Prototype: string dirname ( string $path );
+   Description: Returns directory name component of path.
+*/
+class temp
+{ 
+   function __toString() {
+     return "Object";
+   }
+}
+
+$file_path_variations = array (
+  /* home dir shortcut char */
+  "~/home/user/bar",
+  "~/home/user/bar/",
+  "~/home/user/bar.tar",
+  "~/home/user/bar.tar/",
+
+  /* with hotname:dir notation */
+  "hostname:/home/user/bar.tar",
+  "hostname:/home/user/tbar.gz/",
+  "hostname:/home/user/My Pics.gz",
+  "hostname:/home/user/My Pics.gz/",
+  "hostname:/home/user/My Pics/",
+  "hostname:/home/user/My Pics",
+  
+  /* path containing numeric string */
+  "10.5",
+  "/10.5",
+  "/10.5/",
+  "10.5/",
+  "10/10.gz",
+  '0',
+  "0",
+  
+  /* object */
+  new temp,
+
+  /* path as spaces */
+  " ",
+  ' ',
+
+  /* empty path */
+  "",
+  '',
+  NULL,
+  null
+);
+
+function check_dirname( $paths ) {
+   $loop_counter = 0;
+   $noOfPaths = count($paths);
+   for( ; $loop_counter < $noOfPaths; $loop_counter++ ) {
+     echo "\n--Iteration ";
+     echo $loop_counter +1;
+     echo " --\n"; 
+     var_dump( dirname($paths[$loop_counter]) );
+   }
+}
+
+echo "*** Testing possible variations in path ***\n";
+check_dirname( $file_path_variations );
+
+echo "Done\n";
+?>
+--EXPECTREGEX--
+\*\*\* Testing possible variations in path \*\*\*
+
+--Iteration 1 --
+string\(11\) "~(\\|\/)home(\\|\/)user"
+
+--Iteration 2 --
+string\(11\) "~(\\|\/)home(\\|\/)user"
+
+--Iteration 3 --
+string\(11\) "~(\\|\/)home(\\|\/)user"
+
+--Iteration 4 --
+string\(11\) "~(\\|\/)home(\\|\/)user"
+
+--Iteration 5 --
+string\(19\) "hostname:(\\|\/)home(\\|\/)user"
+
+--Iteration 6 --
+string\(19\) "hostname:(\\|\/)home(\\|\/)user"
+
+--Iteration 7 --
+string\(19\) "hostname:(\\|\/)home(\\|\/)user"
+
+--Iteration 8 --
+string\(19\) "hostname:(\\|\/)home(\\|\/)user"
+
+--Iteration 9 --
+string\(19\) "hostname:(\\|\/)home(\\|\/)user"
+
+--Iteration 10 --
+string\(19\) "hostname:(\\|\/)home(\\|\/)user"
+
+--Iteration 11 --
+string\(1\) "."
+
+--Iteration 12 --
+string\(1\) "(\\|\/)"
+
+--Iteration 13 --
+string\(1\) "(\\|\/)"
+
+--Iteration 14 --
+string\(1\) "."
+
+--Iteration 15 --
+string\(2\) "10"
+
+--Iteration 16 --
+string\(1\) "."
+
+--Iteration 17 --
+string\(1\) "."
+
+--Iteration 18 --
+string\(1\) "."
+
+--Iteration 19 --
+string\(1\) "."
+
+--Iteration 20 --
+string\(1\) "."
+
+--Iteration 21 --
+string\(0\) ""
+
+--Iteration 22 --
+string\(0\) ""
+
+--Iteration 23 --
+string\(0\) ""
+
+--Iteration 24 --
+string\(0\) ""
+Done
\ No newline at end of file
diff --git a/ext/standard/tests/strings/explode1.phpt b/ext/standard/tests/strings/explode1.phpt
new file mode 100644 (file)
index 0000000..f5b71f4
--- /dev/null
@@ -0,0 +1,508 @@
+--TEST--
+Test explode() function
+--INI--
+error_reporting=2047
+--FILE--
+<?php
+/* Prototype: array explode ( string $delimiter, string $string [, int $limit] );
+   Description: Returns an array of strings, each of which is a substring of string 
+                formed by splitting it on boundaries formed by the string delimiter.
+                If limit is set, the returned array will contain a maximum of limit 
+                elements with the last element containing the rest of string.
+*/
+
+echo "*** Testing explode() for basic operations ***\n";
+$delimiters = array (
+  "",  // len=0
+  NULL,
+  "abcd",  // string
+  0,  // zero
+  "0",
+  TRUE,  // boolean value
+  FALSE,
+  -1,  // negative integer
+  -11.23,  // double
+  4,  // positive integer
+  "%",
+);
+$string = "1234NULL23abcd00000TRUEFALSE-11.234444true-11.24%PHP%ZEND";
+/* loop prints an array of strings, each of which is a substring of $string
+   formed by splitting it on boundaries formed by the string $delimiter. 
+ */
+$counter = 1;
+foreach($delimiters as $delimiter) {
+  echo "-- Iteration $counter --\n";
+  var_dump( explode($delimiter, $string, -1) );
+  var_dump( explode($delimiter, $string, 0) );
+  var_dump( explode($delimiter, $string, 1) );
+  var_dump( explode($delimiter, $string, 2) );
+  $counter++;
+}
+
+echo "\n*** Testing explode() with miscelleneous input arguments ***\n";
+
+echo "\n-- Passing positive values of Limit to explode() --\n";
+/* LIMIT=2 */
+var_dump( explode("::", "mon::tues::wed::thurs::fri::sat::sun", 2) );
+
+/* checking for LIMIT =0,1 */
+echo "\n-- Passing limit values 0 and 1 to explode() --\n";
+var_dump( explode(":", "Name:Phone:Address:City:State", 0) );
+var_dump( explode(":", "Name:Phone:Address:City:State", 1) );
+
+/* to check the maximum limit of string that can be given with limit<=0, 
+   default size is 50 but increases dynamically */
+echo "\n*** Testing explode() for maximum limit of string with Limit = -1 ***\n";
+var_dump( explode(":", "1:2:3:4:5:6:7:7:5:6:7:3:4:5:2:8:9:0:5:5:5:5:5:5:5:5:5:5:5:5:55:5:5:5%:%:%:%:5:5:5:%:%:5:5:5:5:5%:%:%:55:1:1", -1) );
+
+echo "\n*** Testing explode() with string variations as input argument ***\n";
+/* String with escape characters */
+echo "\n-- Testing string with escape characters --\n";
+var_dump( explode("\t\n", "1234\t\n5678\n\t9100") );
+var_dump( explode("\r", "1234\rabcd\r5678\rrstu") );
+
+/* String with embedded NULL */
+echo "\n-- Testing string with embedded NULL --\n";
+var_dump( explode("\x00", "abcd\x0n1234\x0005678\x0000efgh\xijkl") );
+var_dump( explode("\0", "abcd\0efgh\0ijkl\x00mnop\x000qrst\00uvwx\000yz") );
+
+/* Checking OBJECTS type */
+echo "\n*** Testing explode() with objects ***\n";
+class string1 {
+  public function __toString() {
+    return "Object";
+  }
+}
+$obj = new string1;
+var_dump( explode("b", $obj) );
+
+echo "\n*** Testing error conditions ***\n";
+/* checking for arguments <2 and >3 */
+var_dump( explode(":", "array1:array2:array3", -1, -33) );
+var_dump( explode(":") );
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing explode() for basic operations ***
+-- Iteration 1 --
+
+Warning: explode(): Empty delimiter. in %s on line %d
+bool(false)
+
+Warning: explode(): Empty delimiter. in %s on line %d
+bool(false)
+
+Warning: explode(): Empty delimiter. in %s on line %d
+bool(false)
+
+Warning: explode(): Empty delimiter. in %s on line %d
+bool(false)
+-- Iteration 2 --
+
+Warning: explode(): Empty delimiter. in %s on line %d
+bool(false)
+
+Warning: explode(): Empty delimiter. in %s on line %d
+bool(false)
+
+Warning: explode(): Empty delimiter. in %s on line %d
+bool(false)
+
+Warning: explode(): Empty delimiter. in %s on line %d
+bool(false)
+-- Iteration 3 --
+array(1) {
+  [0]=>
+  string(10) "1234NULL23"
+}
+array(1) {
+  [0]=>
+  string(57) "1234NULL23abcd00000TRUEFALSE-11.234444true-11.24%PHP%ZEND"
+}
+array(1) {
+  [0]=>
+  string(57) "1234NULL23abcd00000TRUEFALSE-11.234444true-11.24%PHP%ZEND"
+}
+array(2) {
+  [0]=>
+  string(10) "1234NULL23"
+  [1]=>
+  string(43) "00000TRUEFALSE-11.234444true-11.24%PHP%ZEND"
+}
+-- Iteration 4 --
+array(5) {
+  [0]=>
+  string(14) "1234NULL23abcd"
+  [1]=>
+  string(0) ""
+  [2]=>
+  string(0) ""
+  [3]=>
+  string(0) ""
+  [4]=>
+  string(0) ""
+}
+array(1) {
+  [0]=>
+  string(57) "1234NULL23abcd00000TRUEFALSE-11.234444true-11.24%PHP%ZEND"
+}
+array(1) {
+  [0]=>
+  string(57) "1234NULL23abcd00000TRUEFALSE-11.234444true-11.24%PHP%ZEND"
+}
+array(2) {
+  [0]=>
+  string(14) "1234NULL23abcd"
+  [1]=>
+  string(42) "0000TRUEFALSE-11.234444true-11.24%PHP%ZEND"
+}
+-- Iteration 5 --
+array(5) {
+  [0]=>
+  string(14) "1234NULL23abcd"
+  [1]=>
+  string(0) ""
+  [2]=>
+  string(0) ""
+  [3]=>
+  string(0) ""
+  [4]=>
+  string(0) ""
+}
+array(1) {
+  [0]=>
+  string(57) "1234NULL23abcd00000TRUEFALSE-11.234444true-11.24%PHP%ZEND"
+}
+array(1) {
+  [0]=>
+  string(57) "1234NULL23abcd00000TRUEFALSE-11.234444true-11.24%PHP%ZEND"
+}
+array(2) {
+  [0]=>
+  string(14) "1234NULL23abcd"
+  [1]=>
+  string(42) "0000TRUEFALSE-11.234444true-11.24%PHP%ZEND"
+}
+-- Iteration 6 --
+array(5) {
+  [0]=>
+  string(0) ""
+  [1]=>
+  string(28) "234NULL23abcd00000TRUEFALSE-"
+  [2]=>
+  string(0) ""
+  [3]=>
+  string(12) ".234444true-"
+  [4]=>
+  string(0) ""
+}
+array(1) {
+  [0]=>
+  string(57) "1234NULL23abcd00000TRUEFALSE-11.234444true-11.24%PHP%ZEND"
+}
+array(1) {
+  [0]=>
+  string(57) "1234NULL23abcd00000TRUEFALSE-11.234444true-11.24%PHP%ZEND"
+}
+array(2) {
+  [0]=>
+  string(0) ""
+  [1]=>
+  string(56) "234NULL23abcd00000TRUEFALSE-11.234444true-11.24%PHP%ZEND"
+}
+-- Iteration 7 --
+
+Warning: explode(): Empty delimiter. in %s on line %d
+bool(false)
+
+Warning: explode(): Empty delimiter. in %s on line %d
+bool(false)
+
+Warning: explode(): Empty delimiter. in %s on line %d
+bool(false)
+
+Warning: explode(): Empty delimiter. in %s on line %d
+bool(false)
+-- Iteration 8 --
+array(2) {
+  [0]=>
+  string(28) "1234NULL23abcd00000TRUEFALSE"
+  [1]=>
+  string(12) "1.234444true"
+}
+array(1) {
+  [0]=>
+  string(57) "1234NULL23abcd00000TRUEFALSE-11.234444true-11.24%PHP%ZEND"
+}
+array(1) {
+  [0]=>
+  string(57) "1234NULL23abcd00000TRUEFALSE-11.234444true-11.24%PHP%ZEND"
+}
+array(2) {
+  [0]=>
+  string(28) "1234NULL23abcd00000TRUEFALSE"
+  [1]=>
+  string(27) "1.234444true-11.24%PHP%ZEND"
+}
+-- Iteration 9 --
+array(1) {
+  [0]=>
+  string(28) "1234NULL23abcd00000TRUEFALSE"
+}
+array(1) {
+  [0]=>
+  string(57) "1234NULL23abcd00000TRUEFALSE-11.234444true-11.24%PHP%ZEND"
+}
+array(1) {
+  [0]=>
+  string(57) "1234NULL23abcd00000TRUEFALSE-11.234444true-11.24%PHP%ZEND"
+}
+array(2) {
+  [0]=>
+  string(28) "1234NULL23abcd00000TRUEFALSE"
+  [1]=>
+  string(23) "4444true-11.24%PHP%ZEND"
+}
+-- Iteration 10 --
+array(6) {
+  [0]=>
+  string(3) "123"
+  [1]=>
+  string(30) "NULL23abcd00000TRUEFALSE-11.23"
+  [2]=>
+  string(0) ""
+  [3]=>
+  string(0) ""
+  [4]=>
+  string(0) ""
+  [5]=>
+  string(9) "true-11.2"
+}
+array(1) {
+  [0]=>
+  string(57) "1234NULL23abcd00000TRUEFALSE-11.234444true-11.24%PHP%ZEND"
+}
+array(1) {
+  [0]=>
+  string(57) "1234NULL23abcd00000TRUEFALSE-11.234444true-11.24%PHP%ZEND"
+}
+array(2) {
+  [0]=>
+  string(3) "123"
+  [1]=>
+  string(53) "NULL23abcd00000TRUEFALSE-11.234444true-11.24%PHP%ZEND"
+}
+-- Iteration 11 --
+array(2) {
+  [0]=>
+  string(48) "1234NULL23abcd00000TRUEFALSE-11.234444true-11.24"
+  [1]=>
+  string(3) "PHP"
+}
+array(1) {
+  [0]=>
+  string(57) "1234NULL23abcd00000TRUEFALSE-11.234444true-11.24%PHP%ZEND"
+}
+array(1) {
+  [0]=>
+  string(57) "1234NULL23abcd00000TRUEFALSE-11.234444true-11.24%PHP%ZEND"
+}
+array(2) {
+  [0]=>
+  string(48) "1234NULL23abcd00000TRUEFALSE-11.234444true-11.24"
+  [1]=>
+  string(8) "PHP%ZEND"
+}
+
+*** Testing explode() with miscelleneous input arguments ***
+
+-- Passing positive values of Limit to explode() --
+array(2) {
+  [0]=>
+  string(3) "mon"
+  [1]=>
+  string(31) "tues::wed::thurs::fri::sat::sun"
+}
+
+-- Passing limit values 0 and 1 to explode() --
+array(1) {
+  [0]=>
+  string(29) "Name:Phone:Address:City:State"
+}
+array(1) {
+  [0]=>
+  string(29) "Name:Phone:Address:City:State"
+}
+
+*** Testing explode() for maximum limit of string with Limit = -1 ***
+array(51) {
+  [0]=>
+  string(1) "1"
+  [1]=>
+  string(1) "2"
+  [2]=>
+  string(1) "3"
+  [3]=>
+  string(1) "4"
+  [4]=>
+  string(1) "5"
+  [5]=>
+  string(1) "6"
+  [6]=>
+  string(1) "7"
+  [7]=>
+  string(1) "7"
+  [8]=>
+  string(1) "5"
+  [9]=>
+  string(1) "6"
+  [10]=>
+  string(1) "7"
+  [11]=>
+  string(1) "3"
+  [12]=>
+  string(1) "4"
+  [13]=>
+  string(1) "5"
+  [14]=>
+  string(1) "2"
+  [15]=>
+  string(1) "8"
+  [16]=>
+  string(1) "9"
+  [17]=>
+  string(1) "0"
+  [18]=>
+  string(1) "5"
+  [19]=>
+  string(1) "5"
+  [20]=>
+  string(1) "5"
+  [21]=>
+  string(1) "5"
+  [22]=>
+  string(1) "5"
+  [23]=>
+  string(1) "5"
+  [24]=>
+  string(1) "5"
+  [25]=>
+  string(1) "5"
+  [26]=>
+  string(1) "5"
+  [27]=>
+  string(1) "5"
+  [28]=>
+  string(1) "5"
+  [29]=>
+  string(1) "5"
+  [30]=>
+  string(2) "55"
+  [31]=>
+  string(1) "5"
+  [32]=>
+  string(1) "5"
+  [33]=>
+  string(2) "5%"
+  [34]=>
+  string(1) "%"
+  [35]=>
+  string(1) "%"
+  [36]=>
+  string(1) "%"
+  [37]=>
+  string(1) "5"
+  [38]=>
+  string(1) "5"
+  [39]=>
+  string(1) "5"
+  [40]=>
+  string(1) "%"
+  [41]=>
+  string(1) "%"
+  [42]=>
+  string(1) "5"
+  [43]=>
+  string(1) "5"
+  [44]=>
+  string(1) "5"
+  [45]=>
+  string(1) "5"
+  [46]=>
+  string(2) "5%"
+  [47]=>
+  string(1) "%"
+  [48]=>
+  string(1) "%"
+  [49]=>
+  string(2) "55"
+  [50]=>
+  string(1) "1"
+}
+
+*** Testing explode() with string variations as input argument ***
+
+-- Testing string with escape characters --
+array(2) {
+  [0]=>
+  string(4) "1234"
+  [1]=>
+  string(10) "5678
+       9100"
+}
+array(4) {
+  [0]=>
+  string(4) "1234"
+  [1]=>
+  string(4) "abcd"
+  [2]=>
+  string(4) "5678"
+  [3]=>
+  string(4) "rstu"
+}
+
+-- Testing string with embedded NULL --
+array(4) {
+  [0]=>
+  string(4) "abcd"
+  [1]=>
+  string(5) "n1234"
+  [2]=>
+  string(5) "05678"
+  [3]=>
+  string(12) "00efgh\xijkl"
+}
+array(7) {
+  [0]=>
+  string(4) "abcd"
+  [1]=>
+  string(4) "efgh"
+  [2]=>
+  string(4) "ijkl"
+  [3]=>
+  string(4) "mnop"
+  [4]=>
+  string(5) "0qrst"
+  [5]=>
+  string(4) "uvwx"
+  [6]=>
+  string(2) "yz"
+}
+
+*** Testing explode() with objects ***
+array(2) {
+  [0]=>
+  string(1) "O"
+  [1]=>
+  string(4) "ject"
+}
+
+*** Testing error conditions ***
+
+Warning: Wrong parameter count for explode() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for explode() in %s on line %d
+NULL
+Done