summaryrefslogtreecommitdiff
path: root/ext/standard/tests/file
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2013-03-14 05:42:27 +0000
committer <>2013-04-03 16:25:08 +0000
commitc4dd7a1a684490673e25aaf4fabec5df138854c4 (patch)
tree4d57c44caae4480efff02b90b9be86f44bf25409 /ext/standard/tests/file
downloadphp2-master.tar.gz
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/standard/tests/file')
-rw-r--r--ext/standard/tests/file/001-win32.phpt100
-rw-r--r--ext/standard/tests/file/001.phpt146
-rw-r--r--ext/standard/tests/file/002.phpt52
-rw-r--r--ext/standard/tests/file/003.phpt41
-rw-r--r--ext/standard/tests/file/004.phpt61
-rw-r--r--ext/standard/tests/file/005_basic.phpt54
-rw-r--r--ext/standard/tests/file/005_error.phpt126
-rw-r--r--ext/standard/tests/file/005_variation-win32.phpt221
-rw-r--r--ext/standard/tests/file/005_variation.phpt260
-rw-r--r--ext/standard/tests/file/005_variation2-win32.phpt119
-rw-r--r--ext/standard/tests/file/005_variation2.phpt113
-rw-r--r--ext/standard/tests/file/006_basic.phpt58
-rw-r--r--ext/standard/tests/file/006_error.phpt107
-rw-r--r--ext/standard/tests/file/006_variation1.phpt2627
-rw-r--r--ext/standard/tests/file/006_variation2.phpt186
-rw-r--r--ext/standard/tests/file/007_basic.phpt412
-rw-r--r--ext/standard/tests/file/007_error.phpt185
-rw-r--r--ext/standard/tests/file/007_variation1.phpt54
-rw-r--r--ext/standard/tests/file/007_variation10.phpt58
-rw-r--r--ext/standard/tests/file/007_variation11-win32.phpt76
-rw-r--r--ext/standard/tests/file/007_variation11.phpt76
-rw-r--r--ext/standard/tests/file/007_variation12-win32.phpt78
-rw-r--r--ext/standard/tests/file/007_variation12.phpt78
-rw-r--r--ext/standard/tests/file/007_variation13-win32.phpt65
-rw-r--r--ext/standard/tests/file/007_variation13.phpt65
-rw-r--r--ext/standard/tests/file/007_variation14.phpt62
-rw-r--r--ext/standard/tests/file/007_variation15.phpt58
-rw-r--r--ext/standard/tests/file/007_variation16.phpt60
-rw-r--r--ext/standard/tests/file/007_variation17.phpt54
-rw-r--r--ext/standard/tests/file/007_variation18.phpt58
-rw-r--r--ext/standard/tests/file/007_variation19.phpt71
-rw-r--r--ext/standard/tests/file/007_variation2.phpt58
-rw-r--r--ext/standard/tests/file/007_variation20.phpt73
-rw-r--r--ext/standard/tests/file/007_variation21.phpt60
-rw-r--r--ext/standard/tests/file/007_variation22.phpt62
-rw-r--r--ext/standard/tests/file/007_variation23.phpt58
-rw-r--r--ext/standard/tests/file/007_variation24.phpt60
-rw-r--r--ext/standard/tests/file/007_variation3.phpt71
-rw-r--r--ext/standard/tests/file/007_variation4.phpt73
-rw-r--r--ext/standard/tests/file/007_variation5.phpt60
-rw-r--r--ext/standard/tests/file/007_variation6.phpt62
-rw-r--r--ext/standard/tests/file/007_variation7.phpt58
-rw-r--r--ext/standard/tests/file/007_variation8.phpt60
-rw-r--r--ext/standard/tests/file/007_variation9.phpt54
-rw-r--r--ext/standard/tests/file/basename-win32.phpt341
-rw-r--r--ext/standard/tests/file/basename.phptbin0 -> 8229 bytes
-rw-r--r--ext/standard/tests/file/basename_basic-win32.phpt101
-rw-r--r--ext/standard/tests/file/basename_basic.phpt101
-rw-r--r--ext/standard/tests/file/basename_error.phpt38
-rw-r--r--ext/standard/tests/file/basename_variation1-win32.phpt238
-rw-r--r--ext/standard/tests/file/basename_variation1.phpt238
-rw-r--r--ext/standard/tests/file/basename_variation2-win32.phpt253
-rw-r--r--ext/standard/tests/file/basename_variation2.phpt253
-rw-r--r--ext/standard/tests/file/basename_variation3.phpt185
-rw-r--r--ext/standard/tests/file/basename_variation4.phpt188
-rw-r--r--ext/standard/tests/file/bug12556.phpt48
-rw-r--r--ext/standard/tests/file/bug20424.phpt10
-rw-r--r--ext/standard/tests/file/bug22382.phpt25
-rw-r--r--ext/standard/tests/file/bug22414.phpt38
-rw-r--r--ext/standard/tests/file/bug24313.phpt16
-rw-r--r--ext/standard/tests/file/bug24482.phpt37
-rw-r--r--ext/standard/tests/file/bug26003.phptbin0 -> 225 bytes
-rw-r--r--ext/standard/tests/file/bug26615.phpt20
-rw-r--r--ext/standard/tests/file/bug26938.phpt33
-rw-r--r--ext/standard/tests/file/bug27508.phpt80
-rw-r--r--ext/standard/tests/file/bug27619.phpt18
-rw-r--r--ext/standard/tests/file/bug30362.phpt26
-rw-r--r--ext/standard/tests/file/bug30362.txt1
-rw-r--r--ext/standard/tests/file/bug32160.phpt14
-rw-r--r--ext/standard/tests/file/bug32160.txt1
-rw-r--r--ext/standard/tests/file/bug35740.phpt14
-rw-r--r--ext/standard/tests/file/bug35781.phpt24
-rw-r--r--ext/standard/tests/file/bug37158.phpt39
-rw-r--r--ext/standard/tests/file/bug37864.phpt12
-rw-r--r--ext/standard/tests/file/bug38086.phpt55
-rw-r--r--ext/standard/tests/file/bug38086.txt5
-rw-r--r--ext/standard/tests/file/bug38450.phpt114
-rw-r--r--ext/standard/tests/file/bug38450_1.phpt114
-rw-r--r--ext/standard/tests/file/bug38450_2.phpt114
-rw-r--r--ext/standard/tests/file/bug38450_3.phpt105
-rw-r--r--ext/standard/tests/file/bug39367.phpt33
-rw-r--r--ext/standard/tests/file/bug39538.phpt39
-rw-r--r--ext/standard/tests/file/bug39551.phpt24
-rw-r--r--ext/standard/tests/file/bug39673.phpt40
-rw-r--r--ext/standard/tests/file/bug39863.phpt23
-rw-r--r--ext/standard/tests/file/bug40374.phpt17
-rw-r--r--ext/standard/tests/file/bug40501.csv2
-rw-r--r--ext/standard/tests/file/bug40501.phpt20
-rw-r--r--ext/standard/tests/file/bug41655_1.phpt15
-rw-r--r--ext/standard/tests/file/bug41655_2.phpt15
-rw-r--r--ext/standard/tests/file/bug41693.phpt13
-rw-r--r--ext/standard/tests/file/bug41815.phpt27
-rw-r--r--ext/standard/tests/file/bug41874.phpt15
-rw-r--r--ext/standard/tests/file/bug41874_1.phpt16
-rw-r--r--ext/standard/tests/file/bug41874_2.phpt17
-rw-r--r--ext/standard/tests/file/bug41874_3.phpt16
-rw-r--r--ext/standard/tests/file/bug43008.phpt19
-rw-r--r--ext/standard/tests/file/bug43137.phpt20
-rw-r--r--ext/standard/tests/file/bug43216.phpt8
-rw-r--r--ext/standard/tests/file/bug43248.phpt8
-rw-r--r--ext/standard/tests/file/bug43353-win32.phpt25
-rw-r--r--ext/standard/tests/file/bug43353.phpt25
-rw-r--r--ext/standard/tests/file/bug43522.phpt25
-rw-r--r--ext/standard/tests/file/bug44034.phpt41
-rw-r--r--ext/standard/tests/file/bug44607.phpt24
-rw-r--r--ext/standard/tests/file/bug44805.phpt30
-rw-r--r--ext/standard/tests/file/bug45181.phpt16
-rw-r--r--ext/standard/tests/file/bug45303.phpt13
-rw-r--r--ext/standard/tests/file/bug45985.phpt14
-rw-r--r--ext/standard/tests/file/bug46347.phpt24
-rw-r--r--ext/standard/tests/file/bug47767.phpt50
-rw-r--r--ext/standard/tests/file/bug49047.phpt17
-rw-r--r--ext/standard/tests/file/bug51094.phpt22
-rw-r--r--ext/standard/tests/file/bug52624.phpt12
-rw-r--r--ext/standard/tests/file/bug52820.phpt71
-rw-r--r--ext/standard/tests/file/bug53241.phpt23
-rw-r--r--ext/standard/tests/file/bug53848.phpt25
-rw-r--r--ext/standard/tests/file/bug55124.phpt18
-rw-r--r--ext/standard/tests/file/bug60120.phpt74
-rw-r--r--ext/standard/tests/file/bug61961.phpt14
-rw-r--r--ext/standard/tests/file/bug63512.phpt33
-rw-r--r--ext/standard/tests/file/chgrp.phpt15
-rw-r--r--ext/standard/tests/file/chmod_basic-win32.phpt545
-rw-r--r--ext/standard/tests/file/chmod_basic.phpt35
-rw-r--r--ext/standard/tests/file/chmod_error.phpt47
-rw-r--r--ext/standard/tests/file/chmod_variation1.phpt34
-rw-r--r--ext/standard/tests/file/chmod_variation2-win32.phpt74
-rw-r--r--ext/standard/tests/file/chmod_variation2.phpt92
-rw-r--r--ext/standard/tests/file/chmod_variation3.phpt209
-rw-r--r--ext/standard/tests/file/chmod_variation4.phpt201
-rw-r--r--ext/standard/tests/file/chown.phpt15
-rw-r--r--ext/standard/tests/file/chroot_001.phpt30
-rw-r--r--ext/standard/tests/file/clearstatcache_001.phpt43
-rw-r--r--ext/standard/tests/file/clearstatcache_error.phpt19
-rw-r--r--ext/standard/tests/file/copy_basic.phpt58
-rw-r--r--ext/standard/tests/file/copy_error.phpt39
-rw-r--r--ext/standard/tests/file/copy_variation1.phpt145
-rw-r--r--ext/standard/tests/file/copy_variation10.phpt37
-rw-r--r--ext/standard/tests/file/copy_variation11.phpt71
-rw-r--r--ext/standard/tests/file/copy_variation12-win32.phpt47
-rw-r--r--ext/standard/tests/file/copy_variation12.phpt51
-rw-r--r--ext/standard/tests/file/copy_variation13.phpt57
-rw-r--r--ext/standard/tests/file/copy_variation14.phpt48
-rw-r--r--ext/standard/tests/file/copy_variation15.phpt64
-rw-r--r--ext/standard/tests/file/copy_variation16-win32.phpt144
-rw-r--r--ext/standard/tests/file/copy_variation16.phpt143
-rw-r--r--ext/standard/tests/file/copy_variation17.phpt76
-rw-r--r--ext/standard/tests/file/copy_variation18.phpt56
-rw-r--r--ext/standard/tests/file/copy_variation2-win32.phpt218
-rw-r--r--ext/standard/tests/file/copy_variation2.phpt237
-rw-r--r--ext/standard/tests/file/copy_variation3-win32.phpt109
-rw-r--r--ext/standard/tests/file/copy_variation3.phpt110
-rw-r--r--ext/standard/tests/file/copy_variation4.phptbin0 -> 4966 bytes
-rw-r--r--ext/standard/tests/file/copy_variation5-win32.phpt111
-rw-r--r--ext/standard/tests/file/copy_variation5.phpt106
-rw-r--r--ext/standard/tests/file/copy_variation6-win32.phpt143
-rw-r--r--ext/standard/tests/file/copy_variation6.phpt142
-rw-r--r--ext/standard/tests/file/copy_variation7.phpt86
-rw-r--r--ext/standard/tests/file/copy_variation8.phpt176
-rw-r--r--ext/standard/tests/file/copy_variation9.phpt75
-rw-r--r--ext/standard/tests/file/directory_wrapper_fstat_basic.phpt13
-rw-r--r--ext/standard/tests/file/dirname_basic-win32.phpt93
-rw-r--r--ext/standard/tests/file/dirname_basic.phpt94
-rw-r--r--ext/standard/tests/file/dirname_error.phpt40
-rw-r--r--ext/standard/tests/file/dirname_variation1.phpt190
-rw-r--r--ext/standard/tests/file/disk.phpt48
-rw-r--r--ext/standard/tests/file/disk_free_space_basic.phpt70
-rw-r--r--ext/standard/tests/file/disk_free_space_error-win32.phpt75
-rw-r--r--ext/standard/tests/file/disk_free_space_error.phpt67
-rw-r--r--ext/standard/tests/file/disk_free_space_variation.phpt139
-rw-r--r--ext/standard/tests/file/disk_total_space_basic.phpt48
-rw-r--r--ext/standard/tests/file/disk_total_space_error-win32.phpt56
-rw-r--r--ext/standard/tests/file/disk_total_space_error.phpt52
-rw-r--r--ext/standard/tests/file/disk_total_space_variation.phpt123
-rw-r--r--ext/standard/tests/file/fclose_variation1.phpt15
-rw-r--r--ext/standard/tests/file/feof_basic.phpt101
-rw-r--r--ext/standard/tests/file/fflush_basic.phpt58
-rw-r--r--ext/standard/tests/file/fflush_error.phpt90
-rw-r--r--ext/standard/tests/file/fflush_variation1-win32.phpt531
-rw-r--r--ext/standard/tests/file/fflush_variation1.phpt532
-rw-r--r--ext/standard/tests/file/fflush_variation2.phpt443
-rw-r--r--ext/standard/tests/file/fflush_variation3.phpt383
-rw-r--r--ext/standard/tests/file/fflush_variation4.phpt53
-rw-r--r--ext/standard/tests/file/fgetc_basic.phpt543
-rw-r--r--ext/standard/tests/file/fgetc_error.phpt73
-rw-r--r--ext/standard/tests/file/fgetc_variation1.phpt94
-rw-r--r--ext/standard/tests/file/fgetc_variation2.phpt52
-rw-r--r--ext/standard/tests/file/fgetc_variation3.phpt117
-rw-r--r--ext/standard/tests/file/fgetc_variation4.phpt290
-rw-r--r--ext/standard/tests/file/fgetcsv.phpt158
-rw-r--r--ext/standard/tests/file/fgetcsv_error.phpt96
-rw-r--r--ext/standard/tests/file/fgetcsv_variation1.phpt1412
-rw-r--r--ext/standard/tests/file/fgetcsv_variation10.phpt1295
-rw-r--r--ext/standard/tests/file/fgetcsv_variation11.phpt1835
-rw-r--r--ext/standard/tests/file/fgetcsv_variation12.phpt957
-rw-r--r--ext/standard/tests/file/fgetcsv_variation13.phpt189
-rw-r--r--ext/standard/tests/file/fgetcsv_variation14.phpt239
-rw-r--r--ext/standard/tests/file/fgetcsv_variation15.phpt940
-rw-r--r--ext/standard/tests/file/fgetcsv_variation16.phpt944
-rw-r--r--ext/standard/tests/file/fgetcsv_variation17.phpt1565
-rw-r--r--ext/standard/tests/file/fgetcsv_variation18.phpt690
-rw-r--r--ext/standard/tests/file/fgetcsv_variation19.phpt841
-rw-r--r--ext/standard/tests/file/fgetcsv_variation2.phpt1413
-rw-r--r--ext/standard/tests/file/fgetcsv_variation20.phpt191
-rw-r--r--ext/standard/tests/file/fgetcsv_variation21.phpt191
-rw-r--r--ext/standard/tests/file/fgetcsv_variation22.phpt614
-rw-r--r--ext/standard/tests/file/fgetcsv_variation23.phpt48
-rw-r--r--ext/standard/tests/file/fgetcsv_variation24.phpt671
-rw-r--r--ext/standard/tests/file/fgetcsv_variation25.phpt935
-rw-r--r--ext/standard/tests/file/fgetcsv_variation26.phpt441
-rw-r--r--ext/standard/tests/file/fgetcsv_variation27.phpt935
-rw-r--r--ext/standard/tests/file/fgetcsv_variation28.phpt935
-rw-r--r--ext/standard/tests/file/fgetcsv_variation29.phpt615
-rw-r--r--ext/standard/tests/file/fgetcsv_variation3.phpt933
-rw-r--r--ext/standard/tests/file/fgetcsv_variation30.phpt614
-rw-r--r--ext/standard/tests/file/fgetcsv_variation31.phpt616
-rw-r--r--ext/standard/tests/file/fgetcsv_variation4.phpt932
-rw-r--r--ext/standard/tests/file/fgetcsv_variation5.phpt934
-rw-r--r--ext/standard/tests/file/fgetcsv_variation6.phpt2350
-rw-r--r--ext/standard/tests/file/fgetcsv_variation7.phpt1292
-rw-r--r--ext/standard/tests/file/fgetcsv_variation8.phpt1058
-rw-r--r--ext/standard/tests/file/fgetcsv_variation9.phpt1056
-rw-r--r--ext/standard/tests/file/fgets_basic.phpt318
-rw-r--r--ext/standard/tests/file/fgets_error.phpt108
-rw-r--r--ext/standard/tests/file/fgets_socket_variation1.phpt56
-rw-r--r--ext/standard/tests/file/fgets_socket_variation2.phpt63
-rw-r--r--ext/standard/tests/file/fgets_variation1.phpt116
-rw-r--r--ext/standard/tests/file/fgets_variation2.phpt63
-rw-r--r--ext/standard/tests/file/fgets_variation3.phpt500
-rw-r--r--ext/standard/tests/file/fgets_variation4-win32.phpt574
-rw-r--r--ext/standard/tests/file/fgets_variation4.phpt574
-rw-r--r--ext/standard/tests/file/fgets_variation5.phpt302
-rw-r--r--ext/standard/tests/file/fgets_variation6-win32.phpt372
-rw-r--r--ext/standard/tests/file/fgets_variation6.phpt372
-rw-r--r--ext/standard/tests/file/fgetss.phpt83
-rw-r--r--ext/standard/tests/file/fgetss1.phpt69
-rw-r--r--ext/standard/tests/file/fgetss_basic1.phpt135
-rw-r--r--ext/standard/tests/file/fgetss_basic2-win32.phpt216
-rw-r--r--ext/standard/tests/file/fgetss_basic2.phpt214
-rw-r--r--ext/standard/tests/file/fgetss_error.phpt106
-rw-r--r--ext/standard/tests/file/fgetss_variation1-win32.phpt172
-rw-r--r--ext/standard/tests/file/fgetss_variation1.phpt168
-rw-r--r--ext/standard/tests/file/fgetss_variation2.phpt434
-rw-r--r--ext/standard/tests/file/fgetss_variation3-win32.phpt571
-rw-r--r--ext/standard/tests/file/fgetss_variation3.phpt567
-rw-r--r--ext/standard/tests/file/fgetss_variation4.phpt168
-rw-r--r--ext/standard/tests/file/fgetss_variation5-win32.phpt220
-rw-r--r--ext/standard/tests/file/fgetss_variation5.phpt217
-rw-r--r--ext/standard/tests/file/file.inc650
-rw-r--r--ext/standard/tests/file/file_basic.phpt77
-rw-r--r--ext/standard/tests/file/file_error.phpt48
-rw-r--r--ext/standard/tests/file/file_exists_error.phpt40
-rw-r--r--ext/standard/tests/file/file_exists_variation1.phpt30
-rw-r--r--ext/standard/tests/file/file_get_contents_basic.phpt41
-rw-r--r--ext/standard/tests/file/file_get_contents_basic001.phpt21
-rw-r--r--ext/standard/tests/file/file_get_contents_error.phpt67
-rw-r--r--ext/standard/tests/file/file_get_contents_error001.phpt19
-rw-r--r--ext/standard/tests/file/file_get_contents_error002.phpt18
-rw-r--r--ext/standard/tests/file/file_get_contents_file_put_contents_basic.phpt50
-rw-r--r--ext/standard/tests/file/file_get_contents_file_put_contents_error.phpt71
-rw-r--r--ext/standard/tests/file/file_get_contents_file_put_contents_variation1.phpt116
-rw-r--r--ext/standard/tests/file/file_get_contents_file_put_contents_variation2.phpt57
-rw-r--r--ext/standard/tests/file/file_get_contents_variation1.phpt51
-rw-r--r--ext/standard/tests/file/file_get_contents_variation2.phpt52
-rw-r--r--ext/standard/tests/file/file_get_contents_variation3.phpt218
-rw-r--r--ext/standard/tests/file/file_get_contents_variation4.phpt251
-rw-r--r--ext/standard/tests/file/file_get_contents_variation5.phpt222
-rw-r--r--ext/standard/tests/file/file_get_contents_variation6.phpt215
-rw-r--r--ext/standard/tests/file/file_get_contents_variation7-win32.phpt115
-rw-r--r--ext/standard/tests/file/file_get_contents_variation7.phpt104
-rw-r--r--ext/standard/tests/file/file_get_contents_variation8-win32.phpt98
-rw-r--r--ext/standard/tests/file/file_get_contents_variation8.phpt88
-rw-r--r--ext/standard/tests/file/file_get_contents_variation9.phpt56
-rw-r--r--ext/standard/tests/file/file_put_contents.phpt32
-rw-r--r--ext/standard/tests/file/file_put_contents_variation1.phpt43
-rw-r--r--ext/standard/tests/file/file_put_contents_variation2.phpt167
-rw-r--r--ext/standard/tests/file/file_put_contents_variation3.phpt250
-rw-r--r--ext/standard/tests/file/file_put_contents_variation4.phpt51
-rw-r--r--ext/standard/tests/file/file_put_contents_variation5.phpt51
-rw-r--r--ext/standard/tests/file/file_put_contents_variation6.phpt56
-rw-r--r--ext/standard/tests/file/file_put_contents_variation7-win32.phpt130
-rw-r--r--ext/standard/tests/file/file_put_contents_variation7.phpt119
-rw-r--r--ext/standard/tests/file/file_put_contents_variation8-win32.phpt98
-rw-r--r--ext/standard/tests/file/file_put_contents_variation8.phptbin0 -> 2388 bytes
-rw-r--r--ext/standard/tests/file/file_put_contents_variation9.phpt70
-rw-r--r--ext/standard/tests/file/file_variation.phpt160
-rw-r--r--ext/standard/tests/file/file_variation2.phpt210
-rw-r--r--ext/standard/tests/file/file_variation3.phpt294
-rw-r--r--ext/standard/tests/file/file_variation4.phpt291
-rw-r--r--ext/standard/tests/file/file_variation5-win32.phpt74
-rw-r--r--ext/standard/tests/file/file_variation5.phpt94
-rw-r--r--ext/standard/tests/file/file_variation6.phpt261
-rw-r--r--ext/standard/tests/file/file_variation7.phpt87
-rw-r--r--ext/standard/tests/file/file_variation8-win32.phpt142
-rw-r--r--ext/standard/tests/file/file_variation8.phpt128
-rw-r--r--ext/standard/tests/file/file_variation9.phpt89
-rw-r--r--ext/standard/tests/file/filegroup_basic.phpt69
-rw-r--r--ext/standard/tests/file/filegroup_error.phpt44
-rw-r--r--ext/standard/tests/file/filegroup_variation1.phpt47
-rw-r--r--ext/standard/tests/file/filegroup_variation2.phpt71
-rw-r--r--ext/standard/tests/file/filegroup_variation3.phpt85
-rw-r--r--ext/standard/tests/file/fileinode_basic.phpt36
-rw-r--r--ext/standard/tests/file/fileinode_error.phpt44
-rw-r--r--ext/standard/tests/file/fileinode_variation.phpt112
-rw-r--r--ext/standard/tests/file/fileinode_variation1.phpt48
-rw-r--r--ext/standard/tests/file/fileinode_variation2.phpt72
-rw-r--r--ext/standard/tests/file/fileinode_variation3.phpt86
-rw-r--r--ext/standard/tests/file/fileowner_basic.phpt51
-rw-r--r--ext/standard/tests/file/fileowner_error.phpt44
-rw-r--r--ext/standard/tests/file/fileowner_variation1.phpt48
-rw-r--r--ext/standard/tests/file/fileowner_variation2.phpt72
-rw-r--r--ext/standard/tests/file/fileowner_variation3.phpt86
-rw-r--r--ext/standard/tests/file/fileperms_variation1.phpt47
-rw-r--r--ext/standard/tests/file/fileperms_variation2.phpt71
-rw-r--r--ext/standard/tests/file/fileperms_variation3.phpt85
-rw-r--r--ext/standard/tests/file/filesize_basic.phpt39
-rw-r--r--ext/standard/tests/file/filesize_error.phpt41
-rw-r--r--ext/standard/tests/file/filesize_variation1-win32.phpt45
-rw-r--r--ext/standard/tests/file/filesize_variation1.phpt45
-rw-r--r--ext/standard/tests/file/filesize_variation2-win32.phpt83
-rw-r--r--ext/standard/tests/file/filesize_variation2.phpt83
-rw-r--r--ext/standard/tests/file/filesize_variation3-win32.phpt70
-rw-r--r--ext/standard/tests/file/filesize_variation3.phpt70
-rw-r--r--ext/standard/tests/file/filesize_variation4-win32.phpt109
-rw-r--r--ext/standard/tests/file/filesize_variation4.phpt111
-rw-r--r--ext/standard/tests/file/filesize_variation5.phpt34
-rw-r--r--ext/standard/tests/file/filestat.phpt63
-rw-r--r--ext/standard/tests/file/filetype_basic.phpt22
-rw-r--r--ext/standard/tests/file/filetype_error.phpt39
-rw-r--r--ext/standard/tests/file/filetype_variation.phpt78
-rw-r--r--ext/standard/tests/file/filetype_variation2.phpt29
-rw-r--r--ext/standard/tests/file/filetype_variation3.phpt29
-rw-r--r--ext/standard/tests/file/flock.phpt64
-rw-r--r--ext/standard/tests/file/flock_basic.phpt44
-rw-r--r--ext/standard/tests/file/flock_error.phpt112
-rw-r--r--ext/standard/tests/file/flock_variation.phpt371
-rw-r--r--ext/standard/tests/file/fnmatch_basic.phpt49
-rw-r--r--ext/standard/tests/file/fnmatch_error.phpt57
-rw-r--r--ext/standard/tests/file/fnmatch_variation.phpt505
-rw-r--r--ext/standard/tests/file/fopen_include_path.inc92
-rw-r--r--ext/standard/tests/file/fopen_variation1.phpt14
-rw-r--r--ext/standard/tests/file/fopen_variation10-win32.phpt149
-rw-r--r--ext/standard/tests/file/fopen_variation11-win32.phpt147
-rw-r--r--ext/standard/tests/file/fopen_variation12.phpt52
-rw-r--r--ext/standard/tests/file/fopen_variation13.phpt56
-rw-r--r--ext/standard/tests/file/fopen_variation14-win32.phpt189
-rw-r--r--ext/standard/tests/file/fopen_variation14.phpt134
-rw-r--r--ext/standard/tests/file/fopen_variation15-win32.phpt193
-rw-r--r--ext/standard/tests/file/fopen_variation15.phpt138
-rw-r--r--ext/standard/tests/file/fopen_variation16.phpt75
-rw-r--r--ext/standard/tests/file/fopen_variation17.phpt74
-rw-r--r--ext/standard/tests/file/fopen_variation19.phpt110
-rw-r--r--ext/standard/tests/file/fopen_variation3.phpt218
-rw-r--r--ext/standard/tests/file/fopen_variation4.phpt251
-rw-r--r--ext/standard/tests/file/fopen_variation5.phpt151
-rw-r--r--ext/standard/tests/file/fopen_variation6.phpt44
-rw-r--r--ext/standard/tests/file/fopen_variation7.phpt66
-rw-r--r--ext/standard/tests/file/fopen_variation8.phpt150
-rw-r--r--ext/standard/tests/file/fopen_variation9.phpt66
-rw-r--r--ext/standard/tests/file/fopencookie.phpt88
-rw-r--r--ext/standard/tests/file/fpassthru_basic.phpt128
-rw-r--r--ext/standard/tests/file/fpassthru_error.phpt40
-rw-r--r--ext/standard/tests/file/fpassthru_variation.phpt114
-rw-r--r--ext/standard/tests/file/fpassthru_variation1.phpt224
-rw-r--r--ext/standard/tests/file/fputcsv.phpt105
-rw-r--r--ext/standard/tests/file/fputcsv_002.phpt43
-rw-r--r--ext/standard/tests/file/fputcsv_error.phpt97
-rw-r--r--ext/standard/tests/file/fputcsv_variation1.phpt834
-rw-r--r--ext/standard/tests/file/fputcsv_variation10.phpt336
-rw-r--r--ext/standard/tests/file/fputcsv_variation11.phpt834
-rw-r--r--ext/standard/tests/file/fputcsv_variation12.phpt835
-rw-r--r--ext/standard/tests/file/fputcsv_variation13.phpt1051
-rw-r--r--ext/standard/tests/file/fputcsv_variation14.phpt357
-rw-r--r--ext/standard/tests/file/fputcsv_variation2.phpt942
-rw-r--r--ext/standard/tests/file/fputcsv_variation3.phpt942
-rw-r--r--ext/standard/tests/file/fputcsv_variation4.phpt942
-rw-r--r--ext/standard/tests/file/fputcsv_variation5.phpt834
-rw-r--r--ext/standard/tests/file/fputcsv_variation6.phpt837
-rw-r--r--ext/standard/tests/file/fputcsv_variation7.phpt837
-rw-r--r--ext/standard/tests/file/fputcsv_variation8.phpt837
-rw-r--r--ext/standard/tests/file/fputcsv_variation9.phpt1268
-rw-r--r--ext/standard/tests/file/fread_basic.phpt640
-rw-r--r--ext/standard/tests/file/fread_error.phpt114
-rw-r--r--ext/standard/tests/file/fread_fwrite_basic.phpt72
-rw-r--r--ext/standard/tests/file/fread_socket_variation1.phpt16
-rw-r--r--ext/standard/tests/file/fread_variation1.phpt657
-rw-r--r--ext/standard/tests/file/fread_variation2.phpt656
-rw-r--r--ext/standard/tests/file/fread_variation3-win32.phpt498
-rw-r--r--ext/standard/tests/file/fread_variation3.phpt498
-rw-r--r--ext/standard/tests/file/fread_variation4-win32.phpt469
-rw-r--r--ext/standard/tests/file/fread_variation4.phpt469
-rw-r--r--ext/standard/tests/file/fscanf.phpt100
-rw-r--r--ext/standard/tests/file/fscanf_error.phpt99
-rw-r--r--ext/standard/tests/file/fscanf_variation1.phpt50
-rw-r--r--ext/standard/tests/file/fscanf_variation10.phpt222
-rw-r--r--ext/standard/tests/file/fscanf_variation11.phpt713
-rw-r--r--ext/standard/tests/file/fscanf_variation12.phpt946
-rw-r--r--ext/standard/tests/file/fscanf_variation13.phpt246
-rw-r--r--ext/standard/tests/file/fscanf_variation14.phpt1079
-rw-r--r--ext/standard/tests/file/fscanf_variation15.phpt863
-rw-r--r--ext/standard/tests/file/fscanf_variation16.phpt221
-rw-r--r--ext/standard/tests/file/fscanf_variation17.phpt712
-rw-r--r--ext/standard/tests/file/fscanf_variation18.phpt1014
-rw-r--r--ext/standard/tests/file/fscanf_variation19.phpt250
-rw-r--r--ext/standard/tests/file/fscanf_variation2.phpt1008
-rw-r--r--ext/standard/tests/file/fscanf_variation20.phpt1012
-rw-r--r--ext/standard/tests/file/fscanf_variation21.phpt863
-rw-r--r--ext/standard/tests/file/fscanf_variation22.phpt221
-rw-r--r--ext/standard/tests/file/fscanf_variation23.phpt712
-rw-r--r--ext/standard/tests/file/fscanf_variation24.phpt994
-rw-r--r--ext/standard/tests/file/fscanf_variation25.phpt294
-rw-r--r--ext/standard/tests/file/fscanf_variation26.phpt356
-rw-r--r--ext/standard/tests/file/fscanf_variation27.phpt1013
-rw-r--r--ext/standard/tests/file/fscanf_variation28.phpt863
-rw-r--r--ext/standard/tests/file/fscanf_variation29.phpt222
-rw-r--r--ext/standard/tests/file/fscanf_variation3.phpt865
-rw-r--r--ext/standard/tests/file/fscanf_variation30.phpt713
-rw-r--r--ext/standard/tests/file/fscanf_variation31.phpt946
-rw-r--r--ext/standard/tests/file/fscanf_variation32.phpt251
-rw-r--r--ext/standard/tests/file/fscanf_variation33.phpt1019
-rw-r--r--ext/standard/tests/file/fscanf_variation34.phpt869
-rw-r--r--ext/standard/tests/file/fscanf_variation35.phpt217
-rw-r--r--ext/standard/tests/file/fscanf_variation36.phpt708
-rw-r--r--ext/standard/tests/file/fscanf_variation37.phpt946
-rw-r--r--ext/standard/tests/file/fscanf_variation38.phpt246
-rw-r--r--ext/standard/tests/file/fscanf_variation39.phpt1014
-rw-r--r--ext/standard/tests/file/fscanf_variation4.phpt218
-rw-r--r--ext/standard/tests/file/fscanf_variation40.phpt865
-rw-r--r--ext/standard/tests/file/fscanf_variation41.phpt217
-rw-r--r--ext/standard/tests/file/fscanf_variation42.phpt708
-rw-r--r--ext/standard/tests/file/fscanf_variation43.phpt946
-rw-r--r--ext/standard/tests/file/fscanf_variation44.phpt246
-rw-r--r--ext/standard/tests/file/fscanf_variation45.phpt1008
-rw-r--r--ext/standard/tests/file/fscanf_variation46.phpt859
-rw-r--r--ext/standard/tests/file/fscanf_variation47.phpt217
-rw-r--r--ext/standard/tests/file/fscanf_variation48.phpt707
-rw-r--r--ext/standard/tests/file/fscanf_variation49.phpt946
-rw-r--r--ext/standard/tests/file/fscanf_variation5.phpt708
-rw-r--r--ext/standard/tests/file/fscanf_variation50.phpt246
-rw-r--r--ext/standard/tests/file/fscanf_variation51.phpt153
-rw-r--r--ext/standard/tests/file/fscanf_variation52.phpt178
-rw-r--r--ext/standard/tests/file/fscanf_variation53.phpt229
-rw-r--r--ext/standard/tests/file/fscanf_variation54.phpt101
-rw-r--r--ext/standard/tests/file/fscanf_variation55.phpt1691
-rw-r--r--ext/standard/tests/file/fscanf_variation6.phpt946
-rw-r--r--ext/standard/tests/file/fscanf_variation7.phpt246
-rw-r--r--ext/standard/tests/file/fscanf_variation8.phpt1614
-rw-r--r--ext/standard/tests/file/fscanf_variation9.phpt1015
-rw-r--r--ext/standard/tests/file/fseek_dir_basic.phpt96
-rw-r--r--ext/standard/tests/file/fseek_ftell_rewind_basic1.phpt453
-rw-r--r--ext/standard/tests/file/fseek_ftell_rewind_basic2-win32.phpt464
-rw-r--r--ext/standard/tests/file/fseek_ftell_rewind_basic2.phpt463
-rw-r--r--ext/standard/tests/file/fseek_ftell_rewind_error1.phpt99
-rw-r--r--ext/standard/tests/file/fseek_ftell_rewind_error2.phpt95
-rw-r--r--ext/standard/tests/file/fseek_ftell_rewind_error3.phpt95
-rw-r--r--ext/standard/tests/file/fseek_ftell_rewind_variation1.phpt428
-rw-r--r--ext/standard/tests/file/fseek_ftell_rewind_variation2-win32.phpt437
-rw-r--r--ext/standard/tests/file/fseek_ftell_rewind_variation2.phpt437
-rw-r--r--ext/standard/tests/file/fseek_ftell_rewind_variation3.phpt478
-rw-r--r--ext/standard/tests/file/fseek_ftell_rewind_variation4-win32.phpt483
-rw-r--r--ext/standard/tests/file/fseek_ftell_rewind_variation4.phpt483
-rw-r--r--ext/standard/tests/file/fseek_ftell_rewind_variation5.phpt474
-rw-r--r--ext/standard/tests/file/fseek_ftell_rewind_variation6-win32.phpt483
-rw-r--r--ext/standard/tests/file/fseek_ftell_rewind_variation6.phpt483
-rw-r--r--ext/standard/tests/file/fseek_ftell_rewind_variation7.phpt477
-rw-r--r--ext/standard/tests/file/fseek_ftell_rewind_variation8-win32.phpt484
-rw-r--r--ext/standard/tests/file/fseek_ftell_rewind_variation8.phpt484
-rw-r--r--ext/standard/tests/file/fseek_variation1.phpt198
-rw-r--r--ext/standard/tests/file/fseek_variation2.phpt159
-rw-r--r--ext/standard/tests/file/fseek_variation3.phpt54
-rw-r--r--ext/standard/tests/file/fstat.phpt74
-rw-r--r--ext/standard/tests/file/fstat_basic.phpt65
-rw-r--r--ext/standard/tests/file/fstat_error.phpt22
-rw-r--r--ext/standard/tests/file/fstat_variation1.phpt34
-rw-r--r--ext/standard/tests/file/fstat_variation2.phpt31
-rw-r--r--ext/standard/tests/file/fstat_variation3.phpt42
-rw-r--r--ext/standard/tests/file/fstat_variation4.phpt35
-rw-r--r--ext/standard/tests/file/fstat_variation5.phpt31
-rw-r--r--ext/standard/tests/file/fstat_variation6.phpt46
-rw-r--r--ext/standard/tests/file/fstat_variation7.phpt35
-rw-r--r--ext/standard/tests/file/fstat_variation8.phpt33
-rw-r--r--ext/standard/tests/file/ftruncate.phptbin0 -> 1077 bytes
-rw-r--r--ext/standard/tests/file/ftruncate_error.phpt124
-rw-r--r--ext/standard/tests/file/ftruncate_variation1-win32.phpt461
-rw-r--r--ext/standard/tests/file/ftruncate_variation1.phpt461
-rw-r--r--ext/standard/tests/file/ftruncate_variation2-win32.phpt462
-rw-r--r--ext/standard/tests/file/ftruncate_variation2.phpt462
-rw-r--r--ext/standard/tests/file/ftruncate_variation3-win32.phpt461
-rw-r--r--ext/standard/tests/file/ftruncate_variation3.phpt461
-rw-r--r--ext/standard/tests/file/ftruncate_variation4-win32.phpt462
-rw-r--r--ext/standard/tests/file/ftruncate_variation4.phpt462
-rw-r--r--ext/standard/tests/file/ftruncate_variation5-win32.phpt463
-rw-r--r--ext/standard/tests/file/ftruncate_variation5.phpt463
-rw-r--r--ext/standard/tests/file/ftruncate_variation6-win32.phpt482
-rw-r--r--ext/standard/tests/file/ftruncate_variation6.phpt482
-rw-r--r--ext/standard/tests/file/ftruncate_variation7-win32.phpt463
-rw-r--r--ext/standard/tests/file/ftruncate_variation7.phpt463
-rw-r--r--ext/standard/tests/file/fwrite.phpt52
-rw-r--r--ext/standard/tests/file/fwrite_basic-win32.phpt424
-rw-r--r--ext/standard/tests/file/fwrite_basic.phpt424
-rw-r--r--ext/standard/tests/file/fwrite_error.phpt121
-rw-r--r--ext/standard/tests/file/fwrite_variation1-win32.phpt235
-rw-r--r--ext/standard/tests/file/fwrite_variation1.phpt233
-rw-r--r--ext/standard/tests/file/fwrite_variation2-win32.phpt304
-rw-r--r--ext/standard/tests/file/fwrite_variation2.phpt303
-rw-r--r--ext/standard/tests/file/fwrite_variation3-win32.phpt380
-rw-r--r--ext/standard/tests/file/fwrite_variation3.phpt381
-rw-r--r--ext/standard/tests/file/fwrite_variation4-win32.phpt275
-rw-r--r--ext/standard/tests/file/fwrite_variation4.phpt275
-rw-r--r--ext/standard/tests/file/fwrite_variation5.phpt173
-rw-r--r--ext/standard/tests/file/get_current_user.phpt15
-rw-r--r--ext/standard/tests/file/glob_basic.phpt82
-rw-r--r--ext/standard/tests/file/glob_error.phpt53
-rw-r--r--ext/standard/tests/file/glob_error_002-win32.phpt27
-rw-r--r--ext/standard/tests/file/glob_variation-win32.phpt465
-rw-r--r--ext/standard/tests/file/glob_variation.phpt465
-rw-r--r--ext/standard/tests/file/glob_variation2.phpt57
-rw-r--r--ext/standard/tests/file/include_streams.phpt130
-rw-r--r--ext/standard/tests/file/include_userstream_001.phpt82
-rw-r--r--ext/standard/tests/file/include_userstream_002.phpt106
-rw-r--r--ext/standard/tests/file/include_userstream_003.phpt121
-rw-r--r--ext/standard/tests/file/is_dir_basic.phpt43
-rw-r--r--ext/standard/tests/file/is_dir_error.phpt35
-rw-r--r--ext/standard/tests/file/is_dir_variation1.phpt42
-rw-r--r--ext/standard/tests/file/is_dir_variation2.phpt96
-rw-r--r--ext/standard/tests/file/is_dir_variation3.phpt51
-rw-r--r--ext/standard/tests/file/is_dir_variation4.phpt89
-rw-r--r--ext/standard/tests/file/is_executable_basic-win32.phpt1064
-rw-r--r--ext/standard/tests/file/is_executable_basic.phpt1076
-rw-r--r--ext/standard/tests/file/is_executable_error.phpt29
-rw-r--r--ext/standard/tests/file/is_executable_variation1.phpt92
-rw-r--r--ext/standard/tests/file/is_executable_variation2.phpt110
-rw-r--r--ext/standard/tests/file/is_executable_variation3.phpt69
-rw-r--r--ext/standard/tests/file/is_file_basic.phpt48
-rw-r--r--ext/standard/tests/file/is_file_error.phpt51
-rw-r--r--ext/standard/tests/file/is_file_variation1.phpt57
-rw-r--r--ext/standard/tests/file/is_file_variation2.phpt46
-rw-r--r--ext/standard/tests/file/is_file_variation3.phpt60
-rw-r--r--ext/standard/tests/file/is_file_variation4.phpt78
-rw-r--r--ext/standard/tests/file/is_readable_basic-win32.phpt1066
-rw-r--r--ext/standard/tests/file/is_readable_basic.phpt1076
-rw-r--r--ext/standard/tests/file/is_readable_error.phpt29
-rw-r--r--ext/standard/tests/file/is_readable_variation1.phpt105
-rw-r--r--ext/standard/tests/file/is_readable_variation2.phpt109
-rw-r--r--ext/standard/tests/file/is_readable_variation3.phpt68
-rw-r--r--ext/standard/tests/file/is_uploaded_file_basic.phpt48
-rw-r--r--ext/standard/tests/file/is_writable_basic.phpt1588
-rw-r--r--ext/standard/tests/file/is_writable_error.phpt45
-rw-r--r--ext/standard/tests/file/is_writable_variation1.phpt125
-rw-r--r--ext/standard/tests/file/is_writable_variation2.phpt126
-rw-r--r--ext/standard/tests/file/is_writable_variation3.phpt78
-rw-r--r--ext/standard/tests/file/lchgrp_basic.phpt36
-rw-r--r--ext/standard/tests/file/lchown_basic.phpt44
-rw-r--r--ext/standard/tests/file/lchown_error.phpt78
-rw-r--r--ext/standard/tests/file/link_win32.phpt26
-rw-r--r--ext/standard/tests/file/lstat_stat_basic.phpt317
-rw-r--r--ext/standard/tests/file/lstat_stat_error.phpt79
-rw-r--r--ext/standard/tests/file/lstat_stat_variation1.phpt61
-rw-r--r--ext/standard/tests/file/lstat_stat_variation10.phpt59
-rw-r--r--ext/standard/tests/file/lstat_stat_variation11.phpt60
-rw-r--r--ext/standard/tests/file/lstat_stat_variation12.phpt66
-rw-r--r--ext/standard/tests/file/lstat_stat_variation13.phpt58
-rw-r--r--ext/standard/tests/file/lstat_stat_variation14.phpt62
-rw-r--r--ext/standard/tests/file/lstat_stat_variation15.phpt64
-rw-r--r--ext/standard/tests/file/lstat_stat_variation16.phpt58
-rw-r--r--ext/standard/tests/file/lstat_stat_variation17.phpt57
-rw-r--r--ext/standard/tests/file/lstat_stat_variation18.phpt176
-rw-r--r--ext/standard/tests/file/lstat_stat_variation19.phpt285
-rw-r--r--ext/standard/tests/file/lstat_stat_variation2.phpt62
-rw-r--r--ext/standard/tests/file/lstat_stat_variation20.phpt287
-rw-r--r--ext/standard/tests/file/lstat_stat_variation21.phpt65
-rw-r--r--ext/standard/tests/file/lstat_stat_variation22.phpt54
-rw-r--r--ext/standard/tests/file/lstat_stat_variation3.phpt62
-rw-r--r--ext/standard/tests/file/lstat_stat_variation4.phpt65
-rw-r--r--ext/standard/tests/file/lstat_stat_variation5.phpt66
-rw-r--r--ext/standard/tests/file/lstat_stat_variation6.phpt79
-rw-r--r--ext/standard/tests/file/lstat_stat_variation7.phpt57
-rw-r--r--ext/standard/tests/file/lstat_stat_variation8.phpt62
-rw-r--r--ext/standard/tests/file/lstat_stat_variation9.phpt68
-rw-r--r--ext/standard/tests/file/mkdir-001.phpt36
-rw-r--r--ext/standard/tests/file/mkdir-002.phpt55
-rw-r--r--ext/standard/tests/file/mkdir-003.phpt30
-rw-r--r--ext/standard/tests/file/mkdir-004.phpt24
-rw-r--r--ext/standard/tests/file/mkdir-005.phpt25
-rw-r--r--ext/standard/tests/file/mkdir-006.phpt20
-rw-r--r--ext/standard/tests/file/mkdir_rmdir_error.phpt58
-rw-r--r--ext/standard/tests/file/mkdir_rmdir_variation-win32.phpt1613
-rw-r--r--ext/standard/tests/file/mkdir_rmdir_variation1.phpt1579
-rw-r--r--ext/standard/tests/file/mkdir_rmdir_variation2.phpt80
-rw-r--r--ext/standard/tests/file/mkdir_variation1-win32.phpt122
-rw-r--r--ext/standard/tests/file/mkdir_variation1.phpt121
-rw-r--r--ext/standard/tests/file/mkdir_variation2.phpt189
-rw-r--r--ext/standard/tests/file/mkdir_variation3.phpt208
-rw-r--r--ext/standard/tests/file/mkdir_variation4.phpt220
-rw-r--r--ext/standard/tests/file/mkdir_variation5-win32.phpt105
-rw-r--r--ext/standard/tests/file/mkdir_variation5.phpt98
-rw-r--r--ext/standard/tests/file/move_uploaded_file_basic.phpt76
-rw-r--r--ext/standard/tests/file/parse_ini_file.phpt489
-rw-r--r--ext/standard/tests/file/parse_ini_file_error.phpt47
-rw-r--r--ext/standard/tests/file/parse_ini_file_variation1.phpt68
-rw-r--r--ext/standard/tests/file/parse_ini_file_variation2.phpt111
-rw-r--r--ext/standard/tests/file/parse_ini_file_variation3.phpt104
-rw-r--r--ext/standard/tests/file/parse_ini_file_variation4.phpt211
-rw-r--r--ext/standard/tests/file/parse_ini_file_variation5.phpt254
-rw-r--r--ext/standard/tests/file/parse_ini_file_variation6-win32.phpt143
-rw-r--r--ext/standard/tests/file/parse_ini_file_variation6.phpt129
-rw-r--r--ext/standard/tests/file/pathinfo_basic.phpt401
-rw-r--r--ext/standard/tests/file/pathinfo_basic1-win32.phpt609
-rw-r--r--ext/standard/tests/file/pathinfo_basic1.phpt610
-rw-r--r--ext/standard/tests/file/pathinfo_basic2-win32.phpt270
-rw-r--r--ext/standard/tests/file/pathinfo_basic2.phpt273
-rw-r--r--ext/standard/tests/file/pathinfo_error.phpt24
-rw-r--r--ext/standard/tests/file/pathinfo_variation1.phpt190
-rw-r--r--ext/standard/tests/file/pathinfo_variation2.phpt197
-rw-r--r--ext/standard/tests/file/pathinfo_variation3.phpt80
-rw-r--r--ext/standard/tests/file/pathinfo_variaton.phpt442
-rw-r--r--ext/standard/tests/file/pclose_variation1.phpt232
-rw-r--r--ext/standard/tests/file/php_fd_wrapper_01.phpt11
-rw-r--r--ext/standard/tests/file/php_fd_wrapper_02.phpt11
-rw-r--r--ext/standard/tests/file/php_fd_wrapper_03.phpt22
-rw-r--r--ext/standard/tests/file/php_fd_wrapper_04.phpt20
-rw-r--r--ext/standard/tests/file/popen_pclose_basic-win32.phpt75
-rw-r--r--ext/standard/tests/file/popen_pclose_basic.phpt103
-rw-r--r--ext/standard/tests/file/popen_pclose_error-sunos.phpt55
-rw-r--r--ext/standard/tests/file/popen_pclose_error-win32-debug.phpt63
-rw-r--r--ext/standard/tests/file/popen_pclose_error-win32.phpt59
-rw-r--r--ext/standard/tests/file/popen_pclose_error.phpt56
-rw-r--r--ext/standard/tests/file/proc_open01.phpt69
-rw-r--r--ext/standard/tests/file/readfile_basic-win32.phpt530
-rw-r--r--ext/standard/tests/file/readfile_basic.phpt530
-rw-r--r--ext/standard/tests/file/readfile_error.phpt61
-rw-r--r--ext/standard/tests/file/readfile_variation1.phpt46
-rw-r--r--ext/standard/tests/file/readfile_variation10-win32.phpt87
-rw-r--r--ext/standard/tests/file/readfile_variation10.phptbin0 -> 1869 bytes
-rw-r--r--ext/standard/tests/file/readfile_variation2.phpt87
-rw-r--r--ext/standard/tests/file/readfile_variation3.phpt63
-rw-r--r--ext/standard/tests/file/readfile_variation4.phpt251
-rw-r--r--ext/standard/tests/file/readfile_variation5.phpt221
-rw-r--r--ext/standard/tests/file/readfile_variation6.phpt50
-rw-r--r--ext/standard/tests/file/readfile_variation7.phpt50
-rw-r--r--ext/standard/tests/file/readfile_variation8-win32.phpt109
-rw-r--r--ext/standard/tests/file/readfile_variation9.phpt99
-rw-r--r--ext/standard/tests/file/readlink_realpath_basic1.phpt111
-rw-r--r--ext/standard/tests/file/readlink_realpath_basic2.phpt86
-rw-r--r--ext/standard/tests/file/readlink_realpath_error.phpt73
-rw-r--r--ext/standard/tests/file/readlink_realpath_variation1.phpt99
-rw-r--r--ext/standard/tests/file/readlink_realpath_variation2.phpt104
-rw-r--r--ext/standard/tests/file/readlink_realpath_variation3.phpt77
-rw-r--r--ext/standard/tests/file/readlink_variation1.phpt78
-rw-r--r--ext/standard/tests/file/realpath_basic-win32.phpt89
-rw-r--r--ext/standard/tests/file/realpath_basic2.phpt13
-rw-r--r--ext/standard/tests/file/realpath_basic3.phpt86
-rw-r--r--ext/standard/tests/file/realpath_basic4.phpt29
-rw-r--r--ext/standard/tests/file/realpath_cache.phpt30
-rw-r--r--ext/standard/tests/file/realpath_cache_win32.phpt38
-rw-r--r--ext/standard/tests/file/realpath_error-win32.phpt29
-rw-r--r--ext/standard/tests/file/realpath_variation-win32.phpt102
-rw-r--r--ext/standard/tests/file/realpath_variation2.phpt74
-rw-r--r--ext/standard/tests/file/rename_basic.phpt45
-rw-r--r--ext/standard/tests/file/rename_error.phpt35
-rw-r--r--ext/standard/tests/file/rename_variation-win32.phpt87
-rw-r--r--ext/standard/tests/file/rename_variation.phpt72
-rw-r--r--ext/standard/tests/file/rename_variation1-win32.phpt81
-rw-r--r--ext/standard/tests/file/rename_variation1.phpt71
-rw-r--r--ext/standard/tests/file/rename_variation10.phpt253
-rw-r--r--ext/standard/tests/file/rename_variation11-win32.phpt128
-rw-r--r--ext/standard/tests/file/rename_variation12-win32.phpt121
-rw-r--r--ext/standard/tests/file/rename_variation12.phpt121
-rw-r--r--ext/standard/tests/file/rename_variation13-win32.phptbin0 -> 5058 bytes
-rw-r--r--ext/standard/tests/file/rename_variation13.phpt133
-rw-r--r--ext/standard/tests/file/rename_variation2-win32.phpt61
-rw-r--r--ext/standard/tests/file/rename_variation2.phpt65
-rw-r--r--ext/standard/tests/file/rename_variation3-win32.phpt84
-rw-r--r--ext/standard/tests/file/rename_variation3.phpt60
-rw-r--r--ext/standard/tests/file/rename_variation4.phpt51
-rw-r--r--ext/standard/tests/file/rename_variation5.phpt96
-rw-r--r--ext/standard/tests/file/rename_variation6-win32.phpt40
-rw-r--r--ext/standard/tests/file/rename_variation6.phpt36
-rw-r--r--ext/standard/tests/file/rename_variation7-win32.phpt36
-rw-r--r--ext/standard/tests/file/rename_variation7.phpt31
-rw-r--r--ext/standard/tests/file/rename_variation8-win32.phpt70
-rw-r--r--ext/standard/tests/file/rename_variation8.phpt71
-rw-r--r--ext/standard/tests/file/rename_variation9.phpt53
-rw-r--r--ext/standard/tests/file/rmdir_variation1-win32.phpt127
-rw-r--r--ext/standard/tests/file/rmdir_variation1.phpt127
-rw-r--r--ext/standard/tests/file/rmdir_variation2.phpt244
-rw-r--r--ext/standard/tests/file/rmdir_variation3-win32.phpt108
-rw-r--r--ext/standard/tests/file/rmdir_variation3.phpt96
-rw-r--r--ext/standard/tests/file/stat_basic-win32.phpt192
-rw-r--r--ext/standard/tests/file/stat_error-win32.phpt55
-rw-r--r--ext/standard/tests/file/stat_variation1-win32.phpt94
-rw-r--r--ext/standard/tests/file/stat_variation2-win32.phpt65
-rw-r--r--ext/standard/tests/file/stat_variation3-win32.phpt80
-rw-r--r--ext/standard/tests/file/stat_variation4-win32.phpt93
-rw-r--r--ext/standard/tests/file/stat_variation5-win32.phpt66
-rw-r--r--ext/standard/tests/file/stat_variation6-win32.phpt92
-rw-r--r--ext/standard/tests/file/stat_variation7-win32.phpt298
-rw-r--r--ext/standard/tests/file/stat_variation8-win32.phpt77
-rw-r--r--ext/standard/tests/file/statcache-corruption.phpt13
-rw-r--r--ext/standard/tests/file/statpage.phpt20
-rw-r--r--ext/standard/tests/file/stream_001.phpt24
-rw-r--r--ext/standard/tests/file/stream_002.phpt53
-rw-r--r--ext/standard/tests/file/stream_copy_to_stream.phpt154
-rw-r--r--ext/standard/tests/file/stream_enclosed.phpt20
-rw-r--r--ext/standard/tests/file/stream_get_line.phpt18
-rw-r--r--ext/standard/tests/file/stream_rfc2397_001.phpt22
-rw-r--r--ext/standard/tests/file/stream_rfc2397_002.phpt182
-rwxr-xr-xext/standard/tests/file/stream_rfc2397_003.gifbin0 -> 273 bytes
-rw-r--r--ext/standard/tests/file/stream_rfc2397_003.phpt38
-rw-r--r--ext/standard/tests/file/stream_rfc2397_004.phpt32
-rw-r--r--ext/standard/tests/file/stream_rfc2397_005.phpt38
-rw-r--r--ext/standard/tests/file/stream_rfc2397_006.phpt33
-rw-r--r--ext/standard/tests/file/stream_rfc2397_007.phpt143
-rw-r--r--ext/standard/tests/file/stream_supports_lock.phpt46
-rw-r--r--ext/standard/tests/file/symlink.phpt78
-rw-r--r--ext/standard/tests/file/symlink_link_linkinfo_is_link_basic1.phpt114
-rw-r--r--ext/standard/tests/file/symlink_link_linkinfo_is_link_basic2.phpt90
-rw-r--r--ext/standard/tests/file/symlink_link_linkinfo_is_link_error1.phpt115
-rw-r--r--ext/standard/tests/file/symlink_link_linkinfo_is_link_error2.phpt114
-rw-r--r--ext/standard/tests/file/symlink_link_linkinfo_is_link_variation1.phpt136
-rw-r--r--ext/standard/tests/file/symlink_link_linkinfo_is_link_variation2.phpt51
-rw-r--r--ext/standard/tests/file/symlink_link_linkinfo_is_link_variation3.phpt146
-rw-r--r--ext/standard/tests/file/symlink_link_linkinfo_is_link_variation4.phpt120
-rw-r--r--ext/standard/tests/file/symlink_link_linkinfo_is_link_variation5.phpt75
-rw-r--r--ext/standard/tests/file/symlink_link_linkinfo_is_link_variation6.phpt107
-rw-r--r--ext/standard/tests/file/symlink_link_linkinfo_is_link_variation7.phpt94
-rw-r--r--ext/standard/tests/file/symlink_link_linkinfo_is_link_variation8.phpt83
-rw-r--r--ext/standard/tests/file/symlink_link_linkinfo_is_link_variation9.phpt121
-rw-r--r--ext/standard/tests/file/symlink_to_symlink.phpt50
-rw-r--r--ext/standard/tests/file/tempnam_error.phpt48
-rw-r--r--ext/standard/tests/file/tempnam_variation1-win32.phpt103
-rw-r--r--ext/standard/tests/file/tempnam_variation1.phpt116
-rw-r--r--ext/standard/tests/file/tempnam_variation2-win32.phpt163
-rw-r--r--ext/standard/tests/file/tempnam_variation2.phpt163
-rw-r--r--ext/standard/tests/file/tempnam_variation3-win32.phpt115
-rw-r--r--ext/standard/tests/file/tempnam_variation3.phpt122
-rw-r--r--ext/standard/tests/file/tempnam_variation4.phpt1092
-rw-r--r--ext/standard/tests/file/tempnam_variation5-win32.phpt54
-rw-r--r--ext/standard/tests/file/tempnam_variation5.phpt52
-rw-r--r--ext/standard/tests/file/tempnam_variation6-win32.phpt62
-rw-r--r--ext/standard/tests/file/tempnam_variation6.phpt60
-rw-r--r--ext/standard/tests/file/tempnam_variation7-win32.phpt113
-rw-r--r--ext/standard/tests/file/tempnam_variation7.phpt118
-rw-r--r--ext/standard/tests/file/tempnam_variation8-win32.phpt147
-rw-r--r--ext/standard/tests/file/test.csv17
-rw-r--r--ext/standard/tests/file/test2.csv1
-rw-r--r--ext/standard/tests/file/test3.csvbin0 -> 8 bytes
-rw-r--r--ext/standard/tests/file/touch.phpt58
-rw-r--r--ext/standard/tests/file/touch_basic-win32.phpt96
-rw-r--r--ext/standard/tests/file/touch_basic.phpt97
-rw-r--r--ext/standard/tests/file/touch_error.phpt22
-rw-r--r--ext/standard/tests/file/touch_variation1.phpt39
-rw-r--r--ext/standard/tests/file/touch_variation2.phpt24
-rw-r--r--ext/standard/tests/file/touch_variation3-win32.phpt199
-rw-r--r--ext/standard/tests/file/touch_variation3.phpt199
-rw-r--r--ext/standard/tests/file/touch_variation4-win32.phpt199
-rw-r--r--ext/standard/tests/file/touch_variation4.phpt199
-rw-r--r--ext/standard/tests/file/touch_variation5-win32.phpt230
-rw-r--r--ext/standard/tests/file/touch_variation5.phpt230
-rw-r--r--ext/standard/tests/file/touch_variation6-win32.phpt242
-rw-r--r--ext/standard/tests/file/umask_basic.phpt2079
-rw-r--r--ext/standard/tests/file/umask_error.phpt26
-rw-r--r--ext/standard/tests/file/umask_variation1.phpt761
-rw-r--r--ext/standard/tests/file/umask_variation2.phpt899
-rw-r--r--ext/standard/tests/file/umask_variation3.phpt237
-rw-r--r--ext/standard/tests/file/unlink_basic.phpt43
-rw-r--r--ext/standard/tests/file/unlink_error-win32.phpt110
-rw-r--r--ext/standard/tests/file/unlink_error.phpt110
-rw-r--r--ext/standard/tests/file/unlink_variation1-win32.phpt85
-rw-r--r--ext/standard/tests/file/unlink_variation1.phpt92
-rw-r--r--ext/standard/tests/file/unlink_variation10.phpt106
-rw-r--r--ext/standard/tests/file/unlink_variation2-win32.phpt43
-rw-r--r--ext/standard/tests/file/unlink_variation2.phpt37
-rw-r--r--ext/standard/tests/file/unlink_variation3.phpt60
-rw-r--r--ext/standard/tests/file/unlink_variation4.phpt37
-rw-r--r--ext/standard/tests/file/unlink_variation5.phpt2087
-rw-r--r--ext/standard/tests/file/unlink_variation6.phpt41
-rw-r--r--ext/standard/tests/file/unlink_variation7.phpt246
-rw-r--r--ext/standard/tests/file/unlink_variation8-win32.phpt113
-rw-r--r--ext/standard/tests/file/unlink_variation8.phpt206
-rw-r--r--ext/standard/tests/file/unlink_variation9-win32.phpt117
-rw-r--r--ext/standard/tests/file/userdirstream.phpt51
-rw-r--r--ext/standard/tests/file/userfilters.phpt37
-rw-r--r--ext/standard/tests/file/userstreams.phpt325
-rw-r--r--ext/standard/tests/file/userstreams_002.phpt94
-rw-r--r--ext/standard/tests/file/userstreams_003.phpt153
-rw-r--r--ext/standard/tests/file/userstreams_004.phpt58
-rw-r--r--ext/standard/tests/file/userstreams_005.phpt63
-rw-r--r--ext/standard/tests/file/userstreams_006.phpt38
-rw-r--r--ext/standard/tests/file/userstreams_007.phpt49
-rw-r--r--ext/standard/tests/file/userwrapper.phpt83
-rw-r--r--ext/standard/tests/file/windows_acls/bug44859.phpt63
-rw-r--r--ext/standard/tests/file/windows_acls/bug44859_2.phpt63
-rw-r--r--ext/standard/tests/file/windows_acls/bug44859_3.phpt37
-rw-r--r--ext/standard/tests/file/windows_acls/bug44859_4.phpt65
-rw-r--r--ext/standard/tests/file/windows_acls/common.inc199
-rw-r--r--ext/standard/tests/file/windows_acls/tiny.bat1
-rw-r--r--ext/standard/tests/file/windows_acls/tiny.exebin0 -> 133 bytes
-rw-r--r--ext/standard/tests/file/windows_links/bug48746.phpt58
-rw-r--r--ext/standard/tests/file/windows_links/bug48746_1.phpt59
-rw-r--r--ext/standard/tests/file/windows_links/bug48746_2.phpt69
-rw-r--r--ext/standard/tests/file/windows_links/bug48746_3.phpt50
-rw-r--r--ext/standard/tests/file/windows_links/common.inc23
803 files changed, 180721 insertions, 0 deletions
diff --git a/ext/standard/tests/file/001-win32.phpt b/ext/standard/tests/file/001-win32.phpt
new file mode 100644
index 0000000..ee52094
--- /dev/null
+++ b/ext/standard/tests/file/001-win32.phpt
@@ -0,0 +1,100 @@
+--TEST--
+File type functions
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip only for Windows');
+}
+?>
+--FILE--
+<?php
+chdir(dirname(__FILE__));
+@unlink('test.file');
+if (file_exists('test.file')) {
+ echo "test.file exists\n";
+} else {
+ echo "test.file does not exist\n";
+}
+fclose (fopen('test.file', 'w'));
+chmod ('test.file', 0744);
+if (file_exists('test.file')) {
+ echo "test.file exists\n";
+} else {
+ echo "test.file does not exist\n";
+}
+if (is_link('test.file')) {
+ echo "test.file is a symlink\n";
+} else {
+ echo "test.file is not a symlink\n";
+}
+if (file_exists('test.file')) {
+ echo "test.file exists\n";
+} else {
+ echo "test.file does not exist\n";
+}
+$s = stat ('test.file');
+$ls = lstat ('test.file');
+for ($i = 0; $i <= 12; $i++) {
+ if ($ls[$i] != $s[$i]) {
+ echo "test.file lstat and stat differ at element $i\n";
+ }
+}
+echo "test.file is " . filetype('test.file') . "\n";
+printf ("test.file permissions are 0%o\n", 0777 & fileperms('test.file'));
+echo "test.file size is " . filesize('test.file') . "\n";
+if (is_writeable('test.file')) {
+ echo "test.file is writeable\n";
+} else {
+ echo "test.file is not writeable\n";
+}
+if (is_readable('test.file')) {
+ echo "test.file is readable\n";
+} else {
+ echo "test.file is not readable\n";
+}
+if (is_file('test.file')) {
+ echo "test.file is a regular file\n";
+} else {
+ echo "test.file is not a regular file\n";
+}
+if (is_dir('../file')) {
+ echo "../file is a directory\n";
+} else {
+ echo "../file is not a directory\n";
+}
+if (is_dir('test.file')) {
+ echo "test.file is a directory\n";
+} else {
+ echo "test.file is not a directory\n";
+}
+unlink('test.file');
+if (file_exists('test.file')) {
+ echo "test.file exists (cached)\n";
+} else {
+ echo "test.file does not exist\n";
+}
+clearstatcache();
+if (file_exists('test.file')) {
+ echo "test.file exists\n";
+} else {
+ echo "test.file does not exist\n";
+}
+?>
+--EXPECT--
+test.file does not exist
+test.file exists
+test.file is not a symlink
+test.file exists
+test.file is file
+test.file permissions are 0666
+test.file size is 0
+test.file is writeable
+test.file is readable
+test.file is a regular file
+../file is a directory
+test.file is not a directory
+test.file does not exist
+test.file does not exist
+
diff --git a/ext/standard/tests/file/001.phpt b/ext/standard/tests/file/001.phpt
new file mode 100644
index 0000000..d604699
--- /dev/null
+++ b/ext/standard/tests/file/001.phpt
@@ -0,0 +1,146 @@
+--TEST--
+File type functions
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip no symlinks on Windows');
+}
+if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
+?>
+--FILE--
+<?php
+chdir(dirname(__FILE__));
+@unlink('test.file');
+@unlink('test.link');
+if (file_exists('test.file')) {
+ echo "test.file exists\n";
+} else {
+ echo "test.file does not exist\n";
+}
+fclose (fopen('test.file', 'w'));
+chmod ('test.file', 0744);
+if (file_exists('test.file')) {
+ echo "test.file exists\n";
+} else {
+ echo "test.file does not exist\n";
+}
+sleep (2);
+symlink('test.file','test.link');
+if (file_exists('test.link')) {
+ echo "test.link exists\n";
+} else {
+ echo "test.link does not exist\n";
+}
+if (is_link('test.file')) {
+ echo "test.file is a symlink\n";
+} else {
+ echo "test.file is not a symlink\n";
+}
+if (is_link('test.link')) {
+ echo "test.link is a symlink\n";
+} else {
+ echo "test.link is not a symlink\n";
+}
+if (file_exists('test.file')) {
+ echo "test.file exists\n";
+} else {
+ echo "test.file does not exist\n";
+}
+$s = stat ('test.file');
+$ls = lstat ('test.file');
+for ($i = 0; $i <= 12; $i++) {
+ if ($ls[$i] != $s[$i]) {
+ echo "test.file lstat and stat differ at element $i\n";
+ }
+}
+$s = stat ('test.link');
+$ls = lstat ('test.link');
+for ($i = 0; $i <= 11; $i++) {
+ if ($ls[$i] != $s[$i]) {
+ if ($i != 6 && $i != 10 && $i != 11) echo "test.link lstat and stat differ at element $i\n";
+ }
+}
+echo "test.file is " . filetype('test.file') . "\n";
+echo "test.link is " . filetype('test.link') . "\n";
+printf ("test.file permissions are 0%o\n", 0777 & fileperms('test.file'));
+echo "test.file size is " . filesize('test.file') . "\n";
+if (is_writeable('test.file')) {
+ echo "test.file is writeable\n";
+} else {
+ echo "test.file is not writeable\n";
+}
+if (is_readable('test.file')) {
+ echo "test.file is readable\n";
+} else {
+ echo "test.file is not readable\n";
+}
+if (is_executable('test.file')) {
+ echo "test.file is executable\n";
+} else {
+ echo "test.file is not executable\n";
+}
+if (is_file('test.file')) {
+ echo "test.file is a regular file\n";
+} else {
+ echo "test.file is not a regular file\n";
+}
+if (is_file('test.link')) {
+ echo "test.link is a regular file\n";
+} else {
+ echo "test.link is not a regular file\n";
+}
+if (is_dir('test.link')) {
+ echo "test.link is a directory\n";
+} else {
+ echo "test.link is not a directory\n";
+}
+if (is_dir('../file')) {
+ echo "../file is a directory\n";
+} else {
+ echo "../file is not a directory\n";
+}
+if (is_dir('test.file')) {
+ echo "test.file is a directory\n";
+} else {
+ echo "test.file is not a directory\n";
+}
+unlink('test.file');
+unlink('test.link');
+if (file_exists('test.file')) {
+ echo "test.file exists (cached)\n";
+} else {
+ echo "test.file does not exist\n";
+}
+clearstatcache();
+if (file_exists('test.file')) {
+ echo "test.file exists\n";
+} else {
+ echo "test.file does not exist\n";
+}
+?>
+--EXPECT--
+test.file does not exist
+test.file exists
+test.link exists
+test.file is not a symlink
+test.link is a symlink
+test.file exists
+test.link lstat and stat differ at element 1
+test.link lstat and stat differ at element 2
+test.link lstat and stat differ at element 7
+test.link lstat and stat differ at element 8
+test.link lstat and stat differ at element 9
+test.file is file
+test.link is link
+test.file permissions are 0744
+test.file size is 0
+test.file is writeable
+test.file is readable
+test.file is executable
+test.file is a regular file
+test.link is a regular file
+test.link is not a directory
+../file is a directory
+test.file is not a directory
+test.file does not exist
+test.file does not exist
diff --git a/ext/standard/tests/file/002.phpt b/ext/standard/tests/file/002.phpt
new file mode 100644
index 0000000..134f541
--- /dev/null
+++ b/ext/standard/tests/file/002.phpt
@@ -0,0 +1,52 @@
+--TEST--
+File/Stream functions
+--FILE--
+<?php
+
+$data = <<<EOD
+blah blah blah blah blah blah blah
+blah blah blah blah blah blah blah
+blah blah blah blah blah blah blah
+blah blah blah blah blah blah blah
+blah blah blah blah blah blah blah
+blah blah blah blah blah blah blah
+blah blah blah blah blah blah blah
+blah blah blah blah blah blah blah
+blah blah blah blah blah blah blah
+blah blah blah blah blah blah blah
+blah blah blah blah blah blah blah
+blah blah blah blah blah blah blah
+blah blah blah blah blah blah blah
+blah blah blah blah blah blah blah
+blah blah blah blah blah blah blah
+blah blah blah blah blah blah blah
+EOD;
+
+$name = tempnam("./ext/standard/tests/file/", "php");
+$fp = fopen($name, "w");
+fwrite($fp, $data);
+fclose($fp);
+
+//readfile($name);
+echo file_get_contents($name);
+
+unlink($name);
+
+?>
+--EXPECT--
+blah blah blah blah blah blah blah
+blah blah blah blah blah blah blah
+blah blah blah blah blah blah blah
+blah blah blah blah blah blah blah
+blah blah blah blah blah blah blah
+blah blah blah blah blah blah blah
+blah blah blah blah blah blah blah
+blah blah blah blah blah blah blah
+blah blah blah blah blah blah blah
+blah blah blah blah blah blah blah
+blah blah blah blah blah blah blah
+blah blah blah blah blah blah blah
+blah blah blah blah blah blah blah
+blah blah blah blah blah blah blah
+blah blah blah blah blah blah blah
+blah blah blah blah blah blah blah
diff --git a/ext/standard/tests/file/003.phpt b/ext/standard/tests/file/003.phpt
new file mode 100644
index 0000000..8eeaa93
--- /dev/null
+++ b/ext/standard/tests/file/003.phpt
@@ -0,0 +1,41 @@
+--TEST--
+is_*() and file_exists() return values are boolean.
+--FILE--
+<?php
+
+$funcs = array(
+ 'is_writable',
+ 'is_readable',
+ 'is_executable',
+ 'is_file',
+ 'file_exists',
+);
+
+$filename="";
+
+foreach ($funcs as $test) {
+ $bb = $test($filename);
+ echo gettype($bb)."\n";
+ clearstatcache();
+}
+
+$filename="run-tests.php";
+
+foreach ($funcs as $test) {
+ $bb = $test($filename);
+ echo gettype($bb)."\n";
+ clearstatcache();
+}
+
+?>
+--EXPECT--
+boolean
+boolean
+boolean
+boolean
+boolean
+boolean
+boolean
+boolean
+boolean
+boolean
diff --git a/ext/standard/tests/file/004.phpt b/ext/standard/tests/file/004.phpt
new file mode 100644
index 0000000..f1fab47
--- /dev/null
+++ b/ext/standard/tests/file/004.phpt
@@ -0,0 +1,61 @@
+--TEST--
+file_put_contents() test
+--FILE--
+<?php
+ chdir(dirname(__FILE__));
+ for ($i = 1; $i < 6; $i++) {
+ @unlink("./TEST{$i}");
+ }
+
+ echo "String Test: ";
+ echo file_put_contents("TEST1", file_get_contents(__FILE__)) !== FALSE ? 'OK' : 'FAIL';
+ echo "\n";
+
+ $old_int = $int = rand();
+ $ret = file_put_contents("TEST2", $int);
+ echo "Integer Test: ";
+ if ($int === $old_int && $ret !== FALSE && md5($int) == md5_file("TEST2")) {
+ echo 'OK';
+ } else {
+ echo 'FAIL';
+ }
+ echo "\n";
+
+ $old_int = $int = time() / 1000;
+ $ret = file_put_contents("TEST3", $int);
+ echo "Float Test: ";
+ if ($int === $old_int && $ret !== FALSE && md5($int) == md5_file("TEST3")) {
+ echo 'OK';
+ } else {
+ echo 'FAIL';
+ }
+ echo "\n";
+
+ $ret = file_put_contents("TEST4", __FILE__);
+ echo "Bool Test: ";
+ if ($ret !== FALSE && md5(__FILE__) == md5_file("TEST4")) {
+ echo 'OK';
+ } else {
+ echo 'FAIL';
+ }
+ echo "\n";
+
+ $ret = @file_put_contents("TEST5", $_SERVER);
+ echo "Array Test: ";
+ if ($ret !== FALSE && @md5(implode('', $_SERVER)) == md5_file("TEST5")) {
+ echo 'OK';
+ } else {
+ echo 'FAIL';
+ }
+ echo "\n";
+
+ for ($i = 1; $i < 6; $i++) {
+ @unlink("./TEST{$i}");
+ }
+?>
+--EXPECT--
+String Test: OK
+Integer Test: OK
+Float Test: OK
+Bool Test: OK
+Array Test: OK
diff --git a/ext/standard/tests/file/005_basic.phpt b/ext/standard/tests/file/005_basic.phpt
new file mode 100644
index 0000000..5ed1118
--- /dev/null
+++ b/ext/standard/tests/file/005_basic.phpt
@@ -0,0 +1,54 @@
+--TEST--
+Test fileatime(), filemtime(), filectime() & touch() functions : basic functionality
+--FILE--
+<?php
+/*
+ Prototype: int fileatime ( string $filename );
+ Description: Returns the time the file was last accessed, or FALSE
+ in case of an error. The time is returned as a Unix timestamp.
+
+ Prototype: int filemtime ( string $filename );
+ Description: Returns the time the file was last modified, or FALSE
+ in case of an error.
+
+ Prototype: int filectime ( string $filename );
+ Description: Returns the time the file was last changed, or FALSE
+ in case of an error. The time is returned as a Unix timestamp.
+
+ Prototype: bool touch ( string $filename [, int $time [, int $atime]] );
+ Description: Attempts to set the access and modification times of the file
+ named in the filename parameter to the value given in time.
+*/
+
+echo "*** Testing the basic functionality with file ***\n";
+print( @date('Y:M:D:H:i:s', fileatime(__FILE__)) )."\n";
+print( @date('Y:M:D:H:i:s', filemtime(__FILE__)) )."\n";
+print( @date('Y:M:D:H:i:s', filectime(__FILE__)) )."\n";
+print( @date('Y:M:D:H:i:s', touch(dirname(__FILE__)."/005_basic.tmp")) )."\n";
+
+echo "*** Testing the basic functionality with dir ***\n";
+print( @date('Y:M:D:H:i:s', fileatime(".")) )."\n";
+print( @date('Y:M:D:H:i:s', filemtime(".")) )."\n";
+print( @date('Y:M:D:H:i:s', filectime(".")) )."\n";
+print( @date('Y:M:D:H:i:s', touch(dirname(__FILE__)."/005_basic")) )."\n";
+
+echo "\n*** Done ***\n";
+?>
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/005_basic.tmp");
+unlink(dirname(__FILE__)."/005_basic");
+?>
+--EXPECTF--
+*** Testing the basic functionality with file ***
+%d:%s:%s:%d:%d:%d
+%d:%s:%s:%d:%d:%d
+%d:%s:%s:%d:%d:%d
+%d:%s:%s:%d:%d:%d
+*** Testing the basic functionality with dir ***
+%d:%s:%s:%d:%d:%d
+%d:%s:%s:%d:%d:%d
+%d:%s:%s:%d:%d:%d
+%d:%s:%s:%d:%d:%d
+
+*** Done ***
diff --git a/ext/standard/tests/file/005_error.phpt b/ext/standard/tests/file/005_error.phpt
new file mode 100644
index 0000000..fc4852e
--- /dev/null
+++ b/ext/standard/tests/file/005_error.phpt
@@ -0,0 +1,126 @@
+--TEST--
+Test fileatime(), filemtime(), filectime() & touch() functions : error conditions
+--FILE--
+<?php
+/*
+ Prototype: int fileatime ( string $filename );
+ Description: Returns the time the file was last accessed, or FALSE
+ in case of an error. The time is returned as a Unix timestamp.
+
+ Prototype: int filemtime ( string $filename );
+ Description: Returns the time the file was last modified, or FALSE
+ in case of an error.
+
+ Prototype: int filectime ( string $filename );
+ Description: Returns the time the file was last changed, or FALSE
+ in case of an error. The time is returned as a Unix timestamp.
+
+ Prototype: bool touch ( string $filename [, int $time [, int $atime]] );
+ Description: Attempts to set the access and modification times of the file
+ named in the filename parameter to the value given in time.
+*/
+
+echo "*** Testing error conditions ***\n";
+
+echo "\n-- Testing with Non-existing files --";
+/* Both invalid argumetns */
+var_dump( fileatime("/no/such/file/or/dir") );
+var_dump( filemtime("/no/such/file/or/dir") );
+var_dump( filectime("/no/such/file/or/dir") );
+var_dump( touch("/no/such/file/or/dir", 10) );
+
+/* Only one invalid argument */
+var_dump( fileatime(__FILE__, "string") );
+var_dump( filemtime(__FILE__, 100) );
+var_dump( filectime(__FILE__, TRUE) );
+var_dump( touch(__FILE__, 10, 100, 123) );
+
+echo "\n-- Testing No.of arguments less than expected --";
+var_dump( fileatime() );
+var_dump( filemtime() );
+var_dump( filectime() );
+var_dump( touch() );
+
+echo "\n-- Testing No.of arguments greater than expected --";
+/* Both invalid arguments */
+var_dump( fileatime("/no/such/file/or/dir", "string") );
+var_dump( filemtime("/no/such/file/or/dir", 100) );
+var_dump( filectime("/no/such/file/or/dir", TRUE) );
+var_dump( touch("/no/such/file/or/dir", 10, 100, 123) );
+
+/* Only one invalid argument */
+var_dump( fileatime(__FILE__, "string") );
+var_dump( filemtime(__FILE__, 100) );
+var_dump( filectime(__FILE__, TRUE) );
+var_dump( touch(__FILE__, 10, 100, 123) );
+
+echo "\nDone";
+?>
+--EXPECTF--
+*** Testing error conditions ***
+
+-- Testing with Non-existing files --
+Warning: fileatime(): stat failed for /no/such/file/or/dir in %s on line %d
+bool(false)
+
+Warning: filemtime(): stat failed for /no/such/file/or/dir in %s on line %d
+bool(false)
+
+Warning: filectime(): stat failed for /no/such/file/or/dir in %s on line %d
+bool(false)
+
+Warning: touch(): Unable to create file /no/such/file/or/dir because No such file or directory in %s on line %d
+bool(false)
+
+Warning: fileatime() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+
+Warning: filemtime() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+
+Warning: filectime() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+
+Warning: touch() expects at most 3 parameters, 4 given in %s on line %d
+NULL
+
+-- Testing No.of arguments less than expected --
+Warning: fileatime() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: filemtime() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: filectime() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: touch() expects at least 1 parameter, 0 given in %s on line %d
+NULL
+
+-- Testing No.of arguments greater than expected --
+Warning: fileatime() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+
+Warning: filemtime() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+
+Warning: filectime() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+
+Warning: touch() expects at most 3 parameters, 4 given in %s on line %d
+NULL
+
+Warning: fileatime() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+
+Warning: filemtime() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+
+Warning: filectime() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+
+Warning: touch() expects at most 3 parameters, 4 given in %s on line %d
+NULL
+
+Done
+
diff --git a/ext/standard/tests/file/005_variation-win32.phpt b/ext/standard/tests/file/005_variation-win32.phpt
new file mode 100644
index 0000000..3455875
--- /dev/null
+++ b/ext/standard/tests/file/005_variation-win32.phpt
@@ -0,0 +1,221 @@
+--TEST--
+Test fileatime(), filemtime(), filectime() & touch() functions : usage variation
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip Windows-only test');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: int fileatime ( string $filename );
+ Description: Returns the time the file was last accessed, or FALSE
+ in case of an error. The time is returned as a Unix timestamp.
+
+ Prototype: int filemtime ( string $filename );
+ Description: Returns the time the file was last modified, or FALSE
+ in case of an error.
+
+ Prototype: int filectime ( string $filename );
+ Description: Returns the time the file was last changed, or FALSE
+ in case of an error. The time is returned as a Unix timestamp.
+
+ Prototype: bool touch ( string $filename [, int $time [, int $atime]] );
+ Description: Attempts to set the access and modification times of the file
+ named in the filename parameter to the value given in time.
+*/
+
+/*
+ Prototype: void stat_fn(string $filename);
+ Description: Prints access, modification and change times of a file
+*/
+function stat_fn( $filename ) {
+ echo "-- File access time is => ";
+ print( @date( 'Y:M:D:H:i:s', fileatime($filename) ) )."\n";
+ clearstatcache();
+ echo "-- File modification time is => ";
+ print( @date( 'Y:M:D:H:i:s', filemtime($filename) ) )."\n";
+ clearstatcache();
+ echo "-- inode change time is => ";
+ print( @date( 'Y:M:D:H:i:s', filectime($filename) ) )."\n";
+ clearstatcache();
+
+}
+
+echo "*** Testing fileattime(), filemtime(), filectime() & touch() : usage variations ***\n";
+$file_path = dirname(__FILE__);
+// create files
+$file_handle = fopen("$file_path/005_variation1.tmp", "w");
+fclose($file_handle);
+stat_fn("$file_path/005_variation1.tmp");
+sleep(2);
+
+$file_handle = fopen("$file_path/005_variation2.tmp", "w");
+fclose($file_handle);
+stat_fn("$file_path/005_variation2.tmp");
+sleep(2);
+
+$file_handle = fopen("$file_path/005_variation3.tmp", "w");
+fclose($file_handle);
+stat_fn("$file_path/005_variation3.tmp");
+
+// delete files
+unlink("$file_path/005_variation1.tmp");
+unlink("$file_path/005_variation2.tmp");
+unlink("$file_path/005_variation3.tmp");
+
+echo "\n-- Checking different times, just after creating the file --\n";
+$file_name = "$file_path/005_variation1.tmp";
+$file_write_handle = fopen($file_name, "w");
+fclose($file_write_handle);
+stat_fn($file_name);
+sleep(2);
+
+/* filectime + 2 */
+echo "\n-- Checking different times, after changing the file permission --\n";
+chmod($file_name, 0777);
+stat_fn($file_name);
+sleep(2);
+
+/* filemtime + 2 & filectime + 2 */
+echo "\n-- Checking different times, after writing into the file --\n";
+$file_write_handle = fopen($file_name, "w");
+fwrite($file_write_handle, b"Hello, world");
+fclose($file_write_handle);
+stat_fn($file_name);
+sleep(2);
+
+/* fileatime + 2 */
+echo "\n-- Checking different times, after reading from the file --\n";
+$file_read_handle = fopen($file_name ,"r");
+fread($file_read_handle, 10);
+fclose( $file_read_handle);
+stat_fn($file_name);
+sleep(2);
+
+/* No change */
+echo "\n-- Checking different times, after making a copy of the file --\n";
+$file_copy = "$file_path/005_variation_copy.tmp";
+copy($file_name, $file_copy);
+stat_fn($file_name);
+sleep(2);
+
+/* fileatime + 2 */
+echo "\n-- Checking different times, after performing is_file() operation on the file --\n";
+is_file($file_name);
+stat_fn($file_name);
+sleep(2);
+
+
+echo "\n*** Testing touch() function with different time values ***\n";
+$file_name2 = $file_path."/005_variation_touch.tmp";
+$file_handle = fopen($file_name2, "w");
+fclose($file_handle);
+sleep(2);
+
+/* Time is not mentioned */
+var_dump( touch($file_name2) ); //set to current system time
+stat_fn($file_name2);
+sleep(2);
+
+/* set to access(creation time of the file) time */
+var_dump( touch($file_name2, @date(fileatime($file_name2))) );
+stat_fn($file_name2);
+sleep(2);
+
+/* set to access time of $file_name2 */
+var_dump( touch($file_path."/005_variation_touch_fly.tmp", @date(fileatime($file_name2)), time()) );
+stat_fn($file_name2);
+sleep(2);
+
+/* set to default value, with Invalid timestamps */
+var_dump( touch($file_name2, 10) );
+stat_fn($file_name2);
+var_dump( touch($file_name2, 10, 20) );
+stat_fn($file_name2);
+
+/* touch() after renaming the file */
+rename($file_name2, "$file_path/005_variation_touch_new.tmp");
+stat_fn("$file_path/005_variation_touch_new.tmp");
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/005_variation_softlink.tmp");
+unlink($file_path."/005_variation_hardlink.tmp");
+unlink($file_path."/005_variation1.tmp");
+unlink($file_path."/005_variation_copy.tmp");
+unlink($file_path."/005_variation_touch.tmp");
+unlink($file_path."/005_variation_touch_fly.tmp");
+unlink($file_path."/005_variation_touch_new.tmp");
+?>
+--EXPECTF--
+*** Testing fileattime(), filemtime(), filectime() & touch() : usage variations ***
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+
+-- Checking different times, just after creating the file --
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+
+-- Checking different times, after changing the file permission --
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+
+-- Checking different times, after writing into the file --
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+
+-- Checking different times, after reading from the file --
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+
+-- Checking different times, after making a copy of the file --
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+
+-- Checking different times, after performing is_file() operation on the file --
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+
+*** Testing touch() function with different time values ***
+bool(true)
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+bool(true)
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+bool(true)
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+bool(true)
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+bool(true)
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+Done
diff --git a/ext/standard/tests/file/005_variation.phpt b/ext/standard/tests/file/005_variation.phpt
new file mode 100644
index 0000000..7e5eedc
--- /dev/null
+++ b/ext/standard/tests/file/005_variation.phpt
@@ -0,0 +1,260 @@
+--TEST--
+Test fileatime(), filemtime(), filectime() & touch() functions : usage variation
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip Do not run on Windows');
+}
+if (getenv("SKIP_SLOW_TESTS")) {
+ die("skip slow test");
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: int fileatime ( string $filename );
+ Description: Returns the time the file was last accessed, or FALSE
+ in case of an error. The time is returned as a Unix timestamp.
+
+ Prototype: int filemtime ( string $filename );
+ Description: Returns the time the file was last modified, or FALSE
+ in case of an error.
+
+ Prototype: int filectime ( string $filename );
+ Description: Returns the time the file was last changed, or FALSE
+ in case of an error. The time is returned as a Unix timestamp.
+
+ Prototype: bool touch ( string $filename [, int $time [, int $atime]] );
+ Description: Attempts to set the access and modification times of the file
+ named in the filename parameter to the value given in time.
+*/
+
+/*
+ Prototype: void stat_fn(string $filename);
+ Description: Prints access, modification and change times of a file
+*/
+function stat_fn( $filename ) {
+ echo "-- File access time is => ";
+ print( @date( 'Y:M:D:H:i:s', fileatime($filename) ) )."\n";
+ clearstatcache();
+ echo "-- File modification time is => ";
+ print( @date( 'Y:M:D:H:i:s', filemtime($filename) ) )."\n";
+ clearstatcache();
+ echo "-- inode change time is => ";
+ print( @date( 'Y:M:D:H:i:s', filectime($filename) ) )."\n";
+ clearstatcache();
+
+}
+
+echo "*** Testing fileattime(), filemtime(), filectime() & touch() : usage variations ***\n";
+$file_path = dirname(__FILE__);
+// create files
+$file_handle = fopen("$file_path/005_variation1.tmp", "w");
+fclose($file_handle);
+stat_fn("$file_path/005_variation1.tmp");
+sleep(2);
+
+$file_handle = fopen("$file_path/005_variation2.tmp", "w");
+fclose($file_handle);
+stat_fn("$file_path/005_variation2.tmp");
+sleep(2);
+
+$file_handle = fopen("$file_path/005_variation3.tmp", "w");
+fclose($file_handle);
+stat_fn("$file_path/005_variation3.tmp");
+
+// delete files
+unlink("$file_path/005_variation1.tmp");
+unlink("$file_path/005_variation2.tmp");
+unlink("$file_path/005_variation3.tmp");
+
+echo "\n-- Checking different times, just after creating the file --\n";
+$file_name = "$file_path/005_variation1.tmp";
+$file_write_handle = fopen($file_name, "w");
+fclose($file_write_handle);
+stat_fn($file_name);
+sleep(2);
+
+/* filectime + 2 */
+echo "\n-- Checking different times, after changing the file permission --\n";
+chmod($file_name, 0777);
+stat_fn($file_name);
+sleep(2);
+
+/* filemtime + 2 & filectime + 2 */
+echo "\n-- Checking different times, after writing into the file --\n";
+$file_write_handle = fopen($file_name, "w");
+fwrite($file_write_handle, "Hello, world");
+fclose($file_write_handle);
+stat_fn($file_name);
+sleep(2);
+
+/* fileatime + 2 */
+echo "\n-- Checking different times, after reading from the file --\n";
+$file_read_handle = fopen($file_name ,"r");
+fread($file_read_handle, 10);
+fclose( $file_read_handle);
+stat_fn($file_name);
+sleep(2);
+
+/* No change */
+echo "\n-- Checking different times, after creating a softlink to the file --\n";
+symlink($file_name, "$file_path/005_variation_softlink.tmp");
+stat_fn($file_name);
+sleep(2);
+
+/* filectime + 2 */
+echo "\n-- Checking different times, after creating a hardlink to the file --\n";
+link($file_name, "$file_path/005_variation_hardlink.tmp");
+stat_fn($file_name);
+sleep(2);
+
+/* No change */
+echo "\n-- Checking different times, after making a copy of the file --\n";
+$file_copy = "$file_path/005_variation_copy.tmp";
+copy($file_name, $file_copy);
+stat_fn($file_name);
+sleep(2);
+
+/* fileatime + 2 */
+echo "\n-- Checking different times, after performing is_file() operation on the file --\n";
+is_file($file_name);
+stat_fn($file_name);
+sleep(2);
+
+
+echo "\n*** Testing touch() function with different time values ***\n";
+$file_name2 = $file_path."/005_variation_touch.tmp";
+$file_handle = fopen($file_name2, "w");
+fclose($file_handle);
+sleep(2);
+
+/* Time is not mentioned */
+var_dump( touch($file_name2) ); //set to current system time
+stat_fn($file_name2);
+sleep(2);
+
+/* set to access(creation time of the file) time */
+var_dump( touch($file_name2, @date(fileatime($file_name2))) );
+stat_fn($file_name2);
+sleep(2);
+
+/* set to access time of $file_name2 */
+var_dump( touch($file_path."/005_variation_touch_fly.tmp", @date(fileatime($file_name2)), time()) );
+stat_fn($file_name2);
+sleep(2);
+
+/* set to default value, with Invalid timestamps */
+var_dump( touch($file_name2, 10) );
+stat_fn($file_name2);
+var_dump( touch($file_name2, 10, 20) );
+stat_fn($file_name2);
+
+/* touch() after renaming the file */
+rename($file_name2, "$file_path/005_variation_touch_new.tmp");
+stat_fn("$file_path/005_variation_touch_new.tmp");
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+if(file_exists($file_path."/005_variation_softlink.tmp")) {
+ unlink($file_path."/005_variation_softlink.tmp");
+}
+if(file_exists($file_path."/005_variation_hardlink.tmp")) {
+ unlink($file_path."/005_variation_hardlink.tmp");
+}
+if(file_exists($file_path."/005_variation1.tmp")) {
+ unlink($file_path."/005_variation1.tmp");
+}
+if(file_exists($file_path."/005_variation_copy.tmp")) {
+ unlink($file_path."/005_variation_copy.tmp");
+}
+if(file_exists($file_path."/005_variation_touch.tmp")) {
+ unlink($file_path."/005_variation_touch.tmp");
+}
+if(file_exists($file_path."/005_variation_touch_fly.tmp")) {
+ unlink($file_path."/005_variation_touch_fly.tmp");
+}
+if(file_exists($file_path."/005_variation_touch_new.tmp")) {
+ unlink($file_path."/005_variation_touch_new.tmp");
+}
+?>
+--EXPECTF--
+*** Testing fileattime(), filemtime(), filectime() & touch() : usage variations ***
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+
+-- Checking different times, just after creating the file --
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+
+-- Checking different times, after changing the file permission --
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+
+-- Checking different times, after writing into the file --
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+
+-- Checking different times, after reading from the file --
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+
+-- Checking different times, after creating a softlink to the file --
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+
+-- Checking different times, after creating a hardlink to the file --
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+
+-- Checking different times, after making a copy of the file --
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+
+-- Checking different times, after performing is_file() operation on the file --
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+
+*** Testing touch() function with different time values ***
+bool(true)
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+bool(true)
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+bool(true)
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+bool(true)
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+bool(true)
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+Done
diff --git a/ext/standard/tests/file/005_variation2-win32.phpt b/ext/standard/tests/file/005_variation2-win32.phpt
new file mode 100644
index 0000000..8508ecf
--- /dev/null
+++ b/ext/standard/tests/file/005_variation2-win32.phpt
@@ -0,0 +1,119 @@
+--TEST--
+Test fileatime(), filemtime(), filectime() & touch() functions : usage variation
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip.. only for Windows');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: int fileatime ( string $filename );
+ Description: Returns the time the file was last accessed, or FALSE
+ in case of an error. The time is returned as a Unix timestamp.
+
+ Prototype: int filemtime ( string $filename );
+ Description: Returns the time the file was last modified, or FALSE
+ in case of an error.
+
+ Prototype: int filectime ( string $filename );
+ Description: Returns the time the file was last changed, or FALSE
+ in case of an error. The time is returned as a Unix timestamp.
+
+ Prototype: bool touch ( string $filename [, int $time [, int $atime]] );
+ Description: Attempts to set the access and modification times of the file
+ named in the filename parameter to the value given in time.
+*/
+
+/*
+ Prototype: void stat_fn(string $filename);
+ Description: Prints access, modification and change times of a file
+*/
+function stat_fn( $filename ) {
+ echo "\n-- File '$filename' --\n";
+ echo "-- File access time is => ";
+ echo fileatime($filename)."\n";
+ clearstatcache();
+ echo "-- File modification time is => ";
+ echo filemtime($filename)."\n";
+ clearstatcache();
+ echo "-- inode change time is => ";
+ echo filectime($filename)."\n";
+ clearstatcache();
+
+
+}
+
+echo "*** Testing fileattime(), filemtime(), filectime() & touch() : usage variations ***\n";
+echo "\n*** testing file info ***";
+stat_fn(NULL);
+stat_fn(false);
+stat_fn('');
+stat_fn(' ');
+stat_fn('|');
+echo "\n*** testing touch ***";
+var_dump(touch(NULL));
+var_dump(touch(false));
+var_dump(touch(''));
+
+//php generates permission denied, we generate No such file or dir.
+var_dump(touch(' '));
+var_dump(touch('|'));
+
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing fileattime(), filemtime(), filectime() & touch() : usage variations ***
+
+*** testing file info ***
+-- File '' --
+-- File access time is =>
+-- File modification time is =>
+-- inode change time is =>
+
+-- File '' --
+-- File access time is =>
+-- File modification time is =>
+-- inode change time is =>
+
+-- File '' --
+-- File access time is =>
+-- File modification time is =>
+-- inode change time is =>
+
+-- File ' ' --
+-- File access time is =>
+Warning: fileatime(): stat failed for in %s on line %d
+
+-- File modification time is =>
+Warning: filemtime(): stat failed for in %s on line %d
+
+-- inode change time is =>
+Warning: filectime(): stat failed for in %s on line %d
+
+
+-- File '|' --
+-- File access time is =>
+Warning: fileatime(): stat failed for | in %s on line %d
+
+-- File modification time is =>
+Warning: filemtime(): stat failed for | in %s on line %d
+
+-- inode change time is =>
+Warning: filectime(): stat failed for | in %s on line %d
+
+
+*** testing touch ***bool(false)
+bool(false)
+bool(false)
+
+Warning: touch(): %s in %s on line %d
+bool(false)
+
+Warning: touch(): %s in %s on line %d
+bool(false)
+Done
diff --git a/ext/standard/tests/file/005_variation2.phpt b/ext/standard/tests/file/005_variation2.phpt
new file mode 100644
index 0000000..6d4ca5e
--- /dev/null
+++ b/ext/standard/tests/file/005_variation2.phpt
@@ -0,0 +1,113 @@
+--TEST--
+Test fileatime(), filemtime(), filectime() & touch() functions : usage variation
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. only for Non Windows Systems');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: int fileatime ( string $filename );
+ Description: Returns the time the file was last accessed, or FALSE
+ in case of an error. The time is returned as a Unix timestamp.
+
+ Prototype: int filemtime ( string $filename );
+ Description: Returns the time the file was last modified, or FALSE
+ in case of an error.
+
+ Prototype: int filectime ( string $filename );
+ Description: Returns the time the file was last changed, or FALSE
+ in case of an error. The time is returned as a Unix timestamp.
+
+ Prototype: bool touch ( string $filename [, int $time [, int $atime]] );
+ Description: Attempts to set the access and modification times of the file
+ named in the filename parameter to the value given in time.
+*/
+
+/*
+ Prototype: void stat_fn(string $filename);
+ Description: Prints access, modification and change times of a file
+*/
+function stat_fn( $filename ) {
+ echo "\n-- File '$filename' --\n";
+ echo "-- File access time is => ";
+ echo fileatime($filename)."\n";
+ clearstatcache();
+ echo "-- File modification time is => ";
+ echo filemtime($filename)."\n";
+ clearstatcache();
+ echo "-- inode change time is => ";
+ echo filectime($filename)."\n";
+ clearstatcache();
+
+
+}
+
+echo "*** Testing fileattime(), filemtime(), filectime() & touch() : usage variations ***\n";
+echo "\n*** testing touch ***\n";
+$a = touch(NULL);
+$b = touch(false);
+$c = touch('');
+$d = touch(' ');
+$e = touch('|');
+
+var_dump($a);
+var_dump($b);
+var_dump($c);
+var_dump($d);
+var_dump($e);
+
+echo "\n*** testing file info ***";
+stat_fn(NULL);
+stat_fn(false);
+stat_fn('');
+stat_fn(' ');
+stat_fn('|');
+
+var_dump(unlink(' '));
+var_dump(unlink('|'));
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing fileattime(), filemtime(), filectime() & touch() : usage variations ***
+
+*** testing touch ***
+bool(false)
+bool(false)
+bool(false)
+bool(true)
+bool(true)
+
+*** testing file info ***
+-- File '' --
+-- File access time is =>
+-- File modification time is =>
+-- inode change time is =>
+
+-- File '' --
+-- File access time is =>
+-- File modification time is =>
+-- inode change time is =>
+
+-- File '' --
+-- File access time is =>
+-- File modification time is =>
+-- inode change time is =>
+
+-- File ' ' --
+-- File access time is => %d
+-- File modification time is => %d
+-- inode change time is => %d
+
+-- File '|' --
+-- File access time is => %d
+-- File modification time is => %d
+-- inode change time is => %d
+bool(true)
+bool(true)
+Done
diff --git a/ext/standard/tests/file/006_basic.phpt b/ext/standard/tests/file/006_basic.phpt
new file mode 100644
index 0000000..213442c
--- /dev/null
+++ b/ext/standard/tests/file/006_basic.phpt
@@ -0,0 +1,58 @@
+--TEST--
+Test fileperms() & chmod() functions: basic functionality
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip Not on Windows');
+}
+// Skip if being run by root
+$filename = dirname(__FILE__)."/006_root_check.tmp";
+$fp = fopen($filename, 'w');
+fclose($fp);
+if(fileowner($filename) == 0) {
+ unlink ($filename);
+ die('skip cannot be run as root');
+}
+
+unlink($filename);
+
+?>
+--FILE--
+<?php
+/*
+ Prototype: int fileperms ( string $filename );
+ Description: Returns the permissions on the file, or FALSE in case of an error
+
+ Prototype: bool chmod ( string $filename, int $mode );
+ Description: Attempts to change the mode of the file specified by
+ filename to that given in mode
+*/
+$path = dirname(__FILE__);
+
+echo "*** Testing fileperms(), chmod() with files and dirs ***\n";
+fopen($path."/perm.tmp", "w");
+var_dump( chmod($path."/perm.tmp", 0755 ) );
+printf("%o", fileperms($path."/perm.tmp") );
+echo "\n";
+clearstatcache();
+
+mkdir($path."/perm");
+var_dump( chmod( $path."/perm", 0777 ) );
+printf("%o", fileperms($path."/perm") );
+echo "\n";
+clearstatcache();
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/perm.tmp");
+rmdir(dirname(__FILE__)."/perm");
+?>
+--EXPECTF--
+*** Testing fileperms(), chmod() with files and dirs ***
+bool(true)
+100755
+bool(true)
+40777
+Done
diff --git a/ext/standard/tests/file/006_error.phpt b/ext/standard/tests/file/006_error.phpt
new file mode 100644
index 0000000..04cc274
--- /dev/null
+++ b/ext/standard/tests/file/006_error.phpt
@@ -0,0 +1,107 @@
+--TEST--
+Test fileperms(), chmod() functions: error conditions
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip Not on Windows');
+}
+// Skip if being run by root
+$filename = dirname(__FILE__)."/006_root_check.tmp";
+$fp = fopen($filename, 'w');
+fclose($fp);
+if(fileowner($filename) == 0) {
+ unlink ($filename);
+ die('skip cannot be run as root');
+}
+
+unlink($filename);
+
+?>
+--FILE--
+<?php
+/*
+ Prototype: int fileperms ( string $filename )
+ Description: Returns the permissions on the file, or FALSE in case of an error
+
+ Prototype: bool chmod ( string $filename, int $mode )
+ Description: Attempts to change the mode of the file specified by
+ filename to that given in mode
+*/
+
+echo "*** Testing error conditions for fileperms(), chmod() ***\n";
+
+/* With standard files and dirs */
+var_dump( chmod("/etc/passwd", 0777) );
+printf("%o", fileperms("/etc/passwd") );
+echo "\n";
+clearstatcache();
+
+var_dump( chmod("/etc", 0777) );
+printf("%o", fileperms("/etc") );
+echo "\n";
+clearstatcache();
+
+/* With non-existing file or dir */
+var_dump( chmod("/no/such/file/dir", 0777) );
+var_dump( fileperms("/no/such/file/dir") );
+echo "\n";
+
+/* With args less than expected */
+$fp = fopen(dirname(__FILE__)."/006_error.tmp", "w");
+fclose($fp);
+var_dump( chmod(dirname(__FILE__)."/006_error.tmp") );
+var_dump( chmod("nofile") );
+var_dump( chmod() );
+var_dump( fileperms() );
+
+/* With args greater than expected */
+var_dump( chmod(dirname(__FILE__)."/006_error.tmp", 0755, TRUE) );
+var_dump( fileperms(dirname(__FILE__)."/006_error.tmp", 0777) );
+var_dump( fileperms("nofile", 0777) );
+
+echo "\n*** Done ***\n";
+?>
+--CLEAN--
+<?php
+unlink( dirname(__FILE__)."/006_error.tmp");
+?>
+--EXPECTF--
+*** Testing error conditions for fileperms(), chmod() ***
+
+Warning: chmod(): %s in %s on line %d
+bool(false)
+100%d44
+
+Warning: chmod(): %s in %s on line %d
+bool(false)
+40755
+
+Warning: chmod(): No such file or directory in %s on line %d
+bool(false)
+
+Warning: fileperms(): stat failed for /no/such/file/dir in %s on line %d
+bool(false)
+
+
+Warning: chmod() expects exactly 2 parameters, 1 given in %s on line %d
+NULL
+
+Warning: chmod() expects exactly 2 parameters, 1 given in %s on line %d
+NULL
+
+Warning: chmod() expects exactly 2 parameters, 0 given in %s on line %d
+NULL
+
+Warning: fileperms() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: chmod() expects exactly 2 parameters, 3 given in %s on line %d
+NULL
+
+Warning: fileperms() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+
+Warning: fileperms() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+
+*** Done ***
diff --git a/ext/standard/tests/file/006_variation1.phpt b/ext/standard/tests/file/006_variation1.phpt
new file mode 100644
index 0000000..b752d21
--- /dev/null
+++ b/ext/standard/tests/file/006_variation1.phpt
@@ -0,0 +1,2627 @@
+--TEST--
+Test fileperms() & chmod() functions: usage variation - perms(0000-0777)
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip Not on Windows');
+}
+// Skip if being run by root
+$filename = dirname(__FILE__)."/006_root_check.tmp";
+$fp = fopen($filename, 'w');
+fclose($fp);
+if(fileowner($filename) == 0) {
+ unlink ($filename);
+ die('skip cannot be run as root');
+}
+
+unlink($filename);
+
+?>
+--FILE--
+<?php
+/*
+ Prototype: int fileperms ( string $filename );
+ Description: Returns the permissions on the file, or FALSE in case of an error
+
+ Prototype: bool chmod ( string $filename, int $mode );
+ Description: Attempts to change the mode of the file specified by
+ filename to that given in mode
+*/
+
+echo "*** Testing fileperms() & chmod() : usage variations ***\n";
+
+$file_name = dirname(__FILE__)."/006_variation1.tmp";
+$file_handle = fopen($file_name, "w");
+fclose($file_handle);
+$dir_name = dirname(__FILE__)."/006_variation1";
+mkdir($dir_name);
+
+$count = 1;
+echo "-- Testing all permission from octal 0000 to octal 0777 on file and dir --\n";
+for($mode = 0000; $mode <= 0777; $mode++) {
+ echo "-- Iteration $count --\n";
+ var_dump( chmod($file_name, $mode) );
+ printf("%o", fileperms($file_name) );
+ echo "\n";
+ clearstatcache();
+
+ var_dump( chmod($dir_name, $mode) );
+ printf("%o", fileperms($dir_name) );
+ echo "\n";
+ clearstatcache();
+ $count++;
+}
+
+echo "*** Done ***\n";
+?>
+--CLEAN--
+<?php
+chmod(dirname(__FILE__)."/006_variation1.tmp", 0777);
+chmod(dirname(__FILE__)."/006_variation1", 0777);
+unlink(dirname(__FILE__)."/006_variation1.tmp");
+rmdir(dirname(__FILE__)."/006_variation1");
+?>
+--EXPECTF--
+*** Testing fileperms() & chmod() : usage variations ***
+-- Testing all permission from octal 0000 to octal 0777 on file and dir --
+-- Iteration 1 --
+bool(true)
+100000
+bool(true)
+40000
+-- Iteration 2 --
+bool(true)
+100001
+bool(true)
+40001
+-- Iteration 3 --
+bool(true)
+100002
+bool(true)
+40002
+-- Iteration 4 --
+bool(true)
+100003
+bool(true)
+40003
+-- Iteration 5 --
+bool(true)
+100004
+bool(true)
+40004
+-- Iteration 6 --
+bool(true)
+100005
+bool(true)
+40005
+-- Iteration 7 --
+bool(true)
+100006
+bool(true)
+40006
+-- Iteration 8 --
+bool(true)
+100007
+bool(true)
+40007
+-- Iteration 9 --
+bool(true)
+100010
+bool(true)
+40010
+-- Iteration 10 --
+bool(true)
+100011
+bool(true)
+40011
+-- Iteration 11 --
+bool(true)
+100012
+bool(true)
+40012
+-- Iteration 12 --
+bool(true)
+100013
+bool(true)
+40013
+-- Iteration 13 --
+bool(true)
+100014
+bool(true)
+40014
+-- Iteration 14 --
+bool(true)
+100015
+bool(true)
+40015
+-- Iteration 15 --
+bool(true)
+100016
+bool(true)
+40016
+-- Iteration 16 --
+bool(true)
+100017
+bool(true)
+40017
+-- Iteration 17 --
+bool(true)
+100020
+bool(true)
+40020
+-- Iteration 18 --
+bool(true)
+100021
+bool(true)
+40021
+-- Iteration 19 --
+bool(true)
+100022
+bool(true)
+40022
+-- Iteration 20 --
+bool(true)
+100023
+bool(true)
+40023
+-- Iteration 21 --
+bool(true)
+100024
+bool(true)
+40024
+-- Iteration 22 --
+bool(true)
+100025
+bool(true)
+40025
+-- Iteration 23 --
+bool(true)
+100026
+bool(true)
+40026
+-- Iteration 24 --
+bool(true)
+100027
+bool(true)
+40027
+-- Iteration 25 --
+bool(true)
+100030
+bool(true)
+40030
+-- Iteration 26 --
+bool(true)
+100031
+bool(true)
+40031
+-- Iteration 27 --
+bool(true)
+100032
+bool(true)
+40032
+-- Iteration 28 --
+bool(true)
+100033
+bool(true)
+40033
+-- Iteration 29 --
+bool(true)
+100034
+bool(true)
+40034
+-- Iteration 30 --
+bool(true)
+100035
+bool(true)
+40035
+-- Iteration 31 --
+bool(true)
+100036
+bool(true)
+40036
+-- Iteration 32 --
+bool(true)
+100037
+bool(true)
+40037
+-- Iteration 33 --
+bool(true)
+100040
+bool(true)
+40040
+-- Iteration 34 --
+bool(true)
+100041
+bool(true)
+40041
+-- Iteration 35 --
+bool(true)
+100042
+bool(true)
+40042
+-- Iteration 36 --
+bool(true)
+100043
+bool(true)
+40043
+-- Iteration 37 --
+bool(true)
+100044
+bool(true)
+40044
+-- Iteration 38 --
+bool(true)
+100045
+bool(true)
+40045
+-- Iteration 39 --
+bool(true)
+100046
+bool(true)
+40046
+-- Iteration 40 --
+bool(true)
+100047
+bool(true)
+40047
+-- Iteration 41 --
+bool(true)
+100050
+bool(true)
+40050
+-- Iteration 42 --
+bool(true)
+100051
+bool(true)
+40051
+-- Iteration 43 --
+bool(true)
+100052
+bool(true)
+40052
+-- Iteration 44 --
+bool(true)
+100053
+bool(true)
+40053
+-- Iteration 45 --
+bool(true)
+100054
+bool(true)
+40054
+-- Iteration 46 --
+bool(true)
+100055
+bool(true)
+40055
+-- Iteration 47 --
+bool(true)
+100056
+bool(true)
+40056
+-- Iteration 48 --
+bool(true)
+100057
+bool(true)
+40057
+-- Iteration 49 --
+bool(true)
+100060
+bool(true)
+40060
+-- Iteration 50 --
+bool(true)
+100061
+bool(true)
+40061
+-- Iteration 51 --
+bool(true)
+100062
+bool(true)
+40062
+-- Iteration 52 --
+bool(true)
+100063
+bool(true)
+40063
+-- Iteration 53 --
+bool(true)
+100064
+bool(true)
+40064
+-- Iteration 54 --
+bool(true)
+100065
+bool(true)
+40065
+-- Iteration 55 --
+bool(true)
+100066
+bool(true)
+40066
+-- Iteration 56 --
+bool(true)
+100067
+bool(true)
+40067
+-- Iteration 57 --
+bool(true)
+100070
+bool(true)
+40070
+-- Iteration 58 --
+bool(true)
+100071
+bool(true)
+40071
+-- Iteration 59 --
+bool(true)
+100072
+bool(true)
+40072
+-- Iteration 60 --
+bool(true)
+100073
+bool(true)
+40073
+-- Iteration 61 --
+bool(true)
+100074
+bool(true)
+40074
+-- Iteration 62 --
+bool(true)
+100075
+bool(true)
+40075
+-- Iteration 63 --
+bool(true)
+100076
+bool(true)
+40076
+-- Iteration 64 --
+bool(true)
+100077
+bool(true)
+40077
+-- Iteration 65 --
+bool(true)
+100100
+bool(true)
+40100
+-- Iteration 66 --
+bool(true)
+100101
+bool(true)
+40101
+-- Iteration 67 --
+bool(true)
+100102
+bool(true)
+40102
+-- Iteration 68 --
+bool(true)
+100103
+bool(true)
+40103
+-- Iteration 69 --
+bool(true)
+100104
+bool(true)
+40104
+-- Iteration 70 --
+bool(true)
+100105
+bool(true)
+40105
+-- Iteration 71 --
+bool(true)
+100106
+bool(true)
+40106
+-- Iteration 72 --
+bool(true)
+100107
+bool(true)
+40107
+-- Iteration 73 --
+bool(true)
+100110
+bool(true)
+40110
+-- Iteration 74 --
+bool(true)
+100111
+bool(true)
+40111
+-- Iteration 75 --
+bool(true)
+100112
+bool(true)
+40112
+-- Iteration 76 --
+bool(true)
+100113
+bool(true)
+40113
+-- Iteration 77 --
+bool(true)
+100114
+bool(true)
+40114
+-- Iteration 78 --
+bool(true)
+100115
+bool(true)
+40115
+-- Iteration 79 --
+bool(true)
+100116
+bool(true)
+40116
+-- Iteration 80 --
+bool(true)
+100117
+bool(true)
+40117
+-- Iteration 81 --
+bool(true)
+100120
+bool(true)
+40120
+-- Iteration 82 --
+bool(true)
+100121
+bool(true)
+40121
+-- Iteration 83 --
+bool(true)
+100122
+bool(true)
+40122
+-- Iteration 84 --
+bool(true)
+100123
+bool(true)
+40123
+-- Iteration 85 --
+bool(true)
+100124
+bool(true)
+40124
+-- Iteration 86 --
+bool(true)
+100125
+bool(true)
+40125
+-- Iteration 87 --
+bool(true)
+100126
+bool(true)
+40126
+-- Iteration 88 --
+bool(true)
+100127
+bool(true)
+40127
+-- Iteration 89 --
+bool(true)
+100130
+bool(true)
+40130
+-- Iteration 90 --
+bool(true)
+100131
+bool(true)
+40131
+-- Iteration 91 --
+bool(true)
+100132
+bool(true)
+40132
+-- Iteration 92 --
+bool(true)
+100133
+bool(true)
+40133
+-- Iteration 93 --
+bool(true)
+100134
+bool(true)
+40134
+-- Iteration 94 --
+bool(true)
+100135
+bool(true)
+40135
+-- Iteration 95 --
+bool(true)
+100136
+bool(true)
+40136
+-- Iteration 96 --
+bool(true)
+100137
+bool(true)
+40137
+-- Iteration 97 --
+bool(true)
+100140
+bool(true)
+40140
+-- Iteration 98 --
+bool(true)
+100141
+bool(true)
+40141
+-- Iteration 99 --
+bool(true)
+100142
+bool(true)
+40142
+-- Iteration 100 --
+bool(true)
+100143
+bool(true)
+40143
+-- Iteration 101 --
+bool(true)
+100144
+bool(true)
+40144
+-- Iteration 102 --
+bool(true)
+100145
+bool(true)
+40145
+-- Iteration 103 --
+bool(true)
+100146
+bool(true)
+40146
+-- Iteration 104 --
+bool(true)
+100147
+bool(true)
+40147
+-- Iteration 105 --
+bool(true)
+100150
+bool(true)
+40150
+-- Iteration 106 --
+bool(true)
+100151
+bool(true)
+40151
+-- Iteration 107 --
+bool(true)
+100152
+bool(true)
+40152
+-- Iteration 108 --
+bool(true)
+100153
+bool(true)
+40153
+-- Iteration 109 --
+bool(true)
+100154
+bool(true)
+40154
+-- Iteration 110 --
+bool(true)
+100155
+bool(true)
+40155
+-- Iteration 111 --
+bool(true)
+100156
+bool(true)
+40156
+-- Iteration 112 --
+bool(true)
+100157
+bool(true)
+40157
+-- Iteration 113 --
+bool(true)
+100160
+bool(true)
+40160
+-- Iteration 114 --
+bool(true)
+100161
+bool(true)
+40161
+-- Iteration 115 --
+bool(true)
+100162
+bool(true)
+40162
+-- Iteration 116 --
+bool(true)
+100163
+bool(true)
+40163
+-- Iteration 117 --
+bool(true)
+100164
+bool(true)
+40164
+-- Iteration 118 --
+bool(true)
+100165
+bool(true)
+40165
+-- Iteration 119 --
+bool(true)
+100166
+bool(true)
+40166
+-- Iteration 120 --
+bool(true)
+100167
+bool(true)
+40167
+-- Iteration 121 --
+bool(true)
+100170
+bool(true)
+40170
+-- Iteration 122 --
+bool(true)
+100171
+bool(true)
+40171
+-- Iteration 123 --
+bool(true)
+100172
+bool(true)
+40172
+-- Iteration 124 --
+bool(true)
+100173
+bool(true)
+40173
+-- Iteration 125 --
+bool(true)
+100174
+bool(true)
+40174
+-- Iteration 126 --
+bool(true)
+100175
+bool(true)
+40175
+-- Iteration 127 --
+bool(true)
+100176
+bool(true)
+40176
+-- Iteration 128 --
+bool(true)
+100177
+bool(true)
+40177
+-- Iteration 129 --
+bool(true)
+100200
+bool(true)
+40200
+-- Iteration 130 --
+bool(true)
+100201
+bool(true)
+40201
+-- Iteration 131 --
+bool(true)
+100202
+bool(true)
+40202
+-- Iteration 132 --
+bool(true)
+100203
+bool(true)
+40203
+-- Iteration 133 --
+bool(true)
+100204
+bool(true)
+40204
+-- Iteration 134 --
+bool(true)
+100205
+bool(true)
+40205
+-- Iteration 135 --
+bool(true)
+100206
+bool(true)
+40206
+-- Iteration 136 --
+bool(true)
+100207
+bool(true)
+40207
+-- Iteration 137 --
+bool(true)
+100210
+bool(true)
+40210
+-- Iteration 138 --
+bool(true)
+100211
+bool(true)
+40211
+-- Iteration 139 --
+bool(true)
+100212
+bool(true)
+40212
+-- Iteration 140 --
+bool(true)
+100213
+bool(true)
+40213
+-- Iteration 141 --
+bool(true)
+100214
+bool(true)
+40214
+-- Iteration 142 --
+bool(true)
+100215
+bool(true)
+40215
+-- Iteration 143 --
+bool(true)
+100216
+bool(true)
+40216
+-- Iteration 144 --
+bool(true)
+100217
+bool(true)
+40217
+-- Iteration 145 --
+bool(true)
+100220
+bool(true)
+40220
+-- Iteration 146 --
+bool(true)
+100221
+bool(true)
+40221
+-- Iteration 147 --
+bool(true)
+100222
+bool(true)
+40222
+-- Iteration 148 --
+bool(true)
+100223
+bool(true)
+40223
+-- Iteration 149 --
+bool(true)
+100224
+bool(true)
+40224
+-- Iteration 150 --
+bool(true)
+100225
+bool(true)
+40225
+-- Iteration 151 --
+bool(true)
+100226
+bool(true)
+40226
+-- Iteration 152 --
+bool(true)
+100227
+bool(true)
+40227
+-- Iteration 153 --
+bool(true)
+100230
+bool(true)
+40230
+-- Iteration 154 --
+bool(true)
+100231
+bool(true)
+40231
+-- Iteration 155 --
+bool(true)
+100232
+bool(true)
+40232
+-- Iteration 156 --
+bool(true)
+100233
+bool(true)
+40233
+-- Iteration 157 --
+bool(true)
+100234
+bool(true)
+40234
+-- Iteration 158 --
+bool(true)
+100235
+bool(true)
+40235
+-- Iteration 159 --
+bool(true)
+100236
+bool(true)
+40236
+-- Iteration 160 --
+bool(true)
+100237
+bool(true)
+40237
+-- Iteration 161 --
+bool(true)
+100240
+bool(true)
+40240
+-- Iteration 162 --
+bool(true)
+100241
+bool(true)
+40241
+-- Iteration 163 --
+bool(true)
+100242
+bool(true)
+40242
+-- Iteration 164 --
+bool(true)
+100243
+bool(true)
+40243
+-- Iteration 165 --
+bool(true)
+100244
+bool(true)
+40244
+-- Iteration 166 --
+bool(true)
+100245
+bool(true)
+40245
+-- Iteration 167 --
+bool(true)
+100246
+bool(true)
+40246
+-- Iteration 168 --
+bool(true)
+100247
+bool(true)
+40247
+-- Iteration 169 --
+bool(true)
+100250
+bool(true)
+40250
+-- Iteration 170 --
+bool(true)
+100251
+bool(true)
+40251
+-- Iteration 171 --
+bool(true)
+100252
+bool(true)
+40252
+-- Iteration 172 --
+bool(true)
+100253
+bool(true)
+40253
+-- Iteration 173 --
+bool(true)
+100254
+bool(true)
+40254
+-- Iteration 174 --
+bool(true)
+100255
+bool(true)
+40255
+-- Iteration 175 --
+bool(true)
+100256
+bool(true)
+40256
+-- Iteration 176 --
+bool(true)
+100257
+bool(true)
+40257
+-- Iteration 177 --
+bool(true)
+100260
+bool(true)
+40260
+-- Iteration 178 --
+bool(true)
+100261
+bool(true)
+40261
+-- Iteration 179 --
+bool(true)
+100262
+bool(true)
+40262
+-- Iteration 180 --
+bool(true)
+100263
+bool(true)
+40263
+-- Iteration 181 --
+bool(true)
+100264
+bool(true)
+40264
+-- Iteration 182 --
+bool(true)
+100265
+bool(true)
+40265
+-- Iteration 183 --
+bool(true)
+100266
+bool(true)
+40266
+-- Iteration 184 --
+bool(true)
+100267
+bool(true)
+40267
+-- Iteration 185 --
+bool(true)
+100270
+bool(true)
+40270
+-- Iteration 186 --
+bool(true)
+100271
+bool(true)
+40271
+-- Iteration 187 --
+bool(true)
+100272
+bool(true)
+40272
+-- Iteration 188 --
+bool(true)
+100273
+bool(true)
+40273
+-- Iteration 189 --
+bool(true)
+100274
+bool(true)
+40274
+-- Iteration 190 --
+bool(true)
+100275
+bool(true)
+40275
+-- Iteration 191 --
+bool(true)
+100276
+bool(true)
+40276
+-- Iteration 192 --
+bool(true)
+100277
+bool(true)
+40277
+-- Iteration 193 --
+bool(true)
+100300
+bool(true)
+40300
+-- Iteration 194 --
+bool(true)
+100301
+bool(true)
+40301
+-- Iteration 195 --
+bool(true)
+100302
+bool(true)
+40302
+-- Iteration 196 --
+bool(true)
+100303
+bool(true)
+40303
+-- Iteration 197 --
+bool(true)
+100304
+bool(true)
+40304
+-- Iteration 198 --
+bool(true)
+100305
+bool(true)
+40305
+-- Iteration 199 --
+bool(true)
+100306
+bool(true)
+40306
+-- Iteration 200 --
+bool(true)
+100307
+bool(true)
+40307
+-- Iteration 201 --
+bool(true)
+100310
+bool(true)
+40310
+-- Iteration 202 --
+bool(true)
+100311
+bool(true)
+40311
+-- Iteration 203 --
+bool(true)
+100312
+bool(true)
+40312
+-- Iteration 204 --
+bool(true)
+100313
+bool(true)
+40313
+-- Iteration 205 --
+bool(true)
+100314
+bool(true)
+40314
+-- Iteration 206 --
+bool(true)
+100315
+bool(true)
+40315
+-- Iteration 207 --
+bool(true)
+100316
+bool(true)
+40316
+-- Iteration 208 --
+bool(true)
+100317
+bool(true)
+40317
+-- Iteration 209 --
+bool(true)
+100320
+bool(true)
+40320
+-- Iteration 210 --
+bool(true)
+100321
+bool(true)
+40321
+-- Iteration 211 --
+bool(true)
+100322
+bool(true)
+40322
+-- Iteration 212 --
+bool(true)
+100323
+bool(true)
+40323
+-- Iteration 213 --
+bool(true)
+100324
+bool(true)
+40324
+-- Iteration 214 --
+bool(true)
+100325
+bool(true)
+40325
+-- Iteration 215 --
+bool(true)
+100326
+bool(true)
+40326
+-- Iteration 216 --
+bool(true)
+100327
+bool(true)
+40327
+-- Iteration 217 --
+bool(true)
+100330
+bool(true)
+40330
+-- Iteration 218 --
+bool(true)
+100331
+bool(true)
+40331
+-- Iteration 219 --
+bool(true)
+100332
+bool(true)
+40332
+-- Iteration 220 --
+bool(true)
+100333
+bool(true)
+40333
+-- Iteration 221 --
+bool(true)
+100334
+bool(true)
+40334
+-- Iteration 222 --
+bool(true)
+100335
+bool(true)
+40335
+-- Iteration 223 --
+bool(true)
+100336
+bool(true)
+40336
+-- Iteration 224 --
+bool(true)
+100337
+bool(true)
+40337
+-- Iteration 225 --
+bool(true)
+100340
+bool(true)
+40340
+-- Iteration 226 --
+bool(true)
+100341
+bool(true)
+40341
+-- Iteration 227 --
+bool(true)
+100342
+bool(true)
+40342
+-- Iteration 228 --
+bool(true)
+100343
+bool(true)
+40343
+-- Iteration 229 --
+bool(true)
+100344
+bool(true)
+40344
+-- Iteration 230 --
+bool(true)
+100345
+bool(true)
+40345
+-- Iteration 231 --
+bool(true)
+100346
+bool(true)
+40346
+-- Iteration 232 --
+bool(true)
+100347
+bool(true)
+40347
+-- Iteration 233 --
+bool(true)
+100350
+bool(true)
+40350
+-- Iteration 234 --
+bool(true)
+100351
+bool(true)
+40351
+-- Iteration 235 --
+bool(true)
+100352
+bool(true)
+40352
+-- Iteration 236 --
+bool(true)
+100353
+bool(true)
+40353
+-- Iteration 237 --
+bool(true)
+100354
+bool(true)
+40354
+-- Iteration 238 --
+bool(true)
+100355
+bool(true)
+40355
+-- Iteration 239 --
+bool(true)
+100356
+bool(true)
+40356
+-- Iteration 240 --
+bool(true)
+100357
+bool(true)
+40357
+-- Iteration 241 --
+bool(true)
+100360
+bool(true)
+40360
+-- Iteration 242 --
+bool(true)
+100361
+bool(true)
+40361
+-- Iteration 243 --
+bool(true)
+100362
+bool(true)
+40362
+-- Iteration 244 --
+bool(true)
+100363
+bool(true)
+40363
+-- Iteration 245 --
+bool(true)
+100364
+bool(true)
+40364
+-- Iteration 246 --
+bool(true)
+100365
+bool(true)
+40365
+-- Iteration 247 --
+bool(true)
+100366
+bool(true)
+40366
+-- Iteration 248 --
+bool(true)
+100367
+bool(true)
+40367
+-- Iteration 249 --
+bool(true)
+100370
+bool(true)
+40370
+-- Iteration 250 --
+bool(true)
+100371
+bool(true)
+40371
+-- Iteration 251 --
+bool(true)
+100372
+bool(true)
+40372
+-- Iteration 252 --
+bool(true)
+100373
+bool(true)
+40373
+-- Iteration 253 --
+bool(true)
+100374
+bool(true)
+40374
+-- Iteration 254 --
+bool(true)
+100375
+bool(true)
+40375
+-- Iteration 255 --
+bool(true)
+100376
+bool(true)
+40376
+-- Iteration 256 --
+bool(true)
+100377
+bool(true)
+40377
+-- Iteration 257 --
+bool(true)
+100400
+bool(true)
+40400
+-- Iteration 258 --
+bool(true)
+100401
+bool(true)
+40401
+-- Iteration 259 --
+bool(true)
+100402
+bool(true)
+40402
+-- Iteration 260 --
+bool(true)
+100403
+bool(true)
+40403
+-- Iteration 261 --
+bool(true)
+100404
+bool(true)
+40404
+-- Iteration 262 --
+bool(true)
+100405
+bool(true)
+40405
+-- Iteration 263 --
+bool(true)
+100406
+bool(true)
+40406
+-- Iteration 264 --
+bool(true)
+100407
+bool(true)
+40407
+-- Iteration 265 --
+bool(true)
+100410
+bool(true)
+40410
+-- Iteration 266 --
+bool(true)
+100411
+bool(true)
+40411
+-- Iteration 267 --
+bool(true)
+100412
+bool(true)
+40412
+-- Iteration 268 --
+bool(true)
+100413
+bool(true)
+40413
+-- Iteration 269 --
+bool(true)
+100414
+bool(true)
+40414
+-- Iteration 270 --
+bool(true)
+100415
+bool(true)
+40415
+-- Iteration 271 --
+bool(true)
+100416
+bool(true)
+40416
+-- Iteration 272 --
+bool(true)
+100417
+bool(true)
+40417
+-- Iteration 273 --
+bool(true)
+100420
+bool(true)
+40420
+-- Iteration 274 --
+bool(true)
+100421
+bool(true)
+40421
+-- Iteration 275 --
+bool(true)
+100422
+bool(true)
+40422
+-- Iteration 276 --
+bool(true)
+100423
+bool(true)
+40423
+-- Iteration 277 --
+bool(true)
+100424
+bool(true)
+40424
+-- Iteration 278 --
+bool(true)
+100425
+bool(true)
+40425
+-- Iteration 279 --
+bool(true)
+100426
+bool(true)
+40426
+-- Iteration 280 --
+bool(true)
+100427
+bool(true)
+40427
+-- Iteration 281 --
+bool(true)
+100430
+bool(true)
+40430
+-- Iteration 282 --
+bool(true)
+100431
+bool(true)
+40431
+-- Iteration 283 --
+bool(true)
+100432
+bool(true)
+40432
+-- Iteration 284 --
+bool(true)
+100433
+bool(true)
+40433
+-- Iteration 285 --
+bool(true)
+100434
+bool(true)
+40434
+-- Iteration 286 --
+bool(true)
+100435
+bool(true)
+40435
+-- Iteration 287 --
+bool(true)
+100436
+bool(true)
+40436
+-- Iteration 288 --
+bool(true)
+100437
+bool(true)
+40437
+-- Iteration 289 --
+bool(true)
+100440
+bool(true)
+40440
+-- Iteration 290 --
+bool(true)
+100441
+bool(true)
+40441
+-- Iteration 291 --
+bool(true)
+100442
+bool(true)
+40442
+-- Iteration 292 --
+bool(true)
+100443
+bool(true)
+40443
+-- Iteration 293 --
+bool(true)
+100444
+bool(true)
+40444
+-- Iteration 294 --
+bool(true)
+100445
+bool(true)
+40445
+-- Iteration 295 --
+bool(true)
+100446
+bool(true)
+40446
+-- Iteration 296 --
+bool(true)
+100447
+bool(true)
+40447
+-- Iteration 297 --
+bool(true)
+100450
+bool(true)
+40450
+-- Iteration 298 --
+bool(true)
+100451
+bool(true)
+40451
+-- Iteration 299 --
+bool(true)
+100452
+bool(true)
+40452
+-- Iteration 300 --
+bool(true)
+100453
+bool(true)
+40453
+-- Iteration 301 --
+bool(true)
+100454
+bool(true)
+40454
+-- Iteration 302 --
+bool(true)
+100455
+bool(true)
+40455
+-- Iteration 303 --
+bool(true)
+100456
+bool(true)
+40456
+-- Iteration 304 --
+bool(true)
+100457
+bool(true)
+40457
+-- Iteration 305 --
+bool(true)
+100460
+bool(true)
+40460
+-- Iteration 306 --
+bool(true)
+100461
+bool(true)
+40461
+-- Iteration 307 --
+bool(true)
+100462
+bool(true)
+40462
+-- Iteration 308 --
+bool(true)
+100463
+bool(true)
+40463
+-- Iteration 309 --
+bool(true)
+100464
+bool(true)
+40464
+-- Iteration 310 --
+bool(true)
+100465
+bool(true)
+40465
+-- Iteration 311 --
+bool(true)
+100466
+bool(true)
+40466
+-- Iteration 312 --
+bool(true)
+100467
+bool(true)
+40467
+-- Iteration 313 --
+bool(true)
+100470
+bool(true)
+40470
+-- Iteration 314 --
+bool(true)
+100471
+bool(true)
+40471
+-- Iteration 315 --
+bool(true)
+100472
+bool(true)
+40472
+-- Iteration 316 --
+bool(true)
+100473
+bool(true)
+40473
+-- Iteration 317 --
+bool(true)
+100474
+bool(true)
+40474
+-- Iteration 318 --
+bool(true)
+100475
+bool(true)
+40475
+-- Iteration 319 --
+bool(true)
+100476
+bool(true)
+40476
+-- Iteration 320 --
+bool(true)
+100477
+bool(true)
+40477
+-- Iteration 321 --
+bool(true)
+100500
+bool(true)
+40500
+-- Iteration 322 --
+bool(true)
+100501
+bool(true)
+40501
+-- Iteration 323 --
+bool(true)
+100502
+bool(true)
+40502
+-- Iteration 324 --
+bool(true)
+100503
+bool(true)
+40503
+-- Iteration 325 --
+bool(true)
+100504
+bool(true)
+40504
+-- Iteration 326 --
+bool(true)
+100505
+bool(true)
+40505
+-- Iteration 327 --
+bool(true)
+100506
+bool(true)
+40506
+-- Iteration 328 --
+bool(true)
+100507
+bool(true)
+40507
+-- Iteration 329 --
+bool(true)
+100510
+bool(true)
+40510
+-- Iteration 330 --
+bool(true)
+100511
+bool(true)
+40511
+-- Iteration 331 --
+bool(true)
+100512
+bool(true)
+40512
+-- Iteration 332 --
+bool(true)
+100513
+bool(true)
+40513
+-- Iteration 333 --
+bool(true)
+100514
+bool(true)
+40514
+-- Iteration 334 --
+bool(true)
+100515
+bool(true)
+40515
+-- Iteration 335 --
+bool(true)
+100516
+bool(true)
+40516
+-- Iteration 336 --
+bool(true)
+100517
+bool(true)
+40517
+-- Iteration 337 --
+bool(true)
+100520
+bool(true)
+40520
+-- Iteration 338 --
+bool(true)
+100521
+bool(true)
+40521
+-- Iteration 339 --
+bool(true)
+100522
+bool(true)
+40522
+-- Iteration 340 --
+bool(true)
+100523
+bool(true)
+40523
+-- Iteration 341 --
+bool(true)
+100524
+bool(true)
+40524
+-- Iteration 342 --
+bool(true)
+100525
+bool(true)
+40525
+-- Iteration 343 --
+bool(true)
+100526
+bool(true)
+40526
+-- Iteration 344 --
+bool(true)
+100527
+bool(true)
+40527
+-- Iteration 345 --
+bool(true)
+100530
+bool(true)
+40530
+-- Iteration 346 --
+bool(true)
+100531
+bool(true)
+40531
+-- Iteration 347 --
+bool(true)
+100532
+bool(true)
+40532
+-- Iteration 348 --
+bool(true)
+100533
+bool(true)
+40533
+-- Iteration 349 --
+bool(true)
+100534
+bool(true)
+40534
+-- Iteration 350 --
+bool(true)
+100535
+bool(true)
+40535
+-- Iteration 351 --
+bool(true)
+100536
+bool(true)
+40536
+-- Iteration 352 --
+bool(true)
+100537
+bool(true)
+40537
+-- Iteration 353 --
+bool(true)
+100540
+bool(true)
+40540
+-- Iteration 354 --
+bool(true)
+100541
+bool(true)
+40541
+-- Iteration 355 --
+bool(true)
+100542
+bool(true)
+40542
+-- Iteration 356 --
+bool(true)
+100543
+bool(true)
+40543
+-- Iteration 357 --
+bool(true)
+100544
+bool(true)
+40544
+-- Iteration 358 --
+bool(true)
+100545
+bool(true)
+40545
+-- Iteration 359 --
+bool(true)
+100546
+bool(true)
+40546
+-- Iteration 360 --
+bool(true)
+100547
+bool(true)
+40547
+-- Iteration 361 --
+bool(true)
+100550
+bool(true)
+40550
+-- Iteration 362 --
+bool(true)
+100551
+bool(true)
+40551
+-- Iteration 363 --
+bool(true)
+100552
+bool(true)
+40552
+-- Iteration 364 --
+bool(true)
+100553
+bool(true)
+40553
+-- Iteration 365 --
+bool(true)
+100554
+bool(true)
+40554
+-- Iteration 366 --
+bool(true)
+100555
+bool(true)
+40555
+-- Iteration 367 --
+bool(true)
+100556
+bool(true)
+40556
+-- Iteration 368 --
+bool(true)
+100557
+bool(true)
+40557
+-- Iteration 369 --
+bool(true)
+100560
+bool(true)
+40560
+-- Iteration 370 --
+bool(true)
+100561
+bool(true)
+40561
+-- Iteration 371 --
+bool(true)
+100562
+bool(true)
+40562
+-- Iteration 372 --
+bool(true)
+100563
+bool(true)
+40563
+-- Iteration 373 --
+bool(true)
+100564
+bool(true)
+40564
+-- Iteration 374 --
+bool(true)
+100565
+bool(true)
+40565
+-- Iteration 375 --
+bool(true)
+100566
+bool(true)
+40566
+-- Iteration 376 --
+bool(true)
+100567
+bool(true)
+40567
+-- Iteration 377 --
+bool(true)
+100570
+bool(true)
+40570
+-- Iteration 378 --
+bool(true)
+100571
+bool(true)
+40571
+-- Iteration 379 --
+bool(true)
+100572
+bool(true)
+40572
+-- Iteration 380 --
+bool(true)
+100573
+bool(true)
+40573
+-- Iteration 381 --
+bool(true)
+100574
+bool(true)
+40574
+-- Iteration 382 --
+bool(true)
+100575
+bool(true)
+40575
+-- Iteration 383 --
+bool(true)
+100576
+bool(true)
+40576
+-- Iteration 384 --
+bool(true)
+100577
+bool(true)
+40577
+-- Iteration 385 --
+bool(true)
+100600
+bool(true)
+40600
+-- Iteration 386 --
+bool(true)
+100601
+bool(true)
+40601
+-- Iteration 387 --
+bool(true)
+100602
+bool(true)
+40602
+-- Iteration 388 --
+bool(true)
+100603
+bool(true)
+40603
+-- Iteration 389 --
+bool(true)
+100604
+bool(true)
+40604
+-- Iteration 390 --
+bool(true)
+100605
+bool(true)
+40605
+-- Iteration 391 --
+bool(true)
+100606
+bool(true)
+40606
+-- Iteration 392 --
+bool(true)
+100607
+bool(true)
+40607
+-- Iteration 393 --
+bool(true)
+100610
+bool(true)
+40610
+-- Iteration 394 --
+bool(true)
+100611
+bool(true)
+40611
+-- Iteration 395 --
+bool(true)
+100612
+bool(true)
+40612
+-- Iteration 396 --
+bool(true)
+100613
+bool(true)
+40613
+-- Iteration 397 --
+bool(true)
+100614
+bool(true)
+40614
+-- Iteration 398 --
+bool(true)
+100615
+bool(true)
+40615
+-- Iteration 399 --
+bool(true)
+100616
+bool(true)
+40616
+-- Iteration 400 --
+bool(true)
+100617
+bool(true)
+40617
+-- Iteration 401 --
+bool(true)
+100620
+bool(true)
+40620
+-- Iteration 402 --
+bool(true)
+100621
+bool(true)
+40621
+-- Iteration 403 --
+bool(true)
+100622
+bool(true)
+40622
+-- Iteration 404 --
+bool(true)
+100623
+bool(true)
+40623
+-- Iteration 405 --
+bool(true)
+100624
+bool(true)
+40624
+-- Iteration 406 --
+bool(true)
+100625
+bool(true)
+40625
+-- Iteration 407 --
+bool(true)
+100626
+bool(true)
+40626
+-- Iteration 408 --
+bool(true)
+100627
+bool(true)
+40627
+-- Iteration 409 --
+bool(true)
+100630
+bool(true)
+40630
+-- Iteration 410 --
+bool(true)
+100631
+bool(true)
+40631
+-- Iteration 411 --
+bool(true)
+100632
+bool(true)
+40632
+-- Iteration 412 --
+bool(true)
+100633
+bool(true)
+40633
+-- Iteration 413 --
+bool(true)
+100634
+bool(true)
+40634
+-- Iteration 414 --
+bool(true)
+100635
+bool(true)
+40635
+-- Iteration 415 --
+bool(true)
+100636
+bool(true)
+40636
+-- Iteration 416 --
+bool(true)
+100637
+bool(true)
+40637
+-- Iteration 417 --
+bool(true)
+100640
+bool(true)
+40640
+-- Iteration 418 --
+bool(true)
+100641
+bool(true)
+40641
+-- Iteration 419 --
+bool(true)
+100642
+bool(true)
+40642
+-- Iteration 420 --
+bool(true)
+100643
+bool(true)
+40643
+-- Iteration 421 --
+bool(true)
+100644
+bool(true)
+40644
+-- Iteration 422 --
+bool(true)
+100645
+bool(true)
+40645
+-- Iteration 423 --
+bool(true)
+100646
+bool(true)
+40646
+-- Iteration 424 --
+bool(true)
+100647
+bool(true)
+40647
+-- Iteration 425 --
+bool(true)
+100650
+bool(true)
+40650
+-- Iteration 426 --
+bool(true)
+100651
+bool(true)
+40651
+-- Iteration 427 --
+bool(true)
+100652
+bool(true)
+40652
+-- Iteration 428 --
+bool(true)
+100653
+bool(true)
+40653
+-- Iteration 429 --
+bool(true)
+100654
+bool(true)
+40654
+-- Iteration 430 --
+bool(true)
+100655
+bool(true)
+40655
+-- Iteration 431 --
+bool(true)
+100656
+bool(true)
+40656
+-- Iteration 432 --
+bool(true)
+100657
+bool(true)
+40657
+-- Iteration 433 --
+bool(true)
+100660
+bool(true)
+40660
+-- Iteration 434 --
+bool(true)
+100661
+bool(true)
+40661
+-- Iteration 435 --
+bool(true)
+100662
+bool(true)
+40662
+-- Iteration 436 --
+bool(true)
+100663
+bool(true)
+40663
+-- Iteration 437 --
+bool(true)
+100664
+bool(true)
+40664
+-- Iteration 438 --
+bool(true)
+100665
+bool(true)
+40665
+-- Iteration 439 --
+bool(true)
+100666
+bool(true)
+40666
+-- Iteration 440 --
+bool(true)
+100667
+bool(true)
+40667
+-- Iteration 441 --
+bool(true)
+100670
+bool(true)
+40670
+-- Iteration 442 --
+bool(true)
+100671
+bool(true)
+40671
+-- Iteration 443 --
+bool(true)
+100672
+bool(true)
+40672
+-- Iteration 444 --
+bool(true)
+100673
+bool(true)
+40673
+-- Iteration 445 --
+bool(true)
+100674
+bool(true)
+40674
+-- Iteration 446 --
+bool(true)
+100675
+bool(true)
+40675
+-- Iteration 447 --
+bool(true)
+100676
+bool(true)
+40676
+-- Iteration 448 --
+bool(true)
+100677
+bool(true)
+40677
+-- Iteration 449 --
+bool(true)
+100700
+bool(true)
+40700
+-- Iteration 450 --
+bool(true)
+100701
+bool(true)
+40701
+-- Iteration 451 --
+bool(true)
+100702
+bool(true)
+40702
+-- Iteration 452 --
+bool(true)
+100703
+bool(true)
+40703
+-- Iteration 453 --
+bool(true)
+100704
+bool(true)
+40704
+-- Iteration 454 --
+bool(true)
+100705
+bool(true)
+40705
+-- Iteration 455 --
+bool(true)
+100706
+bool(true)
+40706
+-- Iteration 456 --
+bool(true)
+100707
+bool(true)
+40707
+-- Iteration 457 --
+bool(true)
+100710
+bool(true)
+40710
+-- Iteration 458 --
+bool(true)
+100711
+bool(true)
+40711
+-- Iteration 459 --
+bool(true)
+100712
+bool(true)
+40712
+-- Iteration 460 --
+bool(true)
+100713
+bool(true)
+40713
+-- Iteration 461 --
+bool(true)
+100714
+bool(true)
+40714
+-- Iteration 462 --
+bool(true)
+100715
+bool(true)
+40715
+-- Iteration 463 --
+bool(true)
+100716
+bool(true)
+40716
+-- Iteration 464 --
+bool(true)
+100717
+bool(true)
+40717
+-- Iteration 465 --
+bool(true)
+100720
+bool(true)
+40720
+-- Iteration 466 --
+bool(true)
+100721
+bool(true)
+40721
+-- Iteration 467 --
+bool(true)
+100722
+bool(true)
+40722
+-- Iteration 468 --
+bool(true)
+100723
+bool(true)
+40723
+-- Iteration 469 --
+bool(true)
+100724
+bool(true)
+40724
+-- Iteration 470 --
+bool(true)
+100725
+bool(true)
+40725
+-- Iteration 471 --
+bool(true)
+100726
+bool(true)
+40726
+-- Iteration 472 --
+bool(true)
+100727
+bool(true)
+40727
+-- Iteration 473 --
+bool(true)
+100730
+bool(true)
+40730
+-- Iteration 474 --
+bool(true)
+100731
+bool(true)
+40731
+-- Iteration 475 --
+bool(true)
+100732
+bool(true)
+40732
+-- Iteration 476 --
+bool(true)
+100733
+bool(true)
+40733
+-- Iteration 477 --
+bool(true)
+100734
+bool(true)
+40734
+-- Iteration 478 --
+bool(true)
+100735
+bool(true)
+40735
+-- Iteration 479 --
+bool(true)
+100736
+bool(true)
+40736
+-- Iteration 480 --
+bool(true)
+100737
+bool(true)
+40737
+-- Iteration 481 --
+bool(true)
+100740
+bool(true)
+40740
+-- Iteration 482 --
+bool(true)
+100741
+bool(true)
+40741
+-- Iteration 483 --
+bool(true)
+100742
+bool(true)
+40742
+-- Iteration 484 --
+bool(true)
+100743
+bool(true)
+40743
+-- Iteration 485 --
+bool(true)
+100744
+bool(true)
+40744
+-- Iteration 486 --
+bool(true)
+100745
+bool(true)
+40745
+-- Iteration 487 --
+bool(true)
+100746
+bool(true)
+40746
+-- Iteration 488 --
+bool(true)
+100747
+bool(true)
+40747
+-- Iteration 489 --
+bool(true)
+100750
+bool(true)
+40750
+-- Iteration 490 --
+bool(true)
+100751
+bool(true)
+40751
+-- Iteration 491 --
+bool(true)
+100752
+bool(true)
+40752
+-- Iteration 492 --
+bool(true)
+100753
+bool(true)
+40753
+-- Iteration 493 --
+bool(true)
+100754
+bool(true)
+40754
+-- Iteration 494 --
+bool(true)
+100755
+bool(true)
+40755
+-- Iteration 495 --
+bool(true)
+100756
+bool(true)
+40756
+-- Iteration 496 --
+bool(true)
+100757
+bool(true)
+40757
+-- Iteration 497 --
+bool(true)
+100760
+bool(true)
+40760
+-- Iteration 498 --
+bool(true)
+100761
+bool(true)
+40761
+-- Iteration 499 --
+bool(true)
+100762
+bool(true)
+40762
+-- Iteration 500 --
+bool(true)
+100763
+bool(true)
+40763
+-- Iteration 501 --
+bool(true)
+100764
+bool(true)
+40764
+-- Iteration 502 --
+bool(true)
+100765
+bool(true)
+40765
+-- Iteration 503 --
+bool(true)
+100766
+bool(true)
+40766
+-- Iteration 504 --
+bool(true)
+100767
+bool(true)
+40767
+-- Iteration 505 --
+bool(true)
+100770
+bool(true)
+40770
+-- Iteration 506 --
+bool(true)
+100771
+bool(true)
+40771
+-- Iteration 507 --
+bool(true)
+100772
+bool(true)
+40772
+-- Iteration 508 --
+bool(true)
+100773
+bool(true)
+40773
+-- Iteration 509 --
+bool(true)
+100774
+bool(true)
+40774
+-- Iteration 510 --
+bool(true)
+100775
+bool(true)
+40775
+-- Iteration 511 --
+bool(true)
+100776
+bool(true)
+40776
+-- Iteration 512 --
+bool(true)
+100777
+bool(true)
+40777
+*** Done ***
diff --git a/ext/standard/tests/file/006_variation2.phpt b/ext/standard/tests/file/006_variation2.phpt
new file mode 100644
index 0000000..d56207a
--- /dev/null
+++ b/ext/standard/tests/file/006_variation2.phpt
@@ -0,0 +1,186 @@
+--TEST--
+Test fileperms() & chmod() functions: usage variation - misc. perms
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip Not on Windows');
+}
+// Skip if being run by root
+$filename = dirname(__FILE__)."/006_root_check.tmp";
+$fp = fopen($filename, 'w');
+fclose($fp);
+if(fileowner($filename) == 0) {
+ unlink ($filename);
+ die('skip cannot be run as root');
+}
+
+unlink($filename);
+
+?>
+--FILE--
+<?php
+/*
+ Prototype: int fileperms ( string $filename );
+ Description: Returns the permissions on the file, or FALSE in case of an error
+
+ Prototype: bool chmod ( string $filename, int $mode );
+ Description: Attempts to change the mode of the file specified by
+ filename to that given in mode
+*/
+
+/* Testing with miscellaneous Permission */
+
+echo "*** Testing fileperms() & chmod() : usage variations ***\n";
+
+$file_name = dirname(__FILE__)."/006_variation2.tmp";
+$file_handle = fopen($file_name, "w");
+fclose($file_handle);
+$dir_name = dirname(__FILE__)."/006_variation2";
+mkdir($dir_name);
+
+echo "\n*** Testing fileperms(), chmod() with miscellaneous permissions ***\n";
+$perms_array = array(
+ /* testing sticky bit */
+ 07777,
+ 00000,
+ 01000,
+ 011111,
+ /* negative values as permission */
+ -0777, // permissions will be given as 2's complement form of -0777
+ -07777, // permissions will be given as 2's complement form of -07777
+
+ /* decimal values as permission */
+ 777, // permissions will be given as octal equivalent value of 777
+ 7777, // permissions will be given as octal equivalent value of 7777
+ -7777, // permissions are given as 2's complement of octal equivalent of 7777
+
+ /* hex value as permission */
+ 0x777, // permissions will be given as ocatal equivalent value of 0x777
+ 0x7777,
+
+ /* strings notation of permission, wont work properly */
+ "r+w",
+ "r+w+x",
+ "u+rwx",
+ "u+rwx, g+rw, o+wx"
+);
+
+$count = 1;
+foreach($perms_array as $permission) {
+ echo "-- Iteration $count --\n";
+ var_dump( chmod($file_name, $permission) );
+ printf("%o", fileperms($file_name) );
+ echo "\n";
+ clearstatcache();
+
+ var_dump( chmod($dir_name, $permission) );
+ printf("%o", fileperms($dir_name) );
+ echo "\n";
+ clearstatcache();
+ $count++;
+}
+echo "*** Done ***\n";
+?>
+--CLEAN--
+<?php
+chmod(dirname(__FILE__)."/006_variation2.tmp", 0777);
+chmod(dirname(__FILE__)."/006_variation2", 0777);
+unlink(dirname(__FILE__)."/006_variation2.tmp");
+rmdir(dirname(__FILE__)."/006_variation2");
+?>
+--EXPECTF--
+*** Testing fileperms() & chmod() : usage variations ***
+
+*** Testing fileperms(), chmod() with miscellaneous permissions ***
+-- Iteration 1 --
+bool(true)
+107777
+bool(true)
+47777
+-- Iteration 2 --
+bool(true)
+100000
+bool(true)
+40000
+-- Iteration 3 --
+bool(true)
+101000
+bool(true)
+41000
+-- Iteration 4 --
+bool(true)
+101111
+bool(true)
+41111
+-- Iteration 5 --
+bool(true)
+107001
+bool(true)
+47001
+-- Iteration 6 --
+bool(true)
+100001
+bool(true)
+40001
+-- Iteration 7 --
+bool(true)
+101411
+bool(true)
+41411
+-- Iteration 8 --
+bool(true)
+107141
+bool(true)
+47141
+-- Iteration 9 --
+bool(true)
+100637
+bool(true)
+40637
+-- Iteration 10 --
+bool(true)
+103567
+bool(true)
+43567
+-- Iteration 11 --
+bool(true)
+103567
+bool(true)
+43567
+-- Iteration 12 --
+
+Warning: chmod() expects parameter 2 to be long, string given in %s on line %d
+NULL
+103567
+
+Warning: chmod() expects parameter 2 to be long, string given in %s on line %d
+NULL
+43567
+-- Iteration 13 --
+
+Warning: chmod() expects parameter 2 to be long, string given in %s on line %d
+NULL
+103567
+
+Warning: chmod() expects parameter 2 to be long, string given in %s on line %d
+NULL
+43567
+-- Iteration 14 --
+
+Warning: chmod() expects parameter 2 to be long, string given in %s on line %d
+NULL
+103567
+
+Warning: chmod() expects parameter 2 to be long, string given in %s on line %d
+NULL
+43567
+-- Iteration 15 --
+
+Warning: chmod() expects parameter 2 to be long, string given in %s on line %d
+NULL
+103567
+
+Warning: chmod() expects parameter 2 to be long, string given in %s on line %d
+NULL
+43567
+*** Done ***
diff --git a/ext/standard/tests/file/007_basic.phpt b/ext/standard/tests/file/007_basic.phpt
new file mode 100644
index 0000000..eafadf7
--- /dev/null
+++ b/ext/standard/tests/file/007_basic.phpt
@@ -0,0 +1,412 @@
+--TEST--
+Test fopen(), fclose() & feof() functions: basic functionality
+--FILE--
+<?php
+/*
+ Prototype: resource fopen(string $filename, string $mode
+ [, bool $use_include_path [, resource $context]] );
+ Description: Opens file or URL.
+
+ Prototype: bool fclose ( resource $handle );
+ Description: Closes an open file pointer
+
+ Prototype: bool feof ( resource $handle );
+ Description: Tests for end-of-file on a file pointer
+*/
+
+echo "*** Testing basic operations of fopen() and fclose() functions ***\n";
+$modes = array(
+ "w",
+ "wb",
+ "wt",
+ "w+",
+ "w+b",
+ "w+t",
+
+ "r",
+ "rb",
+ "rt",
+ "r+",
+ "r+b",
+ "r+t",
+
+ "a",
+ "ab",
+ "at",
+ "a+",
+ "a+t",
+ "a+b"
+);
+
+for( $i=0; $i<count($modes); $i++ ) {
+ echo "\n-- Iteration with mode '$modes[$i]' --\n";
+
+ $filename = dirname(__FILE__)."/007_basic.tmp";
+ // check fopen()
+ $handle = fopen($filename, $modes[$i]);
+ var_dump($handle );
+ var_dump( ftell($handle) );
+ var_dump( feof($handle) );
+
+ // check fclose()
+ var_dump( fclose($handle) );
+ var_dump( $handle );
+ // confirm the closure, using ftell() and feof(), expect, false
+ var_dump( ftell($handle) );
+ var_dump( feof($handle) );
+}
+
+// remove the temp file
+unlink($filename);
+
+$x_modes = array(
+ "x",
+ "xb",
+ "xt",
+ "x+",
+ "x+b",
+ "x+t"
+);
+
+for( $i=0; $i<count($x_modes); $i++ ) {
+ echo "\n-- Iteration with mode '$x_modes[$i]' --\n";
+ $handle = fopen($filename, $x_modes[$i]);
+ var_dump($handle );
+ var_dump( ftell($handle) );
+ var_dump( feof($handle) );
+
+ // check fclose()
+ var_dump( fclose($handle) );
+ var_dump( $handle );
+ // confirm the closure, using ftell() and feof(), expect, false
+ var_dump( ftell($handle) );
+ var_dump( feof($handle) );
+ var_dump( $handle );
+
+ // remove the file
+ unlink( $filename );
+}
+
+echo "\n*** Done ***\n";
+--EXPECTF--
+*** Testing basic operations of fopen() and fclose() functions ***
+
+-- Iteration with mode 'w' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+-- Iteration with mode 'wb' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+-- Iteration with mode 'wt' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+-- Iteration with mode 'w+' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+-- Iteration with mode 'w+b' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+-- Iteration with mode 'w+t' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+-- Iteration with mode 'r' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+-- Iteration with mode 'rb' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+-- Iteration with mode 'rt' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+-- Iteration with mode 'r+' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+-- Iteration with mode 'r+b' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+-- Iteration with mode 'r+t' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+-- Iteration with mode 'a' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+-- Iteration with mode 'ab' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+-- Iteration with mode 'at' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+-- Iteration with mode 'a+' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+-- Iteration with mode 'a+t' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+-- Iteration with mode 'a+b' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+-- Iteration with mode 'x' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+resource(%d) of type (Unknown)
+
+-- Iteration with mode 'xb' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+resource(%d) of type (Unknown)
+
+-- Iteration with mode 'xt' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+resource(%d) of type (Unknown)
+
+-- Iteration with mode 'x+' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+resource(%d) of type (Unknown)
+
+-- Iteration with mode 'x+b' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+resource(%d) of type (Unknown)
+
+-- Iteration with mode 'x+t' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+resource(%d) of type (Unknown)
+
+*** Done ***
diff --git a/ext/standard/tests/file/007_error.phpt b/ext/standard/tests/file/007_error.phpt
new file mode 100644
index 0000000..a369c9d
--- /dev/null
+++ b/ext/standard/tests/file/007_error.phpt
@@ -0,0 +1,185 @@
+--TEST--
+Test fopen, fclose() & feof() functions: error conditions
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/*
+ Prototype: resource fopen(string $filename, string $mode
+ [, bool $use_include_path [, resource $context]] );
+ Description: Opens file or URL.
+
+ Prototype: bool fclose ( resource $handle );
+ Description: Closes an open file pointer
+
+ Prototype: bool feof ( resource $handle )
+ Description: Returns TRUE if the file pointer is at EOF or an error occurs
+ (including socket timeout); otherwise returns FALSE.
+*/
+
+echo "*** Testing error conditions for fopen(), fclsoe() & feof() ***\n";
+/* Arguments less than minimum no.of args */
+
+// fopen ()
+var_dump(fopen(__FILE__)); // one valid argument
+var_dump(fopen()); // zero argument
+
+// fclose()
+$fp = fopen(__FILE__, "r");
+fclose($fp);
+var_dump( fclose($fp) ); // closed handle
+var_dump( fclose(__FILE__) ); // invalid handle
+var_dump( fclose() ); // zero argument
+
+//feof()
+var_dump( feof($fp) ); // closed handle
+var_dump( feof(__FILE__) ); // invalid handle
+var_dump( feof() ); //zero argument
+
+/* Arguments greater than maximum no.of ags */
+var_dump(fopen(__FILE__, "r", TRUE, "www.example.com", 100));
+
+$fp = fopen(__FILE__, "r");
+var_dump( fclose($fp, "handle") );
+
+var_dump( feof($fp, "handle"));
+fclose($fp);
+
+/* test invalid arguments : non-resources */
+echo "-- Testing fopen(), fclose() & feof() with invalid arguments --\n";
+$invalid_args = array (
+ "string",
+ 10,
+ 10.5,
+ true,
+ array(1,2,3),
+ new stdclass,
+ NULL,
+ ""
+);
+
+/* loop to test fclose with different invalid type of args */
+for($loop_counter = 1; $loop_counter <= count($invalid_args); $loop_counter++) {
+ echo "-- Iteration $loop_counter --\n";
+ var_dump( fopen($invalid_args[$loop_counter - 1], "r") );
+ var_dump( fclose($invalid_args[$loop_counter - 1]) );
+ var_dump( feof($invalid_args[$loop_counter - 1]) );
+}
+
+?>
+--EXPECTF--
+*** Testing error conditions for fopen(), fclsoe() & feof() ***
+
+Warning: fopen() expects at least 2 parameters, 1 given in %s on line %d
+bool(false)
+
+Warning: fopen() expects at least 2 parameters, 0 given in %s on line %d
+bool(false)
+
+Warning: fclose(): 5 is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: fclose() expects parameter 1 to be resource, string given in %s on line %d
+bool(false)
+
+Warning: fclose() expects exactly 1 parameter, 0 given in %s on line %d
+bool(false)
+
+Warning: feof(): 5 is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof() expects parameter 1 to be resource, string given in %s on line %d
+bool(false)
+
+Warning: feof() expects exactly 1 parameter, 0 given in %s on line %d
+bool(false)
+
+Warning: fopen() expects at most 4 parameters, 5 given in %s on line %d
+bool(false)
+
+Warning: fclose() expects exactly 1 parameter, 2 given in %s on line %d
+bool(false)
+
+Warning: feof() expects exactly 1 parameter, 2 given in %s on line %d
+bool(false)
+-- Testing fopen(), fclose() & feof() with invalid arguments --
+-- Iteration 1 --
+
+Warning: fopen(string): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+Warning: fclose() expects parameter 1 to be resource, string given in %s on line %d
+bool(false)
+
+Warning: feof() expects parameter 1 to be resource, string given in %s on line %d
+bool(false)
+-- Iteration 2 --
+
+Warning: fopen(10): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+Warning: fclose() expects parameter 1 to be resource, integer given in %s on line %d
+bool(false)
+
+Warning: feof() expects parameter 1 to be resource, integer given in %s on line %d
+bool(false)
+-- Iteration 3 --
+
+Warning: fopen(10.5): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+Warning: fclose() expects parameter 1 to be resource, double given in %s on line %d
+bool(false)
+
+Warning: feof() expects parameter 1 to be resource, double given in %s on line %d
+bool(false)
+-- Iteration 4 --
+
+Warning: fopen(1): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+Warning: fclose() expects parameter 1 to be resource, boolean given in %s on line %d
+bool(false)
+
+Warning: feof() expects parameter 1 to be resource, boolean given in %s on line %d
+bool(false)
+-- Iteration 5 --
+
+Warning: fopen() expects parameter 1 to be a valid path, array given in %s on line %d
+bool(false)
+
+Warning: fclose() expects parameter 1 to be resource, array given in %s on line %d
+bool(false)
+
+Warning: feof() expects parameter 1 to be resource, array given in %s on line %d
+bool(false)
+-- Iteration 6 --
+
+Warning: fopen() expects parameter 1 to be a valid path, object given in %s on line %d
+bool(false)
+
+Warning: fclose() expects parameter 1 to be resource, object given in %s on line %d
+bool(false)
+
+Warning: feof() expects parameter 1 to be resource, object given in %s on line %d
+bool(false)
+-- Iteration 7 --
+
+Warning: fopen(): Filename cannot be empty in %s on line %d
+bool(false)
+
+Warning: fclose() expects parameter 1 to be resource, null given in %s on line %d
+bool(false)
+
+Warning: feof() expects parameter 1 to be resource, null given in %s on line %d
+bool(false)
+-- Iteration 8 --
+
+Warning: fopen(): Filename cannot be empty in %s on line %d
+bool(false)
+
+Warning: fclose() expects parameter 1 to be resource, string given in %s on line %d
+bool(false)
+
+Warning: feof() expects parameter 1 to be resource, string given in %s on line %d
+bool(false)
diff --git a/ext/standard/tests/file/007_variation1.phpt b/ext/standard/tests/file/007_variation1.phpt
new file mode 100644
index 0000000..6cba146
--- /dev/null
+++ b/ext/standard/tests/file/007_variation1.phpt
@@ -0,0 +1,54 @@
+--TEST--
+Test fopen and fclose() functions - usage variations - "r" mode
+--FILE--
+<?php
+/*
+ fopen() function:
+ Prototype: resource fopen(string $filename, string $mode
+ [, bool $use_include_path [, resource $context]] );
+ Description: Opens file or URL.
+*/
+/*
+ fclose() function:
+ Prototype: bool fclose ( resource $handle );
+ Description: Closes an open file pointer
+*/
+
+/* Test fopen() and fclose(): Opening the file in "r" mode,
+ checking for the file creation, write & read operations,
+ checking for the file pointer position,
+ and fclose function
+*/
+$file_path = dirname(__FILE__);
+require($file_path."/file.inc");
+
+create_files($file_path, 1, "text_with_new_line", 0755, 20, "w", "007_variation", 1, "bytes");
+$file = $file_path."/007_variation1.tmp";
+$string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789";
+
+echo "*** Test fopen() & fclose() functions: with 'r' mode ***\n";
+$file_handle = fopen($file, "r"); //opening the file in "r" mode
+var_dump($file_handle); //Check for the content of handle
+var_dump( get_resource_type($file_handle) ); //Check for the type of resource
+var_dump( ftell($file_handle) ); //Initial position of file pointer
+var_dump( fread($file_handle, 100) ); //Check for read operation
+var_dump( fwrite($file_handle, $string) ); //Check for write operation; fails; expected: 0 bytes
+var_dump( fclose($file_handle) ); //Check for close operation on the file handle
+var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation
+echo "*** Done ***\n";
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/007_variation1.tmp");
+?>
+--EXPECTF--
+*** Test fopen() & fclose() functions: with 'r' mode ***
+resource(%d) of type (stream)
+string(6) "stream"
+int(0)
+string(20) "line
+line of text
+li"
+int(0)
+bool(true)
+string(7) "Unknown"
+*** Done ***
diff --git a/ext/standard/tests/file/007_variation10.phpt b/ext/standard/tests/file/007_variation10.phpt
new file mode 100644
index 0000000..c9f3e01
--- /dev/null
+++ b/ext/standard/tests/file/007_variation10.phpt
@@ -0,0 +1,58 @@
+--TEST--
+Test fopen and fclose() functions - usage variations - "r+t" mode
+--FILE--
+<?php
+/*
+ fopen() function:
+ Prototype: resource fopen(string $filename, string $mode
+ [, bool $use_include_path [, resource $context]] );
+ Description: Opens file or URL.
+*/
+/*
+ fclose() function:
+ Prototype: bool fclose ( resource $handle );
+ Description: Closes an open file pointer
+*/
+
+/* Test fopen() and fclose(): Opening the file in "r+t" mode,
+ checking for the file creation, write & read operations,
+ checking for the file pointer position,
+ and fclose function
+*/
+$file_path = dirname(__FILE__);
+require($file_path."/file.inc");
+
+create_files($file_path, 1, "text_with_new_line", 0755, 20, "w", "007_variation", 10, "bytes");
+$file = $file_path."/007_variation10.tmp";
+$string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789";
+
+echo "*** Test fopen() & fclose() functions: with 'r+t' mode ***\n";
+$file_handle = fopen($file, "r+t"); //opening the file in "r+t" mode
+var_dump($file_handle); //Check for the content of handle
+var_dump( get_resource_type($file_handle) ); //Check for the type of resource
+var_dump( ftell($file_handle) ); //Initial file pointer position, expected at the begining of the file
+var_dump( fread($file_handle, 100) ); //Check for read operation
+var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the end of the file
+var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string
+var_dump( ftell($file_handle) ); //File pointer position after write operation, expected at the end of the file
+var_dump( fclose($file_handle) ); //Check for close operation on the file handle
+var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation
+echo "*** Done ***\n";
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/007_variation10.tmp");
+?>
+--EXPECTF--
+*** Test fopen() & fclose() functions: with 'r+t' mode ***
+resource(%d) of type (stream)
+string(6) "stream"
+int(0)
+string(20) "line
+line of text
+li"
+int(20)
+int(37)
+int(57)
+bool(true)
+string(7) "Unknown"
+*** Done ***
diff --git a/ext/standard/tests/file/007_variation11-win32.phpt b/ext/standard/tests/file/007_variation11-win32.phpt
new file mode 100644
index 0000000..d9c6e83
--- /dev/null
+++ b/ext/standard/tests/file/007_variation11-win32.phpt
@@ -0,0 +1,76 @@
+--TEST--
+Test fopen and fclose() functions - usage variations - "wt" mode
+--SKIPIF--
+<?php
+if( substr(PHP_OS, 0, 3) != "WIN" )
+ die('skip Run only on Windows');
+?>
+--FILE--
+<?php
+/*
+ fopen() function:
+ Prototype: resource fopen(string $filename, string $mode
+ [, bool $use_include_path [, resource $context]] );
+ Description: Opens file or URL.
+*/
+/*
+ fclose() function:
+ Prototype: bool fclose ( resource $handle );
+ Description: Closes an open file pointer
+*/
+
+/* Test fopen() and fclose(): Opening the file in "wt" mode,
+ checking for the file creation, write & read operations,
+ checking for the file pointer position,
+ checking for the file truncation when trying to open an existing file in "wt" mode,
+ and fclose function
+*/
+$file_path = dirname(__FILE__);
+require($file_path."/file.inc");
+
+create_files($file_path, 1, "text_with_new_line", 0755, 20, "wt", "007_variation", 11, "bytes");
+$file = $file_path."/007_variation11.tmp";
+$string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789";
+
+echo "*** Test fopen() & fclose() functions: with 'wt' mode ***\n";
+$file_handle = fopen($file, "wt"); //opening the file "wt" mode
+var_dump($file_handle); //Check for the content of handle
+var_dump( get_resource_type($file_handle) ); //Check for the type of resource
+var_dump( ftell($file_handle) ); //Initial file pointer position, expected at the begining of the file
+var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string
+var_dump( ftell($file_handle) ); //File pointer position after write operation, expected at the end of the file
+rewind($file_handle);
+var_dump( fread($file_handle, 100) ); //Check for read operation; fails; expected: empty string
+var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the begining of the file
+var_dump( fclose($file_handle) ); //Check for close operation on the file handle
+var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation
+
+var_dump( filesize($file) ); //Check for size of existing data file before opening the file in "wt" mode again, expected: size of content
+clearstatcache();
+fclose( fopen($file, "wt") ); //Opening the existing data file again in "wt" mode
+var_dump( filesize($file) ); //Check for size of existing data file after opening the file in "wt" mode again, expected: 0 bytes
+clearstatcache();
+
+unlink($file); //Deleting the file
+fclose( fopen($file, "wt") ); //Opening the non-existing file in "wt" mode, which will be created
+var_dump( file_exists($file) ); //Check for the existance of file
+echo "*** Done ***\n";
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/007_variation11.tmp");
+?>
+--EXPECTF--
+*** Test fopen() & fclose() functions: with 'wt' mode ***
+resource(%d) of type (stream)
+string(6) "stream"
+int(0)
+int(37)
+int(37)
+string(0) ""
+int(0)
+bool(true)
+string(7) "Unknown"
+int(39)
+int(0)
+bool(true)
+*** Done ***
diff --git a/ext/standard/tests/file/007_variation11.phpt b/ext/standard/tests/file/007_variation11.phpt
new file mode 100644
index 0000000..0656c64
--- /dev/null
+++ b/ext/standard/tests/file/007_variation11.phpt
@@ -0,0 +1,76 @@
+--TEST--
+Test fopen and fclose() functions - usage variations - "wt" mode
+--SKIPIF--
+<?php
+if( substr(PHP_OS, 0, 3) == "WIN" )
+ die('skip Do not run on Windows');
+?>
+--FILE--
+<?php
+/*
+ fopen() function:
+ Prototype: resource fopen(string $filename, string $mode
+ [, bool $use_include_path [, resource $context]] );
+ Description: Opens file or URL.
+*/
+/*
+ fclose() function:
+ Prototype: bool fclose ( resource $handle );
+ Description: Closes an open file pointer
+*/
+
+/* Test fopen() and fclose(): Opening the file in "wt" mode,
+ checking for the file creation, write & read operations,
+ checking for the file pointer position,
+ checking for the file truncation when trying to open an existing file in "wt" mode,
+ and fclose function
+*/
+$file_path = dirname(__FILE__);
+require($file_path."/file.inc");
+
+create_files($file_path, 1, "text_with_new_line", 0755, 20, "wt", "007_variation", 11, "bytes");
+$file = $file_path."/007_variation11.tmp";
+$string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789";
+
+echo "*** Test fopen() & fclose() functions: with 'wt' mode ***\n";
+$file_handle = fopen($file, "wt"); //opening the file "wt" mode
+var_dump($file_handle); //Check for the content of handle
+var_dump( get_resource_type($file_handle) ); //Check for the type of resource
+var_dump( ftell($file_handle) ); //Initial file pointer position, expected at the begining of the file
+var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string
+var_dump( ftell($file_handle) ); //File pointer position after write operation, expected at the end of the file
+rewind($file_handle);
+var_dump( fread($file_handle, 100) ); //Check for read operation; fails; expected: empty string
+var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the begining of the file
+var_dump( fclose($file_handle) ); //Check for close operation on the file handle
+var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation
+
+var_dump( filesize($file) ); //Check for size of existing data file before opening the file in "wt" mode again, expected: size of content
+clearstatcache();
+fclose( fopen($file, "wt") ); //Opening the existing data file again in "wt" mode
+var_dump( filesize($file) ); //Check for size of existing data file after opening the file in "wt" mode again, expected: 0 bytes
+clearstatcache();
+
+unlink($file); //Deleting the file
+fclose( fopen($file, "wt") ); //Opening the non-existing file in "wt" mode, which will be created
+var_dump( file_exists($file) ); //Check for the existance of file
+echo "*** Done ***\n";
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/007_variation11.tmp");
+?>
+--EXPECTF--
+*** Test fopen() & fclose() functions: with 'wt' mode ***
+resource(%d) of type (stream)
+string(6) "stream"
+int(0)
+int(37)
+int(37)
+string(0) ""
+int(0)
+bool(true)
+string(7) "Unknown"
+int(37)
+int(0)
+bool(true)
+*** Done ***
diff --git a/ext/standard/tests/file/007_variation12-win32.phpt b/ext/standard/tests/file/007_variation12-win32.phpt
new file mode 100644
index 0000000..0fb9ad8
--- /dev/null
+++ b/ext/standard/tests/file/007_variation12-win32.phpt
@@ -0,0 +1,78 @@
+--TEST--
+Test fopen and fclose() functions - usage variations - "w+t" mode
+--SKIPIF--
+<?php
+if( substr(PHP_OS, 0, 3) != "WIN" )
+ die('skip Run only on Windows');
+?>
+--FILE--
+<?php
+/*
+ fopen() function:
+ Prototype: resource fopen(string $filename, string $mode
+ [, bool $use_include_path [, resource $context]] );
+ Description: Opens file or URL.
+*/
+/*
+ fclose() function:
+ Prototype: bool fclose ( resource $handle );
+ Description: Closes an open file pointer
+*/
+
+/* Test fopen() and fclose(): Opening the file in "w+t" mode,
+ checking for the file creation, write & read operations,
+ checking for the file pointer position,
+ checking for the file truncation when trying to open an existing file in "w+t" mode,
+ and fclose function
+*/
+$file_path = dirname(__FILE__);
+require($file_path."/file.inc");
+
+create_files($file_path, 1, "text_with_new_line", 0755, 20, "w", "007_variation", 12, "bytes");
+$file = $file_path."/007_variation12.tmp";
+$string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789";
+
+echo "*** Test fopen() & fclose() functions: with 'w+t' mode ***\n";
+$file_handle = fopen($file, "w+t"); //opening the file "w+t" mode
+var_dump($file_handle); //Check for the content of handle
+var_dump( get_resource_type($file_handle) ); //Check for the type of resource
+var_dump( ftell($file_handle) ); //Initial file pointer position, expected at the begining of the file
+var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string
+var_dump( ftell($file_handle) ); //File pointer position after write operation, expected at the end of the file
+rewind($file_handle);
+var_dump( fread($file_handle, 100) ); //Check for read operation; passes; expected: content of file
+var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the end of the file
+var_dump( fclose($file_handle) ); //Check for close operation on the file handle
+var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation
+
+var_dump( filesize($file) ); //Check for size of existing data file before opening the file in "w+t" mode again, expected: size of content
+clearstatcache();
+fclose( fopen($file, "w+t") ); //Opening the existing data file again in "w+t" mode
+var_dump( filesize($file) ); //Check for size of existing data file after opening the file in "w+t" mode again, expected: 0 bytes
+clearstatcache();
+
+unlink($file); //Deleting the file
+fclose( fopen($file, "w+t") ); //Opening the non-existing file in "w+t" mode, which will be created
+var_dump( file_exists($file) ); //Check for the existance of file
+echo "*** Done ***\n";
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/007_variation12.tmp");
+?>
+--EXPECTF--
+*** Test fopen() & fclose() functions: with 'w+t' mode ***
+resource(%d) of type (stream)
+string(6) "stream"
+int(0)
+int(37)
+int(37)
+string(37) "abcdefghij
+mnopqrst uvwxyz
+0123456789"
+int(37)
+bool(true)
+string(7) "Unknown"
+int(39)
+int(0)
+bool(true)
+*** Done ***
diff --git a/ext/standard/tests/file/007_variation12.phpt b/ext/standard/tests/file/007_variation12.phpt
new file mode 100644
index 0000000..44488fa
--- /dev/null
+++ b/ext/standard/tests/file/007_variation12.phpt
@@ -0,0 +1,78 @@
+--TEST--
+Test fopen and fclose() functions - usage variations - "w+t" mode
+--SKIPIF--
+<?php
+if( substr(PHP_OS, 0, 3) == "WIN" )
+ die('skip Do not run on Windows');
+?>
+--FILE--
+<?php
+/*
+ fopen() function:
+ Prototype: resource fopen(string $filename, string $mode
+ [, bool $use_include_path [, resource $context]] );
+ Description: Opens file or URL.
+*/
+/*
+ fclose() function:
+ Prototype: bool fclose ( resource $handle );
+ Description: Closes an open file pointer
+*/
+
+/* Test fopen() and fclose(): Opening the file in "w+t" mode,
+ checking for the file creation, write & read operations,
+ checking for the file pointer position,
+ checking for the file truncation when trying to open an existing file in "w+t" mode,
+ and fclose function
+*/
+$file_path = dirname(__FILE__);
+require($file_path."/file.inc");
+
+create_files($file_path, 1, "text_with_new_line", 0755, 20, "w", "007_variation", 12, "bytes");
+$file = $file_path."/007_variation12.tmp";
+$string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789";
+
+echo "*** Test fopen() & fclose() functions: with 'w+t' mode ***\n";
+$file_handle = fopen($file, "w+t"); //opening the file "w+t" mode
+var_dump($file_handle); //Check for the content of handle
+var_dump( get_resource_type($file_handle) ); //Check for the type of resource
+var_dump( ftell($file_handle) ); //Initial file pointer position, expected at the begining of the file
+var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string
+var_dump( ftell($file_handle) ); //File pointer position after write operation, expected at the end of the file
+rewind($file_handle);
+var_dump( fread($file_handle, 100) ); //Check for read operation; passes; expected: content of file
+var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the end of the file
+var_dump( fclose($file_handle) ); //Check for close operation on the file handle
+var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation
+
+var_dump( filesize($file) ); //Check for size of existing data file before opening the file in "w+t" mode again, expected: size of content
+clearstatcache();
+fclose( fopen($file, "w+t") ); //Opening the existing data file again in "w+t" mode
+var_dump( filesize($file) ); //Check for size of existing data file after opening the file in "w+t" mode again, expected: 0 bytes
+clearstatcache();
+
+unlink($file); //Deleting the file
+fclose( fopen($file, "w+t") ); //Opening the non-existing file in "w+t" mode, which will be created
+var_dump( file_exists($file) ); //Check for the existance of file
+echo "*** Done ***\n";
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/007_variation12.tmp");
+?>
+--EXPECTF--
+*** Test fopen() & fclose() functions: with 'w+t' mode ***
+resource(%d) of type (stream)
+string(6) "stream"
+int(0)
+int(37)
+int(37)
+string(37) "abcdefghij
+mnopqrst uvwxyz
+0123456789"
+int(37)
+bool(true)
+string(7) "Unknown"
+int(37)
+int(0)
+bool(true)
+*** Done ***
diff --git a/ext/standard/tests/file/007_variation13-win32.phpt b/ext/standard/tests/file/007_variation13-win32.phpt
new file mode 100644
index 0000000..736b101
--- /dev/null
+++ b/ext/standard/tests/file/007_variation13-win32.phpt
@@ -0,0 +1,65 @@
+--TEST--
+Test fopen and fclose() functions - usage variations - "at" mode
+--SKIPIF--
+<?php
+if( substr(PHP_OS, 0, 3) != "WIN" )
+ die('skip Run only on Windows');
+?>
+--FILE--
+<?php
+/*
+ fopen() function:
+ Prototype: resource fopen(string $filename, string $mode
+ [, bool $use_include_path [, resource $context]] );
+ Description: Opens file or URL.
+*/
+/*
+ fclose() function:
+ Prototype: bool fclose ( resource $handle );
+ Description: Closes an open file pointer
+*/
+
+/* Test fopen() and fclose(): Opening the file in "at" mode,
+ checking for the file creation, write & read operations,
+ checking for the file pointer position,
+ and fclose function
+*/
+$file_path = dirname(__FILE__);
+require($file_path."/file.inc");
+
+create_files($file_path, 1, "text_with_new_line", 0755, 20, "w", "007_variation", 13, "bytes");
+$file = $file_path."/007_variation13.tmp";
+$string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789";
+
+echo "*** Test fopen() & fclose() functions: with 'at' mode ***\n";
+$file_handle = fopen($file, "at"); //opening the file "at" mode
+var_dump($file_handle); //Check for the content of handle
+var_dump( get_resource_type($file_handle) ); //Check for the type of resource
+var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string
+rewind($file_handle);
+var_dump( fread($file_handle, 100) ); //Check for read operation; fails; expected: empty string
+var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the end of the file
+var_dump( fclose($file_handle) ); //Check for close operation on the file handle
+var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation
+var_dump( filesize($file) ); //Check that data hasn't over written; Expected: Size of (initial data + newly added data)
+
+unlink($file); //Deleting the file
+fclose( fopen($file, "at") ); //Opening the non-existing file in "at" mode, which will be created
+var_dump( file_exists($file) ); //Check for the existance of file
+echo "*** Done ***\n";
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/007_variation13.tmp");
+?>
+--EXPECTF--
+*** Test fopen() & fclose() functions: with 'at' mode ***
+resource(%d) of type (stream)
+string(6) "stream"
+int(37)
+string(0) ""
+int(0)
+bool(true)
+string(7) "Unknown"
+int(59)
+bool(true)
+*** Done ***
diff --git a/ext/standard/tests/file/007_variation13.phpt b/ext/standard/tests/file/007_variation13.phpt
new file mode 100644
index 0000000..0cb48d3
--- /dev/null
+++ b/ext/standard/tests/file/007_variation13.phpt
@@ -0,0 +1,65 @@
+--TEST--
+Test fopen and fclose() functions - usage variations - "at" mode
+--SKIPIF--
+<?php
+if( substr(PHP_OS, 0, 3) == "WIN" )
+ die('skip Do not run on Windows');
+?>
+--FILE--
+<?php
+/*
+ fopen() function:
+ Prototype: resource fopen(string $filename, string $mode
+ [, bool $use_include_path [, resource $context]] );
+ Description: Opens file or URL.
+*/
+/*
+ fclose() function:
+ Prototype: bool fclose ( resource $handle );
+ Description: Closes an open file pointer
+*/
+
+/* Test fopen() and fclose(): Opening the file in "at" mode,
+ checking for the file creation, write & read operations,
+ checking for the file pointer position,
+ and fclose function
+*/
+$file_path = dirname(__FILE__);
+require($file_path."/file.inc");
+
+create_files($file_path, 1, "text_with_new_line", 0755, 20, "w", "007_variation", 13, "bytes");
+$file = $file_path."/007_variation13.tmp";
+$string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789";
+
+echo "*** Test fopen() & fclose() functions: with 'at' mode ***\n";
+$file_handle = fopen($file, "at"); //opening the file "at" mode
+var_dump($file_handle); //Check for the content of handle
+var_dump( get_resource_type($file_handle) ); //Check for the type of resource
+var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string
+rewind($file_handle);
+var_dump( fread($file_handle, 100) ); //Check for read operation; fails; expected: empty string
+var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the end of the file
+var_dump( fclose($file_handle) ); //Check for close operation on the file handle
+var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation
+var_dump( filesize($file) ); //Check that data hasn't over written; Expected: Size of (initial data + newly added data)
+
+unlink($file); //Deleting the file
+fclose( fopen($file, "at") ); //Opening the non-existing file in "at" mode, which will be created
+var_dump( file_exists($file) ); //Check for the existance of file
+echo "*** Done ***\n";
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/007_variation13.tmp");
+?>
+--EXPECTF--
+*** Test fopen() & fclose() functions: with 'at' mode ***
+resource(%d) of type (stream)
+string(6) "stream"
+int(37)
+string(0) ""
+int(0)
+bool(true)
+string(7) "Unknown"
+int(57)
+bool(true)
+*** Done ***
diff --git a/ext/standard/tests/file/007_variation14.phpt b/ext/standard/tests/file/007_variation14.phpt
new file mode 100644
index 0000000..ed76ab4
--- /dev/null
+++ b/ext/standard/tests/file/007_variation14.phpt
@@ -0,0 +1,62 @@
+--TEST--
+Test fopen and fclose() functions - usage variations - "a+t" mode
+--FILE--
+<?php
+/*
+ fopen() function:
+ Prototype: resource fopen(string $filename, string $mode
+ [, bool $use_include_path [, resource $context]] );
+ Description: Opens file or URL.
+*/
+/*
+ fclose() function:
+ Prototype: bool fclose ( resource $handle );
+ Description: Closes an open file pointer
+*/
+
+/* Test fopen() and fclose(): Opening the file in "a+t" mode,
+ checking for the file creation, write & read operations,
+ checking for the file pointer position,
+ and fclose function
+*/
+$file_path = dirname(__FILE__);
+require($file_path."/file.inc");
+
+create_files($file_path, 1, "text_with_new_line", 0755, 20, "w", "007_variation", 14, "bytes");
+$file = $file_path."/007_variation14.tmp";
+$string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789";
+
+echo "*** Test fopen() & fclose() functions: with 'a+t' mode ***\n";
+$file_handle = fopen($file, "a+t"); //opening the file "a+t" mode
+var_dump($file_handle); //Check for the content of handle
+var_dump( get_resource_type($file_handle) ); //Check for the type of resource
+var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string
+rewind($file_handle);
+var_dump( fread($file_handle, 100) ); //Check for read operation; passes; expected: content of file
+var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the end of the file
+var_dump( fclose($file_handle) ); //Check for close operation on the file handle
+var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation
+
+unlink($file); //Deleting the file
+fclose( fopen($file, "a+t") ); //Opening the non-existing file in "a+t" mode, which will be created
+var_dump( file_exists($file) ); //Check for the existance of file
+echo "*** Done ***\n";
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/007_variation14.tmp");
+?>
+--EXPECTF--
+*** Test fopen() & fclose() functions: with 'a+t' mode ***
+resource(%d) of type (stream)
+string(6) "stream"
+int(37)
+string(57) "line
+line of text
+liabcdefghij
+mnopqrst uvwxyz
+0123456789"
+int(57)
+bool(true)
+string(7) "Unknown"
+bool(true)
+*** Done ***
diff --git a/ext/standard/tests/file/007_variation15.phpt b/ext/standard/tests/file/007_variation15.phpt
new file mode 100644
index 0000000..11eed0d
--- /dev/null
+++ b/ext/standard/tests/file/007_variation15.phpt
@@ -0,0 +1,58 @@
+--TEST--
+Test fopen and fclose() functions - usage variations - "xt" mode
+--FILE--
+<?php
+/*
+ fopen() function:
+ Prototype: resource fopen(string $filename, string $mode
+ [, bool $use_include_path [, resource $context]] );
+ Description: Opens file or URL.
+*/
+/*
+ fclose() function:
+ Prototype: bool fclose ( resource $handle );
+ Description: Closes an open file pointer
+*/
+
+/* Test fopen() and fclose(): Opening the file in "xt" mode,
+ checking for the file creation, write & read operations,
+ checking for the file pointer position,
+ checking for the warning msg when trying to open an existing file in "xt" mode,
+ and fclose function
+*/
+$file_path = dirname(__FILE__);
+$string = b"abcdefghij\nmnopqrst\tuvwxyz\n0123456789";
+$file = $file_path."/007_variation15.tmp";
+
+echo "*** Test fopen() & fclose() functions: with 'xt' mode ***\n";
+$file_handle = fopen($file, "xt"); //opening the non-existing file in "xt" mode, file will be created
+var_dump($file_handle); //Check for the content of handle
+var_dump( get_resource_type($file_handle) ); //Check for the type of resource
+var_dump( ftell($file_handle) ); //Initial file pointer position, expected at the begining of the file
+var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string
+var_dump( ftell($file_handle) ); //File pointer position after write operation, expected at the end of the file
+rewind($file_handle);
+var_dump( fread($file_handle, 100) ); //Check for read operation; fails; expected: empty string
+var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the begining of the file
+var_dump( fclose($file_handle) ); //Check for close operation on the file handle
+var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation
+$file_handle = fopen($file, "xt"); //Opening the existing data file in 'xt' mode to check for the warning message
+echo "*** Done ***\n";
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/007_variation15.tmp");
+?>
+--EXPECTF--
+*** Test fopen() & fclose() functions: with 'xt' mode ***
+resource(%d) of type (stream)
+%unicode|string%(6) "stream"
+int(0)
+int(37)
+int(37)
+string(0) ""
+int(0)
+bool(true)
+%unicode|string%(7) "Unknown"
+
+Warning: fopen(%s): failed to open stream: File exists in %s on line %s
+*** Done ***
diff --git a/ext/standard/tests/file/007_variation16.phpt b/ext/standard/tests/file/007_variation16.phpt
new file mode 100644
index 0000000..c725aa1
--- /dev/null
+++ b/ext/standard/tests/file/007_variation16.phpt
@@ -0,0 +1,60 @@
+--TEST--
+Test fopen and fclose() functions - usage variations - "x+t" mode
+--FILE--
+<?php
+/*
+ fopen() function:
+ Prototype: resource fopen(string $filename, string $mode
+ [, bool $use_include_path [, resource $context]] );
+ Description: Opens file or URL.
+*/
+/*
+ fclose() function:
+ Prototype: bool fclose ( resource $handle );
+ Description: Closes an open file pointer
+*/
+
+/* Test fopen() and fclose(): Opening the file in "x+t" mode,
+ checking for the file creation, write & read operations,
+ checking for the file pointer position,
+ checking for the warning msg when trying to open an existing file in "x+t" mode,
+ and fclose function
+*/
+$file_path = dirname(__FILE__);
+$string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789";
+$file = $file_path."/007_variation16.tmp";
+
+echo "*** Test fopen() & fclose() functions: with 'x+t' mode ***\n";
+$file_handle = fopen($file, "x+t"); //opening the non-existing file in "x+t" mode, file will be created
+var_dump($file_handle); //Check for the content of handle
+var_dump( get_resource_type($file_handle) ); //Check for the type of resource
+var_dump( ftell($file_handle) ); //Initial file pointer position, expected at the begining of the file
+var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string
+var_dump( ftell($file_handle) ); //File pointer position after write operation, expected at the end of the file
+rewind($file_handle);
+var_dump( fread($file_handle, 100) ); //Check for read operation; passes; expected: content of the file
+var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the end of the file
+var_dump( fclose($file_handle) ); //Check for close operation on the file handle
+var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation
+$file_handle = fopen($file, "x+t"); //Opening the existing data file in "x+t" mode to check for the warning message
+echo "*** Done ***\n";
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/007_variation16.tmp");
+?>
+--EXPECTF--
+*** Test fopen() & fclose() functions: with 'x+t' mode ***
+resource(%d) of type (stream)
+string(6) "stream"
+int(0)
+int(37)
+int(37)
+string(37) "abcdefghij
+mnopqrst uvwxyz
+0123456789"
+int(37)
+bool(true)
+string(7) "Unknown"
+
+Warning: fopen(%s): failed to open stream: File exists in %s on line %d
+*** Done ***
diff --git a/ext/standard/tests/file/007_variation17.phpt b/ext/standard/tests/file/007_variation17.phpt
new file mode 100644
index 0000000..d3408e9
--- /dev/null
+++ b/ext/standard/tests/file/007_variation17.phpt
@@ -0,0 +1,54 @@
+--TEST--
+Test fopen and fclose() functions - usage variations - "rb" mode
+--FILE--
+<?php
+/*
+ fopen() function:
+ Prototype: resource fopen(string $filename, string $mode
+ [, bool $use_include_path [, resource $context]] );
+ Description: Opens file or URL.
+*/
+/*
+ fclose() function:
+ Prototype: bool fclose ( resource $handle );
+ Description: Closes an open file pointer
+*/
+
+/* Test fopen() and fclose(): Opening the file in "rb" mode,
+ checking for the file creation, write & read operations,
+ checking for the file pointer position,
+ and fclose function
+*/
+$file_path = dirname(__FILE__);
+require($file_path."/file.inc");
+
+create_files($file_path, 1, "text_with_new_line", 0755, 20, "w", "007_variation", 17, "bytes");
+$file = $file_path."/007_variation17.tmp";
+$string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789";
+
+echo "*** Test fopen() & fclose() functions: with 'rb' mode ***\n";
+$file_handle = fopen($file, "rb"); //opening the file in "rb" mode
+var_dump($file_handle); //Check for the content of handle
+var_dump( get_resource_type($file_handle) ); //Check for the type of resource
+var_dump( ftell($file_handle) ); //Initial position of file pointer
+var_dump( fread($file_handle, 100) ); //Check for read operation
+var_dump( fwrite($file_handle, $string) ); //Check for write operation; fails; expected: 0 bytes
+var_dump( fclose($file_handle) ); //Check for close operation on the file handle
+var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation
+echo "*** Done ***\n";
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/007_variation17.tmp");
+?>
+--EXPECTF--
+*** Test fopen() & fclose() functions: with 'rb' mode ***
+resource(%d) of type (stream)
+string(6) "stream"
+int(0)
+string(20) "line
+line of text
+li"
+int(0)
+bool(true)
+string(7) "Unknown"
+*** Done ***
diff --git a/ext/standard/tests/file/007_variation18.phpt b/ext/standard/tests/file/007_variation18.phpt
new file mode 100644
index 0000000..991051d
--- /dev/null
+++ b/ext/standard/tests/file/007_variation18.phpt
@@ -0,0 +1,58 @@
+--TEST--
+Test fopen and fclose() functions - usage variations - "r+b" mode
+--FILE--
+<?php
+/*
+ fopen() function:
+ Prototype: resource fopen(string $filename, string $mode
+ [, bool $use_include_path [, resource $context]] );
+ Description: Opens file or URL.
+*/
+/*
+ fclose() function:
+ Prototype: bool fclose ( resource $handle );
+ Description: Closes an open file pointer
+*/
+
+/* Test fopen() and fclose(): Opening the file in "r+b" mode,
+ checking for the file creation, write & read operations,
+ checking for the file pointer position,
+ and fclose function
+*/
+$file_path = dirname(__FILE__);
+require($file_path."/file.inc");
+
+create_files($file_path, 1, "text_with_new_line", 0755, 20, "w", "007_variation", 18, "bytes");
+$file = $file_path."/007_variation18.tmp";
+$string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789";
+
+echo "*** Test fopen() & fclose() functions: with 'r+b' mode ***\n";
+$file_handle = fopen($file, "r+b"); //opening the file in "r+b" mode
+var_dump($file_handle); //Check for the content of handle
+var_dump( get_resource_type($file_handle) ); //Check for the type of resource
+var_dump( ftell($file_handle) ); //Initial file pointer position, expected at the begining of the file
+var_dump( fread($file_handle, 100) ); //Check for read operation
+var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the end of the file
+var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string
+var_dump( ftell($file_handle) ); //File pointer position after write operation, expected at the end of the file
+var_dump( fclose($file_handle) ); //Check for close operation on the file handle
+var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation
+echo "*** Done ***\n";
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/007_variation18.tmp");
+?>
+--EXPECTF--
+*** Test fopen() & fclose() functions: with 'r+b' mode ***
+resource(%d) of type (stream)
+string(6) "stream"
+int(0)
+string(20) "line
+line of text
+li"
+int(20)
+int(37)
+int(57)
+bool(true)
+string(7) "Unknown"
+*** Done ***
diff --git a/ext/standard/tests/file/007_variation19.phpt b/ext/standard/tests/file/007_variation19.phpt
new file mode 100644
index 0000000..3830e4f
--- /dev/null
+++ b/ext/standard/tests/file/007_variation19.phpt
@@ -0,0 +1,71 @@
+--TEST--
+Test fopen and fclose() functions - usage variations - "wb" mode
+--FILE--
+<?php
+/*
+ fopen() function:
+ Prototype: resource fopen(string $filename, string $mode
+ [, bool $use_include_path [, resource $context]] );
+ Description: Opens file or URL.
+*/
+/*
+ fclose() function:
+ Prototype: bool fclose ( resource $handle );
+ Description: Closes an open file pointer
+*/
+
+/* Test fopen() and fclose(): Opening the file in "wb" mode,
+ checking for the file creation, write & read operations,
+ checking for the file pointer position,
+ checking for the file truncation when trying to open an existing file in "wb" mode,
+ and fclose function
+*/
+$file_path = dirname(__FILE__);
+require($file_path."/file.inc");
+
+create_files($file_path, 1, "text_with_new_line", 0755, 20, "wb", "007_variation", 19, "bytes");
+$file = $file_path."/007_variation19.tmp";
+$string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789";
+
+echo "*** Test fopen() & fclose() functions: with 'wb' mode ***\n";
+$file_handle = fopen($file, "wb"); //opening the file "wb" mode
+var_dump($file_handle); //Check for the content of handle
+var_dump( get_resource_type($file_handle) ); //Check for the type of resource
+var_dump( ftell($file_handle) ); //Initial file pointer position, expected at the begining of the file
+var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string
+var_dump( ftell($file_handle) ); //File pointer position after write operation, expected at the end of the file
+rewind($file_handle);
+var_dump( fread($file_handle, 100) ); //Check for read operation; fails; expected: empty string
+var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the begining of the file
+var_dump( fclose($file_handle) ); //Check for close operation on the file handle
+var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation
+
+var_dump( filesize($file) ); //Check for size of existing data file before opening the file in "wb" mode again, expected: size of content
+clearstatcache();
+fclose( fopen($file, "wb") ); //Opening the existing data file again in "wb" mode
+var_dump( filesize($file) ); //Check for size of existing data file after opening the file in "wb" mode again, expected: 0 bytes
+clearstatcache();
+
+unlink($file); //Deleting the file
+fclose( fopen($file, "wb") ); //Opening the non-existing file in "wb" mode, which will be created
+var_dump( file_exists($file) ); //Check for the existance of file
+echo "*** Done ***\n";
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/007_variation19.tmp");
+?>
+--EXPECTF--
+*** Test fopen() & fclose() functions: with 'wb' mode ***
+resource(%d) of type (stream)
+string(6) "stream"
+int(0)
+int(37)
+int(37)
+string(0) ""
+int(0)
+bool(true)
+string(7) "Unknown"
+int(37)
+int(0)
+bool(true)
+*** Done ***
diff --git a/ext/standard/tests/file/007_variation2.phpt b/ext/standard/tests/file/007_variation2.phpt
new file mode 100644
index 0000000..4c883ea
--- /dev/null
+++ b/ext/standard/tests/file/007_variation2.phpt
@@ -0,0 +1,58 @@
+--TEST--
+Test fopen and fclose() functions - usage variations - "r+" mode
+--FILE--
+<?php
+/*
+ fopen() function:
+ Prototype: resource fopen(string $filename, string $mode
+ [, bool $use_include_path [, resource $context]] );
+ Description: Opens file or URL.
+*/
+/*
+ fclose() function:
+ Prototype: bool fclose ( resource $handle );
+ Description: Closes an open file pointer
+*/
+
+/* Test fopen() and fclose(): Opening the file in "r+" mode,
+ checking for the file creation, write & read operations,
+ checking for the file pointer position,
+ and fclose function
+*/
+$file_path = dirname(__FILE__);
+require($file_path."/file.inc");
+
+create_files($file_path, 1, "text_with_new_line", 0755, 20, "w", "007_variation", 2, "bytes");
+$file = $file_path."/007_variation2.tmp";
+$string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789";
+
+echo "*** Test fopen() & fclose() functions: with 'r+' mode ***\n";
+$file_handle = fopen($file, "r+"); //opening the file in "r+" mode
+var_dump($file_handle); //Check for the content of handle
+var_dump( get_resource_type($file_handle) ); //Check for the type of resource
+var_dump( ftell($file_handle) ); //Initial file pointer position, expected at the begining of the file
+var_dump( fread($file_handle, 100) ); //Check for read operation
+var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the end of the file
+var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string
+var_dump( ftell($file_handle) ); //File pointer position after write operation, expected at the end of the file
+var_dump( fclose($file_handle) ); //Check for close operation on the file handle
+var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation
+echo "*** Done ***\n";
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/007_variation2.tmp");
+?>
+--EXPECTF--
+*** Test fopen() & fclose() functions: with 'r+' mode ***
+resource(%d) of type (stream)
+string(6) "stream"
+int(0)
+string(20) "line
+line of text
+li"
+int(20)
+int(37)
+int(57)
+bool(true)
+string(7) "Unknown"
+*** Done *** \ No newline at end of file
diff --git a/ext/standard/tests/file/007_variation20.phpt b/ext/standard/tests/file/007_variation20.phpt
new file mode 100644
index 0000000..4d66dc7
--- /dev/null
+++ b/ext/standard/tests/file/007_variation20.phpt
@@ -0,0 +1,73 @@
+--TEST--
+Test fopen and fclose() functions - usage variations - "w+b" mode
+--FILE--
+<?php
+/*
+ fopen() function:
+ Prototype: resource fopen(string $filename, string $mode
+ [, bool $use_include_path [, resource $context]] );
+ Description: Opens file or URL.
+*/
+/*
+ fclose() function:
+ Prototype: bool fclose ( resource $handle );
+ Description: Closes an open file pointer
+*/
+
+/* Test fopen() and fclose(): Opening the file in "w+b" mode,
+ checking for the file creation, write & read operations,
+ checking for the file pointer position,
+ checking for the file truncation when trying to open an existing file in "w+b" mode,
+ and fclose function
+*/
+$file_path = dirname(__FILE__);
+require($file_path."/file.inc");
+
+create_files($file_path, 1, "text_with_new_line", 0755, 20, "w", "007_variation", 20, "bytes");
+$file = $file_path."/007_variation20.tmp";
+$string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789";
+
+echo "*** Test fopen() & fclose() functions: with 'w+b' mode ***\n";
+$file_handle = fopen($file, "w+b"); //opening the file "w+b" mode
+var_dump($file_handle); //Check for the content of handle
+var_dump( get_resource_type($file_handle) ); //Check for the type of resource
+var_dump( ftell($file_handle) ); //Initial file pointer position, expected at the begining of the file
+var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string
+var_dump( ftell($file_handle) ); //File pointer position after write operation, expected at the end of the file
+rewind($file_handle);
+var_dump( fread($file_handle, 100) ); //Check for read operation; passes; expected: content of file
+var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the end of the file
+var_dump( fclose($file_handle) ); //Check for close operation on the file handle
+var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation
+
+var_dump( filesize($file) ); //Check for size of existing data file before opening the file in "w+b" mode again, expected: size of content
+clearstatcache();
+fclose( fopen($file, "w+b") ); //Opening the existing data file again in "w+b" mode
+var_dump( filesize($file) ); //Check for size of existing data file after opening the file in "w+b" mode again, expected: 0 bytes
+clearstatcache();
+
+unlink($file); //Deleting the file
+fclose( fopen($file, "w+b") ); //Opening the non-existing file in "w+b" mode, which will be created
+var_dump( file_exists($file) ); //Check for the existance of file
+echo "*** Done ***\n";
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/007_variation20.tmp");
+?>
+--EXPECTF--
+*** Test fopen() & fclose() functions: with 'w+b' mode ***
+resource(%d) of type (stream)
+string(6) "stream"
+int(0)
+int(37)
+int(37)
+string(37) "abcdefghij
+mnopqrst uvwxyz
+0123456789"
+int(37)
+bool(true)
+string(7) "Unknown"
+int(37)
+int(0)
+bool(true)
+*** Done ***
diff --git a/ext/standard/tests/file/007_variation21.phpt b/ext/standard/tests/file/007_variation21.phpt
new file mode 100644
index 0000000..6c968f2
--- /dev/null
+++ b/ext/standard/tests/file/007_variation21.phpt
@@ -0,0 +1,60 @@
+--TEST--
+Test fopen and fclose() functions - usage variations - "ab" mode
+--FILE--
+<?php
+/*
+ fopen() function:
+ Prototype: resource fopen(string $filename, string $mode
+ [, bool $use_include_path [, resource $context]] );
+ Description: Opens file or URL.
+*/
+/*
+ fclose() function:
+ Prototype: bool fclose ( resource $handle );
+ Description: Closes an open file pointer
+*/
+
+/* Test fopen() and fclose(): Opening the file in "ab" mode,
+ checking for the file creation, write & read operations,
+ checking for the file pointer position,
+ and fclose function
+*/
+$file_path = dirname(__FILE__);
+require($file_path."/file.inc");
+
+create_files($file_path, 1, "text_with_new_line", 0755, 20, "w", "007_variation", 21, "bytes");
+$file = $file_path."/007_variation21.tmp";
+$string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789";
+
+echo "*** Test fopen() & fclose() functions: with 'ab' mode ***\n";
+$file_handle = fopen($file, "ab"); //opening the file "ab" mode
+var_dump($file_handle); //Check for the content of handle
+var_dump( get_resource_type($file_handle) ); //Check for the type of resource
+var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string
+rewind($file_handle);
+var_dump( fread($file_handle, 100) ); //Check for read operation; fails; expected: empty string
+var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the end of the file
+var_dump( fclose($file_handle) ); //Check for close operation on the file handle
+var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation
+var_dump( filesize($file) ); //Check that data hasn't over written; Expected: Size of (initial data + newly added data)
+
+unlink($file); //Deleting the file
+fclose( fopen($file, "ab") ); //Opening the non-existing file in "ab" mode, which will be created
+var_dump( file_exists($file) ); //Check for the existance of file
+echo "*** Done ***\n";
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/007_variation21.tmp");
+?>
+--EXPECTF--
+*** Test fopen() & fclose() functions: with 'ab' mode ***
+resource(%d) of type (stream)
+string(6) "stream"
+int(37)
+string(0) ""
+int(0)
+bool(true)
+string(7) "Unknown"
+int(57)
+bool(true)
+*** Done ***
diff --git a/ext/standard/tests/file/007_variation22.phpt b/ext/standard/tests/file/007_variation22.phpt
new file mode 100644
index 0000000..d1456fe
--- /dev/null
+++ b/ext/standard/tests/file/007_variation22.phpt
@@ -0,0 +1,62 @@
+--TEST--
+Test fopen and fclose() functions - usage variations - "a+b" mode
+--FILE--
+<?php
+/*
+ fopen() function:
+ Prototype: resource fopen(string $filename, string $mode
+ [, bool $use_include_path [, resource $context]] );
+ Description: Opens file or URL.
+*/
+/*
+ fclose() function:
+ Prototype: bool fclose ( resource $handle );
+ Description: Closes an open file pointer
+*/
+
+/* Test fopen() and fclose(): Opening the file in "a+b" mode,
+ checking for the file creation, write & read operations,
+ checking for the file pointer position,
+ and fclose function
+*/
+$file_path = dirname(__FILE__);
+require($file_path."/file.inc");
+
+create_files($file_path, 1, "text_with_new_line", 0755, 20, "w", "007_variation", 22, "bytes");
+$file = $file_path."/007_variation22.tmp";
+$string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789";
+
+echo "*** Test fopen() & fclose() functions: with 'a+b' mode ***\n";
+$file_handle = fopen($file, "a+b"); //opening the file "a+b" mode
+var_dump($file_handle); //Check for the content of handle
+var_dump( get_resource_type($file_handle) ); //Check for the type of resource
+var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string
+rewind($file_handle);
+var_dump( fread($file_handle, 100) ); //Check for read operation; passes; expected: content of file
+var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the end of the file
+var_dump( fclose($file_handle) ); //Check for close operation on the file handle
+var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation
+
+unlink($file); //Deleting the file
+fclose( fopen($file, "a+b") ); //Opening the non-existing file in "a+b" mode, which will be created
+var_dump( file_exists($file) ); //Check for the existance of file
+echo "*** Done ***\n";
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/007_variation22.tmp");
+?>
+--EXPECTF--
+*** Test fopen() & fclose() functions: with 'a+b' mode ***
+resource(%d) of type (stream)
+string(6) "stream"
+int(37)
+string(57) "line
+line of text
+liabcdefghij
+mnopqrst uvwxyz
+0123456789"
+int(57)
+bool(true)
+string(7) "Unknown"
+bool(true)
+*** Done ***
diff --git a/ext/standard/tests/file/007_variation23.phpt b/ext/standard/tests/file/007_variation23.phpt
new file mode 100644
index 0000000..528f05a
--- /dev/null
+++ b/ext/standard/tests/file/007_variation23.phpt
@@ -0,0 +1,58 @@
+--TEST--
+Test fopen and fclose() functions - usage variations - "xb" mode
+--FILE--
+<?php
+/*
+ fopen() function:
+ Prototype: resource fopen(string $filename, string $mode
+ [, bool $use_include_path [, resource $context]] );
+ Description: Opens file or URL.
+*/
+/*
+ fclose() function:
+ Prototype: bool fclose ( resource $handle );
+ Description: Closes an open file pointer
+*/
+
+/* Test fopen() and fclose(): Opening the file in "xb" mode,
+ checking for the file creation, write & read operations,
+ checking for the file pointer position,
+ checking for the warning msg when trying to open an existing file in "xb" mode,
+ and fclose function
+*/
+$file_path = dirname(__FILE__);
+$string = b"abcdefghij\nmnopqrst\tuvwxyz\n0123456789";
+$file = $file_path."/007_variation23.tmp";
+
+echo "*** Test fopen() & fclose() functions: with 'xb' mode ***\n";
+$file_handle = fopen($file, "xb"); //opening the non-existing file in "xb" mode, file will be created
+var_dump($file_handle); //Check for the content of handle
+var_dump( get_resource_type($file_handle) ); //Check for the type of resource
+var_dump( ftell($file_handle) ); //Initial file pointer position, expected at the begining of the file
+var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string
+var_dump( ftell($file_handle) ); //File pointer position after write operation, expected at the end of the file
+rewind($file_handle);
+var_dump( fread($file_handle, 100) ); //Check for read operation; fails; expected: empty string
+var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the begining of the file
+var_dump( fclose($file_handle) ); //Check for close operation on the file handle
+var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation
+$file_handle = fopen($file, "xb"); //Opening the existing data file in 'xb' mode to check for the warning message
+echo "*** Done ***\n";
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/007_variation23.tmp");
+?>
+--EXPECTF--
+*** Test fopen() & fclose() functions: with 'xb' mode ***
+resource(%d) of type (stream)
+%unicode|string%(6) "stream"
+int(0)
+int(37)
+int(37)
+string(0) ""
+int(0)
+bool(true)
+%unicode|string%(7) "Unknown"
+
+Warning: fopen(%s): failed to open stream: File exists in %s on line %s
+*** Done ***
diff --git a/ext/standard/tests/file/007_variation24.phpt b/ext/standard/tests/file/007_variation24.phpt
new file mode 100644
index 0000000..41fc24c
--- /dev/null
+++ b/ext/standard/tests/file/007_variation24.phpt
@@ -0,0 +1,60 @@
+--TEST--
+Test fopen and fclose() functions - usage variations - "x+b" mode
+--FILE--
+<?php
+/*
+ fopen() function:
+ Prototype: resource fopen(string $filename, string $mode
+ [, bool $use_include_path [, resource $context]] );
+ Description: Opens file or URL.
+*/
+/*
+ fclose() function:
+ Prototype: bool fclose ( resource $handle );
+ Description: Closes an open file pointer
+*/
+
+/* Test fopen() and fclose(): Opening the file in "x+b" mode,
+ checking for the file creation, write & read operations,
+ checking for the file pointer position,
+ checking for the warning msg when trying to open an existing file in "x+b" mode,
+ and fclose function
+*/
+$file_path = dirname(__FILE__);
+$string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789";
+$file = $file_path."/007_variation24.tmp";
+
+echo "*** Test fopen() & fclose() functions: with 'x+b' mode ***\n";
+$file_handle = fopen($file, "x+b"); //opening the non-existing file in "x+b" mode, file will be created
+var_dump($file_handle); //Check for the content of handle
+var_dump( get_resource_type($file_handle) ); //Check for the type of resource
+var_dump( ftell($file_handle) ); //Initial file pointer position, expected at the begining of the file
+var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string
+var_dump( ftell($file_handle) ); //File pointer position after write operation, expected at the end of the file
+rewind($file_handle);
+var_dump( fread($file_handle, 100) ); //Check for read operation; passes; expected: content of the file
+var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the end of the file
+var_dump( fclose($file_handle) ); //Check for close operation on the file handle
+var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation
+$file_handle = fopen($file, "x+b"); //Opening the existing data file in "x+b" mode to check for the warning message
+echo "*** Done ***\n";
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/007_variation24.tmp");
+?>
+--EXPECTF--
+*** Test fopen() & fclose() functions: with 'x+b' mode ***
+resource(%d) of type (stream)
+string(6) "stream"
+int(0)
+int(37)
+int(37)
+string(37) "abcdefghij
+mnopqrst uvwxyz
+0123456789"
+int(37)
+bool(true)
+string(7) "Unknown"
+
+Warning: fopen(%s): failed to open stream: File exists in %s on line %d
+*** Done ***
diff --git a/ext/standard/tests/file/007_variation3.phpt b/ext/standard/tests/file/007_variation3.phpt
new file mode 100644
index 0000000..cd31eba
--- /dev/null
+++ b/ext/standard/tests/file/007_variation3.phpt
@@ -0,0 +1,71 @@
+--TEST--
+Test fopen and fclose() functions - usage variations - "w" mode
+--FILE--
+<?php
+/*
+ fopen() function:
+ Prototype: resource fopen(string $filename, string $mode
+ [, bool $use_include_path [, resource $context]] );
+ Description: Opens file or URL.
+*/
+/*
+ fclose() function:
+ Prototype: bool fclose ( resource $handle );
+ Description: Closes an open file pointer
+*/
+
+/* Test fopen() and fclose(): Opening the file in "w" mode,
+ checking for the file creation, write & read operations,
+ checking for the file pointer position,
+ checking for the file truncation when trying to open an existing file in "w" mode,
+ and fclose function
+*/
+$file_path = dirname(__FILE__);
+require($file_path."/file.inc");
+
+create_files($file_path, 1, "text_with_new_line", 0755, 20, "w", "007_variation", 3, "bytes");
+$file = $file_path."/007_variation3.tmp";
+$string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789";
+
+echo "*** Test fopen() & fclose() functions: with 'w' mode ***\n";
+$file_handle = fopen($file, "w"); //opening the file "w" mode
+var_dump($file_handle); //Check for the content of handle
+var_dump( get_resource_type($file_handle) ); //Check for the type of resource
+var_dump( ftell($file_handle) ); //Initial file pointer position, expected at the begining of the file
+var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string
+var_dump( ftell($file_handle) ); //File pointer position after write operation, expected at the end of the file
+rewind($file_handle);
+var_dump( fread($file_handle, 100) ); //Check for read operation; fails; expected: empty string
+var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the begining of the file
+var_dump( fclose($file_handle) ); //Check for close operation on the file handle
+var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation
+
+var_dump( filesize($file) ); //Check for size of existing data file before opening the file in "w" mode again, expected: size of content
+clearstatcache();
+fclose( fopen($file, "w") ); //Opening the existing data file again in "w" mode
+var_dump( filesize($file) ); //Check for size of existing data file after opening the file in "w" mode again, expected: 0 bytes
+clearstatcache();
+
+unlink($file); //Deleting the file
+fclose( fopen($file, "w") ); //Opening the non-existing file in "w" mode, which will be created
+var_dump( file_exists($file) ); //Check for the existance of file
+echo "*** Done ***\n";
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/007_variation3.tmp");
+?>
+--EXPECTF--
+*** Test fopen() & fclose() functions: with 'w' mode ***
+resource(%d) of type (stream)
+string(6) "stream"
+int(0)
+int(37)
+int(37)
+string(0) ""
+int(0)
+bool(true)
+string(7) "Unknown"
+int(37)
+int(0)
+bool(true)
+*** Done ***
diff --git a/ext/standard/tests/file/007_variation4.phpt b/ext/standard/tests/file/007_variation4.phpt
new file mode 100644
index 0000000..e88324e
--- /dev/null
+++ b/ext/standard/tests/file/007_variation4.phpt
@@ -0,0 +1,73 @@
+--TEST--
+Test fopen and fclose() functions - usage variations - "w+" mode
+--FILE--
+<?php
+/*
+ fopen() function:
+ Prototype: resource fopen(string $filename, string $mode
+ [, bool $use_include_path [, resource $context]] );
+ Description: Opens file or URL.
+*/
+/*
+ fclose() function:
+ Prototype: bool fclose ( resource $handle );
+ Description: Closes an open file pointer
+*/
+
+/* Test fopen() and fclose(): Opening the file in "w+" mode,
+ checking for the file creation, write & read operations,
+ checking for the file pointer position,
+ checking for the file truncation when trying to open an existing file in "w+" mode,
+ and fclose function
+*/
+$file_path = dirname(__FILE__);
+require($file_path."/file.inc");
+
+create_files($file_path, 1, "text_with_new_line", 0755, 20, "w", "007_variation", 4, "bytes");
+$file = $file_path."/007_variation4.tmp";
+$string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789";
+
+echo "*** Test fopen() & fclose() functions: with 'w+' mode ***\n";
+$file_handle = fopen($file, "w+"); //opening the file "w+" mode
+var_dump($file_handle); //Check for the content of handle
+var_dump( get_resource_type($file_handle) ); //Check for the type of resource
+var_dump( ftell($file_handle) ); //Initial file pointer position, expected at the begining of the file
+var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string
+var_dump( ftell($file_handle) ); //File pointer position after write operation, expected at the end of the file
+rewind($file_handle);
+var_dump( fread($file_handle, 100) ); //Check for read operation; passes; expected: content of file
+var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the end of the file
+var_dump( fclose($file_handle) ); //Check for close operation on the file handle
+var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation
+
+var_dump( filesize($file) ); //Check for size of existing data file before opening the file in "w+" mode again, expected: size of content
+clearstatcache();
+fclose( fopen($file, "w+") ); //Opening the existing data file again in "w+" mode
+var_dump( filesize($file) ); //Check for size of existing data file after opening the file in "w+" mode again, expected: 0 bytes
+clearstatcache();
+
+unlink($file); //Deleting the file
+fclose( fopen($file, "w+") ); //Opening the non-existing file in "w+" mode, which will be created
+var_dump( file_exists($file) ); //Check for the existance of file
+echo "*** Done ***\n";
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/007_variation4.tmp");
+?>
+--EXPECTF--
+*** Test fopen() & fclose() functions: with 'w+' mode ***
+resource(%d) of type (stream)
+string(6) "stream"
+int(0)
+int(37)
+int(37)
+string(37) "abcdefghij
+mnopqrst uvwxyz
+0123456789"
+int(37)
+bool(true)
+string(7) "Unknown"
+int(37)
+int(0)
+bool(true)
+*** Done *** \ No newline at end of file
diff --git a/ext/standard/tests/file/007_variation5.phpt b/ext/standard/tests/file/007_variation5.phpt
new file mode 100644
index 0000000..9311534
--- /dev/null
+++ b/ext/standard/tests/file/007_variation5.phpt
@@ -0,0 +1,60 @@
+--TEST--
+Test fopen and fclose() functions - usage variations - "a" mode
+--FILE--
+<?php
+/*
+ fopen() function:
+ Prototype: resource fopen(string $filename, string $mode
+ [, bool $use_include_path [, resource $context]] );
+ Description: Opens file or URL.
+*/
+/*
+ fclose() function:
+ Prototype: bool fclose ( resource $handle );
+ Description: Closes an open file pointer
+*/
+
+/* Test fopen() and fclose(): Opening the file in "a" mode,
+ checking for the file creation, write & read operations,
+ checking for the file pointer position,
+ and fclose function
+*/
+$file_path = dirname(__FILE__);
+require($file_path."/file.inc");
+
+create_files($file_path, 1, "text_with_new_line", 0755, 20, "w", "007_variation", 5, "bytes");
+$file = $file_path."/007_variation5.tmp";
+$string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789";
+
+echo "*** Test fopen() & fclose() functions: with 'a' mode ***\n";
+$file_handle = fopen($file, "a"); //opening the file "a" mode
+var_dump($file_handle); //Check for the content of handle
+var_dump( get_resource_type($file_handle) ); //Check for the type of resource
+var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string
+rewind($file_handle);
+var_dump( fread($file_handle, 100) ); //Check for read operation; fails; expected: empty string
+var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the end of the file
+var_dump( fclose($file_handle) ); //Check for close operation on the file handle
+var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation
+var_dump( filesize($file) ); //Check that data hasn't over written; Expected: Size of (initial data + newly added data)
+
+unlink($file); //Deleting the file
+fclose( fopen($file, "a") ); //Opening the non-existing file in "a" mode, which will be created
+var_dump( file_exists($file) ); //Check for the existance of file
+echo "*** Done ***\n";
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/007_variation5.tmp");
+?>
+--EXPECTF--
+*** Test fopen() & fclose() functions: with 'a' mode ***
+resource(%d) of type (stream)
+string(6) "stream"
+int(37)
+string(0) ""
+int(0)
+bool(true)
+string(7) "Unknown"
+int(57)
+bool(true)
+*** Done ***
diff --git a/ext/standard/tests/file/007_variation6.phpt b/ext/standard/tests/file/007_variation6.phpt
new file mode 100644
index 0000000..b274b05
--- /dev/null
+++ b/ext/standard/tests/file/007_variation6.phpt
@@ -0,0 +1,62 @@
+--TEST--
+Test fopen and fclose() functions - usage variations - "a+" mode
+--FILE--
+<?php
+/*
+ fopen() function:
+ Prototype: resource fopen(string $filename, string $mode
+ [, bool $use_include_path [, resource $context]] );
+ Description: Opens file or URL.
+*/
+/*
+ fclose() function:
+ Prototype: bool fclose ( resource $handle );
+ Description: Closes an open file pointer
+*/
+
+/* Test fopen() and fclose(): Opening the file in "a+" mode,
+ checking for the file creation, write & read operations,
+ checking for the file pointer position,
+ and fclose function
+*/
+$file_path = dirname(__FILE__);
+require($file_path."/file.inc");
+
+create_files($file_path, 1, "text_with_new_line", 0755, 20, "w", "007_variation", 6, "bytes");
+$file = $file_path."/007_variation6.tmp";
+$string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789";
+
+echo "*** Test fopen() & fclose() functions: with 'a+' mode ***\n";
+$file_handle = fopen($file, "a+"); //opening the file "a+" mode
+var_dump($file_handle); //Check for the content of handle
+var_dump( get_resource_type($file_handle) ); //Check for the type of resource
+var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string
+rewind($file_handle);
+var_dump( fread($file_handle, 100) ); //Check for read operation; passes; expected: content of file
+var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the end of the file
+var_dump( fclose($file_handle) ); //Check for close operation on the file handle
+var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation
+
+unlink($file); //Deleting the file
+fclose( fopen($file, "a+") ); //Opening the non-existing file in "a+" mode, which will be created
+var_dump( file_exists($file) ); //Check for the existance of file
+echo "*** Done ***\n";
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/007_variation6.tmp");
+?>
+--EXPECTF--
+*** Test fopen() & fclose() functions: with 'a+' mode ***
+resource(%d) of type (stream)
+string(6) "stream"
+int(37)
+string(57) "line
+line of text
+liabcdefghij
+mnopqrst uvwxyz
+0123456789"
+int(57)
+bool(true)
+string(7) "Unknown"
+bool(true)
+*** Done ***
diff --git a/ext/standard/tests/file/007_variation7.phpt b/ext/standard/tests/file/007_variation7.phpt
new file mode 100644
index 0000000..131daff
--- /dev/null
+++ b/ext/standard/tests/file/007_variation7.phpt
@@ -0,0 +1,58 @@
+--TEST--
+Test fopen and fclose() functions - usage variations - "x" mode
+--FILE--
+<?php
+/*
+ fopen() function:
+ Prototype: resource fopen(string $filename, string $mode
+ [, bool $use_include_path [, resource $context]] );
+ Description: Opens file or URL.
+*/
+/*
+ fclose() function:
+ Prototype: bool fclose ( resource $handle );
+ Description: Closes an open file pointer
+*/
+
+/* Test fopen() and fclose(): Opening the file in "x" mode,
+ checking for the file creation, write & read operations,
+ checking for the file pointer position,
+ checking for the warning msg when trying to open an existing file in "x" mode,
+ and fclose function
+*/
+$file_path = dirname(__FILE__);
+$string = b"abcdefghij\nmnopqrst\tuvwxyz\n0123456789";
+$file = $file_path."/007_variation7.tmp";
+
+echo "*** Test fopen() & fclose() functions: with 'x' mode ***\n";
+$file_handle = fopen($file, "x"); //opening the non-existing file in "x" mode, file will be created
+var_dump($file_handle); //Check for the content of handle
+var_dump( get_resource_type($file_handle) ); //Check for the type of resource
+var_dump( ftell($file_handle) ); //Initial file pointer position, expected at the begining of the file
+var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string
+var_dump( ftell($file_handle) ); //File pointer position after write operation, expected at the end of the file
+rewind($file_handle);
+var_dump( fread($file_handle, 100) ); //Check for read operation; fails; expected: empty string
+var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the begining of the file
+var_dump( fclose($file_handle) ); //Check for close operation on the file handle
+var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation
+$file_handle = fopen($file, "x"); //Opening the existing data file in 'x' mode to check for the warning message
+echo "*** Done ***\n";
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/007_variation7.tmp");
+?>
+--EXPECTF--
+*** Test fopen() & fclose() functions: with 'x' mode ***
+resource(%d) of type (stream)
+%unicode|string%(6) "stream"
+int(0)
+int(37)
+int(37)
+string(0) ""
+int(0)
+bool(true)
+%unicode|string%(7) "Unknown"
+
+Warning: fopen(%s): failed to open stream: File exists in %s on line %s
+*** Done ***
diff --git a/ext/standard/tests/file/007_variation8.phpt b/ext/standard/tests/file/007_variation8.phpt
new file mode 100644
index 0000000..aa84711
--- /dev/null
+++ b/ext/standard/tests/file/007_variation8.phpt
@@ -0,0 +1,60 @@
+--TEST--
+Test fopen and fclose() functions - usage variations - "x+" mode
+--FILE--
+<?php
+/*
+ fopen() function:
+ Prototype: resource fopen(string $filename, string $mode
+ [, bool $use_include_path [, resource $context]] );
+ Description: Opens file or URL.
+*/
+/*
+ fclose() function:
+ Prototype: bool fclose ( resource $handle );
+ Description: Closes an open file pointer
+*/
+
+/* Test fopen() and fclose(): Opening the file in "x+" mode,
+ checking for the file creation, write & read operations,
+ checking for the file pointer position,
+ checking for the warning msg when trying to open an existing file in "x+" mode,
+ and fclose function
+*/
+$file_path = dirname(__FILE__);
+$string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789";
+$file = $file_path."/007_variation8.tmp";
+
+echo "*** Test fopen() & fclose() functions: with 'x+' mode ***\n";
+$file_handle = fopen($file, "x+"); //opening the non-existing file in "x+" mode, file will be created
+var_dump($file_handle); //Check for the content of handle
+var_dump( get_resource_type($file_handle) ); //Check for the type of resource
+var_dump( ftell($file_handle) ); //Initial file pointer position, expected at the begining of the file
+var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string
+var_dump( ftell($file_handle) ); //File pointer position after write operation, expected at the end of the file
+rewind($file_handle);
+var_dump( fread($file_handle, 100) ); //Check for read operation; passes; expected: content of the file
+var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the end of the file
+var_dump( fclose($file_handle) ); //Check for close operation on the file handle
+var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation
+$file_handle = fopen($file, "x+"); //Opening the existing data file in "x+" mode to check for the warning message
+echo "*** Done ***\n";
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/007_variation8.tmp");
+?>
+--EXPECTF--
+*** Test fopen() & fclose() functions: with 'x+' mode ***
+resource(%d) of type (stream)
+string(6) "stream"
+int(0)
+int(37)
+int(37)
+string(37) "abcdefghij
+mnopqrst uvwxyz
+0123456789"
+int(37)
+bool(true)
+string(7) "Unknown"
+
+Warning: fopen(%s): failed to open stream: File exists in %s on line %d
+*** Done ***
diff --git a/ext/standard/tests/file/007_variation9.phpt b/ext/standard/tests/file/007_variation9.phpt
new file mode 100644
index 0000000..ab5f1ca
--- /dev/null
+++ b/ext/standard/tests/file/007_variation9.phpt
@@ -0,0 +1,54 @@
+--TEST--
+Test fopen and fclose() functions - usage variations - "rt" mode
+--FILE--
+<?php
+/*
+ fopen() function:
+ Prototype: resource fopen(string $filename, string $mode
+ [, bool $use_include_path [, resource $context]] );
+ Description: Opens file or URL.
+*/
+/*
+ fclose() function:
+ Prototype: bool fclose ( resource $handle );
+ Description: Closes an open file pointer
+*/
+
+/* Test fopen() and fclose(): Opening the file in "rt" mode,
+ checking for the file creation, write & read operations,
+ checking for the file pointer position,
+ and fclose function
+*/
+$file_path = dirname(__FILE__);
+require($file_path."/file.inc");
+
+create_files($file_path, 1, "text_with_new_line", 0755, 20, "w", "007_variation", 9, "bytes");
+$file = $file_path."/007_variation9.tmp";
+$string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789";
+
+echo "*** Test fopen() & fclose() functions: with 'rt' mode ***\n";
+$file_handle = fopen($file, "rt"); //opening the file in "rt" mode
+var_dump($file_handle); //Check for the content of handle
+var_dump( get_resource_type($file_handle) ); //Check for the type of resource
+var_dump( ftell($file_handle) ); //Initial position of file pointer
+var_dump( fread($file_handle, 100) ); //Check for read operation
+var_dump( fwrite($file_handle, $string) ); //Check for write operation; fails; expected: 0 bytes
+var_dump( fclose($file_handle) ); //Check for close operation on the file handle
+var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation
+echo "*** Done ***\n";
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/007_variation9.tmp");
+?>
+--EXPECTF--
+*** Test fopen() & fclose() functions: with 'rt' mode ***
+resource(%d) of type (stream)
+string(6) "stream"
+int(0)
+string(20) "line
+line of text
+li"
+int(0)
+bool(true)
+string(7) "Unknown"
+*** Done ***
diff --git a/ext/standard/tests/file/basename-win32.phpt b/ext/standard/tests/file/basename-win32.phpt
new file mode 100644
index 0000000..5fd0f96
--- /dev/null
+++ b/ext/standard/tests/file/basename-win32.phpt
@@ -0,0 +1,341 @@
+--TEST--
+basename
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip Windows only basename tests');
+}
+?>
+--FILE--
+<?php
+/*
+ * proto string basename(string path [, string suffix])
+ * Function is implemented in ext/standard/string.c
+ */
+$file_paths = array (
+ /* simple paths */
+ array("bar"),
+ array("\\foo\\bar"),
+ array("foo\\bar"),
+ array("\\bar"),
+
+ /* simple paths with trailing slashes */
+ array("bar\\"),
+ array("\\bar\\"),
+ array("\\foo\\bar\\"),
+ array("foo\\bar\\"),
+ array("\\bar\\"),
+
+ /* paths with suffix removal */
+ array("bar.zip", ".zip"),
+ array("bar.zip", "bar.zip"),
+ array("\\foo\\bar.zip", ".zip"),
+ array("foo\\bar.zip", ".zip"),
+ array("\\bar.zip", ".zip"),
+
+ /* paths with suffix and trailing slashes with suffix removal*/
+ array("bar.zip\\", ".zip"),
+ array("\\bar.zip\\", ".zip"),
+ array("\\foo\\bar.zip\\", ".zip"),
+ array("foo\\bar.zip\\", ".zip"),
+ array("\\bar.zip\\", ".zip"),
+
+ /* paths with basename only suffix, with suffix removal*/
+ array("\\.zip", ".zip"),
+ array(".zip", ".zip"),
+ array("\\foo\\.zip", ".zip"),
+
+ /* paths with basename only suffix & trailing slashes, with suffix removal*/
+ array(".zip\\", ".zip"),
+ array("\\foo\\.zip\\", ".zip"),
+ array("foo\\.zip\\", ".zip"),
+);
+
+$file_path_variations = array (
+ /* paths with shortcut home dir char, with suffix variation */
+ array("C:\\temp\\bar"),
+ array("C:\\temp\\bar", ""),
+ array("C:\\temp\\bar", NULL),
+ array("C:\\temp\\bar", ' '),
+ array("C:\\temp\\bar.tar", ".tar"),
+ array("C:\\temp\\bar.tar", "~"),
+ array("C:\\temp\\bar.tar\\", "~"),
+ array("C:\\temp\\bar.tar\\", ""),
+ array("C:\\temp\\bar.tar", NULL),
+ array("C:\\temp\\bar.tar", ''),
+ array("C:\\temp\\bar.tar", " "),
+
+ /* paths with numeric strings */
+ array("10.5"),
+ array("10.5", ".5"),
+ array("10.5", "10.5"),
+ array("10"),
+ array("105", "5"),
+ array("/10.5"),
+ array("10.5\\"),
+ array("10/10.zip"),
+ array("0"),
+ array('0'),
+
+ /* paths and suffix given as same */
+ array("bar.zip", "bar.zip"),
+ array("\\bar.zip", "\\bar.zip"),
+ array("\\bar.zip\\", "\\bar.zip\\"),
+ array(" ", " "),
+ array(' ', ' '),
+ array(NULL, NULL),
+
+ /* path with spaces */
+ array(" "),
+ array(' '),
+
+ /* empty paths */
+ array(""),
+ array(''),
+ array(NULL)
+);
+
+function check_basename( $path_arrays ) {
+ $loop_counter = 1;
+ foreach ($path_arrays as $path) {
+ echo "\n--Iteration $loop_counter--\n"; $loop_counter++;
+ if( 1 == count($path) ) { // no suffix provided
+ var_dump( basename($path[0]) );
+ } else { // path as well as suffix provided,
+ var_dump( basename($path[0], $path[1]) );
+ }
+ }
+}
+
+echo "*** Testing basic operations ***\n";
+check_basename( $file_paths );
+
+echo "\n*** Testing possible variations in path and suffix ***\n";
+check_basename( $file_path_variations );
+
+echo "\n*** Testing error conditions ***\n";
+// zero arguments
+var_dump( basename() );
+
+// more than expected no. of arguments
+var_dump( basename("\\blah\\tmp\\bar.zip", ".zip", ".zip") );
+
+// passing invalid type arguments
+$object = new stdclass;
+var_dump( basename( array("string\\bar") ) );
+var_dump( basename( array("string\\bar"), "bar" ) );
+var_dump( basename( "bar", array("string\\bar") ) );
+var_dump( basename( $object, "bar" ) );
+var_dump( basename( $object ) );
+var_dump( basename( $object, $object ) );
+var_dump( basename( "bar", $object ) );
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing basic operations ***
+
+--Iteration 1--
+string(3) "bar"
+
+--Iteration 2--
+string(3) "bar"
+
+--Iteration 3--
+string(3) "bar"
+
+--Iteration 4--
+string(3) "bar"
+
+--Iteration 5--
+string(3) "bar"
+
+--Iteration 6--
+string(3) "bar"
+
+--Iteration 7--
+string(3) "bar"
+
+--Iteration 8--
+string(3) "bar"
+
+--Iteration 9--
+string(3) "bar"
+
+--Iteration 10--
+string(3) "bar"
+
+--Iteration 11--
+string(7) "bar.zip"
+
+--Iteration 12--
+string(3) "bar"
+
+--Iteration 13--
+string(3) "bar"
+
+--Iteration 14--
+string(3) "bar"
+
+--Iteration 15--
+string(3) "bar"
+
+--Iteration 16--
+string(3) "bar"
+
+--Iteration 17--
+string(3) "bar"
+
+--Iteration 18--
+string(3) "bar"
+
+--Iteration 19--
+string(3) "bar"
+
+--Iteration 20--
+string(4) ".zip"
+
+--Iteration 21--
+string(4) ".zip"
+
+--Iteration 22--
+string(4) ".zip"
+
+--Iteration 23--
+string(4) ".zip"
+
+--Iteration 24--
+string(4) ".zip"
+
+--Iteration 25--
+string(4) ".zip"
+
+*** Testing possible variations in path and suffix ***
+
+--Iteration 1--
+string(3) "bar"
+
+--Iteration 2--
+string(3) "bar"
+
+--Iteration 3--
+string(3) "bar"
+
+--Iteration 4--
+string(3) "bar"
+
+--Iteration 5--
+string(3) "bar"
+
+--Iteration 6--
+string(7) "bar.tar"
+
+--Iteration 7--
+string(7) "bar.tar"
+
+--Iteration 8--
+string(7) "bar.tar"
+
+--Iteration 9--
+string(7) "bar.tar"
+
+--Iteration 10--
+string(7) "bar.tar"
+
+--Iteration 11--
+string(7) "bar.tar"
+
+--Iteration 12--
+string(4) "10.5"
+
+--Iteration 13--
+string(2) "10"
+
+--Iteration 14--
+string(4) "10.5"
+
+--Iteration 15--
+string(2) "10"
+
+--Iteration 16--
+string(2) "10"
+
+--Iteration 17--
+string(4) "10.5"
+
+--Iteration 18--
+string(4) "10.5"
+
+--Iteration 19--
+string(6) "10.zip"
+
+--Iteration 20--
+string(1) "0"
+
+--Iteration 21--
+string(1) "0"
+
+--Iteration 22--
+string(7) "bar.zip"
+
+--Iteration 23--
+string(7) "bar.zip"
+
+--Iteration 24--
+string(7) "bar.zip"
+
+--Iteration 25--
+string(1) " "
+
+--Iteration 26--
+string(1) " "
+
+--Iteration 27--
+string(0) ""
+
+--Iteration 28--
+string(1) " "
+
+--Iteration 29--
+string(1) " "
+
+--Iteration 30--
+string(0) ""
+
+--Iteration 31--
+string(0) ""
+
+--Iteration 32--
+string(0) ""
+
+*** Testing error conditions ***
+
+Warning: basename() expects at least 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: basename() expects at most 2 parameters, 3 given in %s on line %d
+NULL
+
+Warning: basename() expects parameter 1 to be string, array given in %s on line %d
+NULL
+
+Warning: basename() expects parameter 1 to be string, array given in %s on line %d
+NULL
+
+Warning: basename() expects parameter 2 to be string, array given in %s on line %d
+NULL
+
+Warning: basename() expects parameter 1 to be string, object given in %s on line %d
+NULL
+
+Warning: basename() expects parameter 1 to be string, object given in %s on line %d
+NULL
+
+Warning: basename() expects parameter 1 to be string, object given in %s on line %d
+NULL
+
+Warning: basename() expects parameter 2 to be string, object given in %s on line %d
+NULL
+Done
diff --git a/ext/standard/tests/file/basename.phpt b/ext/standard/tests/file/basename.phpt
new file mode 100644
index 0000000..c0e7498
--- /dev/null
+++ b/ext/standard/tests/file/basename.phpt
Binary files differ
diff --git a/ext/standard/tests/file/basename_basic-win32.phpt b/ext/standard/tests/file/basename_basic-win32.phpt
new file mode 100644
index 0000000..f575c5a
--- /dev/null
+++ b/ext/standard/tests/file/basename_basic-win32.phpt
@@ -0,0 +1,101 @@
+--TEST--
+basename() basic functionality
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip Windows only basename tests');
+}
+?>
+--FILE--
+<?php
+
+$file_paths = array (
+ /* simple paths (forward slashes) */
+ "bar",
+ "/foo/bar",
+ "foo/bar",
+ "/bar",
+
+ /* simple paths with trailing slashes (forward slashes) */
+ "bar/",
+ "/bar/",
+ "/foo/bar/",
+ "foo/bar/",
+ "/bar/",
+
+ /* simple paths (backslashes) */
+ "bar",
+ "\\foo\\bar",
+ "foo\\bar",
+ "\\bar",
+
+ /* simple paths with trailing slashes (backslashes) */
+ "bar\\",
+ "\\bar\\",
+ "\\foo\\bar\\",
+ "foo\\bar\\",
+ "\\bar\\",
+
+ /* paths with numeric strings */
+ "10.5\\10.5",
+ "10.5/10.5",
+ "10.5",
+ "105",
+ "/10.5",
+ "\\10.5",
+ "10.5/",
+ "10.5\\",
+ "10/10.zip",
+ "0",
+ '0',
+
+ /* path with spaces */
+ " ",
+ ' ',
+
+ /* empty paths */
+ "",
+ '',
+ NULL,
+);
+
+foreach ($file_paths as $file_path) {
+ var_dump(basename($file_path));
+}
+
+?>
+--EXPECT--
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(4) "10.5"
+string(4) "10.5"
+string(4) "10.5"
+string(3) "105"
+string(4) "10.5"
+string(4) "10.5"
+string(4) "10.5"
+string(4) "10.5"
+string(6) "10.zip"
+string(1) "0"
+string(1) "0"
+string(1) " "
+string(1) " "
+string(0) ""
+string(0) ""
+string(0) ""
diff --git a/ext/standard/tests/file/basename_basic.phpt b/ext/standard/tests/file/basename_basic.phpt
new file mode 100644
index 0000000..68aefb2
--- /dev/null
+++ b/ext/standard/tests/file/basename_basic.phpt
@@ -0,0 +1,101 @@
+--TEST--
+basename() basic functionality
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip non-windows only test');
+}
+?>
+--FILE--
+<?php
+
+$file_paths = array (
+ /* simple paths (forward slashes) */
+ "bar",
+ "/foo/bar",
+ "foo/bar",
+ "/bar",
+
+ /* simple paths with trailing slashes (forward slashes) */
+ "bar/",
+ "/bar/",
+ "/foo/bar/",
+ "foo/bar/",
+ "/bar/",
+
+ /* simple paths (backslashes) */
+ "bar",
+ "\\foo\\bar",
+ "foo\\bar",
+ "\\bar",
+
+ /* simple paths with trailing slashes (backslashes) */
+ "bar\\",
+ "\\bar\\",
+ "\\foo\\bar\\",
+ "foo\\bar\\",
+ "\\bar\\",
+
+ /* paths with numeric strings */
+ "10.5\\10.5",
+ "10.5/10.5",
+ "10.5",
+ "105",
+ "/10.5",
+ "\\10.5",
+ "10.5/",
+ "10.5\\",
+ "10/10.zip",
+ "0",
+ '0',
+
+ /* path with spaces */
+ " ",
+ ' ',
+
+ /* empty paths */
+ "",
+ '',
+ NULL,
+);
+
+foreach ($file_paths as $file_path) {
+ var_dump(basename($file_path));
+}
+
+?>
+--EXPECT--
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(3) "bar"
+string(8) "\foo\bar"
+string(7) "foo\bar"
+string(4) "\bar"
+string(4) "bar\"
+string(5) "\bar\"
+string(9) "\foo\bar\"
+string(8) "foo\bar\"
+string(5) "\bar\"
+string(9) "10.5\10.5"
+string(4) "10.5"
+string(4) "10.5"
+string(3) "105"
+string(4) "10.5"
+string(5) "\10.5"
+string(4) "10.5"
+string(5) "10.5\"
+string(6) "10.zip"
+string(1) "0"
+string(1) "0"
+string(1) " "
+string(1) " "
+string(0) ""
+string(0) ""
+string(0) ""
diff --git a/ext/standard/tests/file/basename_error.phpt b/ext/standard/tests/file/basename_error.phpt
new file mode 100644
index 0000000..53c53cf
--- /dev/null
+++ b/ext/standard/tests/file/basename_error.phpt
@@ -0,0 +1,38 @@
+--TEST--
+Test basename() function : error conditions
+--FILE--
+<?php
+/* Prototype : string basename(string path [, string suffix])
+ * Description: Returns the filename component of the path
+ * Source code: ext/standard/string.c
+ * Alias to functions:
+ */
+
+echo "*** Testing basename() : error conditions ***\n";
+
+// Zero arguments
+echo "\n-- Testing basename() function with Zero arguments --\n";
+var_dump( basename() );
+
+//Test basename with one more than the expected number of arguments
+echo "\n-- Testing basename() function with more than expected no. of arguments --\n";
+$path = 'string_val';
+$suffix = 'string_val';
+$extra_arg = 10;
+var_dump( basename($path, $suffix, $extra_arg) );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing basename() : error conditions ***
+
+-- Testing basename() function with Zero arguments --
+
+Warning: basename() expects at least 1 parameter, 0 given in %s on line %d
+NULL
+
+-- Testing basename() function with more than expected no. of arguments --
+
+Warning: basename() expects at most 2 parameters, 3 given in %s on line %d
+NULL
+===DONE===
diff --git a/ext/standard/tests/file/basename_variation1-win32.phpt b/ext/standard/tests/file/basename_variation1-win32.phpt
new file mode 100644
index 0000000..0f4293e
--- /dev/null
+++ b/ext/standard/tests/file/basename_variation1-win32.phpt
@@ -0,0 +1,238 @@
+--TEST--
+basename() with various inputs
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip Windows only basename tests');
+}
+?>
+--FILE--
+<?php
+
+$prefixes = array (
+
+ // drive letters
+ "A:/",
+ "Z:/",
+ "A:\\",
+
+ // other prefixes
+ "http://",
+ "blah://",
+ "blah:\\",
+ "hostname:",
+
+ // home directory ~
+ "~/",
+ "~\\",
+);
+
+$paths = array (
+
+ "foo",
+ "foo/",
+ "foo\\",
+ "foo.bar",
+ "foo.bar/",
+ "foo.bar\\",
+ "dir/foo.bar",
+ "dir\\foo.bar",
+ "dir with spaces/foo.bar",
+ "dir with spaces\\foo.bar",
+
+);
+
+foreach ($prefixes as $prefix) {
+ foreach ($paths as $path) {
+ $input = $prefix . $path;
+ echo "basename for path $input is:\n";
+ var_dump(basename($input));
+ }
+}
+
+echo "\ndone\n";
+
+?>
+--EXPECT--
+basename for path A:/foo is:
+string(3) "foo"
+basename for path A:/foo/ is:
+string(3) "foo"
+basename for path A:/foo\ is:
+string(3) "foo"
+basename for path A:/foo.bar is:
+string(7) "foo.bar"
+basename for path A:/foo.bar/ is:
+string(7) "foo.bar"
+basename for path A:/foo.bar\ is:
+string(7) "foo.bar"
+basename for path A:/dir/foo.bar is:
+string(7) "foo.bar"
+basename for path A:/dir\foo.bar is:
+string(7) "foo.bar"
+basename for path A:/dir with spaces/foo.bar is:
+string(7) "foo.bar"
+basename for path A:/dir with spaces\foo.bar is:
+string(7) "foo.bar"
+basename for path Z:/foo is:
+string(3) "foo"
+basename for path Z:/foo/ is:
+string(3) "foo"
+basename for path Z:/foo\ is:
+string(3) "foo"
+basename for path Z:/foo.bar is:
+string(7) "foo.bar"
+basename for path Z:/foo.bar/ is:
+string(7) "foo.bar"
+basename for path Z:/foo.bar\ is:
+string(7) "foo.bar"
+basename for path Z:/dir/foo.bar is:
+string(7) "foo.bar"
+basename for path Z:/dir\foo.bar is:
+string(7) "foo.bar"
+basename for path Z:/dir with spaces/foo.bar is:
+string(7) "foo.bar"
+basename for path Z:/dir with spaces\foo.bar is:
+string(7) "foo.bar"
+basename for path A:\foo is:
+string(3) "foo"
+basename for path A:\foo/ is:
+string(3) "foo"
+basename for path A:\foo\ is:
+string(3) "foo"
+basename for path A:\foo.bar is:
+string(7) "foo.bar"
+basename for path A:\foo.bar/ is:
+string(7) "foo.bar"
+basename for path A:\foo.bar\ is:
+string(7) "foo.bar"
+basename for path A:\dir/foo.bar is:
+string(7) "foo.bar"
+basename for path A:\dir\foo.bar is:
+string(7) "foo.bar"
+basename for path A:\dir with spaces/foo.bar is:
+string(7) "foo.bar"
+basename for path A:\dir with spaces\foo.bar is:
+string(7) "foo.bar"
+basename for path http://foo is:
+string(3) "foo"
+basename for path http://foo/ is:
+string(3) "foo"
+basename for path http://foo\ is:
+string(3) "foo"
+basename for path http://foo.bar is:
+string(7) "foo.bar"
+basename for path http://foo.bar/ is:
+string(7) "foo.bar"
+basename for path http://foo.bar\ is:
+string(7) "foo.bar"
+basename for path http://dir/foo.bar is:
+string(7) "foo.bar"
+basename for path http://dir\foo.bar is:
+string(7) "foo.bar"
+basename for path http://dir with spaces/foo.bar is:
+string(7) "foo.bar"
+basename for path http://dir with spaces\foo.bar is:
+string(7) "foo.bar"
+basename for path blah://foo is:
+string(3) "foo"
+basename for path blah://foo/ is:
+string(3) "foo"
+basename for path blah://foo\ is:
+string(3) "foo"
+basename for path blah://foo.bar is:
+string(7) "foo.bar"
+basename for path blah://foo.bar/ is:
+string(7) "foo.bar"
+basename for path blah://foo.bar\ is:
+string(7) "foo.bar"
+basename for path blah://dir/foo.bar is:
+string(7) "foo.bar"
+basename for path blah://dir\foo.bar is:
+string(7) "foo.bar"
+basename for path blah://dir with spaces/foo.bar is:
+string(7) "foo.bar"
+basename for path blah://dir with spaces\foo.bar is:
+string(7) "foo.bar"
+basename for path blah:\foo is:
+string(3) "foo"
+basename for path blah:\foo/ is:
+string(3) "foo"
+basename for path blah:\foo\ is:
+string(3) "foo"
+basename for path blah:\foo.bar is:
+string(7) "foo.bar"
+basename for path blah:\foo.bar/ is:
+string(7) "foo.bar"
+basename for path blah:\foo.bar\ is:
+string(7) "foo.bar"
+basename for path blah:\dir/foo.bar is:
+string(7) "foo.bar"
+basename for path blah:\dir\foo.bar is:
+string(7) "foo.bar"
+basename for path blah:\dir with spaces/foo.bar is:
+string(7) "foo.bar"
+basename for path blah:\dir with spaces\foo.bar is:
+string(7) "foo.bar"
+basename for path hostname:foo is:
+string(12) "hostname:foo"
+basename for path hostname:foo/ is:
+string(12) "hostname:foo"
+basename for path hostname:foo\ is:
+string(12) "hostname:foo"
+basename for path hostname:foo.bar is:
+string(16) "hostname:foo.bar"
+basename for path hostname:foo.bar/ is:
+string(16) "hostname:foo.bar"
+basename for path hostname:foo.bar\ is:
+string(16) "hostname:foo.bar"
+basename for path hostname:dir/foo.bar is:
+string(7) "foo.bar"
+basename for path hostname:dir\foo.bar is:
+string(7) "foo.bar"
+basename for path hostname:dir with spaces/foo.bar is:
+string(7) "foo.bar"
+basename for path hostname:dir with spaces\foo.bar is:
+string(7) "foo.bar"
+basename for path ~/foo is:
+string(3) "foo"
+basename for path ~/foo/ is:
+string(3) "foo"
+basename for path ~/foo\ is:
+string(3) "foo"
+basename for path ~/foo.bar is:
+string(7) "foo.bar"
+basename for path ~/foo.bar/ is:
+string(7) "foo.bar"
+basename for path ~/foo.bar\ is:
+string(7) "foo.bar"
+basename for path ~/dir/foo.bar is:
+string(7) "foo.bar"
+basename for path ~/dir\foo.bar is:
+string(7) "foo.bar"
+basename for path ~/dir with spaces/foo.bar is:
+string(7) "foo.bar"
+basename for path ~/dir with spaces\foo.bar is:
+string(7) "foo.bar"
+basename for path ~\foo is:
+string(3) "foo"
+basename for path ~\foo/ is:
+string(3) "foo"
+basename for path ~\foo\ is:
+string(3) "foo"
+basename for path ~\foo.bar is:
+string(7) "foo.bar"
+basename for path ~\foo.bar/ is:
+string(7) "foo.bar"
+basename for path ~\foo.bar\ is:
+string(7) "foo.bar"
+basename for path ~\dir/foo.bar is:
+string(7) "foo.bar"
+basename for path ~\dir\foo.bar is:
+string(7) "foo.bar"
+basename for path ~\dir with spaces/foo.bar is:
+string(7) "foo.bar"
+basename for path ~\dir with spaces\foo.bar is:
+string(7) "foo.bar"
+
+done
diff --git a/ext/standard/tests/file/basename_variation1.phpt b/ext/standard/tests/file/basename_variation1.phpt
new file mode 100644
index 0000000..9358238
--- /dev/null
+++ b/ext/standard/tests/file/basename_variation1.phpt
@@ -0,0 +1,238 @@
+--TEST--
+basename() with various inputs
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip non-windows only test');
+}
+?>
+--FILE--
+<?php
+
+$prefixes = array (
+
+ // drive letters
+ "A:/",
+ "Z:/",
+ "A:\\",
+
+ // other prefixes
+ "http://",
+ "blah://",
+ "blah:\\",
+ "hostname:",
+
+ // home directory ~
+ "~/",
+ "~\\",
+);
+
+$paths = array (
+
+ "foo",
+ "foo/",
+ "foo\\",
+ "foo.bar",
+ "foo.bar/",
+ "foo.bar\\",
+ "dir/foo.bar",
+ "dir\\foo.bar",
+ "dir with spaces/foo.bar",
+ "dir with spaces\\foo.bar",
+
+);
+
+foreach ($prefixes as $prefix) {
+ foreach ($paths as $path) {
+ $input = $prefix . $path;
+ echo "basename for path $input is:\n";
+ var_dump(basename($input));
+ }
+}
+
+echo "\ndone\n";
+
+?>
+--EXPECT--
+basename for path A:/foo is:
+string(3) "foo"
+basename for path A:/foo/ is:
+string(3) "foo"
+basename for path A:/foo\ is:
+string(4) "foo\"
+basename for path A:/foo.bar is:
+string(7) "foo.bar"
+basename for path A:/foo.bar/ is:
+string(7) "foo.bar"
+basename for path A:/foo.bar\ is:
+string(8) "foo.bar\"
+basename for path A:/dir/foo.bar is:
+string(7) "foo.bar"
+basename for path A:/dir\foo.bar is:
+string(11) "dir\foo.bar"
+basename for path A:/dir with spaces/foo.bar is:
+string(7) "foo.bar"
+basename for path A:/dir with spaces\foo.bar is:
+string(23) "dir with spaces\foo.bar"
+basename for path Z:/foo is:
+string(3) "foo"
+basename for path Z:/foo/ is:
+string(3) "foo"
+basename for path Z:/foo\ is:
+string(4) "foo\"
+basename for path Z:/foo.bar is:
+string(7) "foo.bar"
+basename for path Z:/foo.bar/ is:
+string(7) "foo.bar"
+basename for path Z:/foo.bar\ is:
+string(8) "foo.bar\"
+basename for path Z:/dir/foo.bar is:
+string(7) "foo.bar"
+basename for path Z:/dir\foo.bar is:
+string(11) "dir\foo.bar"
+basename for path Z:/dir with spaces/foo.bar is:
+string(7) "foo.bar"
+basename for path Z:/dir with spaces\foo.bar is:
+string(23) "dir with spaces\foo.bar"
+basename for path A:\foo is:
+string(6) "A:\foo"
+basename for path A:\foo/ is:
+string(6) "A:\foo"
+basename for path A:\foo\ is:
+string(7) "A:\foo\"
+basename for path A:\foo.bar is:
+string(10) "A:\foo.bar"
+basename for path A:\foo.bar/ is:
+string(10) "A:\foo.bar"
+basename for path A:\foo.bar\ is:
+string(11) "A:\foo.bar\"
+basename for path A:\dir/foo.bar is:
+string(7) "foo.bar"
+basename for path A:\dir\foo.bar is:
+string(14) "A:\dir\foo.bar"
+basename for path A:\dir with spaces/foo.bar is:
+string(7) "foo.bar"
+basename for path A:\dir with spaces\foo.bar is:
+string(26) "A:\dir with spaces\foo.bar"
+basename for path http://foo is:
+string(3) "foo"
+basename for path http://foo/ is:
+string(3) "foo"
+basename for path http://foo\ is:
+string(4) "foo\"
+basename for path http://foo.bar is:
+string(7) "foo.bar"
+basename for path http://foo.bar/ is:
+string(7) "foo.bar"
+basename for path http://foo.bar\ is:
+string(8) "foo.bar\"
+basename for path http://dir/foo.bar is:
+string(7) "foo.bar"
+basename for path http://dir\foo.bar is:
+string(11) "dir\foo.bar"
+basename for path http://dir with spaces/foo.bar is:
+string(7) "foo.bar"
+basename for path http://dir with spaces\foo.bar is:
+string(23) "dir with spaces\foo.bar"
+basename for path blah://foo is:
+string(3) "foo"
+basename for path blah://foo/ is:
+string(3) "foo"
+basename for path blah://foo\ is:
+string(4) "foo\"
+basename for path blah://foo.bar is:
+string(7) "foo.bar"
+basename for path blah://foo.bar/ is:
+string(7) "foo.bar"
+basename for path blah://foo.bar\ is:
+string(8) "foo.bar\"
+basename for path blah://dir/foo.bar is:
+string(7) "foo.bar"
+basename for path blah://dir\foo.bar is:
+string(11) "dir\foo.bar"
+basename for path blah://dir with spaces/foo.bar is:
+string(7) "foo.bar"
+basename for path blah://dir with spaces\foo.bar is:
+string(23) "dir with spaces\foo.bar"
+basename for path blah:\foo is:
+string(9) "blah:\foo"
+basename for path blah:\foo/ is:
+string(9) "blah:\foo"
+basename for path blah:\foo\ is:
+string(10) "blah:\foo\"
+basename for path blah:\foo.bar is:
+string(13) "blah:\foo.bar"
+basename for path blah:\foo.bar/ is:
+string(13) "blah:\foo.bar"
+basename for path blah:\foo.bar\ is:
+string(14) "blah:\foo.bar\"
+basename for path blah:\dir/foo.bar is:
+string(7) "foo.bar"
+basename for path blah:\dir\foo.bar is:
+string(17) "blah:\dir\foo.bar"
+basename for path blah:\dir with spaces/foo.bar is:
+string(7) "foo.bar"
+basename for path blah:\dir with spaces\foo.bar is:
+string(29) "blah:\dir with spaces\foo.bar"
+basename for path hostname:foo is:
+string(12) "hostname:foo"
+basename for path hostname:foo/ is:
+string(12) "hostname:foo"
+basename for path hostname:foo\ is:
+string(13) "hostname:foo\"
+basename for path hostname:foo.bar is:
+string(16) "hostname:foo.bar"
+basename for path hostname:foo.bar/ is:
+string(16) "hostname:foo.bar"
+basename for path hostname:foo.bar\ is:
+string(17) "hostname:foo.bar\"
+basename for path hostname:dir/foo.bar is:
+string(7) "foo.bar"
+basename for path hostname:dir\foo.bar is:
+string(20) "hostname:dir\foo.bar"
+basename for path hostname:dir with spaces/foo.bar is:
+string(7) "foo.bar"
+basename for path hostname:dir with spaces\foo.bar is:
+string(32) "hostname:dir with spaces\foo.bar"
+basename for path ~/foo is:
+string(3) "foo"
+basename for path ~/foo/ is:
+string(3) "foo"
+basename for path ~/foo\ is:
+string(4) "foo\"
+basename for path ~/foo.bar is:
+string(7) "foo.bar"
+basename for path ~/foo.bar/ is:
+string(7) "foo.bar"
+basename for path ~/foo.bar\ is:
+string(8) "foo.bar\"
+basename for path ~/dir/foo.bar is:
+string(7) "foo.bar"
+basename for path ~/dir\foo.bar is:
+string(11) "dir\foo.bar"
+basename for path ~/dir with spaces/foo.bar is:
+string(7) "foo.bar"
+basename for path ~/dir with spaces\foo.bar is:
+string(23) "dir with spaces\foo.bar"
+basename for path ~\foo is:
+string(5) "~\foo"
+basename for path ~\foo/ is:
+string(5) "~\foo"
+basename for path ~\foo\ is:
+string(6) "~\foo\"
+basename for path ~\foo.bar is:
+string(9) "~\foo.bar"
+basename for path ~\foo.bar/ is:
+string(9) "~\foo.bar"
+basename for path ~\foo.bar\ is:
+string(10) "~\foo.bar\"
+basename for path ~\dir/foo.bar is:
+string(7) "foo.bar"
+basename for path ~\dir\foo.bar is:
+string(13) "~\dir\foo.bar"
+basename for path ~\dir with spaces/foo.bar is:
+string(7) "foo.bar"
+basename for path ~\dir with spaces\foo.bar is:
+string(25) "~\dir with spaces\foo.bar"
+
+done
diff --git a/ext/standard/tests/file/basename_variation2-win32.phpt b/ext/standard/tests/file/basename_variation2-win32.phpt
new file mode 100644
index 0000000..5e9961b
--- /dev/null
+++ b/ext/standard/tests/file/basename_variation2-win32.phpt
@@ -0,0 +1,253 @@
+--TEST--
+Testing basename() with various values for the suffix parameter
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip Windows only basename tests');
+}
+?>
+--FILE--
+<?php
+
+$paths = array (
+
+ "foo",
+ "foo/",
+ "foo\\",
+ "foo.bar",
+ "foo.bar/",
+ "foo.bar\\",
+ "dir/foo.bar",
+ "dir\\foo.bar",
+ "dir with spaces/foo.bar",
+ "dir with spaces\\foo.bar",
+
+);
+
+$suffixes = array (
+
+ ".bar",
+ ".b",
+ ".",
+ " ",
+ "foo",
+ "foo.bar",
+ "foo/bar",
+ "foo\\bar",
+ "/",
+ "\\",
+);
+
+foreach ($paths as $path) {
+ foreach ($suffixes as $suffix) {
+ echo "basename for path $path, supplying suffix $suffix is:\n";
+ var_dump(basename($path, $suffix));
+ }
+}
+
+echo "\ndone\n";
+
+?>
+--EXPECT--
+basename for path foo, supplying suffix .bar is:
+string(3) "foo"
+basename for path foo, supplying suffix .b is:
+string(3) "foo"
+basename for path foo, supplying suffix . is:
+string(3) "foo"
+basename for path foo, supplying suffix is:
+string(3) "foo"
+basename for path foo, supplying suffix foo is:
+string(3) "foo"
+basename for path foo, supplying suffix foo.bar is:
+string(3) "foo"
+basename for path foo, supplying suffix foo/bar is:
+string(3) "foo"
+basename for path foo, supplying suffix foo\bar is:
+string(3) "foo"
+basename for path foo, supplying suffix / is:
+string(3) "foo"
+basename for path foo, supplying suffix \ is:
+string(3) "foo"
+basename for path foo/, supplying suffix .bar is:
+string(3) "foo"
+basename for path foo/, supplying suffix .b is:
+string(3) "foo"
+basename for path foo/, supplying suffix . is:
+string(3) "foo"
+basename for path foo/, supplying suffix is:
+string(3) "foo"
+basename for path foo/, supplying suffix foo is:
+string(3) "foo"
+basename for path foo/, supplying suffix foo.bar is:
+string(3) "foo"
+basename for path foo/, supplying suffix foo/bar is:
+string(3) "foo"
+basename for path foo/, supplying suffix foo\bar is:
+string(3) "foo"
+basename for path foo/, supplying suffix / is:
+string(3) "foo"
+basename for path foo/, supplying suffix \ is:
+string(3) "foo"
+basename for path foo\, supplying suffix .bar is:
+string(3) "foo"
+basename for path foo\, supplying suffix .b is:
+string(3) "foo"
+basename for path foo\, supplying suffix . is:
+string(3) "foo"
+basename for path foo\, supplying suffix is:
+string(3) "foo"
+basename for path foo\, supplying suffix foo is:
+string(3) "foo"
+basename for path foo\, supplying suffix foo.bar is:
+string(3) "foo"
+basename for path foo\, supplying suffix foo/bar is:
+string(3) "foo"
+basename for path foo\, supplying suffix foo\bar is:
+string(3) "foo"
+basename for path foo\, supplying suffix / is:
+string(3) "foo"
+basename for path foo\, supplying suffix \ is:
+string(3) "foo"
+basename for path foo.bar, supplying suffix .bar is:
+string(3) "foo"
+basename for path foo.bar, supplying suffix .b is:
+string(7) "foo.bar"
+basename for path foo.bar, supplying suffix . is:
+string(7) "foo.bar"
+basename for path foo.bar, supplying suffix is:
+string(7) "foo.bar"
+basename for path foo.bar, supplying suffix foo is:
+string(7) "foo.bar"
+basename for path foo.bar, supplying suffix foo.bar is:
+string(7) "foo.bar"
+basename for path foo.bar, supplying suffix foo/bar is:
+string(7) "foo.bar"
+basename for path foo.bar, supplying suffix foo\bar is:
+string(7) "foo.bar"
+basename for path foo.bar, supplying suffix / is:
+string(7) "foo.bar"
+basename for path foo.bar, supplying suffix \ is:
+string(7) "foo.bar"
+basename for path foo.bar/, supplying suffix .bar is:
+string(3) "foo"
+basename for path foo.bar/, supplying suffix .b is:
+string(7) "foo.bar"
+basename for path foo.bar/, supplying suffix . is:
+string(7) "foo.bar"
+basename for path foo.bar/, supplying suffix is:
+string(7) "foo.bar"
+basename for path foo.bar/, supplying suffix foo is:
+string(7) "foo.bar"
+basename for path foo.bar/, supplying suffix foo.bar is:
+string(7) "foo.bar"
+basename for path foo.bar/, supplying suffix foo/bar is:
+string(7) "foo.bar"
+basename for path foo.bar/, supplying suffix foo\bar is:
+string(7) "foo.bar"
+basename for path foo.bar/, supplying suffix / is:
+string(7) "foo.bar"
+basename for path foo.bar/, supplying suffix \ is:
+string(7) "foo.bar"
+basename for path foo.bar\, supplying suffix .bar is:
+string(3) "foo"
+basename for path foo.bar\, supplying suffix .b is:
+string(7) "foo.bar"
+basename for path foo.bar\, supplying suffix . is:
+string(7) "foo.bar"
+basename for path foo.bar\, supplying suffix is:
+string(7) "foo.bar"
+basename for path foo.bar\, supplying suffix foo is:
+string(7) "foo.bar"
+basename for path foo.bar\, supplying suffix foo.bar is:
+string(7) "foo.bar"
+basename for path foo.bar\, supplying suffix foo/bar is:
+string(7) "foo.bar"
+basename for path foo.bar\, supplying suffix foo\bar is:
+string(7) "foo.bar"
+basename for path foo.bar\, supplying suffix / is:
+string(7) "foo.bar"
+basename for path foo.bar\, supplying suffix \ is:
+string(7) "foo.bar"
+basename for path dir/foo.bar, supplying suffix .bar is:
+string(3) "foo"
+basename for path dir/foo.bar, supplying suffix .b is:
+string(7) "foo.bar"
+basename for path dir/foo.bar, supplying suffix . is:
+string(7) "foo.bar"
+basename for path dir/foo.bar, supplying suffix is:
+string(7) "foo.bar"
+basename for path dir/foo.bar, supplying suffix foo is:
+string(7) "foo.bar"
+basename for path dir/foo.bar, supplying suffix foo.bar is:
+string(7) "foo.bar"
+basename for path dir/foo.bar, supplying suffix foo/bar is:
+string(7) "foo.bar"
+basename for path dir/foo.bar, supplying suffix foo\bar is:
+string(7) "foo.bar"
+basename for path dir/foo.bar, supplying suffix / is:
+string(7) "foo.bar"
+basename for path dir/foo.bar, supplying suffix \ is:
+string(7) "foo.bar"
+basename for path dir\foo.bar, supplying suffix .bar is:
+string(3) "foo"
+basename for path dir\foo.bar, supplying suffix .b is:
+string(7) "foo.bar"
+basename for path dir\foo.bar, supplying suffix . is:
+string(7) "foo.bar"
+basename for path dir\foo.bar, supplying suffix is:
+string(7) "foo.bar"
+basename for path dir\foo.bar, supplying suffix foo is:
+string(7) "foo.bar"
+basename for path dir\foo.bar, supplying suffix foo.bar is:
+string(7) "foo.bar"
+basename for path dir\foo.bar, supplying suffix foo/bar is:
+string(7) "foo.bar"
+basename for path dir\foo.bar, supplying suffix foo\bar is:
+string(7) "foo.bar"
+basename for path dir\foo.bar, supplying suffix / is:
+string(7) "foo.bar"
+basename for path dir\foo.bar, supplying suffix \ is:
+string(7) "foo.bar"
+basename for path dir with spaces/foo.bar, supplying suffix .bar is:
+string(3) "foo"
+basename for path dir with spaces/foo.bar, supplying suffix .b is:
+string(7) "foo.bar"
+basename for path dir with spaces/foo.bar, supplying suffix . is:
+string(7) "foo.bar"
+basename for path dir with spaces/foo.bar, supplying suffix is:
+string(7) "foo.bar"
+basename for path dir with spaces/foo.bar, supplying suffix foo is:
+string(7) "foo.bar"
+basename for path dir with spaces/foo.bar, supplying suffix foo.bar is:
+string(7) "foo.bar"
+basename for path dir with spaces/foo.bar, supplying suffix foo/bar is:
+string(7) "foo.bar"
+basename for path dir with spaces/foo.bar, supplying suffix foo\bar is:
+string(7) "foo.bar"
+basename for path dir with spaces/foo.bar, supplying suffix / is:
+string(7) "foo.bar"
+basename for path dir with spaces/foo.bar, supplying suffix \ is:
+string(7) "foo.bar"
+basename for path dir with spaces\foo.bar, supplying suffix .bar is:
+string(3) "foo"
+basename for path dir with spaces\foo.bar, supplying suffix .b is:
+string(7) "foo.bar"
+basename for path dir with spaces\foo.bar, supplying suffix . is:
+string(7) "foo.bar"
+basename for path dir with spaces\foo.bar, supplying suffix is:
+string(7) "foo.bar"
+basename for path dir with spaces\foo.bar, supplying suffix foo is:
+string(7) "foo.bar"
+basename for path dir with spaces\foo.bar, supplying suffix foo.bar is:
+string(7) "foo.bar"
+basename for path dir with spaces\foo.bar, supplying suffix foo/bar is:
+string(7) "foo.bar"
+basename for path dir with spaces\foo.bar, supplying suffix foo\bar is:
+string(7) "foo.bar"
+basename for path dir with spaces\foo.bar, supplying suffix / is:
+string(7) "foo.bar"
+basename for path dir with spaces\foo.bar, supplying suffix \ is:
+string(7) "foo.bar"
+
+done
diff --git a/ext/standard/tests/file/basename_variation2.phpt b/ext/standard/tests/file/basename_variation2.phpt
new file mode 100644
index 0000000..96cfd65
--- /dev/null
+++ b/ext/standard/tests/file/basename_variation2.phpt
@@ -0,0 +1,253 @@
+--TEST--
+Testing basename() with various values for the suffix parameter
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip non-windows only test');
+}
+?>
+--FILE--
+<?php
+
+$paths = array (
+
+ "foo",
+ "foo/",
+ "foo\\",
+ "foo.bar",
+ "foo.bar/",
+ "foo.bar\\",
+ "dir/foo.bar",
+ "dir\\foo.bar",
+ "dir with spaces/foo.bar",
+ "dir with spaces\\foo.bar",
+
+);
+
+$suffixes = array (
+
+ ".bar",
+ ".b",
+ ".",
+ " ",
+ "foo",
+ "foo.bar",
+ "foo/bar",
+ "foo\\bar",
+ "/",
+ "\\",
+);
+
+foreach ($paths as $path) {
+ foreach ($suffixes as $suffix) {
+ echo "basename for path $path, supplying suffix $suffix is:\n";
+ var_dump(basename($path, $suffix));
+ }
+}
+
+echo "\ndone\n";
+
+?>
+--EXPECT--
+basename for path foo, supplying suffix .bar is:
+string(3) "foo"
+basename for path foo, supplying suffix .b is:
+string(3) "foo"
+basename for path foo, supplying suffix . is:
+string(3) "foo"
+basename for path foo, supplying suffix is:
+string(3) "foo"
+basename for path foo, supplying suffix foo is:
+string(3) "foo"
+basename for path foo, supplying suffix foo.bar is:
+string(3) "foo"
+basename for path foo, supplying suffix foo/bar is:
+string(3) "foo"
+basename for path foo, supplying suffix foo\bar is:
+string(3) "foo"
+basename for path foo, supplying suffix / is:
+string(3) "foo"
+basename for path foo, supplying suffix \ is:
+string(3) "foo"
+basename for path foo/, supplying suffix .bar is:
+string(3) "foo"
+basename for path foo/, supplying suffix .b is:
+string(3) "foo"
+basename for path foo/, supplying suffix . is:
+string(3) "foo"
+basename for path foo/, supplying suffix is:
+string(3) "foo"
+basename for path foo/, supplying suffix foo is:
+string(3) "foo"
+basename for path foo/, supplying suffix foo.bar is:
+string(3) "foo"
+basename for path foo/, supplying suffix foo/bar is:
+string(3) "foo"
+basename for path foo/, supplying suffix foo\bar is:
+string(3) "foo"
+basename for path foo/, supplying suffix / is:
+string(3) "foo"
+basename for path foo/, supplying suffix \ is:
+string(3) "foo"
+basename for path foo\, supplying suffix .bar is:
+string(4) "foo\"
+basename for path foo\, supplying suffix .b is:
+string(4) "foo\"
+basename for path foo\, supplying suffix . is:
+string(4) "foo\"
+basename for path foo\, supplying suffix is:
+string(4) "foo\"
+basename for path foo\, supplying suffix foo is:
+string(4) "foo\"
+basename for path foo\, supplying suffix foo.bar is:
+string(4) "foo\"
+basename for path foo\, supplying suffix foo/bar is:
+string(4) "foo\"
+basename for path foo\, supplying suffix foo\bar is:
+string(4) "foo\"
+basename for path foo\, supplying suffix / is:
+string(4) "foo\"
+basename for path foo\, supplying suffix \ is:
+string(3) "foo"
+basename for path foo.bar, supplying suffix .bar is:
+string(3) "foo"
+basename for path foo.bar, supplying suffix .b is:
+string(7) "foo.bar"
+basename for path foo.bar, supplying suffix . is:
+string(7) "foo.bar"
+basename for path foo.bar, supplying suffix is:
+string(7) "foo.bar"
+basename for path foo.bar, supplying suffix foo is:
+string(7) "foo.bar"
+basename for path foo.bar, supplying suffix foo.bar is:
+string(7) "foo.bar"
+basename for path foo.bar, supplying suffix foo/bar is:
+string(7) "foo.bar"
+basename for path foo.bar, supplying suffix foo\bar is:
+string(7) "foo.bar"
+basename for path foo.bar, supplying suffix / is:
+string(7) "foo.bar"
+basename for path foo.bar, supplying suffix \ is:
+string(7) "foo.bar"
+basename for path foo.bar/, supplying suffix .bar is:
+string(3) "foo"
+basename for path foo.bar/, supplying suffix .b is:
+string(7) "foo.bar"
+basename for path foo.bar/, supplying suffix . is:
+string(7) "foo.bar"
+basename for path foo.bar/, supplying suffix is:
+string(7) "foo.bar"
+basename for path foo.bar/, supplying suffix foo is:
+string(7) "foo.bar"
+basename for path foo.bar/, supplying suffix foo.bar is:
+string(7) "foo.bar"
+basename for path foo.bar/, supplying suffix foo/bar is:
+string(7) "foo.bar"
+basename for path foo.bar/, supplying suffix foo\bar is:
+string(7) "foo.bar"
+basename for path foo.bar/, supplying suffix / is:
+string(7) "foo.bar"
+basename for path foo.bar/, supplying suffix \ is:
+string(7) "foo.bar"
+basename for path foo.bar\, supplying suffix .bar is:
+string(8) "foo.bar\"
+basename for path foo.bar\, supplying suffix .b is:
+string(8) "foo.bar\"
+basename for path foo.bar\, supplying suffix . is:
+string(8) "foo.bar\"
+basename for path foo.bar\, supplying suffix is:
+string(8) "foo.bar\"
+basename for path foo.bar\, supplying suffix foo is:
+string(8) "foo.bar\"
+basename for path foo.bar\, supplying suffix foo.bar is:
+string(8) "foo.bar\"
+basename for path foo.bar\, supplying suffix foo/bar is:
+string(8) "foo.bar\"
+basename for path foo.bar\, supplying suffix foo\bar is:
+string(8) "foo.bar\"
+basename for path foo.bar\, supplying suffix / is:
+string(8) "foo.bar\"
+basename for path foo.bar\, supplying suffix \ is:
+string(7) "foo.bar"
+basename for path dir/foo.bar, supplying suffix .bar is:
+string(3) "foo"
+basename for path dir/foo.bar, supplying suffix .b is:
+string(7) "foo.bar"
+basename for path dir/foo.bar, supplying suffix . is:
+string(7) "foo.bar"
+basename for path dir/foo.bar, supplying suffix is:
+string(7) "foo.bar"
+basename for path dir/foo.bar, supplying suffix foo is:
+string(7) "foo.bar"
+basename for path dir/foo.bar, supplying suffix foo.bar is:
+string(7) "foo.bar"
+basename for path dir/foo.bar, supplying suffix foo/bar is:
+string(7) "foo.bar"
+basename for path dir/foo.bar, supplying suffix foo\bar is:
+string(7) "foo.bar"
+basename for path dir/foo.bar, supplying suffix / is:
+string(7) "foo.bar"
+basename for path dir/foo.bar, supplying suffix \ is:
+string(7) "foo.bar"
+basename for path dir\foo.bar, supplying suffix .bar is:
+string(7) "dir\foo"
+basename for path dir\foo.bar, supplying suffix .b is:
+string(11) "dir\foo.bar"
+basename for path dir\foo.bar, supplying suffix . is:
+string(11) "dir\foo.bar"
+basename for path dir\foo.bar, supplying suffix is:
+string(11) "dir\foo.bar"
+basename for path dir\foo.bar, supplying suffix foo is:
+string(11) "dir\foo.bar"
+basename for path dir\foo.bar, supplying suffix foo.bar is:
+string(4) "dir\"
+basename for path dir\foo.bar, supplying suffix foo/bar is:
+string(11) "dir\foo.bar"
+basename for path dir\foo.bar, supplying suffix foo\bar is:
+string(11) "dir\foo.bar"
+basename for path dir\foo.bar, supplying suffix / is:
+string(11) "dir\foo.bar"
+basename for path dir\foo.bar, supplying suffix \ is:
+string(11) "dir\foo.bar"
+basename for path dir with spaces/foo.bar, supplying suffix .bar is:
+string(3) "foo"
+basename for path dir with spaces/foo.bar, supplying suffix .b is:
+string(7) "foo.bar"
+basename for path dir with spaces/foo.bar, supplying suffix . is:
+string(7) "foo.bar"
+basename for path dir with spaces/foo.bar, supplying suffix is:
+string(7) "foo.bar"
+basename for path dir with spaces/foo.bar, supplying suffix foo is:
+string(7) "foo.bar"
+basename for path dir with spaces/foo.bar, supplying suffix foo.bar is:
+string(7) "foo.bar"
+basename for path dir with spaces/foo.bar, supplying suffix foo/bar is:
+string(7) "foo.bar"
+basename for path dir with spaces/foo.bar, supplying suffix foo\bar is:
+string(7) "foo.bar"
+basename for path dir with spaces/foo.bar, supplying suffix / is:
+string(7) "foo.bar"
+basename for path dir with spaces/foo.bar, supplying suffix \ is:
+string(7) "foo.bar"
+basename for path dir with spaces\foo.bar, supplying suffix .bar is:
+string(19) "dir with spaces\foo"
+basename for path dir with spaces\foo.bar, supplying suffix .b is:
+string(23) "dir with spaces\foo.bar"
+basename for path dir with spaces\foo.bar, supplying suffix . is:
+string(23) "dir with spaces\foo.bar"
+basename for path dir with spaces\foo.bar, supplying suffix is:
+string(23) "dir with spaces\foo.bar"
+basename for path dir with spaces\foo.bar, supplying suffix foo is:
+string(23) "dir with spaces\foo.bar"
+basename for path dir with spaces\foo.bar, supplying suffix foo.bar is:
+string(16) "dir with spaces\"
+basename for path dir with spaces\foo.bar, supplying suffix foo/bar is:
+string(23) "dir with spaces\foo.bar"
+basename for path dir with spaces\foo.bar, supplying suffix foo\bar is:
+string(23) "dir with spaces\foo.bar"
+basename for path dir with spaces\foo.bar, supplying suffix / is:
+string(23) "dir with spaces\foo.bar"
+basename for path dir with spaces\foo.bar, supplying suffix \ is:
+string(23) "dir with spaces\foo.bar"
+
+done
diff --git a/ext/standard/tests/file/basename_variation3.phpt b/ext/standard/tests/file/basename_variation3.phpt
new file mode 100644
index 0000000..f01f550
--- /dev/null
+++ b/ext/standard/tests/file/basename_variation3.phpt
@@ -0,0 +1,185 @@
+--TEST--
+Test basename() function : first parameter type variations
+--FILE--
+<?php
+/* Prototype : string basename(string path [, string suffix])
+ * Description: Returns the filename component of the path
+ * Source code: ext/standard/string.c
+ * Alias to functions:
+ */
+
+echo "*** Testing basename() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+ // int data
+ 'int 0' => 0,
+ 'int 1' => 1,
+ 'int 12345' => 12345,
+ 'int -12345' => -2345,
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float -10.5' => -10.5,
+ 'float 12.3456789000e10' => 12.3456789000e10,
+ 'float -12.3456789000e10' => -12.3456789000e10,
+ 'float .5' => .5,
+
+ // array data
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for path
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( basename($value) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing basename() : usage variation ***
+
+--int 0--
+string(1) "0"
+
+--int 1--
+string(1) "1"
+
+--int 12345--
+string(5) "12345"
+
+--int -12345--
+string(5) "-2345"
+
+--float 10.5--
+string(4) "10.5"
+
+--float -10.5--
+string(5) "-10.5"
+
+--float 12.3456789000e10--
+string(12) "123456789000"
+
+--float -12.3456789000e10--
+string(13) "-123456789000"
+
+--float .5--
+string(3) "0.5"
+
+--empty array--
+Error: 2 - basename() expects parameter 1 to be string, array given, %s(%d)
+NULL
+
+--int indexed array--
+Error: 2 - basename() expects parameter 1 to be string, array given, %s(%d)
+NULL
+
+--associative array--
+Error: 2 - basename() expects parameter 1 to be string, array given, %s(%d)
+NULL
+
+--nested arrays--
+Error: 2 - basename() expects parameter 1 to be string, array given, %s(%d)
+NULL
+
+--uppercase NULL--
+string(0) ""
+
+--lowercase null--
+string(0) ""
+
+--lowercase true--
+string(1) "1"
+
+--lowercase false--
+string(0) ""
+
+--uppercase TRUE--
+string(1) "1"
+
+--uppercase FALSE--
+string(0) ""
+
+--empty string DQ--
+string(0) ""
+
+--empty string SQ--
+string(0) ""
+
+--instance of classWithToString--
+string(14) "Class A object"
+
+--instance of classWithoutToString--
+Error: 2 - basename() expects parameter 1 to be string, object given, %s(%d)
+NULL
+
+--undefined var--
+string(0) ""
+
+--unset var--
+string(0) ""
+===DONE===
diff --git a/ext/standard/tests/file/basename_variation4.phpt b/ext/standard/tests/file/basename_variation4.phpt
new file mode 100644
index 0000000..88ce61a
--- /dev/null
+++ b/ext/standard/tests/file/basename_variation4.phpt
@@ -0,0 +1,188 @@
+--TEST--
+Test basename() function : second parameter type variation
+--FILE--
+<?php
+/* Prototype : string basename(string path [, string suffix])
+ * Description: Returns the filename component of the path
+ * Source code: ext/standard/string.c
+ * Alias to functions:
+ */
+
+echo "*** Testing basename() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted
+$path = 'path';
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+ // int data
+ 'int 0' => 0,
+ 'int 1' => 1,
+ 'int 12345' => 12345,
+ 'int -12345' => -2345,
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float -10.5' => -10.5,
+ 'float 12.3456789000e10' => 12.3456789000e10,
+ 'float -12.3456789000e10' => -12.3456789000e10,
+ 'float .5' => .5,
+
+ // array data
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for suffix
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( basename($path, $value) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing basename() : usage variation ***
+
+--int 0--
+string(4) "path"
+
+--int 1--
+string(4) "path"
+
+--int 12345--
+string(4) "path"
+
+--int -12345--
+string(4) "path"
+
+--float 10.5--
+string(4) "path"
+
+--float -10.5--
+string(4) "path"
+
+--float 12.3456789000e10--
+string(4) "path"
+
+--float -12.3456789000e10--
+string(4) "path"
+
+--float .5--
+string(4) "path"
+
+--empty array--
+Error: 2 - basename() expects parameter 2 to be string, array given, %s(%d)
+NULL
+
+--int indexed array--
+Error: 2 - basename() expects parameter 2 to be string, array given, %s(%d)
+NULL
+
+--associative array--
+Error: 2 - basename() expects parameter 2 to be string, array given, %s(%d)
+NULL
+
+--nested arrays--
+Error: 2 - basename() expects parameter 2 to be string, array given, %s(%d)
+NULL
+
+--uppercase NULL--
+string(4) "path"
+
+--lowercase null--
+string(4) "path"
+
+--lowercase true--
+string(4) "path"
+
+--lowercase false--
+string(4) "path"
+
+--uppercase TRUE--
+string(4) "path"
+
+--uppercase FALSE--
+string(4) "path"
+
+--empty string DQ--
+string(4) "path"
+
+--empty string SQ--
+string(4) "path"
+
+--instance of classWithToString--
+string(4) "path"
+
+--instance of classWithoutToString--
+Error: 2 - basename() expects parameter 2 to be string, object given, %s(%d)
+NULL
+
+--undefined var--
+string(4) "path"
+
+--unset var--
+string(4) "path"
+===DONE===
diff --git a/ext/standard/tests/file/bug12556.phpt b/ext/standard/tests/file/bug12556.phpt
new file mode 100644
index 0000000..c8e35cf
--- /dev/null
+++ b/ext/standard/tests/file/bug12556.phpt
@@ -0,0 +1,48 @@
+--TEST--
+Bug #12556 (fgetcsv() ignores lengths when quotes not closed)
+--FILE--
+<?php
+$fp = fopen(dirname(__FILE__)."/test.csv", "r");
+while($line = fgetcsv($fp, 24)) {
+ $line = str_replace("\x0d\x0a", "\x0a", $line);
+ var_dump($line);
+}
+fclose($fp);
+?>
+--EXPECT--
+array(4) {
+ [0]=>
+ string(1) "6"
+ [1]=>
+ string(1) "7"
+ [2]=>
+ string(1) "8"
+ [3]=>
+ string(5) "line1"
+}
+array(4) {
+ [0]=>
+ string(1) "1"
+ [1]=>
+ string(1) "2"
+ [2]=>
+ string(1) "3"
+ [3]=>
+ string(186) "line2
+2,4,5,line3
+2,4,5,line3
+2,4,5,line3
+2,4,5,line3
+2,4,5,line3
+2,4,5,line3
+2,4,5,line3
+2,4,5,line3
+2,4,5,line3
+2,4,5,line3
+2,4,5,line3
+2,4,5,line3
+2,4,5,line3
+2,4,5,line3
+2,4,5,line3
+"
+}
diff --git a/ext/standard/tests/file/bug20424.phpt b/ext/standard/tests/file/bug20424.phpt
new file mode 100644
index 0000000..b8f9dfd
--- /dev/null
+++ b/ext/standard/tests/file/bug20424.phpt
@@ -0,0 +1,10 @@
+--TEST--
+Bug #20424 (stream_get_meta_data crashes on a normal file stream)
+--FILE--
+<?php
+$f = fopen(__FILE__, "r");
+$dummy = var_export(stream_get_meta_data($f), TRUE);
+echo "I'm alive!\n";
+?>
+--EXPECT--
+I'm alive!
diff --git a/ext/standard/tests/file/bug22382.phpt b/ext/standard/tests/file/bug22382.phpt
new file mode 100644
index 0000000..2ba36ee
--- /dev/null
+++ b/ext/standard/tests/file/bug22382.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Bug #22382 (fgetcsv() does not handle escaped quotes correctly)
+--FILE--
+<?php
+$fp = fopen(dirname(__FILE__)."/test2.csv", "r");
+while(($line = fgetcsv($fp, 1024))) {
+ var_dump($line);
+}
+fclose($fp);
+?>
+--EXPECT--
+array(6) {
+ [0]=>
+ string(3) "One"
+ [1]=>
+ string(7) "\"Two\""
+ [2]=>
+ string(7) "Three\""
+ [3]=>
+ string(4) "Four"
+ [4]=>
+ string(2) "\\"
+ [5]=>
+ string(28) "\\\\\\\\\\\\\\\\\\\\\\\"\\\\"
+}
diff --git a/ext/standard/tests/file/bug22414.phpt b/ext/standard/tests/file/bug22414.phpt
new file mode 100644
index 0000000..9538c8e
--- /dev/null
+++ b/ext/standard/tests/file/bug22414.phpt
@@ -0,0 +1,38 @@
+--TEST--
+Bug #22414 (passthru() does not read data correctly)
+--INI--
+output_handler=
+--FILE--
+<?php
+
+ $php = getenv('TEST_PHP_EXECUTABLE');
+ $tmpfile = tempnam(__DIR__, 'phpt');
+ $args = ' -n ';
+
+ /* Regular Data Test */
+ passthru($php . $args . ' -r " echo \"HELLO\"; "');
+
+ echo "\n";
+
+ /* Binary Data Test */
+
+ if (substr(PHP_OS, 0, 3) != 'WIN') {
+ $cmd = $php . $args . ' -r \"readfile(@getenv(\'TEST_PHP_EXECUTABLE\')); \"';
+ $cmd = $php . $args . ' -r \' passthru("'.$cmd.'"); \' > '.$tmpfile ;
+ } else {
+ $cmd = $php . $args . ' -r \"readfile(@getenv(\\\\\\"TEST_PHP_EXECUTABLE\\\\\\")); \"';
+ $cmd = $php . $args . ' -r " passthru(\''.$cmd.'\');" > '.$tmpfile ;
+ }
+ exec($cmd);
+
+ if (md5_file($php) == md5_file($tmpfile)) {
+ echo "Works\n";
+ } else {
+ echo "Does not work\n";
+ }
+
+ @unlink($tmpfile);
+?>
+--EXPECT--
+HELLO
+Works
diff --git a/ext/standard/tests/file/bug24313.phpt b/ext/standard/tests/file/bug24313.phpt
new file mode 100644
index 0000000..e5bceee
--- /dev/null
+++ b/ext/standard/tests/file/bug24313.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Bug #24313 (file_exists() throws a warning on nonexistent files when is open_basedir enabled)
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip "/dev" is not available');
+}
+?>
+--INI--
+open_basedir=/dev
+--FILE--
+<?php
+ var_dump(file_exists("/dev/bogus_file_no_such_thing"));
+?>
+--EXPECT--
+bool(false)
diff --git a/ext/standard/tests/file/bug24482.phpt b/ext/standard/tests/file/bug24482.phpt
new file mode 100644
index 0000000..f545f1a
--- /dev/null
+++ b/ext/standard/tests/file/bug24482.phpt
@@ -0,0 +1,37 @@
+--TEST--
+Bug #24482 (GLOB_ONLYDIR not working)
+--SKIPIF--
+<?php
+if (!function_exists("glob")) {
+ die('skip glob() not available');
+}
+?>
+--FILE--
+<?php
+$globdirs = glob("*", GLOB_ONLYDIR);
+
+$dirs = array();
+$dh = opendir(".");
+while (is_string($file = readdir($dh))) {
+ if ($file[0] === ".") continue;
+ if (!is_dir($file)) continue;
+ $dirs[] = $file;
+}
+closedir($dh);
+
+if (count($dirs) != count($globdirs)) {
+ echo "Directory count mismatch\n";
+
+ echo "glob found:\n";
+ sort($globdirs);
+ var_dump($globdirs);
+
+ echo "opendir/readdir/isdir found:\n";
+ sort($dirs);
+ var_dump($dirs);
+} else {
+ echo "OK\n";
+}
+?>
+--EXPECT--
+OK
diff --git a/ext/standard/tests/file/bug26003.phpt b/ext/standard/tests/file/bug26003.phpt
new file mode 100644
index 0000000..7d08374
--- /dev/null
+++ b/ext/standard/tests/file/bug26003.phpt
Binary files differ
diff --git a/ext/standard/tests/file/bug26615.phpt b/ext/standard/tests/file/bug26615.phpt
new file mode 100644
index 0000000..3689fdf
--- /dev/null
+++ b/ext/standard/tests/file/bug26615.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Bug #26615 (exec crash on long input lines)
+--INI--
+variables_order=E
+--FILE--
+<?php
+$out = array();
+$status = -1;
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ exec($_ENV['TEST_PHP_EXECUTABLE'].' -n -r \'for($i=1;$i<=5000;$i++) print "$i\n";\' | tr \'\n\' \' \'', $out, $status);
+} else {
+ exec($_ENV['TEST_PHP_EXECUTABLE'].' -n -r "for($i=1;$i<=5000;$i++) echo $i,\' \';"', $out, $status);
+}
+print_r($out);
+?>
+--EXPECT--
+Array
+(
+ [0] => 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000
+)
diff --git a/ext/standard/tests/file/bug26938.phpt b/ext/standard/tests/file/bug26938.phpt
new file mode 100644
index 0000000..a68d572
--- /dev/null
+++ b/ext/standard/tests/file/bug26938.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Bug #26938 (exec does not read consecutive long lines correctly)
+--FILE--
+<?php
+$out = array();
+$status = -1;
+$php = getenv('TEST_PHP_EXECUTABLE');
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ exec($php . ' -n -r \''
+ . '$lengths = array(10,20000,10000,5,10000,3);'
+ . 'foreach($lengths as $length) {'
+ . ' for($i=0;$i<$length;$i++) print chr(65+$i % 27);'
+ . ' print "\n";'
+ . '}\'', $out, $status);
+} else {
+ exec($php . ' -n -r "'
+ . '$lengths = array(10,20000,10000,5,10000,3);'
+ . 'foreach($lengths as $length) {'
+ . ' for($i=0;$i<$length;$i++) print chr(65+$i % 27);'
+ . ' print \\"\\n\\";'
+ . '}"', $out, $status);
+}
+for ($i=0;$i<6;$i++)
+ print "md5(line $i)= " . md5($out[$i]) . " (length " .
+strlen($out[$i]) . ")\n";
+?>
+--EXPECT--
+md5(line 0)= e86410fa2d6e2634fd8ac5f4b3afe7f3 (length 10)
+md5(line 1)= e84debf3a1d132871d7fe45c1c04c566 (length 20000)
+md5(line 2)= c33b4d2f86908eea5d75ee5a61fd81f4 (length 10000)
+md5(line 3)= 2ecdde3959051d913f61b14579ea136d (length 5)
+md5(line 4)= c33b4d2f86908eea5d75ee5a61fd81f4 (length 10000)
+md5(line 5)= 902fbdd2b1df0c4f70b4a5d23525e932 (length 3)
diff --git a/ext/standard/tests/file/bug27508.phpt b/ext/standard/tests/file/bug27508.phpt
new file mode 100644
index 0000000..7f012bd
--- /dev/null
+++ b/ext/standard/tests/file/bug27508.phpt
@@ -0,0 +1,80 @@
+--TEST--
+Bug #27508 (userspace wrappers have bogus eof indicator)
+--FILE--
+<?php # vim:ft=php
+class FileStream {
+ public $fp;
+
+ function stream_open($path, $mode, $options, &$opened_path)
+ {
+ $url = urldecode(substr($path, 9));
+ $this->fp = fopen($url, $mode);
+
+ return true;
+ }
+
+ function stream_read($count)
+ {
+ return fread($this->fp, $count);
+ }
+
+ function stream_write($data)
+ {
+ return fwrite($this->fp, $data);
+ }
+
+ function stream_tell()
+ {
+ return ftell($this->fp);
+ }
+
+ function stream_eof()
+ {
+ if (!$this->fp) {
+ return true;
+ }
+ return feof($this->fp);
+ }
+
+ function stream_seek($offset, $whence)
+ {
+ return fseek($this->fp, $offset, $whence) == 0 ? true : false;
+ }
+}
+
+stream_wrapper_register("myFile", "FileStream")
+ or die("Failed to register protocol");
+
+$tmp_dir = __DIR__;
+$tn = (binary) tempnam($tmp_dir, 'foo');
+if (!$tn) {
+ die("tempnam failed");
+}
+
+$fp = fopen("myFile://" . urlencode($tn), "w+");
+if (!$fp) {
+ die("fopen failed");
+}
+
+fwrite($fp, b"line1\n");
+fwrite($fp, b"line2\n");
+fwrite($fp, b"line3\n");
+
+debug_zval_dump(feof($fp));
+rewind($fp);
+echo ftell($fp) . "\n";
+debug_zval_dump(feof($fp));
+while ($fp && !feof($fp)) {
+ echo fgets($fp);
+}
+fclose($fp);
+
+unlink($tn);
+?>
+--EXPECT--
+bool(false) refcount(1)
+0
+bool(false) refcount(1)
+line1
+line2
+line3
diff --git a/ext/standard/tests/file/bug27619.phpt b/ext/standard/tests/file/bug27619.phpt
new file mode 100644
index 0000000..095a18c
--- /dev/null
+++ b/ext/standard/tests/file/bug27619.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Bug #27619 (filters not applied to pre-buffered data)
+--FILE--
+<?php
+ $fp = tmpfile();
+ fwrite($fp, "this is a lowercase string.\n");
+ rewind($fp);
+
+ /* Echo out the first four bytes 'this' without applying filter
+ Remainder will get sucked into the read buffer though. */
+ echo fread($fp, 4);
+
+ stream_filter_append($fp, "string.toupper");
+
+ fpassthru($fp);
+?>
+--EXPECT--
+this IS A LOWERCASE STRING.
diff --git a/ext/standard/tests/file/bug30362.phpt b/ext/standard/tests/file/bug30362.phpt
new file mode 100644
index 0000000..1c2b4be
--- /dev/null
+++ b/ext/standard/tests/file/bug30362.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Bug #30362 (stream_get_line() not working as documented)
+--FILE--
+<?php
+
+$resource = fopen(dirname(__FILE__).'/bug30362.txt', 'rb');
+
+for ($i = 0; ($i < 10) && !feof($resource); ++$i ) {
+ $a = "Y";
+ $line = stream_get_line($resource, 50, $a);
+ echo $line . "\n";
+}
+fclose($resource);
+
+?>
+--EXPECT--
+111
+111111111
+111111111
+111111111
+111111111
+111111111
+111111111
+111111111
+111111111
+111111111
diff --git a/ext/standard/tests/file/bug30362.txt b/ext/standard/tests/file/bug30362.txt
new file mode 100644
index 0000000..3a1b7f4
--- /dev/null
+++ b/ext/standard/tests/file/bug30362.txt
@@ -0,0 +1 @@
+111Y111111111Y111111111Y111111111Y111111111Y111111111Y111111111Y111111111Y111111111Y111111111
diff --git a/ext/standard/tests/file/bug32160.phpt b/ext/standard/tests/file/bug32160.phpt
new file mode 100644
index 0000000..e496803
--- /dev/null
+++ b/ext/standard/tests/file/bug32160.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Bug #32160 (copying a file into itself leads to data loss)
+--FILE--
+<?php
+$path = dirname(__FILE__) . "/bug32160.txt";
+var_dump(copy($path, $path));
+chdir(dirname(__FILE__));
+var_dump(copy($path, "bug32160.txt"));
+var_dump(copy("bug32160.txt", "bug32160.txt"));
+?>
+--EXPECT--
+bool(false)
+bool(false)
+bool(false)
diff --git a/ext/standard/tests/file/bug32160.txt b/ext/standard/tests/file/bug32160.txt
new file mode 100644
index 0000000..1e4a6b5
--- /dev/null
+++ b/ext/standard/tests/file/bug32160.txt
@@ -0,0 +1 @@
+copy test
diff --git a/ext/standard/tests/file/bug35740.phpt b/ext/standard/tests/file/bug35740.phpt
new file mode 100644
index 0000000..3526b24
--- /dev/null
+++ b/ext/standard/tests/file/bug35740.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Bug #35740 (memory leak when including a directory)
+--FILE--
+<?php
+
+include (dirname(__FILE__));
+
+echo "Done\n";
+?>
+--EXPECTF--
+Warning: include(%s): failed to open stream: %s in %s on line %d
+
+Warning: include(): Failed opening '%s' for inclusion (include_path='%s') in %s on line %d
+Done
diff --git a/ext/standard/tests/file/bug35781.phpt b/ext/standard/tests/file/bug35781.phpt
new file mode 100644
index 0000000..5dc684a
--- /dev/null
+++ b/ext/standard/tests/file/bug35781.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Bug #35781 (stream_filter_append() causes segfault)
+--FILE--
+<?php
+
+$filename = dirname(__FILE__)."/bug35781.txt";
+
+$fp = fopen($filename, "w");
+stream_filter_append($fp, "string.rot13", -49);
+fwrite($fp, "This is a test\n");
+rewind($fp);
+fpassthru($fp);
+fclose($fp);
+
+var_dump(file_get_contents($filename));
+
+@unlink($filename);
+
+echo "Done\n";
+?>
+--EXPECTF--
+string(15) "Guvf vf n grfg
+"
+Done
diff --git a/ext/standard/tests/file/bug37158.phpt b/ext/standard/tests/file/bug37158.phpt
new file mode 100644
index 0000000..48df46c
--- /dev/null
+++ b/ext/standard/tests/file/bug37158.phpt
@@ -0,0 +1,39 @@
+--TEST--
+Bug #37158 (if userspace stream is present, fread() reads in 8192 max, otherwise it works)
+--FILE--
+<?php
+
+class VariableStream {
+
+ function stream_open($path, $mode, $options, &$opened_path)
+ {
+ return true;
+ }
+}
+
+stream_wrapper_register("var", "VariableStream");
+
+error_reporting(E_ALL | E_STRICT);
+$file = dirname(__FILE__) . '/footest.txt';
+$x = str_repeat(1, 8192);
+$fp = fopen($file, 'w');
+for ($i = 0; $i < 5; $i++) {
+ fwrite($fp, $x);
+}
+fclose($fp);
+
+$fp = fopen($file, 'r');
+$outsidecontents = fread($fp, 20000);
+fclose($fp);
+var_dump('size of contents 1 = ' . strlen($outsidecontents));
+$outsidecontents = file_get_contents($file);
+var_dump('size of contents 2 = ' . strlen($outsidecontents));
+
+unlink($file);
+
+echo "Done\n";
+?>
+--EXPECT--
+string(26) "size of contents 1 = 20000"
+string(26) "size of contents 2 = 40960"
+Done
diff --git a/ext/standard/tests/file/bug37864.phpt b/ext/standard/tests/file/bug37864.phpt
new file mode 100644
index 0000000..f8743bd
--- /dev/null
+++ b/ext/standard/tests/file/bug37864.phpt
@@ -0,0 +1,12 @@
+--TEST--
+Bug #37864 (file_get_contents() leaks on empty file)
+--FILE--
+<?php
+ $tmpfname = tempnam(sys_get_temp_dir(), "emptyfile");
+ var_dump(file_get_contents($tmpfname));
+ echo "done.\n";
+ unlink($tmpfname);
+?>
+--EXPECT--
+string(0) ""
+done.
diff --git a/ext/standard/tests/file/bug38086.phpt b/ext/standard/tests/file/bug38086.phpt
new file mode 100644
index 0000000..d92289e
--- /dev/null
+++ b/ext/standard/tests/file/bug38086.phpt
@@ -0,0 +1,55 @@
+--TEST--
+Bug #38086 (stream_copy_to_stream() returns 0 when maxlen is bigger than the actual length)
+--FILE--
+<?php
+define('WIN', substr(PHP_OS, 0, 3) == 'WIN');
+
+$initial_file = dirname(__FILE__).'/bug38086.txt';
+$new_file = dirname(__FILE__).'/bug38086_1.txt';
+
+$src = fopen($initial_file, 'r');
+stream_filter_append($src, "string.rot13", STREAM_FILTER_READ);
+
+$dest = fopen($new_file, 'w');
+var_dump(stream_copy_to_stream($src, $dest));
+fclose($src); fclose($dest);
+
+if (WIN) {
+ var_dump(str_replace("\r\n","\n", file_get_contents($new_file)));
+} else {
+ var_dump(file_get_contents($new_file));
+}
+unlink($new_file);
+
+$src = fopen($initial_file, 'r');
+stream_filter_append($src, "string.rot13", STREAM_FILTER_READ);
+
+$dest = fopen($new_file, 'w');
+var_dump(stream_copy_to_stream($src, $dest, 10000));
+fclose($src); fclose($dest);
+
+if (WIN) {
+ var_dump(str_replace("\r\n","\n", file_get_contents($new_file)));
+} else {
+ var_dump(file_get_contents($new_file));
+}
+unlink($new_file);
+
+echo "Done\n";
+?>
+--EXPECTF--
+int(%d)
+string(134) "Nabgure qnl
+Jura gur cnvaf bs yvsr jba'g one zl jnl
+V'yy oernx gurfr punvaf
+Gung ubyq zr qbja
+V'yy grne lbh qbja vagb zl cevingr uryy
+"
+int(%d)
+string(134) "Nabgure qnl
+Jura gur cnvaf bs yvsr jba'g one zl jnl
+V'yy oernx gurfr punvaf
+Gung ubyq zr qbja
+V'yy grne lbh qbja vagb zl cevingr uryy
+"
+Done
diff --git a/ext/standard/tests/file/bug38086.txt b/ext/standard/tests/file/bug38086.txt
new file mode 100644
index 0000000..8e32472
--- /dev/null
+++ b/ext/standard/tests/file/bug38086.txt
@@ -0,0 +1,5 @@
+Another day
+When the pains of life won't bar my way
+I'll break these chains
+That hold me down
+I'll tear you down into my private hell
diff --git a/ext/standard/tests/file/bug38450.phpt b/ext/standard/tests/file/bug38450.phpt
new file mode 100644
index 0000000..d108897
--- /dev/null
+++ b/ext/standard/tests/file/bug38450.phpt
@@ -0,0 +1,114 @@
+--TEST--
+Bug #38450 (constructor is not called for classes used in userspace stream wrappers)
+--FILE--
+<?php
+
+class VariableStream {
+ var $position;
+ var $varname;
+
+ function VariableStream($var) {
+ var_dump("constructor!");
+ }
+
+ function stream_open($path, $mode, $options, &$opened_path)
+ {
+ $url = parse_url($path);
+ $this->varname = $url["host"];
+ $this->position = 0;
+
+ return true;
+ }
+
+ function stream_read($count)
+ {
+ $ret = substr($GLOBALS[$this->varname], $this->position, $count);
+ $this->position += strlen($ret);
+ return $ret;
+ }
+
+ function stream_write($data)
+ {
+ $left = substr($GLOBALS[$this->varname], 0, $this->position);
+ $right = substr($GLOBALS[$this->varname], $this->position + strlen($data));
+ $GLOBALS[$this->varname] = $left . $data . $right;
+ $this->position += strlen($data);
+ return strlen($data);
+ }
+
+ function stream_tell()
+ {
+ return $this->position;
+ }
+
+ function stream_eof()
+ {
+ return $this->position >= strlen($GLOBALS[$this->varname]);
+ }
+ function stream_seek($offset, $whence)
+ {
+ switch ($whence) {
+ case SEEK_SET:
+ if ($offset < strlen($GLOBALS[$this->varname]) && $offset >= 0) {
+ $this->position = $offset;
+ return true;
+ } else {
+ return false;
+ }
+ break;
+
+ case SEEK_CUR:
+ if ($offset >= 0) {
+ $this->position += $offset;
+ return true;
+ } else {
+ return false;
+ }
+ break;
+
+ case SEEK_END:
+ if (strlen($GLOBALS[$this->varname]) + $offset >= 0) {
+ $this->position = strlen($GLOBALS[$this->varname]) + $offset;
+ return true;
+ } else {
+ return false;
+ }
+ break;
+
+ default:
+ return false;
+ }
+ }
+}
+
+stream_wrapper_register("var", "VariableStream")
+ or die("Failed to register protocol");
+
+$myvar = "";
+
+$fp = fopen("var://myvar", "r+");
+
+fwrite($fp, b"line1\n");
+fwrite($fp, b"line2\n");
+fwrite($fp, b"line3\n");
+
+rewind($fp);
+while (!feof($fp)) {
+ echo fgets($fp);
+}
+fclose($fp);
+var_dump($myvar);
+
+echo "Done\n";
+?>
+--EXPECTF--
+Warning: Missing argument 1 for VariableStream::VariableStream() in %s on line %d
+string(12) "constructor!"
+line1
+line2
+line3
+string(18) "line1
+line2
+line3
+"
+Done
diff --git a/ext/standard/tests/file/bug38450_1.phpt b/ext/standard/tests/file/bug38450_1.phpt
new file mode 100644
index 0000000..07e413b
--- /dev/null
+++ b/ext/standard/tests/file/bug38450_1.phpt
@@ -0,0 +1,114 @@
+--TEST--
+Bug #38450 (constructor is not called for classes used in userspace stream wrappers)
+--FILE--
+<?php
+
+class VariableStream {
+ var $position;
+ var $varname;
+
+ function __construct($var) {
+ var_dump("constructor!");
+ }
+
+ function stream_open($path, $mode, $options, &$opened_path)
+ {
+ $url = parse_url($path);
+ $this->varname = $url["host"];
+ $this->position = 0;
+
+ return true;
+ }
+
+ function stream_read($count)
+ {
+ $ret = substr($GLOBALS[$this->varname], $this->position, $count);
+ $this->position += strlen($ret);
+ return $ret;
+ }
+
+ function stream_write($data)
+ {
+ $left = substr($GLOBALS[$this->varname], 0, $this->position);
+ $right = substr($GLOBALS[$this->varname], $this->position + strlen($data));
+ $GLOBALS[$this->varname] = $left . $data . $right;
+ $this->position += strlen($data);
+ return strlen($data);
+ }
+
+ function stream_tell()
+ {
+ return $this->position;
+ }
+
+ function stream_eof()
+ {
+ return $this->position >= strlen($GLOBALS[$this->varname]);
+ }
+ function stream_seek($offset, $whence)
+ {
+ switch ($whence) {
+ case SEEK_SET:
+ if ($offset < strlen($GLOBALS[$this->varname]) && $offset >= 0) {
+ $this->position = $offset;
+ return true;
+ } else {
+ return false;
+ }
+ break;
+
+ case SEEK_CUR:
+ if ($offset >= 0) {
+ $this->position += $offset;
+ return true;
+ } else {
+ return false;
+ }
+ break;
+
+ case SEEK_END:
+ if (strlen($GLOBALS[$this->varname]) + $offset >= 0) {
+ $this->position = strlen($GLOBALS[$this->varname]) + $offset;
+ return true;
+ } else {
+ return false;
+ }
+ break;
+
+ default:
+ return false;
+ }
+ }
+}
+
+stream_wrapper_register("var", "VariableStream")
+ or die("Failed to register protocol");
+
+$myvar = "";
+
+$fp = fopen("var://myvar", "r+");
+
+fwrite($fp, b"line1\n");
+fwrite($fp, b"line2\n");
+fwrite($fp, b"line3\n");
+
+rewind($fp);
+while (!feof($fp)) {
+ echo fgets($fp);
+}
+fclose($fp);
+var_dump($myvar);
+
+echo "Done\n";
+?>
+--EXPECTF--
+Warning: Missing argument 1 for VariableStream::__construct() in %s on line %d
+string(12) "constructor!"
+line1
+line2
+line3
+string(18) "line1
+line2
+line3
+"
+Done
diff --git a/ext/standard/tests/file/bug38450_2.phpt b/ext/standard/tests/file/bug38450_2.phpt
new file mode 100644
index 0000000..625fd7c
--- /dev/null
+++ b/ext/standard/tests/file/bug38450_2.phpt
@@ -0,0 +1,114 @@
+--TEST--
+Bug #38450 (constructor is not called for classes used in userspace stream wrappers)
+--FILE--
+<?php
+
+class VariableStream {
+ var $position;
+ var $varname;
+
+ function __construct($var) {
+ throw new Exception("constructor");
+ }
+
+ function stream_open($path, $mode, $options, &$opened_path)
+ {
+ $url = parse_url($path);
+ $this->varname = $url["host"];
+ $this->position = 0;
+
+ return true;
+ }
+
+ function stream_read($count)
+ {
+ $ret = substr($GLOBALS[$this->varname], $this->position, $count);
+ $this->position += strlen($ret);
+ return $ret;
+ }
+
+ function stream_write($data)
+ {
+ $left = substr($GLOBALS[$this->varname], 0, $this->position);
+ $right = substr($GLOBALS[$this->varname], $this->position + strlen($data));
+ $GLOBALS[$this->varname] = $left . $data . $right;
+ $this->position += strlen($data);
+ return strlen($data);
+ }
+
+ function stream_tell()
+ {
+ return $this->position;
+ }
+
+ function stream_eof()
+ {
+ return $this->position >= strlen($GLOBALS[$this->varname]);
+ }
+ function stream_seek($offset, $whence)
+ {
+ switch ($whence) {
+ case SEEK_SET:
+ if ($offset < strlen($GLOBALS[$this->varname]) && $offset >= 0) {
+ $this->position = $offset;
+ return true;
+ } else {
+ return false;
+ }
+ break;
+
+ case SEEK_CUR:
+ if ($offset >= 0) {
+ $this->position += $offset;
+ return true;
+ } else {
+ return false;
+ }
+ break;
+
+ case SEEK_END:
+ if (strlen($GLOBALS[$this->varname]) + $offset >= 0) {
+ $this->position = strlen($GLOBALS[$this->varname]) + $offset;
+ return true;
+ } else {
+ return false;
+ }
+ break;
+
+ default:
+ return false;
+ }
+ }
+}
+
+stream_wrapper_register("var", "VariableStream")
+ or die("Failed to register protocol");
+
+$myvar = "";
+
+$fp = fopen("var://myvar", "r+");
+
+fwrite($fp, "line1\n");
+fwrite($fp, "line2\n");
+fwrite($fp, "line3\n");
+
+rewind($fp);
+while (!feof($fp)) {
+ echo fgets($fp);
+}
+fclose($fp);
+var_dump($myvar);
+
+echo "Done\n";
+?>
+--EXPECTF--
+Warning: Missing argument 1 for VariableStream::__construct() in %s on line %d
+
+Warning: fopen(var://myvar): failed to open stream: "VariableStream::stream_open" call failed in %s on line %d
+
+Fatal error: Uncaught exception 'Exception' with message 'constructor' in %s:%d
+Stack trace:
+#0 [internal function]: VariableStream->__construct()
+#1 %s(%d): fopen('var://myvar', 'r+')
+#2 {main}
+ thrown in %s on line %d
diff --git a/ext/standard/tests/file/bug38450_3.phpt b/ext/standard/tests/file/bug38450_3.phpt
new file mode 100644
index 0000000..389de87
--- /dev/null
+++ b/ext/standard/tests/file/bug38450_3.phpt
@@ -0,0 +1,105 @@
+--TEST--
+Bug #38450 (constructor is not called for classes used in userspace stream wrappers)
+--FILE--
+<?php
+
+class VariableStream {
+ var $position;
+ var $varname;
+
+ function __construct(array $var) {
+ var_dump("constructor!");
+ }
+
+ function stream_open($path, $mode, $options, &$opened_path)
+ {
+ $url = parse_url($path);
+ $this->varname = $url["host"];
+ $this->position = 0;
+
+ return true;
+ }
+
+ function stream_read($count)
+ {
+ $ret = substr($GLOBALS[$this->varname], $this->position, $count);
+ $this->position += strlen($ret);
+ return $ret;
+ }
+
+ function stream_write($data)
+ {
+ $left = substr($GLOBALS[$this->varname], 0, $this->position);
+ $right = substr($GLOBALS[$this->varname], $this->position + strlen($data));
+ $GLOBALS[$this->varname] = $left . $data . $right;
+ $this->position += strlen($data);
+ return strlen($data);
+ }
+
+ function stream_tell()
+ {
+ return $this->position;
+ }
+
+ function stream_eof()
+ {
+ return $this->position >= strlen($GLOBALS[$this->varname]);
+ }
+ function stream_seek($offset, $whence)
+ {
+ switch ($whence) {
+ case SEEK_SET:
+ if ($offset < strlen($GLOBALS[$this->varname]) && $offset >= 0) {
+ $this->position = $offset;
+ return true;
+ } else {
+ return false;
+ }
+ break;
+
+ case SEEK_CUR:
+ if ($offset >= 0) {
+ $this->position += $offset;
+ return true;
+ } else {
+ return false;
+ }
+ break;
+
+ case SEEK_END:
+ if (strlen($GLOBALS[$this->varname]) + $offset >= 0) {
+ $this->position = strlen($GLOBALS[$this->varname]) + $offset;
+ return true;
+ } else {
+ return false;
+ }
+ break;
+
+ default:
+ return false;
+ }
+ }
+}
+
+stream_wrapper_register("var", "VariableStream")
+ or die("Failed to register protocol");
+
+$myvar = "";
+
+$fp = fopen("var://myvar", "r+");
+
+fwrite($fp, "line1\n");
+fwrite($fp, "line2\n");
+fwrite($fp, "line3\n");
+
+rewind($fp);
+while (!feof($fp)) {
+ echo fgets($fp);
+}
+fclose($fp);
+var_dump($myvar);
+
+echo "Done\n";
+?>
+--EXPECTF--
+Catchable fatal error: Argument 1 passed to VariableStream::__construct() must be of the type array, none given in %s on line %d
diff --git a/ext/standard/tests/file/bug39367.phpt b/ext/standard/tests/file/bug39367.phpt
new file mode 100644
index 0000000..f3e79fc
--- /dev/null
+++ b/ext/standard/tests/file/bug39367.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Bug #39367 (clearstatcache() doesn't clear realpath cache)
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip no symlinks on Windows');
+}
+?>
+--FILE--
+<?php
+function test() {
+ unlink('/tmp/1link');
+ unlink('/tmp/1tmp');
+ unlink('/tmp/testfile1');
+
+ file_put_contents('/tmp/testfile1', 'ok');
+ symlink('/tmp/testfile1', '/tmp/1tmp');
+ rename('/tmp/1tmp', '/tmp/1link');
+ echo file_get_contents('/tmp/1link')."\n";
+
+ unlink('/tmp/1link');
+ clearstatcache(true);
+
+ echo file_get_contents('/tmp/1link')."\n";
+
+ unlink('/tmp/1link');
+ unlink('/tmp/1tmp');
+ unlink('/tmp/testfile1');
+}
+@test();
+?>
+--EXPECT--
+ok
diff --git a/ext/standard/tests/file/bug39538.phpt b/ext/standard/tests/file/bug39538.phpt
new file mode 100644
index 0000000..71b5dea
--- /dev/null
+++ b/ext/standard/tests/file/bug39538.phpt
@@ -0,0 +1,39 @@
+--TEST--
+Bug #39538 (fgetcsv can't handle starting newlines and trailing odd number of backslashes)
+--FILE--
+<?php
+$content = array("\"\nthis is an test\", \"next data\", \"p\narsed\"","\"\r\nthis is an test\", \"next data\", \"p\r\narsed\"","\"\n\rthis is an test\", \"next data\", \"p\n\rarsed\"");
+
+$file = dirname(__FILE__) . "/bug39538.csv";
+@unlink($file);
+foreach ($content as $v) {
+ file_put_contents($file, $v);
+ print_r (fgetcsv(fopen($file, "r"), filesize($file)));
+}
+@unlink($file);
+?>
+--EXPECT--
+Array
+(
+ [0] =>
+this is an test
+ [1] => next data
+ [2] => p
+arsed
+)
+Array
+(
+ [0] =>
+this is an test
+ [1] => next data
+ [2] => p
+arsed
+)
+Array
+(
+ [0] =>
+ this is an test
+ [1] => next data
+ [2] => p
+ arsed
+)
diff --git a/ext/standard/tests/file/bug39551.phpt b/ext/standard/tests/file/bug39551.phpt
new file mode 100644
index 0000000..c047a30
--- /dev/null
+++ b/ext/standard/tests/file/bug39551.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Bug #39551 (Segfault with stream_bucket_new in user filter)
+--FILE--
+<?php
+
+$bucket = stream_bucket_new(fopen('php://temp', 'w+'), '');
+
+class bucketFilter {
+ public function filter($in, $out, &$consumed, $closing ){
+
+ $bucket = stream_bucket_new(fopen('php://temp', 'w+'), '');
+ stream_bucket_append($out, $bucket);
+ return PSFS_PASS_ON;
+ }
+}
+
+stream_filter_register('bucketfault', 'bucketFilter');
+stream_filter_append($s = fopen('php://temp', 'r+'), 'bucketfault');
+stream_get_contents($s);
+
+echo "Done\n";
+?>
+--EXPECTF--
+Done
diff --git a/ext/standard/tests/file/bug39673.phpt b/ext/standard/tests/file/bug39673.phpt
new file mode 100644
index 0000000..3836f21
--- /dev/null
+++ b/ext/standard/tests/file/bug39673.phpt
@@ -0,0 +1,40 @@
+--TEST--
+Bug #39673 (file_get_contents causes bus error on certain offsets)
+--FILE--
+<?php
+
+$str = str_repeat("test", 3456);
+
+$filename = dirname(__FILE__).'/bug39673.txt';
+file_put_contents($filename, $str);
+
+$offsets = array(
+ -1,
+ 0,
+ 3456*4,
+ 3456*4 - 1,
+ 3456*4 + 1,
+ 2000,
+ 5000,
+ 100000,
+);
+
+
+foreach ($offsets as $offset) {
+ $r = file_get_contents($filename, false, null, $offset);
+ var_dump(strlen($r));
+}
+
+@unlink($filename);
+echo "Done\n";
+?>
+--EXPECTF--
+int(13824)
+int(13824)
+int(0)
+int(1)
+int(0)
+int(11824)
+int(8824)
+int(0)
+Done
diff --git a/ext/standard/tests/file/bug39863.phpt b/ext/standard/tests/file/bug39863.phpt
new file mode 100644
index 0000000..5e26b5a
--- /dev/null
+++ b/ext/standard/tests/file/bug39863.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Bug #39863 (file_exists() silently truncates after a null byte)
+--CREDITS--
+Andrew van der Stock, vanderaj @ owasp.org
+--FILE--
+<?php
+
+$filename = __FILE__ . chr(0). ".ridiculous";
+
+if (file_exists($filename)) {
+ echo "FAIL\n";
+}
+else {
+ echo "PASS\n";
+}
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+Warning: file_exists() expects parameter 1 to be a valid path, string given in %s on line %d
+PASS
+===DONE===
+
diff --git a/ext/standard/tests/file/bug40374.phpt b/ext/standard/tests/file/bug40374.phpt
new file mode 100644
index 0000000..327289e
--- /dev/null
+++ b/ext/standard/tests/file/bug40374.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Bug #40374 (php_shutdown_temporary_directory() tries to free local value)
+--FILE--
+<?php
+
+$file = tempnam(sys_get_temp_dir(), "test_");
+var_dump($file);
+$fp = fopen($file, "wt");
+fwrite($fp, "test");
+fclose($fp);
+unlink($file);
+
+echo "Done\n";
+?>
+--EXPECTF--
+string(%d) "%s"
+Done
diff --git a/ext/standard/tests/file/bug40501.csv b/ext/standard/tests/file/bug40501.csv
new file mode 100644
index 0000000..c786ed9
--- /dev/null
+++ b/ext/standard/tests/file/bug40501.csv
@@ -0,0 +1,2 @@
+"this element contains the delimiter, and ends with an odd number of
+backslashes (ex: 1)\",and it isn't the last element$ \ No newline at end of file
diff --git a/ext/standard/tests/file/bug40501.phpt b/ext/standard/tests/file/bug40501.phpt
new file mode 100644
index 0000000..806aba6
--- /dev/null
+++ b/ext/standard/tests/file/bug40501.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Bug #40501 (fgetcsv() can't handle trailing odd number of backslashes)
+--FILE--
+<?php
+$file = dirname(__FILE__).'/bug40501.csv';
+
+$h = fopen($file, 'r');
+$data = fgetcsv($h, NULL, ',', '"', '"');
+fclose($h);
+
+var_dump($data);
+?>
+--EXPECTF--
+array(2) {
+ [0]=>
+ string(%d) "this element contains the delimiter, and ends with an odd number of
+backslashes (ex: 1)\"
+ [1]=>
+ string(%d) "and it isn't the last element$"
+}
diff --git a/ext/standard/tests/file/bug41655_1.phpt b/ext/standard/tests/file/bug41655_1.phpt
new file mode 100644
index 0000000..62d64df
--- /dev/null
+++ b/ext/standard/tests/file/bug41655_1.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Bug #41655 (open_basedir bypass via glob()) 1/2
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--INI--
+open_basedir=/tmp
+--FILE--
+<?php
+$a=glob("./*.jpeg");
+var_dump($a);
+echo "Done\n";
+?>
+--EXPECT--
+bool(false)
+Done \ No newline at end of file
diff --git a/ext/standard/tests/file/bug41655_2.phpt b/ext/standard/tests/file/bug41655_2.phpt
new file mode 100644
index 0000000..d406f1b
--- /dev/null
+++ b/ext/standard/tests/file/bug41655_2.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Bug #41655 (open_basedir bypass via glob()) 2/2
+--INI--
+open_basedir=/
+--FILE--
+<?php
+ $dir = dirname(__FILE__);
+ $a=glob($dir . "/test.*");
+ print_r($a);
+?>
+--EXPECTF--
+Array
+(
+ [0] => %stest.csv
+)
diff --git a/ext/standard/tests/file/bug41693.phpt b/ext/standard/tests/file/bug41693.phpt
new file mode 100644
index 0000000..6c7ff5b
--- /dev/null
+++ b/ext/standard/tests/file/bug41693.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Bug #41693 (scandir() allows empty directory names)
+--FILE--
+<?php
+
+var_dump(scandir(''));
+
+echo "Done\n";
+?>
+--EXPECTF--
+Warning: scandir(): Directory name cannot be empty in %s on line %d
+bool(false)
+Done
diff --git a/ext/standard/tests/file/bug41815.phpt b/ext/standard/tests/file/bug41815.phpt
new file mode 100644
index 0000000..f77468d
--- /dev/null
+++ b/ext/standard/tests/file/bug41815.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Bug #41815 (Concurrent read/write fails when EOF is reached)
+--FILE--
+<?php
+
+$filename = dirname(__FILE__)."/concur_rw.txt";
+
+@unlink($filename);
+$writer = fopen($filename, "wt");
+$reader = fopen($filename, "r");
+fread($reader, 1);
+fwrite($writer, "foo");
+
+if (strlen(fread($reader, 10)) > 0) {
+ echo "OK\n";
+}
+
+fclose($writer);
+fclose($reader);
+
+@unlink($filename);
+
+echo "Done\n";
+?>
+--EXPECTF--
+OK
+Done
diff --git a/ext/standard/tests/file/bug41874.phpt b/ext/standard/tests/file/bug41874.phpt
new file mode 100644
index 0000000..827f486
--- /dev/null
+++ b/ext/standard/tests/file/bug41874.phpt
@@ -0,0 +1,15 @@
+--TEST--
+bug #41874 (Separate STDOUT and STDERR in exec functions)
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != 'WIN' ) die('skip windows only test');
+?>
+--FILE--
+<?php
+$result = exec('cd 1:\non_existant; dir nonexistant');
+echo "$result";
+system('cd 1:\non_existant; dir nonexistant');
+?>
+--EXPECT--
+The system cannot find the drive specified.
+The system cannot find the drive specified.
diff --git a/ext/standard/tests/file/bug41874_1.phpt b/ext/standard/tests/file/bug41874_1.phpt
new file mode 100644
index 0000000..c6ddef8
--- /dev/null
+++ b/ext/standard/tests/file/bug41874_1.phpt
@@ -0,0 +1,16 @@
+--TEST--
+bug #41874 (Separate STDOUT and STDERR in exec functions)
+--CREDITS--
+Venkat Raman Don
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != 'WIN' ) {
+ die('skip windows only test');
+}
+?>
+--FILE--
+<?php
+popen("1:\\non_existent", "r");
+?>
+--EXPECT--
+The system cannot find the drive specified. \ No newline at end of file
diff --git a/ext/standard/tests/file/bug41874_2.phpt b/ext/standard/tests/file/bug41874_2.phpt
new file mode 100644
index 0000000..5d7b7ca
--- /dev/null
+++ b/ext/standard/tests/file/bug41874_2.phpt
@@ -0,0 +1,17 @@
+--TEST--
+bug #41874 (Separate STDOUT and STDERR in exec functions)
+--CREDITS--
+Venkat Raman Don
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != 'WIN' ) {
+ die('skip windows only test');
+}
+?>
+--FILE--
+<?php
+$result = exec('cd 1:\\non_existant; dir nonexistant');
+echo "$result";
+?>
+--EXPECT--
+The system cannot find the drive specified. \ No newline at end of file
diff --git a/ext/standard/tests/file/bug41874_3.phpt b/ext/standard/tests/file/bug41874_3.phpt
new file mode 100644
index 0000000..4d7b139
--- /dev/null
+++ b/ext/standard/tests/file/bug41874_3.phpt
@@ -0,0 +1,16 @@
+--TEST--
+bug #41874 (Separate STDOUT and STDERR in exec functions)
+--CREDITS--
+Venkat Raman Don
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != 'WIN' ) {
+ die('skip windows only test');
+}
+?>
+--FILE--
+<?php
+system('cd 1:\\non_existant; dir nonexistant');
+?>
+--EXPECT--
+The system cannot find the drive specified. \ No newline at end of file
diff --git a/ext/standard/tests/file/bug43008.phpt b/ext/standard/tests/file/bug43008.phpt
new file mode 100644
index 0000000..d2e3efd
--- /dev/null
+++ b/ext/standard/tests/file/bug43008.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Bug #43008 (php://filter uris ignore url encoded filternames and can't handle slashes)
+--SKIPIF--
+<?php
+if (!extension_loaded("iconv")) die("skip iconv extension not available");
+?>
+--FILE--
+<?php
+$url = b""
+ . b"php://filter/read="
+ . urlencode(b"convert.iconv.ISO-8859-15/UTF-8")
+ . b'|' . urlencode(b"string.rot13")
+ . b'|' . urlencode(b"string.rot13")
+ . b'|' . urlencode(b"convert.iconv.UTF-8/ISO-8859-15")
+ . b"/resource=data://text/plain,foob%E2r";
+var_dump(urlencode(file_get_contents($url)));
+?>
+--EXPECTF--
+string(8) "foob%E2r"
diff --git a/ext/standard/tests/file/bug43137.phpt b/ext/standard/tests/file/bug43137.phpt
new file mode 100644
index 0000000..8125445
--- /dev/null
+++ b/ext/standard/tests/file/bug43137.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Bug #43137 (rmdir() and rename() do not clear statcache)
+--FILE--
+<?php
+ $toname = "TO_" . md5(microtime());
+ $dirname = "FROM_" . md5(microtime());
+
+ mkdir($dirname);
+ var_dump(is_dir($dirname)); // Expected: true
+ rename($dirname, $toname);
+ var_dump(is_dir($dirname)); // Expected: false
+ var_dump(is_dir($toname)); // Expected: true
+ rmdir($toname);
+ var_dump(is_dir($toname)); // Expected: false
+?>
+--EXPECT--
+bool(true)
+bool(false)
+bool(true)
+bool(false)
diff --git a/ext/standard/tests/file/bug43216.phpt b/ext/standard/tests/file/bug43216.phpt
new file mode 100644
index 0000000..b7e4253
--- /dev/null
+++ b/ext/standard/tests/file/bug43216.phpt
@@ -0,0 +1,8 @@
+--TEST--
+Bug #43216 (stream_is_local() returns false on file://)
+--FILE--
+<?php
+var_dump(stream_is_local("file://"));
+?>
+--EXPECT--
+bool(true)
diff --git a/ext/standard/tests/file/bug43248.phpt b/ext/standard/tests/file/bug43248.phpt
new file mode 100644
index 0000000..1096435
--- /dev/null
+++ b/ext/standard/tests/file/bug43248.phpt
@@ -0,0 +1,8 @@
+--TEST--
+Bug #43248 (backward compatibility break in realpath())
+--FILE--
+<?php
+echo realpath(dirname(__FILE__) . '/../file/');
+?>
+--EXPECTF--
+%sfile
diff --git a/ext/standard/tests/file/bug43353-win32.phpt b/ext/standard/tests/file/bug43353-win32.phpt
new file mode 100644
index 0000000..0667f69
--- /dev/null
+++ b/ext/standard/tests/file/bug43353-win32.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Bug #43353 wrong detection of 'data' wrapper
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+ die("skip Run only on Windows");
+?>
+--INI--
+allow_url_fopen=1
+--FILE--
+<?php
+
+var_dump(is_dir('file:///datafoo:test'));
+var_dump(is_dir('datafoo:test'));
+var_dump(file_get_contents('data:text/plain,foo'));
+var_dump(file_get_contents('datafoo:text/plain,foo'));
+
+?>
+--EXPECTF--
+bool(false)
+bool(false)
+string(3) "foo"
+
+Warning: file_get_contents(datafoo:text/plain,foo): failed to open stream: Invalid argument in %s
+bool(false)
diff --git a/ext/standard/tests/file/bug43353.phpt b/ext/standard/tests/file/bug43353.phpt
new file mode 100644
index 0000000..87d0650
--- /dev/null
+++ b/ext/standard/tests/file/bug43353.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Bug #43353 wrong detection of 'data' wrapper
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+ die("skip on Windows");
+?>
+--INI--
+allow_url_fopen=1
+--FILE--
+<?php
+
+var_dump(is_dir('file:///datafoo:test'));
+var_dump(is_dir('datafoo:test'));
+var_dump(file_get_contents('data:text/plain,foo'));
+var_dump(file_get_contents('datafoo:text/plain,foo'));
+
+?>
+--EXPECTF--
+bool(false)
+bool(false)
+string(3) "foo"
+
+Warning: file_get_contents(datafoo:text/plain,foo): failed to open stream: No such file or directory in %s
+bool(false)
diff --git a/ext/standard/tests/file/bug43522.phpt b/ext/standard/tests/file/bug43522.phpt
new file mode 100644
index 0000000..10e44fc
--- /dev/null
+++ b/ext/standard/tests/file/bug43522.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Bug #43522 (stream_get_line() eats additional characters)
+--FILE--
+<?php // 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ
+
+$fp = fopen(__FILE__, 'r'); // Open self
+
+DoTest($fp, 'ZZZ'); // test multi-char delimiter
+DoTest($fp, "Z"); // test single-char delimiter
+
+function DoTest($fp, $delim) {
+ echo "Delimiter: " . $delim . "\n";
+ rewind($fp);
+ echo "\t" . stream_get_line($fp, 10, $delim) . "\n";
+ echo "\t" . stream_get_line($fp, 10, $delim) . "\n";
+}
+
+?>
+--EXPECT--
+Delimiter: ZZZ
+ <?php // 1
+ 234567890A
+Delimiter: Z
+ <?php // 1
+ 234567890A
diff --git a/ext/standard/tests/file/bug44034.phpt b/ext/standard/tests/file/bug44034.phpt
new file mode 100644
index 0000000..36d88a9
--- /dev/null
+++ b/ext/standard/tests/file/bug44034.phpt
@@ -0,0 +1,41 @@
+--TEST--
+Bug #44034
+--INI--
+allow_url_fopen=1
+--FILE--
+<?php
+
+$urls = array();
+$urls[] = "data://text/plain,foo\r\nbar\r\n";
+$urls[] = "data://text/plain,\r\nfoo\r\nbar\r\n";
+$urls[] = "data://text/plain,foo\r\nbar";
+
+foreach($urls as $url) {
+ echo strtr($url, array("\r" => "\\r", "\n" => "\\n")) . "\n";
+ var_dump(file($url, FILE_IGNORE_NEW_LINES));
+}
+?>
+--EXPECTF--
+data://text/plain,foo\r\nbar\r\n
+array(2) {
+ [0]=>
+ %unicode|string%(3) "foo"
+ [1]=>
+ %unicode|string%(3) "bar"
+}
+data://text/plain,\r\nfoo\r\nbar\r\n
+array(3) {
+ [0]=>
+ %unicode|string%(0) ""
+ [1]=>
+ %unicode|string%(3) "foo"
+ [2]=>
+ %unicode|string%(3) "bar"
+}
+data://text/plain,foo\r\nbar
+array(2) {
+ [0]=>
+ %unicode|string%(3) "foo"
+ [1]=>
+ %unicode|string%(3) "bar"
+}
diff --git a/ext/standard/tests/file/bug44607.phpt b/ext/standard/tests/file/bug44607.phpt
new file mode 100644
index 0000000..dc5e4cb
--- /dev/null
+++ b/ext/standard/tests/file/bug44607.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Bug #44607 (stream_get_line unable to correctly identify the "ending" in the stream content)
+--FILE--
+<?php
+$eol = '<EOL>';
+$tempnam = __DIR__ . '/' . 'tmpbug44607.txt';
+$data = str_repeat('.', 14000);
+$data .= $eol;
+$data .= $data;
+file_put_contents($tempnam, $data);
+$fd = fopen($tempnam, 'r');
+var_dump(strlen(stream_get_line($fd, 15000, $eol)));
+var_dump(strlen(stream_get_line($fd, 15000, $eol)));
+fseek($fd, 1, SEEK_SET);
+var_dump(strlen(stream_get_line($fd, 15000, $eol)));
+var_dump(strlen(stream_get_line($fd, 15000, $eol)));
+fclose($fd);
+unlink($tempnam);
+?>
+--EXPECT--
+int(14000)
+int(14000)
+int(13999)
+int(14000)
diff --git a/ext/standard/tests/file/bug44805.phpt b/ext/standard/tests/file/bug44805.phpt
new file mode 100644
index 0000000..85f1255
--- /dev/null
+++ b/ext/standard/tests/file/bug44805.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Bug#44806 (rename() function is not portable to Windows)
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip.. only for Windows');
+}
+?>
+--FILE--
+<?php
+$dirname = dirname(__FILE__);
+$file1 = $dirname . DIRECTORY_SEPARATOR . "file1.txt";
+$file2 = $dirname . DIRECTORY_SEPARATOR . "file2.txt";
+
+file_put_contents($file1, "this is file 1");
+file_put_contents($file2, "this is file 2");
+
+rename($file1, $file2);
+
+echo "reading file 2: ";
+readfile($file2);
+if (file_exists($file1)) {
+ unlink($file1);
+}
+if (file_exists($file1)) {
+ unlink($file2);
+}
+?>
+--EXPECT--
+reading file 2: this is file 1
diff --git a/ext/standard/tests/file/bug45181.phpt b/ext/standard/tests/file/bug45181.phpt
new file mode 100644
index 0000000..d64fa89
--- /dev/null
+++ b/ext/standard/tests/file/bug45181.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Bug #45181 (chdir() should clear relative entries in stat cache)
+--FILE--
+<?php
+mkdir("bug45181_x");
+var_dump(is_dir("bug45181_x"));
+chdir("bug45181_x");
+var_dump(is_dir("bug45181_x"));
+?>
+--CLEAN--
+<?php
+rmdir("bug45181_x");
+?>
+--EXPECT--
+bool(true)
+bool(false)
diff --git a/ext/standard/tests/file/bug45303.phpt b/ext/standard/tests/file/bug45303.phpt
new file mode 100644
index 0000000..0a4b33b
--- /dev/null
+++ b/ext/standard/tests/file/bug45303.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Bug #45303 (Opening php:// wrapper in append mode results in a warning)
+--FILE--
+<?php
+$fd = fopen("php://stdout","a");
+var_dump($fd);
+var_dump(fseek($fd, 1024*1024, SEEK_SET));
+?>
+--EXPECTF--
+resource(%d) of type (stream)
+
+Warning: fseek(): stream does not support seeking in %s
+int(-1)
diff --git a/ext/standard/tests/file/bug45985.phpt b/ext/standard/tests/file/bug45985.phpt
new file mode 100644
index 0000000..1b98da2
--- /dev/null
+++ b/ext/standard/tests/file/bug45985.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Bug #35740 (touch() opened file raises a warning)
+--FILE--
+<?php
+$file = __DIR__ . '/' . '__tmp_35740.dat';
+file_put_contents($file, 'test');
+$f = fopen($file, 'r');
+touch($file);
+fclose($f);
+@unlink($file);
+echo "ok";
+?>
+--EXPECT--
+ok
diff --git a/ext/standard/tests/file/bug46347.phpt b/ext/standard/tests/file/bug46347.phpt
new file mode 100644
index 0000000..af81bc2
--- /dev/null
+++ b/ext/standard/tests/file/bug46347.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Bug #46347 (parse_ini_file() doesn't support * in keys)
+--FILE--
+<?php
+
+$str = <<< EOF
+[section]
+part1.*.part2 = 1
+EOF;
+
+$file = __DIR__ . '/parse.ini';
+file_put_contents($file, $str);
+
+var_dump(parse_ini_file($file));
+?>
+--CLEAN--
+<?php
+unlink(__DIR__.'/parse.ini');
+?>
+--EXPECTF--
+array(1) {
+ [%u|b%"part1.*.part2"]=>
+ %unicode|string%(1) "1"
+}
diff --git a/ext/standard/tests/file/bug47767.phpt b/ext/standard/tests/file/bug47767.phpt
new file mode 100644
index 0000000..312476a
--- /dev/null
+++ b/ext/standard/tests/file/bug47767.phpt
@@ -0,0 +1,50 @@
+--TEST--
+bug #47767 (include_once does not resolve windows symlinks or junctions)
+--CREDITS--
+Venkat Raman Don
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != 'WIN' ) {
+ die('skip windows only test');
+}
+if(PHP_WINDOWS_VERSION_MAJOR < 6) {
+ die('skip windows version 6.0+ only test');
+}
+
+$ret = exec('mklink rename_variation13tmp.lnk ' . __FILE__ .' 2>&1', $out);
+if (strpos($ret, 'privilege')) {
+ die('skip. SeCreateSymbolicLinkPrivilege not enable for this user.');
+}
+?>
+--FILE--
+<?php
+echo "Testing include_once using file symbolic link\n";
+$filename = __DIR__ . '\\a.php';
+$content = '<?php echo "I am included\n" ?>';
+file_put_contents($filename, $content);
+$softlinkname = __DIR__ . '\\a_slink.php';
+symlink($filename, $softlinkname);
+include_once("$filename");
+include_once("$softlinkname");
+include_once("$softlinkname");
+
+echo "Testing include_once using directory symbolic link\n";
+$softdirlinkname = __DIR__ . "\\a_dir";
+symlink(__DIR__, $softdirlinkname);
+include_once("$softdirlinkname" . '\\a.php');
+
+echo "Testing include_once using junction points\n";
+$junctionname = __DIR__ . '\\a_jdir';
+exec("mklink /J $junctionname " . __DIR__);
+include_once("$junctionname" . '\\a.php');
+
+unlink($filename);
+unlink($softlinkname);
+rmdir($softdirlinkname);
+rmdir($junctionname);
+?>
+--EXPECT--
+Testing include_once using file symbolic link
+I am included
+Testing include_once using directory symbolic link
+Testing include_once using junction points \ No newline at end of file
diff --git a/ext/standard/tests/file/bug49047.phpt b/ext/standard/tests/file/bug49047.phpt
new file mode 100644
index 0000000..1ccc94e
--- /dev/null
+++ b/ext/standard/tests/file/bug49047.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Test fopen() function : variation: interesting paths, no use include path
+--FILE--
+<?php
+// fopen with interesting windows paths.
+$testdir = __DIR__ . '/bug47177.tmpdir';
+mkdir($testdir);
+$t = time() - 3600;
+touch($testdir, $t);
+clearstatcache();
+$t2 = filemtime($testdir);
+if ($t2 != $t) echo "failed (got $t2, expecting $t)\n";
+rmdir($testdir);
+echo "Ok.";
+?>
+--EXPECTF--
+Ok.
diff --git a/ext/standard/tests/file/bug51094.phpt b/ext/standard/tests/file/bug51094.phpt
new file mode 100644
index 0000000..f35dfb6
--- /dev/null
+++ b/ext/standard/tests/file/bug51094.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Fixed bug #51094 (parse_ini_file() with INI_SCANNER_RAW cuts a value that includes a semi-colon).
+--FILE--
+<?php
+
+$ini = parse_ini_string('ini="ini;raw"', null, INI_SCANNER_RAW);
+var_dump($ini['ini']);
+$ini = parse_ini_string('ini="ini;raw', null, INI_SCANNER_RAW);
+var_dump($ini['ini']);
+$ini = parse_ini_string('ini=ini;raw', null, INI_SCANNER_RAW);
+var_dump($ini['ini']);
+$ini = parse_ini_string('ini=ini"raw', null, INI_SCANNER_RAW);
+var_dump($ini['ini']);
+$ini = parse_ini_string("ini=\r\niniraw", null, INI_SCANNER_RAW);
+var_dump($ini['ini']);
+--EXPECTF--
+string(7) "ini;raw"
+string(4) ""ini"
+string(3) "ini"
+string(7) "ini"raw"
+string(0) ""
+
diff --git a/ext/standard/tests/file/bug52624.phpt b/ext/standard/tests/file/bug52624.phpt
new file mode 100644
index 0000000..ee61eb9
--- /dev/null
+++ b/ext/standard/tests/file/bug52624.phpt
@@ -0,0 +1,12 @@
+--TEST--
+Bug #52624 (tempnam() by-pass open_basedir with inexistent directory)
+--INI--
+open_basedir=.
+--FILE--
+<?php
+
+echo tempnam("directory_that_not_exists", "prefix_");
+
+?>
+--EXPECTF--
+Warning: tempnam(): open_basedir restriction in effect. File(%s) is not within the allowed path(s): (%s) in %s on line %d
diff --git a/ext/standard/tests/file/bug52820.phpt b/ext/standard/tests/file/bug52820.phpt
new file mode 100644
index 0000000..91976b0
--- /dev/null
+++ b/ext/standard/tests/file/bug52820.phpt
@@ -0,0 +1,71 @@
+--TEST--
+Bug #52820 (writes to fopencookie FILE* not commited when seeking the stream)
+--SKIPIF--
+<?php
+if (!function_exists('leak_variable'))
+ die("skip only for debug builds");
+/* unfortunately no standard function does a cast to FILE*, so we need
+ * curl to test this */
+if (!extension_loaded("curl")) exit("skip curl extension not loaded");
+$handle=curl_init('http://127.0.0.1:37349/');
+curl_setopt($handle, CURLOPT_VERBOSE, true);
+curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
+if (!curl_setopt($handle, CURLOPT_STDERR, fopen("php://memory", "w+")))
+ die("skip fopencookie not supported on this platform");
+--FILE--
+<?php
+function do_stuff($url) {
+ $handle=curl_init('http://127.0.0.1:37349/');
+ curl_setopt($handle, CURLOPT_VERBOSE, true);
+ curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($handle, CURLOPT_STDERR, $o = fopen($url, "w+"));
+ curl_exec($handle);
+ echo "About to rewind!\n";
+ rewind($o);
+ echo stream_get_contents($o);
+ return $o;
+}
+
+echo "temp stream (close after):\n";
+fclose(do_stuff("php://temp"));
+
+echo "\nmemory stream (close after):\n";
+fclose(do_stuff("php://memory"));
+
+echo "\ntemp stream (leak):\n";
+leak_variable(do_stuff("php://temp"), true);
+
+echo "\nmemory stream (leak):\n";
+leak_variable(do_stuff("php://memory"), true);
+
+echo "\nDone.\n";
+--EXPECTF--
+temp stream (close after):
+About to rewind!
+* About to connect() to 127.0.0.1 port 37349%r.*%r
+* Trying 127.0.0.1...%A* Connection refused
+* couldn't connect to host%S
+* Closing connection #0
+
+memory stream (close after):
+About to rewind!
+* About to connect() to 127.0.0.1 port 37349%r.*%r
+* Trying 127.0.0.1...%A* Connection refused
+* couldn't connect to host%S
+* Closing connection #0
+
+temp stream (leak):
+About to rewind!
+* About to connect() to 127.0.0.1 port 37349%r.*%r
+* Trying 127.0.0.1...%A* Connection refused
+* couldn't connect to host%S
+* Closing connection #0
+
+memory stream (leak):
+About to rewind!
+* About to connect() to 127.0.0.1 port 37349%r.*%r
+* Trying 127.0.0.1...%A* Connection refused
+* couldn't connect to host%S
+* Closing connection #0
+
+Done.
diff --git a/ext/standard/tests/file/bug53241.phpt b/ext/standard/tests/file/bug53241.phpt
new file mode 100644
index 0000000..685bf14
--- /dev/null
+++ b/ext/standard/tests/file/bug53241.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Bug #53241 (stream casting that relies on fdopen/fopencookie fails with 'xb' mode)
+--SKIPIF--
+<?php
+/* unfortunately no standard function does a cast to FILE*, so we need
+ * curl to test this */
+if (!extension_loaded("curl")) exit("skip curl extension not loaded");
+--FILE--
+<?php
+$fn = __DIR__ . "/test.tmp";
+@unlink($fn);
+$fh = fopen($fn, 'xb');
+$ch = curl_init('http://www.yahoo.com/');
+var_dump(curl_setopt($ch, CURLOPT_FILE, $fh));
+echo "Done.\n";
+--CLEAN--
+<?php
+$fn = __DIR__ . "/test.tmp";
+@unlink($fn);
+?>
+--EXPECT--
+bool(true)
+Done.
diff --git a/ext/standard/tests/file/bug53848.phpt b/ext/standard/tests/file/bug53848.phpt
new file mode 100644
index 0000000..016d59d
--- /dev/null
+++ b/ext/standard/tests/file/bug53848.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Bug #53848 (fgetcsv removes leading spaces from fields)
+--FILE--
+<?php
+$file = dirname(__FILE__) . "/bug39538.csv";
+@unlink($file);
+file_put_contents($file, "a,b\n c, d");
+$fp = fopen($file, "r");
+while ($l = fgetcsv($fp)) var_dump($l);
+fclose($fp);
+@unlink($file);
+?>
+--EXPECT--
+array(2) {
+ [0]=>
+ string(1) "a"
+ [1]=>
+ string(1) "b"
+}
+array(2) {
+ [0]=>
+ string(3) " c"
+ [1]=>
+ string(3) " d"
+}
diff --git a/ext/standard/tests/file/bug55124.phpt b/ext/standard/tests/file/bug55124.phpt
new file mode 100644
index 0000000..1915b7f
--- /dev/null
+++ b/ext/standard/tests/file/bug55124.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Bug #55124 (recursive mkdir fails with current (dot) directory in path)
+--FILE--
+<?php
+$old_dir_path = getcwd();
+chdir(__DIR__);
+mkdir('a/./b', 0755, true);
+if (is_dir('a/b')) {
+ rmdir('a/b');
+}
+if (is_dir('./a')) {
+ rmdir('a');
+}
+chdir($old_dir_path);
+echo "OK";
+?>
+--EXPECT--
+OK
diff --git a/ext/standard/tests/file/bug60120.phpt b/ext/standard/tests/file/bug60120.phpt
new file mode 100644
index 0000000..8915bb8
--- /dev/null
+++ b/ext/standard/tests/file/bug60120.phpt
@@ -0,0 +1,74 @@
+--TEST--
+Bug #60120 (proc_open hangs when data in stdin/out/err is getting larger or equal to 2048)
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip only for Windows');
+}
+$php = getenv('TEST_PHP_EXECUTABLE');
+if (!$php) {
+ die("No php executable defined\n");
+}
+?>
+--FILE--
+<?php
+
+error_reporting(E_ALL);
+
+$php = getenv('TEST_PHP_EXECUTABLE');
+if (!$php) {
+ die("No php executable defined\n");
+}
+$cmd = 'php -r "fwrite(STDOUT, $in = file_get_contents(\'php://stdin\')); fwrite(STDERR, $in);"';
+$descriptors = array(array('pipe', 'r'), array('pipe', 'w'), array('pipe', 'w'));
+$stdin = str_repeat('*', 1024 * 16) . '!';
+$stdin = str_repeat('*', 2049 );
+
+$options = array_merge(array('suppress_errors' => true, 'binary_pipes' => true, 'bypass_shell' => false));
+$process = proc_open($cmd, $descriptors, $pipes, getcwd(), array(), $options);
+
+foreach ($pipes as $pipe) {
+ stream_set_blocking($pipe, false);
+}
+$writePipes = array($pipes[0]);
+$stdinLen = strlen($stdin);
+$stdinOffset = 0;
+
+unset($pipes[0]);
+
+while ($pipes || $writePipes) {
+ $r = $pipes;
+ $w = $writePipes;
+ $e = null;
+ $n = stream_select($r, $w, $e, 60);
+
+ if (false === $n) {
+ break;
+ } elseif ($n === 0) {
+ proc_terminate($process);
+
+ }
+ if ($w) {
+ $written = fwrite($writePipes[0], (binary)substr($stdin, $stdinOffset), 8192);
+ if (false !== $written) {
+ $stdinOffset += $written;
+ }
+ if ($stdinOffset >= $stdinLen) {
+ fclose($writePipes[0]);
+ $writePipes = null;
+ }
+ }
+
+ foreach ($r as $pipe) {
+ $type = array_search($pipe, $pipes);
+ $data = fread($pipe, 8192);
+ if (false === $data || feof($pipe)) {
+ fclose($pipe);
+ unset($pipes[$type]);
+ }
+ }
+}
+echo "OK.";
+?>
+--EXPECT--
+OK.
diff --git a/ext/standard/tests/file/bug61961.phpt b/ext/standard/tests/file/bug61961.phpt
new file mode 100644
index 0000000..ff0279a
--- /dev/null
+++ b/ext/standard/tests/file/bug61961.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Bug #61961 (file_get_content leaks when access empty file with max length)
+--FILE--
+<?php
+$tmp_empty_file = __FILE__ . ".tmp";
+file_put_contents($tmp_empty_file, "");
+
+var_dump(file_get_contents($tmp_empty_file, NULL, NULL, NULL, 10));
+unlink($tmp_empty_file);
+?>
+==DONE==
+--EXPECT--
+string(0) ""
+==DONE== \ No newline at end of file
diff --git a/ext/standard/tests/file/bug63512.phpt b/ext/standard/tests/file/bug63512.phpt
new file mode 100644
index 0000000..049db26
--- /dev/null
+++ b/ext/standard/tests/file/bug63512.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Fixed bug #63512 (parse_ini_file() with INI_SCANNER_RAW removes quotes from value).
+--FILE--
+<?php
+
+$array = parse_ini_string('
+ int = 123
+ constant = INSTALL_ROOT
+ quotedString = "string"
+ a = INSTALL_ROOT "waa"
+ b = "INSTALL_ROOT"
+ c = "waa" INSTALL_ROOT
+ d = INSTALL_ROOT "INSTALL_ROOT"', false, INI_SCANNER_RAW);
+
+var_dump($array);
+--EXPECTF--
+array(7) {
+ ["int"]=>
+ string(3) "123"
+ ["constant"]=>
+ string(12) "INSTALL_ROOT"
+ ["quotedString"]=>
+ string(6) "string"
+ ["a"]=>
+ string(18) "INSTALL_ROOT "waa""
+ ["b"]=>
+ string(12) "INSTALL_ROOT"
+ ["c"]=>
+ string(18) ""waa" INSTALL_ROOT"
+ ["d"]=>
+ string(27) "INSTALL_ROOT "INSTALL_ROOT""
+}
+
diff --git a/ext/standard/tests/file/chgrp.phpt b/ext/standard/tests/file/chgrp.phpt
new file mode 100644
index 0000000..9c85f5c
--- /dev/null
+++ b/ext/standard/tests/file/chgrp.phpt
@@ -0,0 +1,15 @@
+--TEST--
+chgrp() with NULL as group name
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+ die("skip, not supported on Windows");
+?>
+--FILE--
+<?php
+chgrp("sjhgfskhagkfdgskjfhgskfsdgfkdsajf", NULL);
+echo "ALIVE\n";
+?>
+--EXPECTF--
+Warning: chgrp(): parameter 2 should be string or integer, null given in %schgrp.php on line 2
+ALIVE
diff --git a/ext/standard/tests/file/chmod_basic-win32.phpt b/ext/standard/tests/file/chmod_basic-win32.phpt
new file mode 100644
index 0000000..ca224f7
--- /dev/null
+++ b/ext/standard/tests/file/chmod_basic-win32.phpt
@@ -0,0 +1,545 @@
+--TEST--
+chmod() basic fuctionality
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip Windows only chmod test');
+}
+?>
+--FILE--
+<?php
+
+define("PERMISSIONS_MASK", 0777);
+
+$filename = __FILE__ . ".tmp";
+
+$fd = fopen($filename, "w+");
+fclose($fd);
+
+for ($perms_to_set = 0777; $perms_to_set >= 0; $perms_to_set--) {
+ chmod($filename, $perms_to_set);
+ $set_perms = (fileperms($filename) & PERMISSIONS_MASK);
+ clearstatcache();
+ printf("Setting mode %o gives mode %o\n", $perms_to_set, $set_perms);
+}
+var_dump(chmod($filename, 0777));
+
+unlink($filename);
+echo "done";
+
+?>
+--EXPECT--
+Setting mode 777 gives mode 666
+Setting mode 776 gives mode 666
+Setting mode 775 gives mode 666
+Setting mode 774 gives mode 666
+Setting mode 773 gives mode 666
+Setting mode 772 gives mode 666
+Setting mode 771 gives mode 666
+Setting mode 770 gives mode 666
+Setting mode 767 gives mode 666
+Setting mode 766 gives mode 666
+Setting mode 765 gives mode 666
+Setting mode 764 gives mode 666
+Setting mode 763 gives mode 666
+Setting mode 762 gives mode 666
+Setting mode 761 gives mode 666
+Setting mode 760 gives mode 666
+Setting mode 757 gives mode 666
+Setting mode 756 gives mode 666
+Setting mode 755 gives mode 666
+Setting mode 754 gives mode 666
+Setting mode 753 gives mode 666
+Setting mode 752 gives mode 666
+Setting mode 751 gives mode 666
+Setting mode 750 gives mode 666
+Setting mode 747 gives mode 666
+Setting mode 746 gives mode 666
+Setting mode 745 gives mode 666
+Setting mode 744 gives mode 666
+Setting mode 743 gives mode 666
+Setting mode 742 gives mode 666
+Setting mode 741 gives mode 666
+Setting mode 740 gives mode 666
+Setting mode 737 gives mode 666
+Setting mode 736 gives mode 666
+Setting mode 735 gives mode 666
+Setting mode 734 gives mode 666
+Setting mode 733 gives mode 666
+Setting mode 732 gives mode 666
+Setting mode 731 gives mode 666
+Setting mode 730 gives mode 666
+Setting mode 727 gives mode 666
+Setting mode 726 gives mode 666
+Setting mode 725 gives mode 666
+Setting mode 724 gives mode 666
+Setting mode 723 gives mode 666
+Setting mode 722 gives mode 666
+Setting mode 721 gives mode 666
+Setting mode 720 gives mode 666
+Setting mode 717 gives mode 666
+Setting mode 716 gives mode 666
+Setting mode 715 gives mode 666
+Setting mode 714 gives mode 666
+Setting mode 713 gives mode 666
+Setting mode 712 gives mode 666
+Setting mode 711 gives mode 666
+Setting mode 710 gives mode 666
+Setting mode 707 gives mode 666
+Setting mode 706 gives mode 666
+Setting mode 705 gives mode 666
+Setting mode 704 gives mode 666
+Setting mode 703 gives mode 666
+Setting mode 702 gives mode 666
+Setting mode 701 gives mode 666
+Setting mode 700 gives mode 666
+Setting mode 677 gives mode 666
+Setting mode 676 gives mode 666
+Setting mode 675 gives mode 666
+Setting mode 674 gives mode 666
+Setting mode 673 gives mode 666
+Setting mode 672 gives mode 666
+Setting mode 671 gives mode 666
+Setting mode 670 gives mode 666
+Setting mode 667 gives mode 666
+Setting mode 666 gives mode 666
+Setting mode 665 gives mode 666
+Setting mode 664 gives mode 666
+Setting mode 663 gives mode 666
+Setting mode 662 gives mode 666
+Setting mode 661 gives mode 666
+Setting mode 660 gives mode 666
+Setting mode 657 gives mode 666
+Setting mode 656 gives mode 666
+Setting mode 655 gives mode 666
+Setting mode 654 gives mode 666
+Setting mode 653 gives mode 666
+Setting mode 652 gives mode 666
+Setting mode 651 gives mode 666
+Setting mode 650 gives mode 666
+Setting mode 647 gives mode 666
+Setting mode 646 gives mode 666
+Setting mode 645 gives mode 666
+Setting mode 644 gives mode 666
+Setting mode 643 gives mode 666
+Setting mode 642 gives mode 666
+Setting mode 641 gives mode 666
+Setting mode 640 gives mode 666
+Setting mode 637 gives mode 666
+Setting mode 636 gives mode 666
+Setting mode 635 gives mode 666
+Setting mode 634 gives mode 666
+Setting mode 633 gives mode 666
+Setting mode 632 gives mode 666
+Setting mode 631 gives mode 666
+Setting mode 630 gives mode 666
+Setting mode 627 gives mode 666
+Setting mode 626 gives mode 666
+Setting mode 625 gives mode 666
+Setting mode 624 gives mode 666
+Setting mode 623 gives mode 666
+Setting mode 622 gives mode 666
+Setting mode 621 gives mode 666
+Setting mode 620 gives mode 666
+Setting mode 617 gives mode 666
+Setting mode 616 gives mode 666
+Setting mode 615 gives mode 666
+Setting mode 614 gives mode 666
+Setting mode 613 gives mode 666
+Setting mode 612 gives mode 666
+Setting mode 611 gives mode 666
+Setting mode 610 gives mode 666
+Setting mode 607 gives mode 666
+Setting mode 606 gives mode 666
+Setting mode 605 gives mode 666
+Setting mode 604 gives mode 666
+Setting mode 603 gives mode 666
+Setting mode 602 gives mode 666
+Setting mode 601 gives mode 666
+Setting mode 600 gives mode 666
+Setting mode 577 gives mode 444
+Setting mode 576 gives mode 444
+Setting mode 575 gives mode 444
+Setting mode 574 gives mode 444
+Setting mode 573 gives mode 444
+Setting mode 572 gives mode 444
+Setting mode 571 gives mode 444
+Setting mode 570 gives mode 444
+Setting mode 567 gives mode 444
+Setting mode 566 gives mode 444
+Setting mode 565 gives mode 444
+Setting mode 564 gives mode 444
+Setting mode 563 gives mode 444
+Setting mode 562 gives mode 444
+Setting mode 561 gives mode 444
+Setting mode 560 gives mode 444
+Setting mode 557 gives mode 444
+Setting mode 556 gives mode 444
+Setting mode 555 gives mode 444
+Setting mode 554 gives mode 444
+Setting mode 553 gives mode 444
+Setting mode 552 gives mode 444
+Setting mode 551 gives mode 444
+Setting mode 550 gives mode 444
+Setting mode 547 gives mode 444
+Setting mode 546 gives mode 444
+Setting mode 545 gives mode 444
+Setting mode 544 gives mode 444
+Setting mode 543 gives mode 444
+Setting mode 542 gives mode 444
+Setting mode 541 gives mode 444
+Setting mode 540 gives mode 444
+Setting mode 537 gives mode 444
+Setting mode 536 gives mode 444
+Setting mode 535 gives mode 444
+Setting mode 534 gives mode 444
+Setting mode 533 gives mode 444
+Setting mode 532 gives mode 444
+Setting mode 531 gives mode 444
+Setting mode 530 gives mode 444
+Setting mode 527 gives mode 444
+Setting mode 526 gives mode 444
+Setting mode 525 gives mode 444
+Setting mode 524 gives mode 444
+Setting mode 523 gives mode 444
+Setting mode 522 gives mode 444
+Setting mode 521 gives mode 444
+Setting mode 520 gives mode 444
+Setting mode 517 gives mode 444
+Setting mode 516 gives mode 444
+Setting mode 515 gives mode 444
+Setting mode 514 gives mode 444
+Setting mode 513 gives mode 444
+Setting mode 512 gives mode 444
+Setting mode 511 gives mode 444
+Setting mode 510 gives mode 444
+Setting mode 507 gives mode 444
+Setting mode 506 gives mode 444
+Setting mode 505 gives mode 444
+Setting mode 504 gives mode 444
+Setting mode 503 gives mode 444
+Setting mode 502 gives mode 444
+Setting mode 501 gives mode 444
+Setting mode 500 gives mode 444
+Setting mode 477 gives mode 444
+Setting mode 476 gives mode 444
+Setting mode 475 gives mode 444
+Setting mode 474 gives mode 444
+Setting mode 473 gives mode 444
+Setting mode 472 gives mode 444
+Setting mode 471 gives mode 444
+Setting mode 470 gives mode 444
+Setting mode 467 gives mode 444
+Setting mode 466 gives mode 444
+Setting mode 465 gives mode 444
+Setting mode 464 gives mode 444
+Setting mode 463 gives mode 444
+Setting mode 462 gives mode 444
+Setting mode 461 gives mode 444
+Setting mode 460 gives mode 444
+Setting mode 457 gives mode 444
+Setting mode 456 gives mode 444
+Setting mode 455 gives mode 444
+Setting mode 454 gives mode 444
+Setting mode 453 gives mode 444
+Setting mode 452 gives mode 444
+Setting mode 451 gives mode 444
+Setting mode 450 gives mode 444
+Setting mode 447 gives mode 444
+Setting mode 446 gives mode 444
+Setting mode 445 gives mode 444
+Setting mode 444 gives mode 444
+Setting mode 443 gives mode 444
+Setting mode 442 gives mode 444
+Setting mode 441 gives mode 444
+Setting mode 440 gives mode 444
+Setting mode 437 gives mode 444
+Setting mode 436 gives mode 444
+Setting mode 435 gives mode 444
+Setting mode 434 gives mode 444
+Setting mode 433 gives mode 444
+Setting mode 432 gives mode 444
+Setting mode 431 gives mode 444
+Setting mode 430 gives mode 444
+Setting mode 427 gives mode 444
+Setting mode 426 gives mode 444
+Setting mode 425 gives mode 444
+Setting mode 424 gives mode 444
+Setting mode 423 gives mode 444
+Setting mode 422 gives mode 444
+Setting mode 421 gives mode 444
+Setting mode 420 gives mode 444
+Setting mode 417 gives mode 444
+Setting mode 416 gives mode 444
+Setting mode 415 gives mode 444
+Setting mode 414 gives mode 444
+Setting mode 413 gives mode 444
+Setting mode 412 gives mode 444
+Setting mode 411 gives mode 444
+Setting mode 410 gives mode 444
+Setting mode 407 gives mode 444
+Setting mode 406 gives mode 444
+Setting mode 405 gives mode 444
+Setting mode 404 gives mode 444
+Setting mode 403 gives mode 444
+Setting mode 402 gives mode 444
+Setting mode 401 gives mode 444
+Setting mode 400 gives mode 444
+Setting mode 377 gives mode 666
+Setting mode 376 gives mode 666
+Setting mode 375 gives mode 666
+Setting mode 374 gives mode 666
+Setting mode 373 gives mode 666
+Setting mode 372 gives mode 666
+Setting mode 371 gives mode 666
+Setting mode 370 gives mode 666
+Setting mode 367 gives mode 666
+Setting mode 366 gives mode 666
+Setting mode 365 gives mode 666
+Setting mode 364 gives mode 666
+Setting mode 363 gives mode 666
+Setting mode 362 gives mode 666
+Setting mode 361 gives mode 666
+Setting mode 360 gives mode 666
+Setting mode 357 gives mode 666
+Setting mode 356 gives mode 666
+Setting mode 355 gives mode 666
+Setting mode 354 gives mode 666
+Setting mode 353 gives mode 666
+Setting mode 352 gives mode 666
+Setting mode 351 gives mode 666
+Setting mode 350 gives mode 666
+Setting mode 347 gives mode 666
+Setting mode 346 gives mode 666
+Setting mode 345 gives mode 666
+Setting mode 344 gives mode 666
+Setting mode 343 gives mode 666
+Setting mode 342 gives mode 666
+Setting mode 341 gives mode 666
+Setting mode 340 gives mode 666
+Setting mode 337 gives mode 666
+Setting mode 336 gives mode 666
+Setting mode 335 gives mode 666
+Setting mode 334 gives mode 666
+Setting mode 333 gives mode 666
+Setting mode 332 gives mode 666
+Setting mode 331 gives mode 666
+Setting mode 330 gives mode 666
+Setting mode 327 gives mode 666
+Setting mode 326 gives mode 666
+Setting mode 325 gives mode 666
+Setting mode 324 gives mode 666
+Setting mode 323 gives mode 666
+Setting mode 322 gives mode 666
+Setting mode 321 gives mode 666
+Setting mode 320 gives mode 666
+Setting mode 317 gives mode 666
+Setting mode 316 gives mode 666
+Setting mode 315 gives mode 666
+Setting mode 314 gives mode 666
+Setting mode 313 gives mode 666
+Setting mode 312 gives mode 666
+Setting mode 311 gives mode 666
+Setting mode 310 gives mode 666
+Setting mode 307 gives mode 666
+Setting mode 306 gives mode 666
+Setting mode 305 gives mode 666
+Setting mode 304 gives mode 666
+Setting mode 303 gives mode 666
+Setting mode 302 gives mode 666
+Setting mode 301 gives mode 666
+Setting mode 300 gives mode 666
+Setting mode 277 gives mode 666
+Setting mode 276 gives mode 666
+Setting mode 275 gives mode 666
+Setting mode 274 gives mode 666
+Setting mode 273 gives mode 666
+Setting mode 272 gives mode 666
+Setting mode 271 gives mode 666
+Setting mode 270 gives mode 666
+Setting mode 267 gives mode 666
+Setting mode 266 gives mode 666
+Setting mode 265 gives mode 666
+Setting mode 264 gives mode 666
+Setting mode 263 gives mode 666
+Setting mode 262 gives mode 666
+Setting mode 261 gives mode 666
+Setting mode 260 gives mode 666
+Setting mode 257 gives mode 666
+Setting mode 256 gives mode 666
+Setting mode 255 gives mode 666
+Setting mode 254 gives mode 666
+Setting mode 253 gives mode 666
+Setting mode 252 gives mode 666
+Setting mode 251 gives mode 666
+Setting mode 250 gives mode 666
+Setting mode 247 gives mode 666
+Setting mode 246 gives mode 666
+Setting mode 245 gives mode 666
+Setting mode 244 gives mode 666
+Setting mode 243 gives mode 666
+Setting mode 242 gives mode 666
+Setting mode 241 gives mode 666
+Setting mode 240 gives mode 666
+Setting mode 237 gives mode 666
+Setting mode 236 gives mode 666
+Setting mode 235 gives mode 666
+Setting mode 234 gives mode 666
+Setting mode 233 gives mode 666
+Setting mode 232 gives mode 666
+Setting mode 231 gives mode 666
+Setting mode 230 gives mode 666
+Setting mode 227 gives mode 666
+Setting mode 226 gives mode 666
+Setting mode 225 gives mode 666
+Setting mode 224 gives mode 666
+Setting mode 223 gives mode 666
+Setting mode 222 gives mode 666
+Setting mode 221 gives mode 666
+Setting mode 220 gives mode 666
+Setting mode 217 gives mode 666
+Setting mode 216 gives mode 666
+Setting mode 215 gives mode 666
+Setting mode 214 gives mode 666
+Setting mode 213 gives mode 666
+Setting mode 212 gives mode 666
+Setting mode 211 gives mode 666
+Setting mode 210 gives mode 666
+Setting mode 207 gives mode 666
+Setting mode 206 gives mode 666
+Setting mode 205 gives mode 666
+Setting mode 204 gives mode 666
+Setting mode 203 gives mode 666
+Setting mode 202 gives mode 666
+Setting mode 201 gives mode 666
+Setting mode 200 gives mode 666
+Setting mode 177 gives mode 444
+Setting mode 176 gives mode 444
+Setting mode 175 gives mode 444
+Setting mode 174 gives mode 444
+Setting mode 173 gives mode 444
+Setting mode 172 gives mode 444
+Setting mode 171 gives mode 444
+Setting mode 170 gives mode 444
+Setting mode 167 gives mode 444
+Setting mode 166 gives mode 444
+Setting mode 165 gives mode 444
+Setting mode 164 gives mode 444
+Setting mode 163 gives mode 444
+Setting mode 162 gives mode 444
+Setting mode 161 gives mode 444
+Setting mode 160 gives mode 444
+Setting mode 157 gives mode 444
+Setting mode 156 gives mode 444
+Setting mode 155 gives mode 444
+Setting mode 154 gives mode 444
+Setting mode 153 gives mode 444
+Setting mode 152 gives mode 444
+Setting mode 151 gives mode 444
+Setting mode 150 gives mode 444
+Setting mode 147 gives mode 444
+Setting mode 146 gives mode 444
+Setting mode 145 gives mode 444
+Setting mode 144 gives mode 444
+Setting mode 143 gives mode 444
+Setting mode 142 gives mode 444
+Setting mode 141 gives mode 444
+Setting mode 140 gives mode 444
+Setting mode 137 gives mode 444
+Setting mode 136 gives mode 444
+Setting mode 135 gives mode 444
+Setting mode 134 gives mode 444
+Setting mode 133 gives mode 444
+Setting mode 132 gives mode 444
+Setting mode 131 gives mode 444
+Setting mode 130 gives mode 444
+Setting mode 127 gives mode 444
+Setting mode 126 gives mode 444
+Setting mode 125 gives mode 444
+Setting mode 124 gives mode 444
+Setting mode 123 gives mode 444
+Setting mode 122 gives mode 444
+Setting mode 121 gives mode 444
+Setting mode 120 gives mode 444
+Setting mode 117 gives mode 444
+Setting mode 116 gives mode 444
+Setting mode 115 gives mode 444
+Setting mode 114 gives mode 444
+Setting mode 113 gives mode 444
+Setting mode 112 gives mode 444
+Setting mode 111 gives mode 444
+Setting mode 110 gives mode 444
+Setting mode 107 gives mode 444
+Setting mode 106 gives mode 444
+Setting mode 105 gives mode 444
+Setting mode 104 gives mode 444
+Setting mode 103 gives mode 444
+Setting mode 102 gives mode 444
+Setting mode 101 gives mode 444
+Setting mode 100 gives mode 444
+Setting mode 77 gives mode 444
+Setting mode 76 gives mode 444
+Setting mode 75 gives mode 444
+Setting mode 74 gives mode 444
+Setting mode 73 gives mode 444
+Setting mode 72 gives mode 444
+Setting mode 71 gives mode 444
+Setting mode 70 gives mode 444
+Setting mode 67 gives mode 444
+Setting mode 66 gives mode 444
+Setting mode 65 gives mode 444
+Setting mode 64 gives mode 444
+Setting mode 63 gives mode 444
+Setting mode 62 gives mode 444
+Setting mode 61 gives mode 444
+Setting mode 60 gives mode 444
+Setting mode 57 gives mode 444
+Setting mode 56 gives mode 444
+Setting mode 55 gives mode 444
+Setting mode 54 gives mode 444
+Setting mode 53 gives mode 444
+Setting mode 52 gives mode 444
+Setting mode 51 gives mode 444
+Setting mode 50 gives mode 444
+Setting mode 47 gives mode 444
+Setting mode 46 gives mode 444
+Setting mode 45 gives mode 444
+Setting mode 44 gives mode 444
+Setting mode 43 gives mode 444
+Setting mode 42 gives mode 444
+Setting mode 41 gives mode 444
+Setting mode 40 gives mode 444
+Setting mode 37 gives mode 444
+Setting mode 36 gives mode 444
+Setting mode 35 gives mode 444
+Setting mode 34 gives mode 444
+Setting mode 33 gives mode 444
+Setting mode 32 gives mode 444
+Setting mode 31 gives mode 444
+Setting mode 30 gives mode 444
+Setting mode 27 gives mode 444
+Setting mode 26 gives mode 444
+Setting mode 25 gives mode 444
+Setting mode 24 gives mode 444
+Setting mode 23 gives mode 444
+Setting mode 22 gives mode 444
+Setting mode 21 gives mode 444
+Setting mode 20 gives mode 444
+Setting mode 17 gives mode 444
+Setting mode 16 gives mode 444
+Setting mode 15 gives mode 444
+Setting mode 14 gives mode 444
+Setting mode 13 gives mode 444
+Setting mode 12 gives mode 444
+Setting mode 11 gives mode 444
+Setting mode 10 gives mode 444
+Setting mode 7 gives mode 444
+Setting mode 6 gives mode 444
+Setting mode 5 gives mode 444
+Setting mode 4 gives mode 444
+Setting mode 3 gives mode 444
+Setting mode 2 gives mode 444
+Setting mode 1 gives mode 444
+Setting mode 0 gives mode 444
+bool(true)
+done
diff --git a/ext/standard/tests/file/chmod_basic.phpt b/ext/standard/tests/file/chmod_basic.phpt
new file mode 100644
index 0000000..582f273
--- /dev/null
+++ b/ext/standard/tests/file/chmod_basic.phpt
@@ -0,0 +1,35 @@
+--TEST--
+chmod() basic fuctionality
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip non-windows only test');
+}
+?>
+--FILE--
+<?php
+
+define("MODE_MASK", 07777);
+
+$filename = __FILE__ . ".tmp";
+
+$fd = fopen($filename, "w+");
+fclose($fd);
+
+for ($perms_to_set = 07777; $perms_to_set >= 0; $perms_to_set--) {
+ chmod($filename, $perms_to_set);
+ $set_perms = (fileperms($filename) & MODE_MASK);
+ clearstatcache();
+ if ($set_perms != $perms_to_set) {
+ printf("Error: %o does not match %o\n", $set_perms, $perms_to_set);
+ }
+}
+var_dump(chmod($filename, 0777));
+
+unlink($filename);
+echo "done";
+
+?>
+--EXPECT--
+bool(true)
+done
diff --git a/ext/standard/tests/file/chmod_error.phpt b/ext/standard/tests/file/chmod_error.phpt
new file mode 100644
index 0000000..f4cae3b
--- /dev/null
+++ b/ext/standard/tests/file/chmod_error.phpt
@@ -0,0 +1,47 @@
+--TEST--
+Test chmod() function : error conditions
+--FILE--
+<?php
+/* Prototype : bool chmod(string filename, int mode)
+ * Description: Change file mode
+ * Source code: ext/standard/filestat.c
+ * Alias to functions:
+ */
+
+echo "*** Testing chmod() : error conditions ***\n";
+
+
+//Test chmod with one more than the expected number of arguments
+echo "\n-- Testing chmod() function with more than expected no. of arguments --\n";
+$filename = 'string_val';
+$mode = 10;
+$extra_arg = 10;
+var_dump( chmod($filename, $mode, $extra_arg) );
+
+// Testing chmod with one less than the expected number of arguments
+echo "\n-- Testing chmod() function with less than expected no. of arguments --\n";
+$filename = 'string_val';
+var_dump( chmod($filename) );
+
+// testing chmod with a non-existing file
+$filename = "___nonExisitingFile___";
+var_dump(chmod($filename, 0777));
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing chmod() : error conditions ***
+
+-- Testing chmod() function with more than expected no. of arguments --
+
+Warning: chmod() expects exactly 2 parameters, 3 given in %s on line %d
+NULL
+
+-- Testing chmod() function with less than expected no. of arguments --
+
+Warning: chmod() expects exactly 2 parameters, 1 given in %s on line %d
+NULL
+
+Warning: chmod(): No such file or directory in %s on line %d
+bool(false)
+===DONE===
diff --git a/ext/standard/tests/file/chmod_variation1.phpt b/ext/standard/tests/file/chmod_variation1.phpt
new file mode 100644
index 0000000..f35e54e
--- /dev/null
+++ b/ext/standard/tests/file/chmod_variation1.phpt
@@ -0,0 +1,34 @@
+--TEST--
+chmod() on a directory
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip non-windows only test');
+}
+?>
+--FILE--
+<?php
+
+define("PERMISSIONS_MASK", 0777);
+
+$dirname = dirname(__FILE__) . "/" . basename(__FILE__, ".php") . "testdir";
+mkdir($dirname);
+
+for ($perms_to_set = 0777; $perms_to_set >= 0; $perms_to_set--) {
+ chmod($dirname, $perms_to_set);
+ $set_perms = (fileperms($dirname) & PERMISSIONS_MASK);
+ clearstatcache();
+ if ($set_perms != $perms_to_set) {
+ printf("Error: %o does not match %o\n", $set_perms, $perms_to_set);
+ }
+}
+
+var_dump(chmod($dirname, 0777));
+rmdir($dirname);
+
+echo "done";
+
+?>
+--EXPECT--
+bool(true)
+done
diff --git a/ext/standard/tests/file/chmod_variation2-win32.phpt b/ext/standard/tests/file/chmod_variation2-win32.phpt
new file mode 100644
index 0000000..bc379ff
--- /dev/null
+++ b/ext/standard/tests/file/chmod_variation2-win32.phpt
@@ -0,0 +1,74 @@
+--TEST--
+chmod() with various paths
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip Windows only chmod test');
+}
+?>
+--FILE--
+<?php
+
+define("PERMISSIONS_MASK", 0777);
+
+$script_directory = dirname(__FILE__);
+chdir($script_directory);
+$test_dirname = basename(__FILE__, ".php") . "testdir";
+mkdir($test_dirname);
+
+$filepath = __FILE__ . ".tmp";
+$filename = basename($filepath);
+$fd = fopen($filepath, "w+");
+fclose($fd);
+
+echo "chmod() on a path containing .. and .\n";
+var_dump(chmod("./$test_dirname/../$filename", 0777));
+var_dump(chmod("./$test_dirname/../$filename", 0755));
+clearstatcache();
+printf("%o\n", fileperms($filepath) & PERMISSIONS_MASK);
+
+echo "\nchmod() on a path containing .. with invalid directories\n";
+var_dump(chmod($filepath, 0777));
+var_dump(chmod("./$test_dirname/bad_dir/../../$filename", 0755));
+clearstatcache();
+printf("%o\n", fileperms($filepath) & PERMISSIONS_MASK);
+
+echo "\nchmod() on a relative path from a different working directory\n";
+chdir($test_dirname);
+var_dump(chmod("../$filename", 0777));
+var_dump(chmod("../$filename", 0755));
+clearstatcache();
+printf("%o\n", fileperms($filepath) & PERMISSIONS_MASK);
+chdir($script_directory);
+
+echo "\nchmod() on a directory with a trailing /\n";
+var_dump(chmod($test_dirname, 0777));
+var_dump(chmod("$test_dirname/", 0775));
+clearstatcache();
+printf("%o\n", fileperms($filepath) & PERMISSIONS_MASK);
+
+chdir($script_directory);
+rmdir($test_dirname);
+unlink($filepath);
+
+?>
+--EXPECTF--
+chmod() on a path containing .. and .
+bool(true)
+bool(true)
+666
+
+chmod() on a path containing .. with invalid directories
+bool(true)
+bool(true)
+666
+
+chmod() on a relative path from a different working directory
+bool(true)
+bool(true)
+666
+
+chmod() on a directory with a trailing /
+bool(true)
+bool(true)
+666
diff --git a/ext/standard/tests/file/chmod_variation2.phpt b/ext/standard/tests/file/chmod_variation2.phpt
new file mode 100644
index 0000000..b193acf
--- /dev/null
+++ b/ext/standard/tests/file/chmod_variation2.phpt
@@ -0,0 +1,92 @@
+--TEST--
+chmod() with various paths
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip non-windows only test');
+}
+?>
+--FILE--
+<?php
+
+define("PERMISSIONS_MASK", 0777);
+
+$script_directory = dirname(__FILE__);
+chdir($script_directory);
+$test_dirname = basename(__FILE__, ".php") . "testdir";
+mkdir($test_dirname);
+
+$filepath = __FILE__ . ".tmp";
+$filename = basename($filepath);
+$fd = fopen($filepath, "w+");
+fclose($fd);
+
+echo "chmod() on a path containing .. and .\n";
+var_dump(chmod("./$test_dirname/../$filename", 0777));
+var_dump(chmod("./$test_dirname/../$filename", 0755));
+clearstatcache();
+printf("%o\n", fileperms($filepath) & PERMISSIONS_MASK);
+
+echo "\nchmod() on a path containing .. with invalid directories\n";
+var_dump(chmod($filepath, 0777));
+var_dump(chmod("./$test_dirname/bad_dir/../../$filename", 0755));
+clearstatcache();
+printf("%o\n", fileperms($filepath) & PERMISSIONS_MASK);
+
+echo "\nchmod() on a linked file\n";
+$linkname = "somelink";
+var_dump(symlink($filepath, $linkname));
+var_dump(chmod($filepath, 0777));
+var_dump(chmod($linkname, 0755));
+clearstatcache();
+printf("%o\n", fileperms($filepath) & PERMISSIONS_MASK);
+var_dump(unlink($linkname));
+
+echo "\nchmod() on a relative path from a different working directory\n";
+chdir($test_dirname);
+var_dump(chmod("../$filename", 0777));
+var_dump(chmod("../$filename", 0755));
+clearstatcache();
+printf("%o\n", fileperms($filepath) & PERMISSIONS_MASK);
+chdir($script_directory);
+
+echo "\nchmod() on a directory with a trailing /\n";
+var_dump(chmod($test_dirname, 0777));
+var_dump(chmod("$test_dirname/", 0775));
+clearstatcache();
+printf("%o\n", fileperms($filepath) & PERMISSIONS_MASK);
+
+chdir($script_directory);
+rmdir($test_dirname);
+unlink($filepath);
+
+?>
+--EXPECTF--
+chmod() on a path containing .. and .
+bool(true)
+bool(true)
+755
+
+chmod() on a path containing .. with invalid directories
+bool(true)
+
+Warning: chmod(): No such file or directory in %s on line %d
+bool(false)
+777
+
+chmod() on a linked file
+bool(true)
+bool(true)
+bool(true)
+755
+bool(true)
+
+chmod() on a relative path from a different working directory
+bool(true)
+bool(true)
+755
+
+chmod() on a directory with a trailing /
+bool(true)
+bool(true)
+755
diff --git a/ext/standard/tests/file/chmod_variation3.phpt b/ext/standard/tests/file/chmod_variation3.phpt
new file mode 100644
index 0000000..7c637b8
--- /dev/null
+++ b/ext/standard/tests/file/chmod_variation3.phpt
@@ -0,0 +1,209 @@
+--TEST--
+Test chmod() function : first parameter variation
+--FILE--
+<?php
+/* Prototype : bool chmod(string filename, int mode)
+ * Description: Change file mode
+ * Source code: ext/standard/filestat.c
+ * Alias to functions:
+ */
+
+echo "*** Testing chmod() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$mode = 0777;
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+ // int data
+ 'int 0' => 0,
+ 'int 1' => 1,
+ 'int 12345' => 12345,
+ 'int -12345' => -2345,
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float -10.5' => -10.5,
+ 'float 12.3456789000e10' => 12.3456789000e10,
+ 'float -12.3456789000e10' => -12.3456789000e10,
+ 'float .5' => .5,
+
+ // array data
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for filename
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( chmod($value, $mode) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing chmod() : usage variation ***
+
+--int 0--
+Error: 2 - chmod(): No such file or directory, %s(%d)
+bool(false)
+
+--int 1--
+Error: 2 - chmod(): No such file or directory, %s(%d)
+bool(false)
+
+--int 12345--
+Error: 2 - chmod(): No such file or directory, %s(%d)
+bool(false)
+
+--int -12345--
+Error: 2 - chmod(): No such file or directory, %s(%d)
+bool(false)
+
+--float 10.5--
+Error: 2 - chmod(): No such file or directory, %s(%d)
+bool(false)
+
+--float -10.5--
+Error: 2 - chmod(): No such file or directory, %s(%d)
+bool(false)
+
+--float 12.3456789000e10--
+Error: 2 - chmod(): No such file or directory, %s(%d)
+bool(false)
+
+--float -12.3456789000e10--
+Error: 2 - chmod(): No such file or directory, %s(%d)
+bool(false)
+
+--float .5--
+Error: 2 - chmod(): No such file or directory, %s(%d)
+bool(false)
+
+--empty array--
+Error: 2 - chmod() expects parameter 1 to be a valid path, array given, %s(%d)
+NULL
+
+--int indexed array--
+Error: 2 - chmod() expects parameter 1 to be a valid path, array given, %s(%d)
+NULL
+
+--associative array--
+Error: 2 - chmod() expects parameter 1 to be a valid path, array given, %s(%d)
+NULL
+
+--nested arrays--
+Error: 2 - chmod() expects parameter 1 to be a valid path, array given, %s(%d)
+NULL
+
+--uppercase NULL--
+Error: 2 - chmod(): %s, %s(%d)
+bool(false)
+
+--lowercase null--
+Error: 2 - chmod(): %s, %s(%d)
+bool(false)
+
+--lowercase true--
+Error: 2 - chmod(): No such file or directory, %s(%d)
+bool(false)
+
+--lowercase false--
+Error: 2 - chmod(): %s, %s(%d)
+bool(false)
+
+--uppercase TRUE--
+Error: 2 - chmod(): No such file or directory, %s(%d)
+bool(false)
+
+--uppercase FALSE--
+Error: 2 - chmod(): %s, %s(%d)
+bool(false)
+
+--empty string DQ--
+Error: 2 - chmod(): %s, %s(%d)
+bool(false)
+
+--empty string SQ--
+Error: 2 - chmod(): %s, %s(%d)
+bool(false)
+
+--instance of classWithToString--
+Error: 2 - chmod(): No such file or directory, %s(%d)
+bool(false)
+
+--instance of classWithoutToString--
+Error: 2 - chmod() expects parameter 1 to be a valid path, object given, %s(%d)
+NULL
+
+--undefined var--
+Error: 2 - chmod(): %s, %s(%d)
+bool(false)
+
+--unset var--
+Error: 2 - chmod(): %s, %s(%d)
+bool(false)
+===DONE===
+
diff --git a/ext/standard/tests/file/chmod_variation4.phpt b/ext/standard/tests/file/chmod_variation4.phpt
new file mode 100644
index 0000000..15310f1
--- /dev/null
+++ b/ext/standard/tests/file/chmod_variation4.phpt
@@ -0,0 +1,201 @@
+--TEST--
+Test chmod() function : second parameter variation
+--FILE--
+<?php
+/* Prototype : bool chmod(string filename, int mode)
+ * Description: Change file mode
+ * Source code: ext/standard/filestat.c
+ * Alias to functions:
+ */
+
+echo "*** Testing chmod() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted
+$filename = __FILE__ . ".tmp";
+$fd = fopen($filename, "w+");
+fclose($fd);
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float -10.5' => -10.5,
+ 'float 12.3456789000e10' => 12.3456789000e10,
+ 'float -12.3456789000e10' => -12.3456789000e10,
+ 'float .5' => .5,
+
+ // array data
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // string data
+ 'string DQ' => "string",
+ 'string SQ' => 'string',
+ 'mixed case string' => "sTrInG",
+ 'heredoc' => $heredoc,
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for mode
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( chmod($filename, $value) );
+};
+
+chmod($filename, 0777);
+unlink($filename);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing chmod() : usage variation ***
+
+--float 10.5--
+bool(true)
+
+--float -10.5--
+bool(true)
+
+--float 12.3456789000e10--
+bool(true)
+
+--float -12.3456789000e10--
+bool(true)
+
+--float .5--
+bool(true)
+
+--empty array--
+Error: 2 - chmod() expects parameter 2 to be long, array given, %s(%d)
+NULL
+
+--int indexed array--
+Error: 2 - chmod() expects parameter 2 to be long, array given, %s(%d)
+NULL
+
+--associative array--
+Error: 2 - chmod() expects parameter 2 to be long, array given, %s(%d)
+NULL
+
+--nested arrays--
+Error: 2 - chmod() expects parameter 2 to be long, array given, %s(%d)
+NULL
+
+--uppercase NULL--
+bool(true)
+
+--lowercase null--
+bool(true)
+
+--lowercase true--
+bool(true)
+
+--lowercase false--
+bool(true)
+
+--uppercase TRUE--
+bool(true)
+
+--uppercase FALSE--
+bool(true)
+
+--empty string DQ--
+Error: 2 - chmod() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--empty string SQ--
+Error: 2 - chmod() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--string DQ--
+Error: 2 - chmod() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--string SQ--
+Error: 2 - chmod() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--mixed case string--
+Error: 2 - chmod() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--heredoc--
+Error: 2 - chmod() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--instance of classWithToString--
+Error: 2 - chmod() expects parameter 2 to be long, object given, %s(%d)
+NULL
+
+--instance of classWithoutToString--
+Error: 2 - chmod() expects parameter 2 to be long, object given, %s(%d)
+NULL
+
+--undefined var--
+bool(true)
+
+--unset var--
+bool(true)
+===DONE===
+
diff --git a/ext/standard/tests/file/chown.phpt b/ext/standard/tests/file/chown.phpt
new file mode 100644
index 0000000..9075d3d
--- /dev/null
+++ b/ext/standard/tests/file/chown.phpt
@@ -0,0 +1,15 @@
+--TEST--
+chown() with NULL as user name
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+ die("skip, not supported on Windows");
+?>
+--FILE--
+<?php
+chown("sjhgfskhagkfdgskjfhgskfsdgfkdsajf", NULL);
+echo "ALIVE\n";
+?>
+--EXPECTF--
+Warning: chown(): parameter 2 should be string or integer, null given in %schown.php on line %d
+ALIVE
diff --git a/ext/standard/tests/file/chroot_001.phpt b/ext/standard/tests/file/chroot_001.phpt
new file mode 100644
index 0000000..daa1a83
--- /dev/null
+++ b/ext/standard/tests/file/chroot_001.phpt
@@ -0,0 +1,30 @@
+--TEST--
+chroot()
+--SKIPIF--
+<?php
+chdir("/");
+if (!@mkdir("testtmpskipifdir")) {
+ die("skip for root only");
+}
+rmdir("testtmpskipifdir");
+if (!function_exists("chroot")) {
+ die("skip chroot() not available");
+}
+?>
+--FILE--
+<?php
+mkdir("chroot_001_x");
+var_dump(is_dir("chroot_001_x"));
+var_dump(chroot("chroot_001_x"));
+var_dump(is_dir("chroot_001_x"));
+var_dump(realpath("."));
+?>
+--CLEAN--
+<?php
+rmdir("chroot_001_x");
+?>
+--EXPECTF--
+bool(true)
+bool(true)
+bool(false)
+%unicode|string%(1) "/"
diff --git a/ext/standard/tests/file/clearstatcache_001.phpt b/ext/standard/tests/file/clearstatcache_001.phpt
new file mode 100644
index 0000000..4282430
--- /dev/null
+++ b/ext/standard/tests/file/clearstatcache_001.phpt
@@ -0,0 +1,43 @@
+--TEST--
+clearstatcache() optional parameters
+--SKIPIF--
+<?php
+if (strncmp(PHP_OS, "WIN", 3) === 0) {
+ die('skip not for Windows');
+}
+?>
+--FILE--
+<?php
+
+@rmdir(__FILE__ . "_dir1");
+@rmdir(__FILE__ . "_dir2");
+@unlink(__FILE__ . "_link1");
+@unlink(__FILE__ . "_link2");
+
+mkdir(__FILE__ . "_dir1");
+mkdir(__FILE__ . "_dir2");
+symlink(__FILE__ . "_link1", __FILE__ . "_link2");
+symlink(__FILE__ . "_dir1", __FILE__ . "_link1");
+
+var_dump(realpath(__FILE__ . "_link2"));
+passthru("rm -f " . escapeshellarg(__FILE__ . "_link1"));
+var_dump(realpath(__FILE__ . "_link2"));
+clearstatcache(false);
+var_dump(realpath(__FILE__ . "_link2"));
+clearstatcache(true, "/foo/bar");
+var_dump(realpath(__FILE__ . "_link2"));
+clearstatcache(true, __FILE__ . "_link2");
+clearstatcache(true, __FILE__ . "_link1");
+var_dump(realpath(__FILE__ . "_link2"));
+
+@rmdir(__FILE__ . "_dir1");
+@rmdir(__FILE__ . "_dir2");
+@unlink(__FILE__ . "_link1");
+@unlink(__FILE__ . "_link2");
+?>
+--EXPECTF--
+%unicode|string%(%d) "%s_dir1"
+%unicode|string%(%d) "%s_dir1"
+%unicode|string%(%d) "%s_dir1"
+%unicode|string%(%d) "%s_dir1"
+bool(false)
diff --git a/ext/standard/tests/file/clearstatcache_error.phpt b/ext/standard/tests/file/clearstatcache_error.phpt
new file mode 100644
index 0000000..ee7d1af
--- /dev/null
+++ b/ext/standard/tests/file/clearstatcache_error.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Test clearstatcache() function: error conditions
+--FILE--
+<?php
+/*
+ Prototype: void clearstatcache ([bool clear_realpath_cache[, filename]]);
+ Description: clears files status cache
+*/
+
+echo "*** Testing clearstatcache() function: error conditions ***\n";
+var_dump( clearstatcache(0, "/foo/bar", 1) ); //No.of args more than expected
+echo "*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing clearstatcache() function: error conditions ***
+
+Warning: clearstatcache() expects at most 2 parameters, 3 given in %s on line %d
+NULL
+*** Done ***
diff --git a/ext/standard/tests/file/copy_basic.phpt b/ext/standard/tests/file/copy_basic.phpt
new file mode 100644
index 0000000..32788f9
--- /dev/null
+++ b/ext/standard/tests/file/copy_basic.phpt
@@ -0,0 +1,58 @@
+--TEST--
+Test copy() function: basic functionality
+--FILE--
+<?php
+/* Prototype: bool copy ( string $source, string $dest );
+ * Description: Makes a copy of the file source to dest.
+ * Returns TRUE on success or FALSE on failure.
+ */
+
+echo "*** Testing copy() function: to copy file from source to destination --\n";
+
+var_dump( file_exists(__FILE__) );
+
+/* copying the file */
+$file_path = dirname(__FILE__);
+$file_name1 = $file_path."/copy_basic1.tmp";
+$file_name2 = $file_path."/copy_basic2.tmp";
+var_dump( copy(__FILE__, $file_name1) );
+var_dump( copy($file_name1, $file_name2) );
+
+echo "-- Checking whether the copy of file exists --\n";
+var_dump( file_exists($file_name1) );
+var_dump( file_exists($file_name2) );
+
+echo "-- Checking filepermissions of file and its copies --\n";
+printf( "%o", fileperms(__FILE__) );
+echo "\n";
+printf( "%o", fileperms($file_name1) );
+echo "\n";
+printf( "%o", fileperms($file_name2) );
+echo "\n";
+
+echo "*** Done ***\n";
+?>
+
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$file_name1 = $file_path."/copy_basic1.tmp";
+$file_name2 = $file_path."/copy_basic2.tmp";
+unlink($file_name1);
+unlink($file_name2);
+?>
+
+--EXPECTF--
+*** Testing copy() function: to copy file from source to destination --
+bool(true)
+bool(true)
+bool(true)
+-- Checking whether the copy of file exists --
+bool(true)
+bool(true)
+-- Checking filepermissions of file and its copies --
+%d
+%d
+%d
+*** Done ***
+
diff --git a/ext/standard/tests/file/copy_error.phpt b/ext/standard/tests/file/copy_error.phpt
new file mode 100644
index 0000000..96072eb
--- /dev/null
+++ b/ext/standard/tests/file/copy_error.phpt
@@ -0,0 +1,39 @@
+--TEST--
+Test copy() function: error conditions
+--FILE--
+<?php
+/* Prototype: bool copy ( string $source, string $dest );
+ * Description: Makes a copy of the file source to dest.
+ * Returns TRUE on success or FALSE on failure.
+ */
+
+echo "*** Testing copy() function: error conditions --\n";
+/* Invalid args */
+var_dump( copy("/no/file", "file") );
+
+/* No.of args less than expected */
+var_dump( copy() );
+var_dump( copy(__FILE__) );
+
+/* No.of args less than expected */
+var_dump( copy(__FILE__, "file1", "file1") );
+
+echo "*** Done ***\n";
+?>
+
+--EXPECTF--
+*** Testing copy() function: error conditions --
+
+Warning: copy(/no/file): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+Warning: copy() expects at least 2 parameters, 0 given in %s on line %d
+NULL
+
+Warning: copy() expects at least 2 parameters, 1 given in %s on line %d
+NULL
+
+Warning: copy() expects parameter 3 to be resource, string given in %s on line %d
+NULL
+*** Done ***
+
diff --git a/ext/standard/tests/file/copy_variation1.phpt b/ext/standard/tests/file/copy_variation1.phpt
new file mode 100644
index 0000000..4d0a973
--- /dev/null
+++ b/ext/standard/tests/file/copy_variation1.phpt
@@ -0,0 +1,145 @@
+--TEST--
+Test copy() function: usage variations - destination file names(numerics/strings)
+--FILE--
+<?php
+/* Prototype: bool copy ( string $source, string $dest );
+ Description: Makes a copy of the file source to dest.
+ Returns TRUE on success or FALSE on failure.
+*/
+
+/* Test copy() function: In creation of destination file names containing numerics/strings
+ and checking the existence and size of destination files
+*/
+
+echo "*** Test copy() function: destination file names containing numerics/strings ***\n";
+$file_path = dirname(__FILE__);
+$src_file_name = $file_path."/copy_variation1.tmp";
+$file_handle = fopen($src_file_name, "w");
+fwrite( $file_handle, str_repeat(b"Hello2World...\n", 100) );
+fclose($file_handle);
+
+/* array of destination file names */
+$dest_files = array(
+
+ /* File names containing numerics, strings */
+ "copy.tmp", //regular file name
+ "copy_copy_variation1.tmp",
+ ".tmp", //file name only with extension
+ "123.tmp", //file name starts with numeric and with regular extension
+ "copy_variation1.123", //file name with numeric extension
+ "123", //numeric
+ "123copy_variation1.tmp", //file name containing numeric & string
+ "copy_variation.tmp123", //file name containing string & numeric
+ chr(99).chr(111).chr(112).chr(121).chr(49).".tmp" //file name containing ASCII values
+);
+
+echo "Size of the source file before copy operation => ";
+var_dump( filesize("$src_file_name") );
+clearstatcache();
+
+echo "\n-- Now applying copy() on source file to create copies --";
+$count = 1;
+foreach($dest_files as $dest_file) {
+ echo "\n-- Iteration $count --\n";
+
+ $dest_file_name = "$file_path/$dest_file";
+
+ echo "Copy operation => ";
+ var_dump( copy($src_file_name, $dest_file_name) );
+
+ echo "Existence of destination file => ";
+ var_dump( file_exists($dest_file_name) );
+
+ echo "Destination file name => ";
+ print($dest_file_name);
+ echo "\n";
+
+ echo "Size of source file => ";
+ var_dump( filesize($src_file_name) );
+ clearstatcache();
+
+ echo "Size of destination file => ";
+ var_dump( filesize($dest_file_name) );
+ clearstatcache();
+
+ unlink($dest_file_name);
+
+ $count++;
+}
+
+echo "*** Done ***\n";
+?>
+
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/copy_variation1.tmp");
+?>
+
+--EXPECTF--
+*** Test copy() function: destination file names containing numerics/strings ***
+Size of the source file before copy operation => int(1500)
+
+-- Now applying copy() on source file to create copies --
+-- Iteration 1 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/copy.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 2 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/copy_copy_variation1.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 3 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 4 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/123.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 5 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/copy_variation1.123
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 6 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/123
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 7 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/123copy_variation1.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 8 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/copy_variation.tmp123
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 9 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/copy1.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+*** Done ***
diff --git a/ext/standard/tests/file/copy_variation10.phpt b/ext/standard/tests/file/copy_variation10.phpt
new file mode 100644
index 0000000..98494af
--- /dev/null
+++ b/ext/standard/tests/file/copy_variation10.phpt
@@ -0,0 +1,37 @@
+--TEST--
+Test copy() function: usage variations - identical names
+--FILE--
+<?php
+/* Prototype: bool copy ( string $source, string $dest );
+ Description: Makes a copy of the file source to dest.
+ Returns TRUE on success or FALSE on failure.
+*/
+
+/* Test copy(): Try copying source file to desntination file, where destination file name is identical to source name */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test copy(): Trying to create a copy of file with the same source name ***\n";
+$file = $file_path."/copy_variation10.tmp";
+$file_handle = fopen($file, "w");
+fwrite($file_handle, str_repeat(b"Hello2world...\n", 100));
+fclose($file_handle);
+
+var_dump( copy($file, $file) );
+var_dump( file_exists($file) );
+var_dump( filesize($file) );
+
+echo "*** Done ***\n";
+?>
+
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/copy_variation10.tmp");
+?>
+
+--EXPECTF--
+*** Test copy(): Trying to create a copy of file with the same source name ***
+bool(false)
+bool(true)
+int(1500)
+*** Done ***
diff --git a/ext/standard/tests/file/copy_variation11.phpt b/ext/standard/tests/file/copy_variation11.phpt
new file mode 100644
index 0000000..adee8e1
--- /dev/null
+++ b/ext/standard/tests/file/copy_variation11.phpt
@@ -0,0 +1,71 @@
+--TEST--
+Test copy() function: usage variations - existing dir as destination
+--FILE--
+<?php
+/* Prototype: bool copy ( string $source, string $dest );
+ Description: Makes a copy of the file source to dest.
+ Returns TRUE on success or FALSE on failure.
+*/
+
+/* Test copy(): Trying to copy the file to a destination, where destination is an existing dir */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test copy() function: Trying to create a copy of source file as a dir ***\n";
+$file = $file_path."/copy_variation11.tmp";
+$file_handle = fopen($file, "w");
+fwrite($file_handle, str_repeat(b"Hello, world...", 20));
+fclose($file_handle);
+
+$dir = $file_path."/copy_variation11";
+mkdir($dir);
+
+echo "Size of source before copy operation => ";
+var_dump( filesize($file) ); //size of source before copy
+clearstatcache();
+echo "Size of destination before copy operation => ";
+var_dump( filesize($dir) ); //size of destination before copy
+clearstatcache();
+
+echo "\n-- Now applying copy() operation --\n";
+var_dump( copy($file, $dir) ); //expected: bool(false)
+
+var_dump( file_exists($file) ); //expected: bool(true)
+var_dump( file_exists($dir) ); //expected: bool(true)
+
+var_dump( is_file($file) ); //expected: bool(true)
+var_dump( is_dir($file) ); //expected: bool(false)
+
+var_dump( is_file($dir) ); //expected: bool(false)
+var_dump( is_dir($dir) ); //expected: bool(true)
+
+var_dump( filesize($file) ); //size of source after copy
+var_dump( filesize($dir) ); //size of destination after copy
+
+echo "*** Done ***\n";
+?>
+
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/copy_variation11.tmp");
+rmdir(dirname(__FILE__)."/copy_variation11");
+?>
+
+--EXPECTF--
+*** Test copy() function: Trying to create a copy of source file as a dir ***
+Size of source before copy operation => int(300)
+Size of destination before copy operation => int(%d)
+
+-- Now applying copy() operation --
+
+Warning: %s
+bool(false)
+bool(true)
+bool(true)
+bool(true)
+bool(false)
+bool(false)
+bool(true)
+int(300)
+int(%d)
+*** Done ***
diff --git a/ext/standard/tests/file/copy_variation12-win32.phpt b/ext/standard/tests/file/copy_variation12-win32.phpt
new file mode 100644
index 0000000..4d39de3
--- /dev/null
+++ b/ext/standard/tests/file/copy_variation12-win32.phpt
@@ -0,0 +1,47 @@
+--TEST--
+Test copy() function: usage variations - dir as source
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+ die("skip Run only on Windows");
+?>
+--FILE--
+<?php
+/* Prototype: bool copy ( string $source, string $dest );
+ Description: Makes a copy of the file source to dest.
+ Returns TRUE on success or FALSE on failure.
+*/
+
+/* Test copy(): Trying to create a copy of an existing dir */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test copy() function: Trying to create a copy of an existing dir ***\n";
+$src_dir = $file_path."/copy_variation12";
+mkdir($src_dir);
+
+$dest = $file_path."/copy_copy_variation12";
+
+var_dump( copy($src_dir, $dest) );
+
+var_dump( file_exists($dest) );
+
+var_dump( filesize($src_dir) );
+
+echo "*** Done ***\n";
+?>
+
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/copy_copy_variation12");
+rmdir(dirname(__FILE__)."/copy_variation12");
+?>
+
+--EXPECTF--
+*** Test copy() function: Trying to create a copy of an existing dir ***
+
+Warning: copy(): The first argument to copy() function cannot be a directory in %s on line %d
+bool(false)
+bool(false)
+int(0)
+*** Done ***
diff --git a/ext/standard/tests/file/copy_variation12.phpt b/ext/standard/tests/file/copy_variation12.phpt
new file mode 100644
index 0000000..7f96fd0
--- /dev/null
+++ b/ext/standard/tests/file/copy_variation12.phpt
@@ -0,0 +1,51 @@
+--TEST--
+Test copy() function: usage variations - dir as source (Bug #42111)
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+ die("skip Do not run on Windows");
+?>
+
+--FILE--
+<?php
+/* Prototype: bool copy ( string $source, string $dest );
+ Description: Makes a copy of the file source to dest.
+ Returns TRUE on success or FALSE on failure.
+*/
+
+/* Test copy(): Trying to create a copy of an existing dir */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test copy() function: Trying to create a copy of an existing dir ***\n";
+$src_dir = $file_path."/copy_variation12";
+mkdir($src_dir);
+
+$dest = $file_path."/copy_copy_variation12";
+
+var_dump( copy($src_dir, $dest) );
+
+var_dump( file_exists($dest) );
+
+var_dump( filesize($src_dir) );
+var_dump( filesize($dest) );
+
+echo "*** Done ***\n";
+?>
+
+--CLEAN--
+<?php
+rmdir(dirname(__FILE__)."/copy_variation12");
+?>
+
+--EXPECTF--
+*** Test copy() function: Trying to create a copy of an existing dir ***
+
+Warning: copy(): The first argument to copy() function cannot be a directory in %scopy_variation12.php on line %d
+bool(false)
+bool(false)
+int(%d)
+
+Warning: filesize(): stat failed for %scopy_copy_variation12 in %scopy_variation12.php on line %d
+bool(false)
+*** Done ***
diff --git a/ext/standard/tests/file/copy_variation13.phpt b/ext/standard/tests/file/copy_variation13.phpt
new file mode 100644
index 0000000..779f82b
--- /dev/null
+++ b/ext/standard/tests/file/copy_variation13.phpt
@@ -0,0 +1,57 @@
+--TEST--
+Test copy() function: usage variations - src as dir and dest as an existing file(Bug #42243)
+--FILE--
+<?php
+/* Prototype: bool copy ( string $source, string $dest );
+ Description: Makes a copy of the file source to dest.
+ Returns TRUE on success or FALSE on failure.
+*/
+
+/* Test copy(): Trying to copy dir to an existing file */
+
+echo "*** Test copy() function: Trying to copy dir to file ***\n";
+$file_path = dirname(__FILE__);
+$file = $file_path."/copy_variation13_dir.tmp";
+fclose(fopen($file, "w"));
+$dir = $file_path."/copy_variation13";
+mkdir($dir);
+
+echo "*** Testing copy() in copying dir to file ***\n";
+var_dump( copy($dir, $file) );
+
+var_dump( file_exists($file) );
+var_dump( file_exists($dir) );
+
+var_dump( is_file($dir) );
+var_dump( is_dir($dir) );
+
+var_dump( is_file($file) );
+var_dump( is_dir($file) );
+
+var_dump( filesize($file) );
+var_dump( filesize($dir) );
+
+echo "*** Done ***\n";
+?>
+
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/copy_variation13_dir.tmp");
+rmdir(dirname(__FILE__)."/copy_variation13");
+?>
+
+--EXPECTF--
+*** Test copy() function: Trying to copy dir to file ***
+*** Testing copy() in copying dir to file ***
+
+Warning: copy(): The first argument to copy() function cannot be a directory in %scopy_variation13.php on line %d
+bool(false)
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+bool(true)
+bool(false)
+int(%d)
+int(%d)
+*** Done ***
diff --git a/ext/standard/tests/file/copy_variation14.phpt b/ext/standard/tests/file/copy_variation14.phpt
new file mode 100644
index 0000000..1a39c1c
--- /dev/null
+++ b/ext/standard/tests/file/copy_variation14.phpt
@@ -0,0 +1,48 @@
+--TEST--
+Test copy() function: usage variations - non existing src/dest
+--FILE--
+<?php
+/* Prototype: bool copy ( string $source, string $dest );
+ Description: Makes a copy of the file source to dest.
+ Returns TRUE on success or FALSE on failure.
+*/
+
+/* Test copy(): Trying to create a copy of non-existing source in an existing destination
+ and an existing source in non-existing destiantion */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test copy() function: Trying to create a copy of non-existing source in existing destination ***";
+$file = $file_path."/copy_variation14.tmp";
+$file_handle = fopen($file, "w");
+fwrite($file_handle, str_repeat(b"Hello2world...\n", 100));
+fclose($file_handle);
+
+var_dump( copy($file_path."/nosuchfile.tmp", $file_path."/copy_nosuchfile.tmp") ); //With non-existing source
+var_dump( file_exists($file_path."/copy_nosuchfile.tmp") );
+
+echo "\n*** Test copy() function: Trying to create copy of an existing source in non-existing destination ***";
+var_dump( copy($file, $file_path."/nodir/copy_nosuchfile.tmp") ); //With non-existing dir path
+var_dump( file_exists($file_path."/nodir/copy_nosuchfile.tmp") );
+var_dump( filesize($file) ); //size of the source
+
+echo "*** Done ***\n";
+?>
+
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/copy_variation14.tmp");
+?>
+
+--EXPECTF--
+*** Test copy() function: Trying to create a copy of non-existing source in existing destination ***
+Warning: copy(%s): %s
+bool(false)
+bool(false)
+
+*** Test copy() function: Trying to create copy of an existing source in non-existing destination ***
+Warning: copy(%s): %s
+bool(false)
+bool(false)
+int(1500)
+*** Done ***
diff --git a/ext/standard/tests/file/copy_variation15.phpt b/ext/standard/tests/file/copy_variation15.phpt
new file mode 100644
index 0000000..fbf5e7b
--- /dev/null
+++ b/ext/standard/tests/file/copy_variation15.phpt
@@ -0,0 +1,64 @@
+--TEST--
+Test copy() function: usage variations - destination dir access perms
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == 'WIN')
+ die("skip do not run on Windows");
+// Skip if being run by root (files are always readable, writeable and executable)
+$filename = dirname(__FILE__)."/copy_variation15_root_check.tmp";
+$fp = fopen($filename, 'w');
+fclose($fp);
+if(fileowner($filename) == 0) {
+ unlink ($filename);
+ die('skip cannot be run as root');
+}
+unlink($filename);
+?>
+--FILE--
+<?php
+/* Prototype: bool copy ( string $source, string $dest );
+ Description: Makes a copy of the file source to dest.
+ Returns TRUE on success or FALSE on failure.
+*/
+
+/* Test copy(): Trying to create a copy of file in a dir which doesn't have write permissions */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test copy() function: Trying to create a copy of file in a dir which doesn't have write permissions ***";
+$file = $file_path."/copy_variation15.tmp";
+$file_handle = fopen($file, "w");
+fwrite($file_handle, str_repeat(b"Hello, world...", 20));
+fclose($file_handle);
+
+$dir = $file_path."/copy_variation15";
+mkdir($dir);
+
+$old_perms = fileperms($dir);
+
+chmod($dir, 0555); //dir without write permissions
+
+$dest = $dir."/copy_copy_variation15.tmp";
+
+var_dump( copy($file, $dir."/copy_copy_variation15.tmp") );
+var_dump( file_exists($dir."/copy_copy_variation15_dir.tmp") );
+var_dump( filesize($file) ); //size of source
+
+chmod($dir, $old_perms);
+
+echo "*** Done ***\n";
+?>
+
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/copy_variation15.tmp");
+rmdir(dirname(__FILE__)."/copy_variation15");
+?>
+
+--EXPECTF--
+*** Test copy() function: Trying to create a copy of file in a dir which doesn't have write permissions ***
+Warning: copy(%s): %s
+bool(false)
+bool(false)
+int(300)
+*** Done ***
diff --git a/ext/standard/tests/file/copy_variation16-win32.phpt b/ext/standard/tests/file/copy_variation16-win32.phpt
new file mode 100644
index 0000000..7688f5e
--- /dev/null
+++ b/ext/standard/tests/file/copy_variation16-win32.phpt
@@ -0,0 +1,144 @@
+--TEST--
+Test copy() function: usage variations - copy data file across dirs
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+ die("skip Run only on Windows");
+?>
+--FILE--
+<?php
+/* Prototype: bool copy ( string $source, string $dest );
+ Description: Makes a copy of the file source to dest.
+ Returns TRUE on success or FALSE on failure.
+*/
+
+/* Test copy() function: Trying to create copy of source file
+ into different destination dir paths given in various notations */
+
+echo "*** Testing copy() function: copying data file across directories ***\n";
+$base_dir = dirname(__FILE__)."/copy_variation16";
+mkdir($base_dir);
+
+$sub_dir = $base_dir."/copy_variation16_sub";
+mkdir($sub_dir);
+
+$dirname_with_blank = $sub_dir."/copy variation6";
+mkdir($dirname_with_blank);
+
+$src_file_name = dirname(__FILE__)."/copy_variation16.tmp";
+$file_handle = fopen($src_file_name, "w");
+fwrite($file_handle, str_repeat(b"Hello world, this is 2007 year ...\n", 100));
+fclose($file_handle);
+
+echo "- Size of source file => ";
+var_dump( filesize($src_file_name) );
+clearstatcache();
+
+$dests = array(
+ $base_dir."/copy_copy_variation16.tmp",
+ $base_dir."/copy_variation16_sub/copy_copy_variation16.tmp",
+ "$sub_dir/copy_copy_variation16.tmp",
+ "$sub_dir/../copy_copy_variation16.tmp",
+ "$sub_dir/../copy_variation16_sub/copy_copy_variation16.tmp",
+ "$sub_dir/..///../copy_copy_variation16.tmp",
+ "$sub_dir/..///../*",
+ "$dirname_with_blank/copy_copy_variation16.tmp"
+);
+
+echo "\n--- Now applying copy() on source file to create copies ---";
+$count = 1;
+foreach($dests as $dest) {
+ echo "\n-- Iteration $count --\n";
+
+ echo "Size of source file => ";
+ var_dump( filesize($src_file_name) );
+
+ echo "Copy operation => ";
+ var_dump( copy($src_file_name, $dest) );
+
+ echo "Existence of destination file => ";
+ var_dump( file_exists($dest) );
+
+ if( file_exists($dest) ){
+ echo "Destination file name is => ";
+ print($dest);
+ echo "\n";
+
+ echo "Size of destination file => ";
+ var_dump( filesize($dest) );
+ clearstatcache();
+
+ unlink("$dest");
+ }
+ $count++;
+}
+
+unlink($src_file_name);
+rmdir($dirname_with_blank);
+rmdir($sub_dir);
+rmdir($base_dir);
+
+echo "*** Done ***\n";
+?>
+
+--EXPECTF--
+*** Testing copy() function: copying data file across directories ***
+- Size of source file => int(3500)
+
+--- Now applying copy() on source file to create copies ---
+-- Iteration 1 --
+Size of source file => int(3500)
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name is => %s/copy_variation16/copy_copy_variation16.tmp
+Size of destination file => int(3500)
+
+-- Iteration 2 --
+Size of source file => int(3500)
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name is => %s/copy_variation16/copy_variation16_sub/copy_copy_variation16.tmp
+Size of destination file => int(3500)
+
+-- Iteration 3 --
+Size of source file => int(3500)
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name is => %s/copy_variation16/copy_variation16_sub/copy_copy_variation16.tmp
+Size of destination file => int(3500)
+
+-- Iteration 4 --
+Size of source file => int(3500)
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name is => %s/copy_variation16/copy_variation16_sub/../copy_copy_variation16.tmp
+Size of destination file => int(3500)
+
+-- Iteration 5 --
+Size of source file => int(3500)
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name is => %s/copy_variation16/copy_variation16_sub/../copy_variation16_sub/copy_copy_variation16.tmp
+Size of destination file => int(3500)
+
+-- Iteration 6 --
+Size of source file => int(3500)
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name is => %s/copy_variation16/copy_variation16_sub/..///../copy_copy_variation16.tmp
+Size of destination file => int(3500)
+
+-- Iteration 7 --
+Size of source file => int(3500)
+Copy operation =>
+Warning: copy(%s): failed to open stream: No such file or directory in %s on line %s
+bool(false)
+Existence of destination file => bool(false)
+
+-- Iteration 8 --
+Size of source file => int(3500)
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name is => %s/copy_variation16/copy_variation16_sub/copy variation6/copy_copy_variation16.tmp
+Size of destination file => int(3500)
+*** Done ***
diff --git a/ext/standard/tests/file/copy_variation16.phpt b/ext/standard/tests/file/copy_variation16.phpt
new file mode 100644
index 0000000..9ad834b
--- /dev/null
+++ b/ext/standard/tests/file/copy_variation16.phpt
@@ -0,0 +1,143 @@
+--TEST--
+Test copy() function: usage variations - copy data file across dirs
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+ die("skip Do not run on Windows");
+?>
+--FILE--
+<?php
+/* Prototype: bool copy ( string $source, string $dest );
+ Description: Makes a copy of the file source to dest.
+ Returns TRUE on success or FALSE on failure.
+*/
+
+/* Test copy() function: Trying to create copy of source file
+ into different destination dir paths given in various notations */
+
+echo "*** Testing copy() function: copying data file across directories ***\n";
+$base_dir = dirname(__FILE__)."/copy_variation16";
+mkdir($base_dir);
+
+$sub_dir = $base_dir."/copy_variation16_sub";
+mkdir($sub_dir);
+
+$dirname_with_blank = $sub_dir."/copy variation6";
+mkdir($dirname_with_blank);
+
+$src_file_name = dirname(__FILE__)."/copy_variation16.tmp";
+$file_handle = fopen($src_file_name, "w");
+fwrite($file_handle, str_repeat("Hello world, this is 2007 year ...\n", 100));
+fclose($file_handle);
+
+echo "- Size of source file => ";
+var_dump( filesize($src_file_name) );
+clearstatcache();
+
+$dests = array(
+ $base_dir."/copy_copy_variation16.tmp",
+ $base_dir."/copy_variation16_sub/copy_copy_variation16.tmp",
+ "$sub_dir/copy_copy_variation16.tmp",
+ "$sub_dir/../copy_copy_variation16.tmp",
+ "$sub_dir/../copy_variation16_sub/copy_copy_variation16.tmp",
+ "$sub_dir/..///../copy_copy_variation16.tmp",
+ "$sub_dir/..///../*",
+ "$dirname_with_blank/copy_copy_variation16.tmp"
+);
+
+echo "\n--- Now applying copy() on source file to create copies ---";
+$count = 1;
+foreach($dests as $dest) {
+ echo "\n-- Iteration $count --\n";
+
+ echo "Size of source file => ";
+ var_dump( filesize($src_file_name) );
+
+ echo "Copy operation => ";
+ var_dump( copy($src_file_name, $dest) );
+
+ echo "Existence of destination file => ";
+ var_dump( file_exists($dest) );
+
+ echo "Destination file name is => ";
+ print($dest);
+ echo "\n";
+
+ echo "Size of destination file => ";
+ var_dump( filesize($dest) );
+ clearstatcache();
+
+ unlink("$dest");
+
+ $count++;
+}
+
+unlink($src_file_name);
+rmdir($dirname_with_blank);
+rmdir($sub_dir);
+rmdir($base_dir);
+
+echo "*** Done ***\n";
+?>
+
+--EXPECTF--
+*** Testing copy() function: copying data file across directories ***
+- Size of source file => int(3500)
+
+--- Now applying copy() on source file to create copies ---
+-- Iteration 1 --
+Size of source file => int(3500)
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name is => %s/copy_variation16/copy_copy_variation16.tmp
+Size of destination file => int(3500)
+
+-- Iteration 2 --
+Size of source file => int(3500)
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name is => %s/copy_variation16/copy_variation16_sub/copy_copy_variation16.tmp
+Size of destination file => int(3500)
+
+-- Iteration 3 --
+Size of source file => int(3500)
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name is => %s/copy_variation16/copy_variation16_sub/copy_copy_variation16.tmp
+Size of destination file => int(3500)
+
+-- Iteration 4 --
+Size of source file => int(3500)
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name is => %s/copy_variation16/copy_variation16_sub/../copy_copy_variation16.tmp
+Size of destination file => int(3500)
+
+-- Iteration 5 --
+Size of source file => int(3500)
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name is => %s/copy_variation16/copy_variation16_sub/../copy_variation16_sub/copy_copy_variation16.tmp
+Size of destination file => int(3500)
+
+-- Iteration 6 --
+Size of source file => int(3500)
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name is => %s/copy_variation16/copy_variation16_sub/..///../copy_copy_variation16.tmp
+Size of destination file => int(3500)
+
+-- Iteration 7 --
+Size of source file => int(3500)
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name is => %s/copy_variation16/copy_variation16_sub/..///../*
+Size of destination file => int(3500)
+
+-- Iteration 8 --
+Size of source file => int(3500)
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name is => %s/copy_variation16/copy_variation16_sub/copy variation6/copy_copy_variation16.tmp
+Size of destination file => int(3500)
+*** Done ***
diff --git a/ext/standard/tests/file/copy_variation17.phpt b/ext/standard/tests/file/copy_variation17.phpt
new file mode 100644
index 0000000..97f1665
--- /dev/null
+++ b/ext/standard/tests/file/copy_variation17.phpt
@@ -0,0 +1,76 @@
+--TEST--
+Test copy() function: usage variations - wildcard chars in source
+--FILE--
+<?php
+/* Prototype: bool copy ( string $source, string $dest );
+ Description: Makes a copy of the file source to dest.
+ Returns TRUE on success or FALSE on failure.
+*/
+
+/* Test copy(): Trying to copy the source file which is given with the combination of wild-card chars */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test copy() function: With source file names containing wild-card chars ***\n";
+$src_file = $file_path."/copy_variation17.tmp";
+$file_handle = fopen($src_file, "w");
+fwrite($file_handle, str_repeat(b"Hello2world...\n", 100));
+fclose($file_handle);
+
+$dir = $file_path."/copy_variation17";
+mkdir($dir);
+
+$src_file_names = array(
+ $file_path."/copy_variation17.tmp", //without wild-card char
+ $file_path."/copy*17.tmp",
+ $file_path."/*_variation17.tmp",
+ $file_path."/copy_variation*.tmp",
+ $file_path."/*.tmp"
+);
+
+$dest_file_name = $dir."/copy_copy_variation17.tmp";
+
+$count = 1;
+foreach($src_file_names as $src_file_name) {
+ var_dump( copy($src_file_name, $dest_file_name) );
+ var_dump( file_exists($dest_file_name) );
+
+ if( file_exists($dest_file_name) ) {
+ var_dump( filesize($dest_file_name) ); //size of destination
+ unlink($dest_file_name);
+ }
+
+ $count++;
+}
+
+echo "*** Done ***\n";
+?>
+
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/copy_variation17.tmp");
+rmdir(dirname(__FILE__)."/copy_variation17");
+?>
+
+--EXPECTF--
+*** Test copy() function: With source file names containing wild-card chars ***
+bool(true)
+bool(true)
+int(1500)
+
+Warning: copy(%s): %s
+bool(false)
+bool(false)
+
+Warning: copy(%s): %s
+bool(false)
+bool(false)
+
+Warning: copy(%s): %s
+bool(false)
+bool(false)
+
+Warning: copy(%s): %s
+bool(false)
+bool(false)
+*** Done ***
diff --git a/ext/standard/tests/file/copy_variation18.phpt b/ext/standard/tests/file/copy_variation18.phpt
new file mode 100644
index 0000000..53467af
--- /dev/null
+++ b/ext/standard/tests/file/copy_variation18.phpt
@@ -0,0 +1,56 @@
+--TEST--
+Test copy() function: usage variations - stat after copy
+--FILE--
+<?php
+/* Prototype: bool copy ( string $source, string $dest );
+ Description: Makes a copy of the file source to dest.
+ Returns TRUE on success or FALSE on failure.
+*/
+
+/* Test copy(): checking stat of file before and after after copy operation */
+
+$file_path = dirname(__FILE__);
+
+require($file_path."/file.inc");
+
+echo "*** Test copy() function: stat of file before and after copy ***\n";
+$src_file_name = $file_path."/copy_variation18.tmp";
+$file_handle = fopen($src_file_name, "w");
+fwrite($file_handle, str_repeat("Hello2world...\n", 100));
+fclose($file_handle);
+
+$dest_file_name = $file_path."/copy_copy_variation18.tmp";
+
+clearstatcache();
+
+$stat_before_copy = stat($src_file_name);
+clearstatcache();
+
+echo "Copy operation => ";
+var_dump( copy($src_file_name, $dest_file_name) );
+
+$stat_after_copy = stat($src_file_name);
+clearstatcache();
+
+// compare all stat fields except access time
+$stat_keys_to_compare = array("dev", "ino", "mode", "nlink", "uid", "gid",
+ "rdev", "size", "mtime", "ctime",
+ "blksize", "blocks");
+
+echo "Comparing the stats of file before and after copy operation => ";
+var_dump( compare_stats($stat_before_copy, $stat_after_copy, $stat_keys_to_compare) );
+
+echo "*** Done ***\n";
+?>
+
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/copy_copy_variation18.tmp");
+unlink(dirname(__FILE__)."/copy_variation18.tmp");
+?>
+
+--EXPECTF--
+*** Test copy() function: stat of file before and after copy ***
+Copy operation => bool(true)
+Comparing the stats of file before and after copy operation => bool(true)
+*** Done ***
diff --git a/ext/standard/tests/file/copy_variation2-win32.phpt b/ext/standard/tests/file/copy_variation2-win32.phpt
new file mode 100644
index 0000000..4819d63
--- /dev/null
+++ b/ext/standard/tests/file/copy_variation2-win32.phpt
@@ -0,0 +1,218 @@
+--TEST--
+Test copy() function: usage variations - destination file names(special chars)
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+ die("skip only run on Windows");
+?>
+--FILE--
+<?php
+/* Prototype: bool copy ( string $source, string $dest );
+ Description: Makes a copy of the file source to dest.
+ Returns TRUE on success or FALSE on failure.
+*/
+
+/* Test copy() function: In creation of destination file names containing special characters
+ and checking the existence and size of destination files
+*/
+
+echo "*** Test copy() function: destination file names containing special characters ***\n";
+$file_path = dirname(__FILE__);
+$src_file_name = $file_path."/copy_variation2.tmp";
+$file_handle = fopen($src_file_name, "w");
+fwrite( $file_handle, str_repeat(b"Hello2World...\n", 100) );
+fclose($file_handle);
+
+/* array of destination file names */
+$dest_files = array(
+
+ /* File names containing special(non-alpha numeric) characters */
+ "_copy_variation2.tmp",
+ "@copy_variation2.tmp",
+ "#copy_variation2.tmp",
+ "+copy_variation2.tmp",
+ "?copy_variation2.tmp",
+ ">copy_variation2.tmp",
+ "!copy_variation2.tmp",
+ "&copy_variation2.tmp",
+ "(copy_variation2.tmp",
+ ":copy_variation2.tmp",
+ ";copy_variation2.tmp",
+ "=copy_variation2.tmp",
+ "[copy_variation2.tmp",
+ "^copy_variation2.tmp",
+ "{copy_variation2.tmp",
+ "|copy_variation2.tmp",
+ "~copy_variation2.tmp",
+ "\$copy_variation2.tmp"
+);
+
+echo "Size of the source file before copy operation => ";
+var_dump( filesize("$src_file_name") );
+clearstatcache();
+
+echo "\n--- Now applying copy() on source file to create copies ---";
+$count = 1;
+foreach($dest_files as $dest_file) {
+ echo "\n-- Iteration $count --\n";
+ $dest_file_name = $file_path."/$dest_file";
+
+ echo "Copy operation => ";
+ var_dump( copy($src_file_name, $dest_file_name) );
+
+ echo "Existence of destination file => ";
+ var_dump( file_exists($dest_file_name) );
+
+ if( file_exists($dest_file_name) ) {
+ echo "Destination file name => ";
+ print($dest_file_name);
+ echo "\n";
+
+ echo "Size of source file => ";
+ var_dump( filesize($src_file_name) );
+ clearstatcache();
+
+ echo "Size of destination file => ";
+ var_dump( filesize($dest_file_name) );
+ clearstatcache();
+
+ unlink($dest_file_name);
+ }
+ $count++;
+}
+
+echo "*** Done ***\n";
+?>
+
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/copy_variation2.tmp");
+?>
+
+--EXPECTF--
+*** Test copy() function: destination file names containing special characters ***
+Size of the source file before copy operation => int(1500)
+
+--- Now applying copy() on source file to create copies ---
+-- Iteration 1 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/_copy_variation2.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 2 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/@copy_variation2.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 3 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/#copy_variation2.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 4 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/+copy_variation2.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 5 --
+Copy operation =>
+Warning: copy(%s): %s
+bool(false)
+Existence of destination file => bool(false)
+
+-- Iteration 6 --
+Copy operation =>
+Warning: copy(%s): %s
+bool(false)
+Existence of destination file => bool(false)
+
+-- Iteration 7 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/!copy_variation2.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 8 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/&copy_variation2.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 9 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/(copy_variation2.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 10 --
+Copy operation =>
+Warning: copy(%s): %s
+bool(false)
+Existence of destination file => bool(false)
+
+-- Iteration 11 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/;copy_variation2.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 12 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/=copy_variation2.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 13 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/[copy_variation2.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 14 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/^copy_variation2.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 15 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/{copy_variation2.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 16 --
+Copy operation =>
+Warning: copy(%s): %s
+bool(false)
+Existence of destination file => bool(false)
+
+-- Iteration 17 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/~copy_variation2.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 18 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/$copy_variation2.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+*** Done ***
diff --git a/ext/standard/tests/file/copy_variation2.phpt b/ext/standard/tests/file/copy_variation2.phpt
new file mode 100644
index 0000000..d99f5a8
--- /dev/null
+++ b/ext/standard/tests/file/copy_variation2.phpt
@@ -0,0 +1,237 @@
+--TEST--
+Test copy() function: usage variations - destination file names(special chars)
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+ die("skip do not run on Windows");
+?>
+--FILE--
+<?php
+/* Prototype: bool copy ( string $source, string $dest );
+ Description: Makes a copy of the file source to dest.
+ Returns TRUE on success or FALSE on failure.
+*/
+
+/* Test copy() function: In creation of destination file names containing special characters
+ and checking the existence and size of destination files
+*/
+
+echo "*** Test copy() function: destination file names containing special characters ***\n";
+$file_path = dirname(__FILE__);
+$src_file_name = $file_path."/copy_variation2.tmp";
+$file_handle = fopen($src_file_name, "w");
+fwrite( $file_handle, str_repeat(b"Hello2World...\n", 100) );
+fclose($file_handle);
+
+/* array of destination file names */
+$dest_files = array(
+
+ /* File names containing special(non-alpha numeric) characters */
+ "_copy_variation2.tmp",
+ "@copy_variation2.tmp",
+ "#copy_variation2.tmp",
+ "+copy_variation2.tmp",
+ "*copy_variation2.tmp",
+ "?copy_variation2.tmp",
+ "<copy_variation2.tmp",
+ ">copy_variation2.tmp",
+ "!copy_variation2.tmp",
+ "&copy_variation2.tmp",
+ "(copy_variation2.tmp",
+ ":copy_variation2.tmp",
+ ";copy_variation2.tmp",
+ "=copy_variation2.tmp",
+ "[copy_variation2.tmp",
+ "^copy_variation2.tmp",
+ "{copy_variation2.tmp",
+ "|copy_variation2.tmp",
+ "~copy_variation2.tmp",
+ "\$copy_variation2.tmp"
+);
+
+echo "Size of the source file before copy operation => ";
+var_dump( filesize("$src_file_name") );
+clearstatcache();
+
+echo "\n--- Now applying copy() on source file to create copies ---";
+$count = 1;
+foreach($dest_files as $dest_file) {
+ echo "\n-- Iteration $count --\n";
+ $dest_file_name = $file_path."/$dest_file";
+
+ echo "Copy operation => ";
+ var_dump( copy($src_file_name, $dest_file_name) );
+
+ echo "Existence of destination file => ";
+ var_dump( file_exists($dest_file_name) );
+
+ echo "Destination file name => ";
+ print($dest_file_name);
+ echo "\n";
+
+ echo "Size of source file => ";
+ var_dump( filesize($src_file_name) );
+ clearstatcache();
+
+ echo "Size of destination file => ";
+ var_dump( filesize($dest_file_name) );
+ clearstatcache();
+
+ unlink($dest_file_name);
+
+ $count++;
+}
+
+echo "*** Done ***\n";
+?>
+
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/copy_variation2.tmp");
+?>
+
+--EXPECTF--
+*** Test copy() function: destination file names containing special characters ***
+Size of the source file before copy operation => int(1500)
+
+--- Now applying copy() on source file to create copies ---
+-- Iteration 1 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/_copy_variation2.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 2 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/@copy_variation2.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 3 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/#copy_variation2.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 4 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/+copy_variation2.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 5 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/*copy_variation2.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 6 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/?copy_variation2.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 7 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/<copy_variation2.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 8 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/>copy_variation2.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 9 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/!copy_variation2.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 10 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/&copy_variation2.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 11 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/(copy_variation2.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 12 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/:copy_variation2.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 13 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/;copy_variation2.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 14 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/=copy_variation2.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 15 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/[copy_variation2.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 16 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/^copy_variation2.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 17 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/{copy_variation2.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 18 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/|copy_variation2.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 19 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/~copy_variation2.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 20 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/$copy_variation2.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+*** Done ***
diff --git a/ext/standard/tests/file/copy_variation3-win32.phpt b/ext/standard/tests/file/copy_variation3-win32.phpt
new file mode 100644
index 0000000..68ce4a1
--- /dev/null
+++ b/ext/standard/tests/file/copy_variation3-win32.phpt
@@ -0,0 +1,109 @@
+--TEST--
+Test copy() function: usage variations - destination file names(white spaces)
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+ die("skip only run on Windows");
+?>
+--FILE--
+<?php
+/* Prototype: bool copy ( string $source, string $dest );
+ Description: Makes a copy of the file source to dest.
+ Returns TRUE on success or FALSE on failure.
+*/
+
+/* Test copy() function: In creation of destination file names containing white spaces
+ and checking the existence and size of destination files
+*/
+
+echo "*** Test copy() function: destination file names containing whitespaces ***\n";
+$file_path = dirname(__FILE__);
+$src_file_name = $file_path."/copy_variation3.tmp";
+$file_handle = fopen($src_file_name, "w");
+fwrite( $file_handle, str_repeat(b"Hello2World...\n", 100) );
+fclose($file_handle);
+
+/* array of destination file names */
+$dest_files = array(
+
+ /* File names containing whitespaces */
+ "copy variation3.tmp", //file name containing blank space
+ " copy_variation3.tmp", //file name starts with blank space
+ "copy\tvariation3.tmp",
+ " ", //blank space as file name
+);
+
+echo "Size of the source file before copy operation => ";
+var_dump( filesize("$src_file_name") );
+clearstatcache();
+
+echo "\n-- Now applying copy() on source file to create copies --";
+$count = 1;
+foreach($dest_files as $dest_file) {
+
+ echo "\n-- Iteration $count --\n";
+ $dest_file_name = $dest_file;
+
+ echo "Copy operation => ";
+ var_dump( copy($src_file_name, $dest_file_name) );
+
+ echo "Existence of destination file => ";
+ var_dump( file_exists($dest_file_name) );
+
+ if( file_exists($dest_file_name) ) {
+ echo "Destination file name => ";
+ print($dest_file_name);
+ echo "\n";
+
+ echo "Size of source file => ";
+ var_dump( filesize($src_file_name) );
+ clearstatcache();
+
+ echo "Size of destination file => ";
+ var_dump( filesize($dest_file_name) );
+ clearstatcache();
+
+ unlink($dest_file_name);
+ }
+ $count++;
+}
+
+echo "*** Done ***\n";
+?>
+
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/copy_variation3.tmp");
+?>
+
+--EXPECTF--
+*** Test copy() function: destination file names containing whitespaces ***
+Size of the source file before copy operation => int(1500)
+
+-- Now applying copy() on source file to create copies --
+-- Iteration 1 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => copy variation3.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 2 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => copy_variation3.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 3 --
+Copy operation =>
+Warning: copy(%s): %s
+bool(false)
+Existence of destination file => bool(false)
+
+-- Iteration 4 --
+Copy operation =>
+Warning: copy(%s): %s
+bool(false)
+Existence of destination file => bool(false)
+*** Done ***
diff --git a/ext/standard/tests/file/copy_variation3.phpt b/ext/standard/tests/file/copy_variation3.phpt
new file mode 100644
index 0000000..1c45c8c
--- /dev/null
+++ b/ext/standard/tests/file/copy_variation3.phpt
@@ -0,0 +1,110 @@
+--TEST--
+Test copy() function: usage variations - destination file names(white spaces)
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+ die("skip do not run on Windows");
+?>
+--FILE--
+<?php
+/* Prototype: bool copy ( string $source, string $dest );
+ Description: Makes a copy of the file source to dest.
+ Returns TRUE on success or FALSE on failure.
+*/
+
+/* Test copy() function: In creation of destination file names containing white spaces
+ and checking the existence and size of destination files
+*/
+
+echo "*** Test copy() function: destination file names containing whitespaces ***\n";
+$file_path = dirname(__FILE__);
+$src_file_name = $file_path."/copy_variation3.tmp";
+$file_handle = fopen($src_file_name, "w");
+fwrite( $file_handle, str_repeat(b"Hello2World...\n", 100) );
+fclose($file_handle);
+
+/* array of destination file names */
+$dest_files = array(
+
+ /* File names containing whitespaces */
+ "copy variation3.tmp", //file name containing blank space
+ " copy_variation3.tmp", //file name starts with blank space
+ "copy\tvariation3.tmp",
+ " ", //blank space as file name
+);
+
+echo "Size of the source file before copy operation => ";
+var_dump( filesize("$src_file_name") );
+clearstatcache();
+
+echo "\n-- Now applying copy() on source file to create copies --";
+$count = 1;
+foreach($dest_files as $dest_file) {
+
+ echo "\n-- Iteration $count --\n";
+ $dest_file_name = $dest_file;
+
+ echo "Copy operation => ";
+ var_dump( copy($src_file_name, $dest_file_name) );
+
+ echo "Existence of destination file => ";
+ var_dump( file_exists($dest_file_name) );
+
+ echo "Destination file name => ";
+ print($dest_file_name);
+ echo "\n";
+
+ echo "Size of source file => ";
+ var_dump( filesize($src_file_name) );
+ clearstatcache();
+
+ echo "Size of destination file => ";
+ var_dump( filesize($dest_file_name) );
+ clearstatcache();
+
+ unlink($dest_file_name);
+
+ $count++;
+}
+
+echo "*** Done ***\n";
+?>
+
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/copy_variation3.tmp");
+?>
+
+--EXPECTF--
+*** Test copy() function: destination file names containing whitespaces ***
+Size of the source file before copy operation => int(1500)
+
+-- Now applying copy() on source file to create copies --
+-- Iteration 1 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => copy variation3.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 2 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => copy_variation3.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 3 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => copy variation3.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 4 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name =>
+Size of source file => int(1500)
+Size of destination file => int(1500)
+*** Done ***
diff --git a/ext/standard/tests/file/copy_variation4.phpt b/ext/standard/tests/file/copy_variation4.phpt
new file mode 100644
index 0000000..3c8224d
--- /dev/null
+++ b/ext/standard/tests/file/copy_variation4.phpt
Binary files differ
diff --git a/ext/standard/tests/file/copy_variation5-win32.phpt b/ext/standard/tests/file/copy_variation5-win32.phpt
new file mode 100644
index 0000000..baf7be4
--- /dev/null
+++ b/ext/standard/tests/file/copy_variation5-win32.phpt
@@ -0,0 +1,111 @@
+--TEST--
+Test copy() function: usage variations - destination file names(case sensitive)
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+ die("skip only run on Windows");
+?>
+--FILE--
+<?php
+/* Prototype: bool copy ( string $source, string $dest );
+ Description: Makes a copy of the file source to dest.
+ Returns TRUE on success or FALSE on failure.
+*/
+
+/* Test copy() function: Checking case sensitivity in creation of destination file names
+ and the existence and size of destination files
+*/
+
+echo "*** Test copy() function: checking case sensitivity in creation of destination file names ***\n";
+$file_path = dirname(__FILE__);
+$src_file_name = $file_path."/copy_variation5.tmp";
+$file_handle = fopen($src_file_name, "w");
+fwrite( $file_handle, str_repeat(b"Hello2World...\n", 100) );
+fclose($file_handle);
+
+/* array of destination file names */
+$dest_files = array(
+
+ /* Checking case sensitiveness */
+ "COPY.tmp",
+ "COPY.TMP",
+ "CopY.TMP"
+);
+
+echo "Size of the source file before copy operation => ";
+var_dump( filesize($src_file_name) );
+clearstatcache();
+
+echo "\n-- Now applying copy() on source file to create copies --";
+$count = 1;
+foreach($dest_files as $dest_file) {
+
+ echo "\n-- Iteration $count --\n";
+ $dest_file_name = $file_path."/$dest_file";
+
+ echo "Copy operation => ";
+ var_dump( copy($src_file_name, $dest_file_name) );
+
+ echo "Existence of destination file => ";
+ var_dump( file_exists($dest_file_name) );
+
+ echo "Destination file name => ";
+ print($dest_file_name);
+ echo "\n";
+
+ echo "Size of source file => ";
+ var_dump( filesize($src_file_name) );
+ clearstatcache();
+
+ echo "Size of destination file => ";
+ var_dump( filesize($dest_file_name) );
+ clearstatcache();
+
+ $count++;
+}
+
+
+$count = 1;
+foreach($dest_files as $dest_file) {
+ unlink($file_path."/".$dest_file);
+ $count++;
+}
+
+echo "*** Done ***\n";
+?>
+
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/copy_variation5.tmp");
+?>
+
+--EXPECTF--
+*** Test copy() function: checking case sensitivity in creation of destination file names ***
+Size of the source file before copy operation => int(1500)
+
+-- Now applying copy() on source file to create copies --
+-- Iteration 1 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/COPY.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 2 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/COPY.TMP
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 3 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/CopY.TMP
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+Warning: unlink(%s/COPY.TMP): No such file or directory in %s on line %d
+
+Warning: unlink(%s/CopY.TMP): No such file or directory in %s on line %d
+*** Done ***
diff --git a/ext/standard/tests/file/copy_variation5.phpt b/ext/standard/tests/file/copy_variation5.phpt
new file mode 100644
index 0000000..8abc9c9
--- /dev/null
+++ b/ext/standard/tests/file/copy_variation5.phpt
@@ -0,0 +1,106 @@
+--TEST--
+Test copy() function: usage variations - destination file names(case sensitive)
+--SKIPIF--
+<?php
+if( (stristr(PHP_OS, "Darwin")) || (stristr(PHP_OS, "Win")) )
+ die("skip do not run on MacOS/Windows");
+?>
+--FILE--
+<?php
+/* Prototype: bool copy ( string $source, string $dest );
+ Description: Makes a copy of the file source to dest.
+ Returns TRUE on success or FALSE on failure.
+*/
+
+/* Test copy() function: Checking case sensitivity in creation of destination file names
+ and the existence and size of destination files
+*/
+
+echo "*** Test copy() function: checking case sensitivity in creation of destination file names ***\n";
+$file_path = dirname(__FILE__);
+$src_file_name = $file_path."/copy_variation5.tmp";
+$file_handle = fopen($src_file_name, "w");
+fwrite( $file_handle, str_repeat(b"Hello2World...\n", 100) );
+fclose($file_handle);
+
+/* array of destination file names */
+$dest_files = array(
+
+ /* Checking case sensitiveness */
+ "COPY.tmp",
+ "COPY.TMP",
+ "CopY.TMP"
+);
+
+echo "Size of the source file before copy operation => ";
+var_dump( filesize($src_file_name) );
+clearstatcache();
+
+echo "\n-- Now applying copy() on source file to create copies --";
+$count = 1;
+foreach($dest_files as $dest_file) {
+
+ echo "\n-- Iteration $count --\n";
+ $dest_file_name = $file_path."/$dest_file";
+
+ echo "Copy operation => ";
+ var_dump( copy($src_file_name, $dest_file_name) );
+
+ echo "Existence of destination file => ";
+ var_dump( file_exists($dest_file_name) );
+
+ echo "Destination file name => ";
+ print($dest_file_name);
+ echo "\n";
+
+ echo "Size of source file => ";
+ var_dump( filesize($src_file_name) );
+ clearstatcache();
+
+ echo "Size of destination file => ";
+ var_dump( filesize($dest_file_name) );
+ clearstatcache();
+
+ $count++;
+}
+
+$count = 1;
+foreach($dest_files as $dest_file) {
+ unlink($file_path."/".$dest_file);
+ $count++;
+}
+
+echo "*** Done ***\n";
+?>
+
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/copy_variation5.tmp");
+?>
+
+--EXPECTF--
+*** Test copy() function: checking case sensitivity in creation of destination file names ***
+Size of the source file before copy operation => int(1500)
+
+-- Now applying copy() on source file to create copies --
+-- Iteration 1 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/COPY.tmp
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 2 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/COPY.TMP
+Size of source file => int(1500)
+Size of destination file => int(1500)
+
+-- Iteration 3 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name => %s/CopY.TMP
+Size of source file => int(1500)
+Size of destination file => int(1500)
+*** Done ***
diff --git a/ext/standard/tests/file/copy_variation6-win32.phpt b/ext/standard/tests/file/copy_variation6-win32.phpt
new file mode 100644
index 0000000..524b21d
--- /dev/null
+++ b/ext/standard/tests/file/copy_variation6-win32.phpt
@@ -0,0 +1,143 @@
+--TEST--
+Test copy() function: usage variations - copy empty file across dirs
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+ die("skip Only run on Windows");
+?>
+--FILE--
+<?php
+/* Prototype: bool copy ( string $source, string $dest );
+ Description: Makes a copy of the file source to dest.
+ Returns TRUE on success or FALSE on failure.
+*/
+
+/* Test copy() function: Trying to create copy of source file
+ into different destination dir paths given in various notations */
+
+echo "*** Test copy() function: copying file across directories ***\n";
+$base_dir = dirname(__FILE__)."/copy_variation6";
+mkdir($base_dir);
+
+$sub_dir = $base_dir."/copy_variation6_sub";
+mkdir($sub_dir);
+
+$dirname_with_blank = $sub_dir."/copy variation6";
+mkdir($dirname_with_blank);
+
+$src_file_name = dirname(__FILE__)."/copy_variation6.tmp";
+fclose( fopen($src_file_name, "w") );
+
+echo "Size of source file => ";
+var_dump( filesize($src_file_name) );
+clearstatcache();
+
+$dests = array(
+ $base_dir."/copy_copy_variation6.tmp",
+ $base_dir."/copy_variation6_sub/copy_copy_variation6.tmp",
+ "$sub_dir/copy_copy_variation6.tmp",
+ "$sub_dir/../copy_copy_variation6.tmp",
+ "$sub_dir/../copy_variation6_sub/copy_copy_variation6.tmp",
+ "$sub_dir/..///../copy_copy_variation6.tmp",
+ "$sub_dir/..///../*",
+ "$dirname_with_blank/copy_copy_variation6.tmp"
+);
+
+echo "\n-- Now applying copy() on source file to create copies --";
+$count = 1;
+foreach($dests as $dest) {
+ echo "\n-- Iteration $count --\n";
+
+ echo "Copy operation => ";
+ var_dump( copy($src_file_name, $dest) );
+
+ echo "Existence of destination file => ";
+ var_dump( file_exists($dest) );
+
+ if( file_exists($dest) ) {
+ echo "Destination file name is => ";
+ print($dest);
+ echo "\n";
+
+ echo "Size of source file => ";
+ var_dump( filesize($src_file_name) );
+ clearstatcache();
+
+ echo "Size of destination file => ";
+ var_dump( filesize($dest) );
+ clearstatcache();
+
+ unlink("$dest");
+ }
+
+ $count++;
+}
+
+unlink($src_file_name);
+rmdir($dirname_with_blank);
+rmdir($sub_dir);
+rmdir($base_dir);
+
+echo "*** Done ***\n";
+?>
+
+--EXPECTF--
+*** Test copy() function: copying file across directories ***
+Size of source file => int(0)
+
+-- Now applying copy() on source file to create copies --
+-- Iteration 1 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name is => %s/copy_variation6/copy_copy_variation6.tmp
+Size of source file => int(0)
+Size of destination file => int(0)
+
+-- Iteration 2 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name is => %s/copy_variation6/copy_variation6_sub/copy_copy_variation6.tmp
+Size of source file => int(0)
+Size of destination file => int(0)
+
+-- Iteration 3 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name is => %s/copy_variation6/copy_variation6_sub/copy_copy_variation6.tmp
+Size of source file => int(0)
+Size of destination file => int(0)
+
+-- Iteration 4 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name is => %s/copy_variation6/copy_variation6_sub/../copy_copy_variation6.tmp
+Size of source file => int(0)
+Size of destination file => int(0)
+
+-- Iteration 5 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name is => %s/copy_variation6/copy_variation6_sub/../copy_variation6_sub/copy_copy_variation6.tmp
+Size of source file => int(0)
+Size of destination file => int(0)
+
+-- Iteration 6 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name is => %s/copy_variation6/copy_variation6_sub/..///../copy_copy_variation6.tmp
+Size of source file => int(0)
+Size of destination file => int(0)
+
+-- Iteration 7 --
+Copy operation =>
+Warning: copy(%s/copy_variation6/copy_variation6_sub/..///../*): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+Existence of destination file => bool(false)
+
+-- Iteration 8 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name is => %s/copy_variation6/copy_variation6_sub/copy variation6/copy_copy_variation6.tmp
+Size of source file => int(0)
+Size of destination file => int(0)
+*** Done ***
diff --git a/ext/standard/tests/file/copy_variation6.phpt b/ext/standard/tests/file/copy_variation6.phpt
new file mode 100644
index 0000000..3213c6b
--- /dev/null
+++ b/ext/standard/tests/file/copy_variation6.phpt
@@ -0,0 +1,142 @@
+--TEST--
+Test copy() function: usage variations - copy empty file across dirs
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+ die("skip Do not run on Windows");
+?>
+--FILE--
+<?php
+/* Prototype: bool copy ( string $source, string $dest );
+ Description: Makes a copy of the file source to dest.
+ Returns TRUE on success or FALSE on failure.
+*/
+
+/* Test copy() function: Trying to create copy of source file
+ into different destination dir paths given in various notations */
+
+echo "*** Test copy() function: copying file across directories ***\n";
+$base_dir = dirname(__FILE__)."/copy_variation6";
+mkdir($base_dir);
+
+$sub_dir = $base_dir."/copy_variation6_sub";
+mkdir($sub_dir);
+
+$dirname_with_blank = $sub_dir."/copy variation6";
+mkdir($dirname_with_blank);
+
+$src_file_name = dirname(__FILE__)."/copy_variation6.tmp";
+fclose( fopen($src_file_name, "w") );
+
+echo "Size of source file => ";
+var_dump( filesize($src_file_name) );
+clearstatcache();
+
+$dests = array(
+ $base_dir."/copy_copy_variation6.tmp",
+ $base_dir."/copy_variation6_sub/copy_copy_variation6.tmp",
+ "$sub_dir/copy_copy_variation6.tmp",
+ "$sub_dir/../copy_copy_variation6.tmp",
+ "$sub_dir/../copy_variation6_sub/copy_copy_variation6.tmp",
+ "$sub_dir/..///../copy_copy_variation6.tmp",
+ "$sub_dir/..///../*",
+ "$dirname_with_blank/copy_copy_variation6.tmp"
+);
+
+echo "\n-- Now applying copy() on source file to create copies --";
+$count = 1;
+foreach($dests as $dest) {
+ echo "\n-- Iteration $count --\n";
+
+ echo "Copy operation => ";
+ var_dump( copy($src_file_name, $dest) );
+
+ echo "Existence of destination file => ";
+ var_dump( file_exists($dest) );
+
+ echo "Destination file name is => ";
+ print($dest);
+ echo "\n";
+
+ echo "Size of source file => ";
+ var_dump( filesize($src_file_name) );
+ clearstatcache();
+
+ echo "Size of destination file => ";
+ var_dump( filesize($dest) );
+ clearstatcache();
+
+ unlink("$dest");
+
+ $count++;
+}
+
+unlink($src_file_name);
+rmdir($dirname_with_blank);
+rmdir($sub_dir);
+rmdir($base_dir);
+
+echo "*** Done ***\n";
+?>
+
+--EXPECTF--
+*** Test copy() function: copying file across directories ***
+Size of source file => int(0)
+
+-- Now applying copy() on source file to create copies --
+-- Iteration 1 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name is => %s/copy_variation6/copy_copy_variation6.tmp
+Size of source file => int(0)
+Size of destination file => int(0)
+
+-- Iteration 2 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name is => %s/copy_variation6/copy_variation6_sub/copy_copy_variation6.tmp
+Size of source file => int(0)
+Size of destination file => int(0)
+
+-- Iteration 3 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name is => %s/copy_variation6/copy_variation6_sub/copy_copy_variation6.tmp
+Size of source file => int(0)
+Size of destination file => int(0)
+
+-- Iteration 4 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name is => %s/copy_variation6/copy_variation6_sub/../copy_copy_variation6.tmp
+Size of source file => int(0)
+Size of destination file => int(0)
+
+-- Iteration 5 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name is => %s/copy_variation6/copy_variation6_sub/../copy_variation6_sub/copy_copy_variation6.tmp
+Size of source file => int(0)
+Size of destination file => int(0)
+
+-- Iteration 6 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name is => %s/copy_variation6/copy_variation6_sub/..///../copy_copy_variation6.tmp
+Size of source file => int(0)
+Size of destination file => int(0)
+
+-- Iteration 7 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name is => %s/copy_variation6/copy_variation6_sub/..///../*
+Size of source file => int(0)
+Size of destination file => int(0)
+
+-- Iteration 8 --
+Copy operation => bool(true)
+Existence of destination file => bool(true)
+Destination file name is => %s/copy_variation6/copy_variation6_sub/copy variation6/copy_copy_variation6.tmp
+Size of source file => int(0)
+Size of destination file => int(0)
+*** Done ***
diff --git a/ext/standard/tests/file/copy_variation7.phpt b/ext/standard/tests/file/copy_variation7.phpt
new file mode 100644
index 0000000..d687b07
--- /dev/null
+++ b/ext/standard/tests/file/copy_variation7.phpt
@@ -0,0 +1,86 @@
+--TEST--
+Test copy() function: usage variations - links
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+ die("skip Invalid for Windows");
+?>
+
+--FILE--
+<?php
+/* Prototype: bool copy ( string $source, string $dest );
+ Description: Makes a copy of the file source to dest.
+ Returns TRUE on success or FALSE on failure.
+*/
+
+/* Test copy() function: Trying to create copy of links */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Testing copy() with symlink and hardlink ***\n";
+$file = $file_path."/copy_variation7.tmp";
+$file_handle = fopen($file, "w");
+fwrite( $file_handle, str_repeat(b"Hello World, this is 2007 year ....\n", 100) );
+fclose($file_handle);
+
+$symlink = $file_path."/copy_variation7_symlink.tmp";
+$hardlink = $file_path."/copy_variation7_hardlink.tmp";
+
+symlink($file, $symlink); //creating symlink
+link($file, $hardlink); //creating hardlink
+
+echo "Size of source files => \n";
+var_dump( filesize($file_path."/copy_variation7_symlink.tmp") ); //size of the symlink itself
+clearstatcache();
+var_dump( filesize($file_path."/copy_variation7_hardlink.tmp") ); //size of the file
+clearstatcache();
+
+echo "-- Now applying copy() on source link to create copies --\n";
+echo "-- With symlink --\n";
+var_dump( copy($symlink, $file_path."/copy_copy_variation7_symlink.tmp") );
+var_dump( file_exists($file_path."/copy_copy_variation7_symlink.tmp") );
+var_dump( is_link($file_path."/copy_copy_variation7_symlink.tmp") );
+var_dump( is_file($file_path."/copy_copy_variation7_symlink.tmp") );
+var_dump( filesize($file_path."/copy_copy_variation7_symlink.tmp") );
+clearstatcache();
+
+echo "-- With hardlink --\n";
+var_dump( copy($hardlink, $file_path."/copy_copy_variation7_hardlink.tmp") );
+var_dump( file_exists($file_path."/copy_copy_variation7_hardlink.tmp") );
+var_dump( is_link($file_path."/copy_copy_variation7_hardlink.tmp") );
+var_dump( is_file($file_path."/copy_copy_variation7_hardlink.tmp") );
+var_dump( filesize($file_path."/copy_copy_variation7_hardlink.tmp") );
+clearstatcache();
+
+echo "*** Done ***\n";
+?>
+
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/copy_copy_variation7_symlink.tmp");
+unlink($file_path."/copy_copy_variation7_hardlink.tmp");
+unlink($file_path."/copy_variation7_symlink.tmp");
+unlink($file_path."/copy_variation7_hardlink.tmp");
+unlink($file_path."/copy_variation7.tmp");
+?>
+
+--EXPECTF--
+*** Testing copy() with symlink and hardlink ***
+Size of source files =>
+int(%d)
+int(3600)
+-- Now applying copy() on source link to create copies --
+-- With symlink --
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+int(3600)
+-- With hardlink --
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+int(3600)
+*** Done ***
diff --git a/ext/standard/tests/file/copy_variation8.phpt b/ext/standard/tests/file/copy_variation8.phpt
new file mode 100644
index 0000000..63f57f3
--- /dev/null
+++ b/ext/standard/tests/file/copy_variation8.phpt
@@ -0,0 +1,176 @@
+--TEST--
+Test copy() function: usage variations - copying links across dirs
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+ die("skip Invalid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype: bool copy ( string $source, string $dest );
+ Description: Makes a copy of the file source to dest.
+ Returns TRUE on success or FALSE on failure.
+*/
+
+/* Trying to copy the links across dir paths given in various notations
+ and dirs having limited access */
+
+echo "*** Testing copy() function: copying links across different directories ***\n";
+
+$file_path = dirname(__FILE__);
+
+$base_dir = $file_path."/copy_variation8";
+mkdir($base_dir);
+$sub_dir = $base_dir."/copy_variation8_sub";
+mkdir($sub_dir);
+$dirname_with_blank = $sub_dir."/copy variation6";
+mkdir($dirname_with_blank);
+
+$file = $file_path."/copy_variation8.tmp";
+fclose( fopen($file, "w") );
+
+$symlink = $file_path."/copy_variation8_symlink.tmp";
+$hardlink = $file_path."/copy_variation8_hardlink.tmp";
+
+symlink($file, $symlink); //creating symlink
+link($file, $hardlink); //creating hardlink
+
+$dests = array(
+ $base_dir."/copy_copy_variation8.tmp",
+ $base_dir."/copy_variation8_sub/copy_copy_variation8.tmp",
+ "$sub_dir/copy_copy_variation8.tmp",
+ "$sub_dir/../copy_copy_variation8.tmp",
+ "$sub_dir/../copy_variation8_sub/copy_copy_variation8.tmp",
+ "$sub_dir/..///../copy_copy_variation8.tmp",
+ "$sub_dir/..///../*",
+ "$dirname_with_blank/copy_copy_variation8.tmp"
+);
+
+$count = 1;
+foreach($dests as $dest) {
+ echo "\n-- Iteration $count --\n";
+ echo "- With symlink -\n";
+ var_dump( copy($symlink, $dest) );
+ var_dump( file_exists($dest) );
+ var_dump( is_link($dest) ); //expected: bool(false)
+ var_dump( is_file($dest) ); //expected: bool(true)
+ clearstatcache();
+ unlink("$dest");
+ echo "- With hardlink -\n";
+ var_dump( copy($hardlink, $dest) );
+ var_dump( file_exists($dest) );
+ var_dump( is_link($dest) ); //expected: bool(flase)
+ var_dump( is_file($dest) ); //expected: bool(true)
+ clearstatcache();
+ unlink("$dest");
+ $count++;
+}
+
+unlink($symlink);
+unlink($hardlink);
+unlink($file);
+rmdir($dirname_with_blank);
+rmdir($sub_dir);
+rmdir($base_dir);
+
+echo "*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing copy() function: copying links across different directories ***
+
+-- Iteration 1 --
+- With symlink -
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+- With hardlink -
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+
+-- Iteration 2 --
+- With symlink -
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+- With hardlink -
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+
+-- Iteration 3 --
+- With symlink -
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+- With hardlink -
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+
+-- Iteration 4 --
+- With symlink -
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+- With hardlink -
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+
+-- Iteration 5 --
+- With symlink -
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+- With hardlink -
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+
+-- Iteration 6 --
+- With symlink -
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+- With hardlink -
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+
+-- Iteration 7 --
+- With symlink -
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+- With hardlink -
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+
+-- Iteration 8 --
+- With symlink -
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+- With hardlink -
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+*** Done ***
diff --git a/ext/standard/tests/file/copy_variation9.phpt b/ext/standard/tests/file/copy_variation9.phpt
new file mode 100644
index 0000000..824bed0
--- /dev/null
+++ b/ext/standard/tests/file/copy_variation9.phpt
@@ -0,0 +1,75 @@
+--TEST--
+Test copy() function: usage variations - destination file access perms
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == 'WIN')
+ die("skip do not run on Windows");
+
+// Skip if being run by root (files are always readable, writeable and executable)
+$filename = dirname(__FILE__)."/copy_variation9_root_check.tmp";
+$fp = fopen($filename, 'w');
+fclose($fp);
+if(fileowner($filename) == 0) {
+ unlink ($filename);
+ die('skip cannot be run as root');
+}
+unlink($filename);
+?>
+--FILE--
+<?php
+/* Prototype: bool copy ( string $source, string $dest );
+ Description: Makes a copy of the file source to dest.
+ Returns TRUE on success or FALSE on failure.
+*/
+
+/* Test copy(): Trying to copy source file to destination file with and without write permissions */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test copy() function: destination with/without write permissions ***\n";
+$src_file_name = $file_path."/copy_variation9.tmp";
+$file_handle = fopen($src_file_name, "w");
+fwrite($file_handle, str_repeat(b"Hello2world...\n", 100));
+fclose($file_handle);
+
+$dest_file_name = $file_path."/copy_copy_variation9.tmp";
+
+
+echo "\n-- With write permissions --\n";
+var_dump( file_exists($src_file_name) );
+var_dump( copy($src_file_name, $dest_file_name) );
+var_dump( file_exists($dest_file_name) );
+var_dump( filesize($dest_file_name) );
+
+echo "\n-- Without write permissions --\n";
+chmod($file_path."/copy_copy_variation9.tmp", 0555); //No write permissions
+var_dump( file_exists($src_file_name) );
+var_dump( copy($src_file_name, $dest_file_name) );
+var_dump( file_exists($dest_file_name) );
+var_dump( filesize($dest_file_name) );
+
+echo "*** Done ***\n";
+?>
+
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/copy_copy_variation9.tmp");
+unlink(dirname(__FILE__)."/copy_variation9.tmp");
+?>
+--EXPECTF--
+*** Test copy() function: destination with/without write permissions ***
+
+-- With write permissions --
+bool(true)
+bool(true)
+bool(true)
+int(1500)
+
+-- Without write permissions --
+bool(true)
+
+Warning: %s
+bool(false)
+bool(true)
+int(1500)
+*** Done ***
diff --git a/ext/standard/tests/file/directory_wrapper_fstat_basic.phpt b/ext/standard/tests/file/directory_wrapper_fstat_basic.phpt
new file mode 100644
index 0000000..87f8523
--- /dev/null
+++ b/ext/standard/tests/file/directory_wrapper_fstat_basic.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Test function fstat() on directory wrapper
+--FILE--
+<?php
+$d = dirname(__FILE__);
+$h = opendir($d);
+var_dump(fstat($h));
+closedir($h);
+?>
+===DONE===
+--EXPECT--
+bool(false)
+===DONE=== \ No newline at end of file
diff --git a/ext/standard/tests/file/dirname_basic-win32.phpt b/ext/standard/tests/file/dirname_basic-win32.phpt
new file mode 100644
index 0000000..61a6e33
--- /dev/null
+++ b/ext/standard/tests/file/dirname_basic-win32.phpt
@@ -0,0 +1,93 @@
+--TEST--
+Test dirname() function : basic functionality
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+ die("skip Only valid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype : string dirname(string path)
+ * Description: Returns the directory name component of the path
+ * Source code: ext/standard/string.c
+ * Alias to functions:
+ */
+
+echo "*** Testing dirname() : basic functionality ***\n";
+
+
+// Initialise all required variables
+$paths = array(
+ '',
+ ' ',
+ 'c:',
+ 'c:\\',
+ 'c:/',
+ 'afile',
+ 'c:\test\afile',
+ 'c:\\test\\afile',
+ 'c://test//afile',
+ 'c:\test\afile\\',
+ '/usr/lib/locale/en_US',
+ '//usr/lib//locale/en_US',
+ '\\',
+ '\\\\',
+ '/',
+ '//',
+ '///',
+ '/usr/lib/locale/en_US/',
+ 'c:\windows/system32\drivers/etc\hosts',
+ '/usr\lib/locale\en_US',
+ ' c:\test\adir\afile.txt',
+ 'c:\test\adir\afile.txt ',
+ ' c:\test\adir\afile.txt ',
+ ' /usr/lib/locale/en_US',
+ '/usr/lib/locale/en_US ',
+ ' /usr/lib/locale/en_US ',
+ ' c:',
+ ' c:\test\adir\afile.txt',
+ '/usr',
+ '/usr/',
+ );
+
+foreach ($paths as $path) {
+ var_dump( dirname($path) );
+}
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing dirname() : basic functionality ***
+string(0) ""
+string(1) "."
+string(2) "c:"
+string(3) "c:\"
+string(3) "c:\"
+string(1) "."
+string(7) "c:\test"
+string(7) "c:\test"
+string(8) "c://test"
+string(7) "c:\test"
+string(15) "/usr/lib/locale"
+string(17) "//usr/lib//locale"
+string(1) "\"
+string(1) "\"
+string(1) "\"
+string(1) "\"
+string(1) "\"
+string(15) "/usr/lib/locale"
+string(31) "c:\windows/system32\drivers/etc"
+string(15) "/usr\lib/locale"
+string(15) " c:\test\adir"
+string(12) "c:\test\adir"
+string(15) " c:\test\adir"
+string(18) " /usr/lib/locale"
+string(15) "/usr/lib/locale"
+string(18) " /usr/lib/locale"
+string(1) "."
+string(14) " c:\test\adir"
+string(1) "\"
+string(1) "\"
+===DONE===
diff --git a/ext/standard/tests/file/dirname_basic.phpt b/ext/standard/tests/file/dirname_basic.phpt
new file mode 100644
index 0000000..8f1944e
--- /dev/null
+++ b/ext/standard/tests/file/dirname_basic.phpt
@@ -0,0 +1,94 @@
+--TEST--
+Test dirname() function : basic functionality
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+ die("skip Not valid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype : string dirname(string path)
+ * Description: Returns the directory name component of the path
+ * Source code: ext/standard/string.c
+ * Alias to functions:
+ */
+
+echo "*** Testing dirname() : basic functionality ***\n";
+
+
+// Initialise all required variables
+$paths = array(
+ '',
+ ' ',
+ 'c:',
+ 'c:\\',
+ 'c:/',
+ 'afile',
+ 'c:\test\afile',
+ 'c:\\test\\afile',
+ 'c://test//afile',
+ 'c:\test\afile\\',
+ '/usr/lib/locale/en_US',
+ '//usr/lib//locale/en_US',
+ '\\',
+ '\\\\',
+ '/',
+ '//',
+ '///',
+ '/usr/lib/locale/en_US/',
+ 'c:\windows/system32\drivers/etc\hosts',
+ '/usr\lib/locale\en_US',
+ ' c:\test\adir\afile.txt',
+ 'c:\test\adir\afile.txt ',
+ ' c:\test\adir\afile.txt ',
+ ' /usr/lib/locale/en_US',
+ '/usr/lib/locale/en_US ',
+ ' /usr/lib/locale/en_US ',
+ ' c:',
+ ' c:\test\adir\afile.txt',
+ '/usr',
+ '/usr/'
+ );
+
+foreach ($paths as $path) {
+ var_dump( dirname($path) );
+}
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing dirname() : basic functionality ***
+string(0) ""
+string(1) "."
+string(1) "."
+string(1) "."
+string(1) "."
+string(1) "."
+string(1) "."
+string(1) "."
+string(8) "c://test"
+string(1) "."
+string(15) "/usr/lib/locale"
+string(17) "//usr/lib//locale"
+string(1) "."
+string(1) "."
+string(1) "/"
+string(1) "/"
+string(1) "/"
+string(15) "/usr/lib/locale"
+string(27) "c:\windows/system32\drivers"
+string(8) "/usr\lib"
+string(1) "."
+string(1) "."
+string(1) "."
+string(18) " /usr/lib/locale"
+string(15) "/usr/lib/locale"
+string(18) " /usr/lib/locale"
+string(1) "."
+string(1) "."
+string(1) "/"
+string(1) "/"
+===DONE===
+
diff --git a/ext/standard/tests/file/dirname_error.phpt b/ext/standard/tests/file/dirname_error.phpt
new file mode 100644
index 0000000..dc7814f
--- /dev/null
+++ b/ext/standard/tests/file/dirname_error.phpt
@@ -0,0 +1,40 @@
+--TEST--
+Test dirname() function : error conditions
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : string dirname(string path)
+ * Description: Returns the directory name component of the path
+ * Source code: ext/standard/string.c
+ * Alias to functions:
+ */
+
+echo "*** Testing dirname() : error conditions ***\n";
+
+// Zero arguments
+echo "\n-- Testing dirname() function with Zero arguments --\n";
+var_dump( dirname() );
+
+//Test dirname with one more than the expected number of arguments
+echo "\n-- Testing dirname() function with more than expected no. of arguments --\n";
+$path = 'string_val';
+$extra_arg = 10;
+var_dump( dirname($path, $extra_arg) );
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing dirname() : error conditions ***
+
+-- Testing dirname() function with Zero arguments --
+
+Warning: dirname() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+-- Testing dirname() function with more than expected no. of arguments --
+
+Warning: dirname() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+===DONE===
+
diff --git a/ext/standard/tests/file/dirname_variation1.phpt b/ext/standard/tests/file/dirname_variation1.phpt
new file mode 100644
index 0000000..15041ff
--- /dev/null
+++ b/ext/standard/tests/file/dirname_variation1.phpt
@@ -0,0 +1,190 @@
+--TEST--
+Test dirname() function : usage variation
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : string dirname(string path)
+ * Description: Returns the directory name component of the path
+ * Source code: ext/standard/string.c
+ * Alias to functions:
+ */
+
+echo "*** Testing dirname() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+ // int data
+ 'int 0' => 0,
+ 'int 1' => 1,
+ 'int 12345' => 12345,
+ 'int -12345' => -2345,
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float -10.5' => -10.5,
+ 'float 12.3456789000e10' => 12.3456789000e10,
+ 'float -12.3456789000e10' => -12.3456789000e10,
+ 'float .5' => .5,
+
+ // array data
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for path
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( dirname($value) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing dirname() : usage variation ***
+
+--int 0--
+string(1) "."
+
+--int 1--
+string(1) "."
+
+--int 12345--
+string(1) "."
+
+--int -12345--
+string(1) "."
+
+--float 10.5--
+string(1) "."
+
+--float -10.5--
+string(1) "."
+
+--float 12.3456789000e10--
+string(1) "."
+
+--float -12.3456789000e10--
+string(1) "."
+
+--float .5--
+string(1) "."
+
+--empty array--
+Error: 2 - dirname() expects parameter 1 to be string, array given, %s(%d)
+NULL
+
+--int indexed array--
+Error: 2 - dirname() expects parameter 1 to be string, array given, %s(%d)
+NULL
+
+--associative array--
+Error: 2 - dirname() expects parameter 1 to be string, array given, %s(%d)
+NULL
+
+--nested arrays--
+Error: 2 - dirname() expects parameter 1 to be string, array given, %s(%d)
+NULL
+
+--uppercase NULL--
+string(0) ""
+
+--lowercase null--
+string(0) ""
+
+--lowercase true--
+string(1) "."
+
+--lowercase false--
+string(0) ""
+
+--uppercase TRUE--
+string(1) "."
+
+--uppercase FALSE--
+string(0) ""
+
+--empty string DQ--
+string(0) ""
+
+--empty string SQ--
+string(0) ""
+
+--instance of classWithToString--
+string(1) "."
+
+--instance of classWithoutToString--
+Error: 2 - dirname() expects parameter 1 to be string, object given, %s(%d)
+NULL
+
+--undefined var--
+string(0) ""
+
+--unset var--
+string(0) ""
+===DONE===
+
diff --git a/ext/standard/tests/file/disk.phpt b/ext/standard/tests/file/disk.phpt
new file mode 100644
index 0000000..6eef4b4
--- /dev/null
+++ b/ext/standard/tests/file/disk.phpt
@@ -0,0 +1,48 @@
+--TEST--
+disk_total_space() and disk_free_space() tests
+--INI--
+precision=14
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip not for Windows');
+}
+?>
+--FILE--
+<?php
+
+var_dump(disk_free_space());
+var_dump(disk_total_space());
+
+var_dump(disk_free_space(-1));
+var_dump(disk_total_space(-1));
+
+var_dump(disk_free_space("/"));
+var_dump(disk_total_space("/"));
+
+var_dump(disk_free_space("/some/path/here"));
+var_dump(disk_total_space("/some/path/here"));
+
+echo "Done\n";
+?>
+--EXPECTF--
+Warning: disk_free_space() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: disk_total_space() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: disk_free_space(): No such file or directory in %s on line %d
+bool(false)
+
+Warning: disk_total_space(): No such file or directory in %s on line %d
+bool(false)
+float(%d)
+float(%d)
+
+Warning: disk_free_space(): No such file or directory in %s on line %d
+bool(false)
+
+Warning: disk_total_space(): No such file or directory in %s on line %d
+bool(false)
+Done
diff --git a/ext/standard/tests/file/disk_free_space_basic.phpt b/ext/standard/tests/file/disk_free_space_basic.phpt
new file mode 100644
index 0000000..7ea8d36
--- /dev/null
+++ b/ext/standard/tests/file/disk_free_space_basic.phpt
@@ -0,0 +1,70 @@
+--TEST--
+Test disk_free_space and its alias diskfreespace() functions : basic functionality
+--INI--
+memory_limit=32M
+--FILE--
+<?php
+/*
+ * Prototype: float disk_free_space( string directory )
+ * Description: Given a string containing a directory, this function
+ * will return the number of bytes available on the corresponding
+ * filesystem or disk partition
+ */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Testing with existing directory ***\n";
+var_dump( disk_free_space($file_path) );
+var_dump( diskfreespace($file_path) );
+
+echo "*** Testing with newly created directory ***\n";
+$dir = "/disk_free_space";
+mkdir($file_path.$dir);
+echo" \n Free Space before writing to a file\n";
+$space1 = disk_free_space($file_path.$dir);
+var_dump( $space1 );
+
+$fh = fopen($file_path.$dir."/disk_free_space.tmp", "a");
+$data = str_repeat("x", 4096);
+fwrite($fh, (binary)$data);
+fclose($fh);
+
+echo "\n Free Space after writing to a file\n";
+$space2 = disk_free_space($file_path.$dir);
+var_dump( $space2 );
+
+if( $space1 > $space2 )
+ echo "\n Free Space Value Is Correct\n";
+else
+ echo "\n Free Space Value Is Incorrect\n";
+
+echo "*** Testing with Binary Input ***\n";
+var_dump( disk_free_space(b"$file_path") );
+
+echo"\n--- Done ---";
+?>
+
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/disk_free_space/disk_free_space.tmp");
+rmdir($file_path."/disk_free_space");
+?>
+
+--EXPECTF--
+*** Testing with existing directory ***
+float(%d)
+float(%d)
+*** Testing with newly created directory ***
+
+ Free Space before writing to a file
+float(%d)
+
+ Free Space after writing to a file
+float(%d)
+
+ Free Space Value Is Correct
+*** Testing with Binary Input ***
+float(%d)
+
+--- Done ---
diff --git a/ext/standard/tests/file/disk_free_space_error-win32.phpt b/ext/standard/tests/file/disk_free_space_error-win32.phpt
new file mode 100644
index 0000000..21e7bf6
--- /dev/null
+++ b/ext/standard/tests/file/disk_free_space_error-win32.phpt
@@ -0,0 +1,75 @@
+--TEST--
+Test disk_free_space and its alias diskfreespace() functions : error conditions
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != 'WIN' )
+ die("skip Valid only for Windows");
+?>
+--FILE--
+<?php
+/*
+ * Prototype: float disk_free_space( string directory )
+ * Description: Given a string containing a directory, this function will
+ * return the number of bytes available on the corresponding
+ * filesystem or disk partition
+ */
+
+echo "*** Testing error conditions ***\n";
+$file_path = dirname(__FILE__);
+var_dump( disk_free_space() ); // Zero Arguments
+var_dump( diskfreespace() );
+
+var_dump( disk_free_space( $file_path, "extra argument") ); // More than valid number of arguments
+var_dump( diskfreespace( $file_path, "extra argument") );
+
+
+var_dump( disk_free_space( $file_path."/dir1" )); // Invalid directory
+var_dump( diskfreespace( $file_path."/dir1" ));
+
+$fh = fopen( $file_path."/disk_free_space.tmp", "w" );
+fwrite( $fh, " Garbage data for the temporary file" );
+var_dump( disk_free_space( $file_path."/disk_free_space.tmp" )); // file input instead of directory
+var_dump( diskfreespace( $file_path."/disk_free_space.tmp" ));
+fclose($fh);
+
+echo"\n-- Done --";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/disk_free_space.tmp");
+
+?>
+--EXPECTF--
+*** Testing error conditions ***
+
+Warning: disk_free_space() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: diskfreespace() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: disk_free_space() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+
+Warning: diskfreespace() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+
+Warning: disk_free_space(): The system cannot find the path specified.
+ in %s on line %d
+bool(false)
+
+Warning: diskfreespace(): The system cannot find the path specified.
+ in %s on line %d
+bool(false)
+
+Warning: disk_free_space(): The directory name is invalid.
+ in %s on line %d
+bool(false)
+
+Warning: diskfreespace(): The directory name is invalid.
+ in %s on line %d
+bool(false)
+
+-- Done --
+
diff --git a/ext/standard/tests/file/disk_free_space_error.phpt b/ext/standard/tests/file/disk_free_space_error.phpt
new file mode 100644
index 0000000..ddd25a3
--- /dev/null
+++ b/ext/standard/tests/file/disk_free_space_error.phpt
@@ -0,0 +1,67 @@
+--TEST--
+Test disk_free_space and its alias diskfreespace() functions : error conditions.
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == 'WIN')
+ die("skip Not valid on Windows");
+?>
+--FILE--
+<?php
+/*
+ * Prototype: float disk_free_space( string directory )
+ * Description: Given a string containing a directory, this function will
+ * return the number of bytes available on the corresponding
+ * filesystem or disk partition
+ */
+
+echo "*** Testing error conditions ***\n";
+$file_path = dirname(__FILE__);
+var_dump( disk_free_space() ); // Zero Arguments
+var_dump( diskfreespace() );
+
+var_dump( disk_free_space( $file_path, "extra argument") ); // More than valid number of arguments
+var_dump( diskfreespace( $file_path, "extra argument") );
+
+
+var_dump( disk_free_space( $file_path."/dir1" )); // Invalid directory
+var_dump( diskfreespace( $file_path."/dir1" ));
+
+$fh = fopen( $file_path."/disk_free_space.tmp", "w" );
+fwrite( $fh, (binary)" Garbage data for the temporary file" );
+var_dump( disk_free_space( $file_path."/disk_free_space.tmp" )); // file input instead of directory
+var_dump( diskfreespace( $file_path."/disk_free_space.tmp" ));
+fclose($fh);
+
+echo"\n-- Done --";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/disk_free_space.tmp");
+
+?>
+--EXPECTF--
+*** Testing error conditions ***
+
+Warning: disk_free_space() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: diskfreespace() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: disk_free_space() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+
+Warning: diskfreespace() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+
+Warning: disk_free_space(): No such file or directory in %s on line %d
+bool(false)
+
+Warning: diskfreespace(): No such file or directory in %s on line %d
+bool(false)
+float(%d)
+float(%d)
+
+-- Done --
+
diff --git a/ext/standard/tests/file/disk_free_space_variation.phpt b/ext/standard/tests/file/disk_free_space_variation.phpt
new file mode 100644
index 0000000..adb1aca
--- /dev/null
+++ b/ext/standard/tests/file/disk_free_space_variation.phpt
@@ -0,0 +1,139 @@
+--TEST--
+Test disk_free_space and its alias diskfreespace() functions : Usage Variations
+--FILE--
+<?php
+/*
+ * Prototype: float disk_free_space( string directory )
+ * Description: Given a string containing a directory, this function
+ * will return the number of bytes available on the corresponding
+ * filesystem or disk partition
+ */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Testing with a directory ***\n";
+var_dump( disk_free_space($file_path."/..") );
+var_dump( diskfreespace($file_path."/..") );
+
+echo "\nTesting for the return type ***\n";
+$return_value = disk_free_space($file_path);
+var_dump( is_float($return_value) );
+
+echo "\n*** Testing with different directory combinations ***";
+$dir = "/disk_free_space";
+mkdir($file_path.$dir);
+
+$dirs_arr = array(
+ ".",
+ $file_path.$dir,
+ $file_path."/.".$dir,
+
+ /* Testing a file trailing slash */
+ $file_path."".$dir."/",
+ $file_path."/.".$dir."/",
+
+ /* Testing file with double trailing slashes */
+ $file_path.$dir."//",
+ $file_path."/.".$dir."//",
+ $file_path."/./".$dir."//",
+
+ /* Testing Binary safe */
+ $file_path.$dir.chr(0),
+ $file_path."/.".$dir.chr(0),
+ ".".chr(0).$file_path.$dir,
+ ".".chr(0).$file_path.$dir.chr(0)
+);
+
+$count = 1;
+/* loop through to test each element the above array */
+foreach($dirs_arr as $dir1) {
+ echo "\n-- Iteration $count --\n";
+ var_dump( disk_free_space( $dir1 ) );
+ var_dump( diskfreespace( $dir1 ) );
+ $count++;
+}
+
+echo"\n--- Done ---";
+?>
+
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+rmdir($file_path."/disk_free_space");
+?>
+
+
+--EXPECTF--
+*** Testing with a directory ***
+float(%d)
+float(%d)
+
+Testing for the return type ***
+bool(true)
+
+*** Testing with different directory combinations ***
+-- Iteration 1 --
+float(%d)
+float(%d)
+
+-- Iteration 2 --
+float(%d)
+float(%d)
+
+-- Iteration 3 --
+float(%d)
+float(%d)
+
+-- Iteration 4 --
+float(%d)
+float(%d)
+
+-- Iteration 5 --
+float(%d)
+float(%d)
+
+-- Iteration 6 --
+float(%d)
+float(%d)
+
+-- Iteration 7 --
+float(%d)
+float(%d)
+
+-- Iteration 8 --
+float(%d)
+float(%d)
+
+-- Iteration 9 --
+
+Warning: disk_free_space() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+
+Warning: diskfreespace() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+
+-- Iteration 10 --
+
+Warning: disk_free_space() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+
+Warning: diskfreespace() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+
+-- Iteration 11 --
+
+Warning: disk_free_space() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+
+Warning: diskfreespace() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+
+-- Iteration 12 --
+
+Warning: disk_free_space() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+
+Warning: diskfreespace() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+
+--- Done ---
diff --git a/ext/standard/tests/file/disk_total_space_basic.phpt b/ext/standard/tests/file/disk_total_space_basic.phpt
new file mode 100644
index 0000000..d211f39
--- /dev/null
+++ b/ext/standard/tests/file/disk_total_space_basic.phpt
@@ -0,0 +1,48 @@
+--TEST--
+Test disk_total_space() function : basic functionality
+--FILE--
+<?php
+/*
+ * Prototype: float disk_total_space( string $directory );
+ * Description: given a string containing a directory, this function will
+ * return the total number of bytes on the corresponding filesyatem
+ * or disk partition.
+ */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Testing with normal directory ***\n";
+var_dump( disk_total_space($file_path) );
+
+echo "*** Testing with newly created directory ***\n";
+$dir = "/disk_total_space";
+
+mkdir($file_path.$dir);
+var_dump( disk_total_space($file_path.$dir) );
+$fh = fopen($file_path.$dir."/disk_total_space.tmp", "w");
+fwrite($fh, (binary)"Garbage Data Garbage Data Garbage Data Garbage Data Garbage Data Garbage Data Garbage Data");
+
+fclose($fh);
+
+echo"\nTotal Space after writing to a file\n";
+var_dump( disk_total_space($file_path.$dir) );
+
+echo"\n-- Done --";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/disk_total_space/disk_total_space.tmp");
+rmdir($file_path."/disk_total_space");
+?>
+
+--EXPECTF--
+*** Testing with normal directory ***
+float(%d)
+*** Testing with newly created directory ***
+float(%d)
+
+Total Space after writing to a file
+float(%d)
+
+-- Done --
diff --git a/ext/standard/tests/file/disk_total_space_error-win32.phpt b/ext/standard/tests/file/disk_total_space_error-win32.phpt
new file mode 100644
index 0000000..a3ea183
--- /dev/null
+++ b/ext/standard/tests/file/disk_total_space_error-win32.phpt
@@ -0,0 +1,56 @@
+--TEST--
+Test disk_total_space() function : error conditions
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != 'WIN' )
+ die("skip Valid only for Windows");
+?>
+--FILE--
+<?php
+/*
+ * Prototype: float disk_total_space( string $directory );
+ * Description: given a string containing a directory, this function
+ * will return the total number of bytes on the corresponding
+ * filesystem or disk partition
+ */
+
+echo "*** Testing error conditions ***\n";
+$file_path = dirname(__FILE__);
+var_dump( disk_total_space() ); // Zero Arguments
+
+var_dump( disk_total_space( $file_path, "extra argument") ); // More than valid number of arguments
+
+
+var_dump( disk_total_space( $file_path."/dir1" )); // Invalid directory
+
+$fh = fopen( $file_path."/disk_total_space.tmp", "w" );
+fwrite( $fh, " Garbage data for the temporary file" );
+var_dump( disk_total_space( $file_path."/disk_total_space.tmp" )); // file input instead of directory
+fclose($fh);
+
+echo"\n--- Done ---";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/disk_total_space.tmp");
+?>
+--EXPECTF--
+*** Testing error conditions ***
+
+Warning: disk_total_space() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: disk_total_space() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+
+Warning: disk_total_space(): The system cannot find the path specified.
+ in %s on line %d
+bool(false)
+
+Warning: disk_total_space(): The directory name is invalid.
+ in %s on line %d
+bool(false)
+
+--- Done ---
+
diff --git a/ext/standard/tests/file/disk_total_space_error.phpt b/ext/standard/tests/file/disk_total_space_error.phpt
new file mode 100644
index 0000000..d986f77
--- /dev/null
+++ b/ext/standard/tests/file/disk_total_space_error.phpt
@@ -0,0 +1,52 @@
+--TEST--
+Test disk_total_space() function : error conditions
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == 'WIN')
+ die("skip Not valid on Windows");
+?>
+--FILE--
+<?php
+/*
+ * Prototype: float disk_total_space( string $directory );
+ * Description: given a string containing a directory, this function
+ * will return the total number of bytes on the corresponding
+ * filesystem or disk partition
+ */
+
+echo "*** Testing error conditions ***\n";
+$file_path = dirname(__FILE__);
+var_dump( disk_total_space() ); // Zero Arguments
+
+var_dump( disk_total_space( $file_path, "extra argument") ); // More than valid number of arguments
+
+
+var_dump( disk_total_space( $file_path."/dir1" )); // Invalid directory
+
+$fh = fopen( $file_path."/disk_total_space.tmp", "w" );
+fwrite( $fh, (binary)" Garbage data for the temporary file" );
+var_dump( disk_total_space( $file_path."/disk_total_space.tmp" )); // file input instead of directory
+fclose($fh);
+
+echo"\n--- Done ---";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/disk_total_space.tmp");
+?>
+--EXPECTF--
+*** Testing error conditions ***
+
+Warning: disk_total_space() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: disk_total_space() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+
+Warning: disk_total_space(): No such file or directory in %s on line %d
+bool(false)
+float(%d)
+
+--- Done ---
+
diff --git a/ext/standard/tests/file/disk_total_space_variation.phpt b/ext/standard/tests/file/disk_total_space_variation.phpt
new file mode 100644
index 0000000..ba2ceb2
--- /dev/null
+++ b/ext/standard/tests/file/disk_total_space_variation.phpt
@@ -0,0 +1,123 @@
+--TEST--
+Testing disk_total_space() functions : Usage Variations.
+--FILE--
+<?php
+/*
+ * Prototype: float disk_total_space( string directory )
+ * Description: given a string containing a directory, this function
+ * will return the total number of bytes on the corresponding
+ * filesystem or disk partition.
+ */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Testing with a directory ***\n";
+var_dump( disk_total_space($file_path."/..") );
+
+echo "\nTesting for the return type ***\n";
+$return_value = disk_total_space($file_path);
+var_dump( is_float($return_value) );
+
+echo "\n*** Testing with different directory combinations ***";
+$dir = "/disk_total_space";
+
+mkdir($file_path.$dir);
+
+$dirs_arr = array(
+ ".",
+ $file_path.$dir,
+ $file_path."/.".$dir,
+
+ /* Testing a file trailing slash */
+ $file_path."".$dir."/",
+ $file_path."/.".$dir."/",
+
+ /* Testing file with double trailing slashes */
+ $file_path.$dir."//",
+ $file_path."/.".$dir."//",
+ $file_path."/./".$dir."//",
+
+ /* Testing Binary safe */
+ $file_path.$dir.chr(0),
+ $file_path."/.".$dir.chr(0),
+ ".".chr(0).$file_path.$dir,
+ ".".chr(0).$file_path.$dir.chr(0)
+);
+
+
+$count = 1;
+/* loop through to test each element the above array */
+foreach($dirs_arr as $dir1) {
+ echo "\n-- Iteration $count --\n";
+ var_dump( disk_total_space( $dir1 ) );
+ $count++;
+}
+
+echo "*** Testing with Binary Input ***\n";
+var_dump( disk_total_space(b"$file_path") );
+
+echo"\n--- Done ---";
+?>
+
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+rmdir($file_path."/disk_total_space");
+?>
+
+
+--EXPECTF--
+*** Testing with a directory ***
+float(%d)
+
+Testing for the return type ***
+bool(true)
+
+*** Testing with different directory combinations ***
+-- Iteration 1 --
+float(%d)
+
+-- Iteration 2 --
+float(%d)
+
+-- Iteration 3 --
+float(%d)
+
+-- Iteration 4 --
+float(%d)
+
+-- Iteration 5 --
+float(%d)
+
+-- Iteration 6 --
+float(%d)
+
+-- Iteration 7 --
+float(%d)
+
+-- Iteration 8 --
+float(%d)
+
+-- Iteration 9 --
+
+Warning: disk_total_space() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+
+-- Iteration 10 --
+
+Warning: disk_total_space() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+
+-- Iteration 11 --
+
+Warning: disk_total_space() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+
+-- Iteration 12 --
+
+Warning: disk_total_space() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+*** Testing with Binary Input ***
+float(%d)
+
+--- Done ---
diff --git a/ext/standard/tests/file/fclose_variation1.phpt b/ext/standard/tests/file/fclose_variation1.phpt
new file mode 100644
index 0000000..43a6c34
--- /dev/null
+++ b/ext/standard/tests/file/fclose_variation1.phpt
@@ -0,0 +1,15 @@
+--TEST--
+fclose() actually closes streams with refcount > 1
+--FILE--
+<?php
+$s = fopen(__FILE__, "rb");
+function separate_zval(&$var) { }
+$s2 = $s;
+separate_zval($s2);
+fclose($s);
+echo fread($s2, strlen("<?php"));
+echo "\nDone.\n";
+--EXPECTF--
+Warning: fread(): %d is not a valid stream resource in %s on line %d
+
+Done.
diff --git a/ext/standard/tests/file/feof_basic.phpt b/ext/standard/tests/file/feof_basic.phpt
new file mode 100644
index 0000000..ff1d179
--- /dev/null
+++ b/ext/standard/tests/file/feof_basic.phpt
@@ -0,0 +1,101 @@
+--TEST--
+Test feof() function : basic functionality
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : proto bool feof(resource fp)
+ * Description: Test for end-of-file on a file pointer
+ * Source code: ext/standard/file.c
+ * Alias to functions: gzeof
+ */
+
+echo "*** Testing feof() : basic functionality ***\n";
+$tmpFile1 = __FILE__.".tmp1";
+$h = fopen($tmpFile1, 'wb');
+$count = 10;
+for ($i = 1; $i <= $count; $i++) {
+ fwrite($h, "some data $i\n");
+}
+fclose($h);
+
+echo "\n*** testing reading complete file using feof to stop ***\n";
+$h = fopen($tmpFile1, 'rb');
+
+//feof is not set to true until you try to read past the end of file.
+//so fgets will be called even if we are at the end of the file on
+//last time to set the eof flag but it will fail to read.
+$lastline = "";
+while (!feof($h)) {
+ $previousLine = $lastline;
+ $lastline = fgets($h);
+}
+echo $previousLine;
+var_dump($lastline); // this should be false
+fclose($h);
+
+$tmpFile2 = __FILE__.".tmp2";
+$h = fopen($tmpFile2, 'wb+');
+$count = 10;
+echo "*** writing $count lines, testing feof ***\n";
+for ($i = 1; $i <=$count; $i++) {
+ fwrite($h, "some data $i\n");
+ var_dump(feof($h));
+}
+
+echo "*** testing feof on unclosed file after a read ***\n";
+
+fread($h, 100);
+var_dump(feof($h));
+
+$eofPointer = ftell($h);
+
+echo "*** testing feof after a seek to near the beginning ***\n";
+fseek($h, 20, SEEK_SET);
+var_dump(feof($h));
+
+echo "*** testing feof after a seek to end ***\n";
+fseek($h, $eofPointer, SEEK_SET);
+var_dump(feof($h));
+
+echo "*** testing feof after a seek passed the end ***\n";
+fseek($h, $eofPointer + 1000, SEEK_SET);
+var_dump(feof($h));
+
+echo "*** closing file, testing eof ***\n";
+fclose($h);
+feof($h);
+unlink($tmpFile1);
+unlink($tmpFile2);
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing feof() : basic functionality ***
+
+*** testing reading complete file using feof to stop ***
+some data 10
+bool(false)
+*** writing 10 lines, testing feof ***
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+*** testing feof on unclosed file after a read ***
+bool(true)
+*** testing feof after a seek to near the beginning ***
+bool(false)
+*** testing feof after a seek to end ***
+bool(false)
+*** testing feof after a seek passed the end ***
+bool(false)
+*** closing file, testing eof ***
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+Done
diff --git a/ext/standard/tests/file/fflush_basic.phpt b/ext/standard/tests/file/fflush_basic.phpt
new file mode 100644
index 0000000..f375c4f
--- /dev/null
+++ b/ext/standard/tests/file/fflush_basic.phpt
@@ -0,0 +1,58 @@
+--TEST--
+Test fflush() function: basic functionality
+--FILE--
+<?php
+/* Prototype: bool fflush ( resource $handle );
+ Description: Flushes the output to a file
+*/
+
+echo "*** Testing fflush(): writing to a file and reading the contents ***\n";
+$data = <<<EOD
+first line of string
+second line of string
+third line of string
+EOD;
+
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fflush_basic.tmp";
+
+// opening a file
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+if(substr(PHP_OS, 0, 3) == "WIN") {
+ $data = str_replace("\r",'', $data);
+}
+
+// writing data to the file
+var_dump( fwrite($file_handle, $data) );
+var_dump( fflush($file_handle) );
+var_dump( readfile($filename) );
+
+echo "\n*** Testing fflush(): for return type ***\n";
+$return_value = fflush($file_handle);
+var_dump( is_bool($return_value) );
+fclose($file_handle);
+echo "\n*** Done ***";
+?>
+
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fflush_basic.tmp";
+unlink($filename);
+?>
+
+--EXPECTF--
+*** Testing fflush(): writing to a file and reading the contents ***
+int(63)
+bool(true)
+first line of string
+second line of string
+third line of stringint(63)
+
+*** Testing fflush(): for return type ***
+bool(true)
+
+*** Done ***
diff --git a/ext/standard/tests/file/fflush_error.phpt b/ext/standard/tests/file/fflush_error.phpt
new file mode 100644
index 0000000..6d7f731
--- /dev/null
+++ b/ext/standard/tests/file/fflush_error.phpt
@@ -0,0 +1,90 @@
+--TEST--
+Test fflush() function: error conditions
+--FILE--
+<?php
+/*
+ Prototype: bool fflush ( resource $handle );
+ Description: Flushes the output to a file
+*/
+
+echo "*** Testing error conditions ***\n";
+$file_path = dirname(__FILE__);
+
+// zero argument
+echo "-- Testing fflush(): with zero argument --\n";
+var_dump( fflush() );
+
+// more than expected no. of args
+echo "-- Testing fflush(): with more than expected number of arguments --\n";
+
+$filename = "$file_path/fflush_error.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+var_dump( fflush($file_handle, $file_handle) );
+fclose($file_handle);
+
+// test invalid arguments : non-resources
+echo "-- Testing fflush(): with invalid arguments --\n";
+$invalid_args = array (
+ "string",
+ 10,
+ 10.5,
+ true,
+ array(1,2,3),
+ new stdclass
+);
+
+/* loop to test fflush() with different invalid type of args */
+for($loop_counter = 1; $loop_counter <= count($invalid_args); $loop_counter++) {
+ echo "-- Iteration $loop_counter --\n";
+ var_dump( fflush($invalid_args[$loop_counter - 1]) );
+}
+echo "\n*** Done ***";
+?>
+
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink("$file_path/fflush_error.tmp");
+?>
+
+--EXPECTF--
+*** Testing error conditions ***
+-- Testing fflush(): with zero argument --
+
+Warning: fflush() expects exactly 1 parameter, 0 given in %s on line %d
+bool(false)
+-- Testing fflush(): with more than expected number of arguments --
+
+Warning: fflush() expects exactly 1 parameter, 2 given in %s on line %d
+bool(false)
+-- Testing fflush(): with invalid arguments --
+-- Iteration 1 --
+
+Warning: fflush() expects parameter 1 to be resource, string given in %s on line %d
+bool(false)
+-- Iteration 2 --
+
+Warning: fflush() expects parameter 1 to be resource, integer given in %s on line %d
+bool(false)
+-- Iteration 3 --
+
+Warning: fflush() expects parameter 1 to be resource, double given in %s on line %d
+bool(false)
+-- Iteration 4 --
+
+Warning: fflush() expects parameter 1 to be resource, boolean given in %s on line %d
+bool(false)
+-- Iteration 5 --
+
+Warning: fflush() expects parameter 1 to be resource, array given in %s on line %d
+bool(false)
+-- Iteration 6 --
+
+Warning: fflush() expects parameter 1 to be resource, object given in %s on line %d
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fflush_variation1-win32.phpt b/ext/standard/tests/file/fflush_variation1-win32.phpt
new file mode 100644
index 0000000..0b6b096
--- /dev/null
+++ b/ext/standard/tests/file/fflush_variation1-win32.phpt
@@ -0,0 +1,531 @@
+--TEST--
+Test fflush() function: usage variations - files in different modes
+--SKIPIF--
+<?php
+if( substr(PHP_OS, 0, 3) != "WIN" )
+ die("skip.. only for Windows");
+?>
+
+--FILE--
+<?php
+/* Prototype: bool fflush ( resource $handle );
+ Description: Flushes the output to a file
+*/
+
+/* test fflush() with handle to the files opened in different modes */
+
+$file_path = dirname(__FILE__);
+require $file_path.'/file.inc';
+
+echo "*** Testing fflush(): with various types of files ***\n";
+$file_types = array("empty", "numeric", "text", "text_with_new_line", "alphanumeric");
+$file_modes = array("w", "wb", "wt", "w+", "w+b", "w+t",
+ "a", "ab", "at", "a+","a+b", "a+t",
+ "x", "xb", "xt", "x+", "x+b", "x+t");
+
+$file_name = "$file_path/fflush_variation1.tmp";
+
+$count = 1;
+
+foreach( $file_types as $type ) {
+ echo "-- Iteration $count with file containing $type Data--\n";
+ foreach( $file_modes as $mode ) {
+ echo "-- File opened in $mode mode --\n";
+
+ // creating the file except for x mode
+ if( substr($mode, 0, 1) != "x" ) {
+ $file_handle = fopen($file_name, "w");
+ if($file_handle == false)
+ exit("Error:failed to open file $file_name");
+
+ // filling the file some data if mode is append mode
+ if( substr($mode, 0, 1) == "a")
+ fill_file($file_handle, $type, 10);
+ fclose($file_handle);
+ }
+
+ // opening the file in different modes
+ $file_handle = fopen($file_name, $mode);
+ if($file_handle == false)
+ exit("Error:failed to open file $file_name");
+
+ // writing data to the file
+ var_dump( fill_file($file_handle, $type, 50) );
+ var_dump( fflush($file_handle) );
+ fclose($file_handle);
+
+ // reading the contents of the file after flushing
+ var_dump( readfile($file_name) );
+ unlink($file_name);
+ }
+ $count++;
+}
+
+echo "\n*** Done ***";
+?>
+--EXPECTF--
+*** Testing fflush(): with various types of files ***
+-- Iteration 1 with file containing empty Data--
+-- File opened in w mode --
+bool(true)
+bool(true)
+int(0)
+-- File opened in wb mode --
+bool(true)
+bool(true)
+int(0)
+-- File opened in wt mode --
+bool(true)
+bool(true)
+int(0)
+-- File opened in w+ mode --
+bool(true)
+bool(true)
+int(0)
+-- File opened in w+b mode --
+bool(true)
+bool(true)
+int(0)
+-- File opened in w+t mode --
+bool(true)
+bool(true)
+int(0)
+-- File opened in a mode --
+bool(true)
+bool(true)
+int(0)
+-- File opened in ab mode --
+bool(true)
+bool(true)
+int(0)
+-- File opened in at mode --
+bool(true)
+bool(true)
+int(0)
+-- File opened in a+ mode --
+bool(true)
+bool(true)
+int(0)
+-- File opened in a+b mode --
+bool(true)
+bool(true)
+int(0)
+-- File opened in a+t mode --
+bool(true)
+bool(true)
+int(0)
+-- File opened in x mode --
+bool(true)
+bool(true)
+int(0)
+-- File opened in xb mode --
+bool(true)
+bool(true)
+int(0)
+-- File opened in xt mode --
+bool(true)
+bool(true)
+int(0)
+-- File opened in x+ mode --
+bool(true)
+bool(true)
+int(0)
+-- File opened in x+b mode --
+bool(true)
+bool(true)
+int(0)
+-- File opened in x+t mode --
+bool(true)
+bool(true)
+int(0)
+-- Iteration 2 with file containing numeric Data--
+-- File opened in w mode --
+bool(true)
+bool(true)
+22222222222222222222222222222222222222222222222222int(50)
+-- File opened in wb mode --
+bool(true)
+bool(true)
+22222222222222222222222222222222222222222222222222int(50)
+-- File opened in wt mode --
+bool(true)
+bool(true)
+22222222222222222222222222222222222222222222222222int(50)
+-- File opened in w+ mode --
+bool(true)
+bool(true)
+22222222222222222222222222222222222222222222222222int(50)
+-- File opened in w+b mode --
+bool(true)
+bool(true)
+22222222222222222222222222222222222222222222222222int(50)
+-- File opened in w+t mode --
+bool(true)
+bool(true)
+22222222222222222222222222222222222222222222222222int(50)
+-- File opened in a mode --
+bool(true)
+bool(true)
+222222222222222222222222222222222222222222222222222222222222int(60)
+-- File opened in ab mode --
+bool(true)
+bool(true)
+222222222222222222222222222222222222222222222222222222222222int(60)
+-- File opened in at mode --
+bool(true)
+bool(true)
+222222222222222222222222222222222222222222222222222222222222int(60)
+-- File opened in a+ mode --
+bool(true)
+bool(true)
+222222222222222222222222222222222222222222222222222222222222int(60)
+-- File opened in a+b mode --
+bool(true)
+bool(true)
+222222222222222222222222222222222222222222222222222222222222int(60)
+-- File opened in a+t mode --
+bool(true)
+bool(true)
+222222222222222222222222222222222222222222222222222222222222int(60)
+-- File opened in x mode --
+bool(true)
+bool(true)
+22222222222222222222222222222222222222222222222222int(50)
+-- File opened in xb mode --
+bool(true)
+bool(true)
+22222222222222222222222222222222222222222222222222int(50)
+-- File opened in xt mode --
+bool(true)
+bool(true)
+22222222222222222222222222222222222222222222222222int(50)
+-- File opened in x+ mode --
+bool(true)
+bool(true)
+22222222222222222222222222222222222222222222222222int(50)
+-- File opened in x+b mode --
+bool(true)
+bool(true)
+22222222222222222222222222222222222222222222222222int(50)
+-- File opened in x+t mode --
+bool(true)
+bool(true)
+22222222222222222222222222222222222222222222222222int(50)
+-- Iteration 3 with file containing text Data--
+-- File opened in w mode --
+bool(true)
+bool(true)
+text text text text text text text text text text int(50)
+-- File opened in wb mode --
+bool(true)
+bool(true)
+text text text text text text text text text text int(50)
+-- File opened in wt mode --
+bool(true)
+bool(true)
+text text text text text text text text text text int(50)
+-- File opened in w+ mode --
+bool(true)
+bool(true)
+text text text text text text text text text text int(50)
+-- File opened in w+b mode --
+bool(true)
+bool(true)
+text text text text text text text text text text int(50)
+-- File opened in w+t mode --
+bool(true)
+bool(true)
+text text text text text text text text text text int(50)
+-- File opened in a mode --
+bool(true)
+bool(true)
+text text text text text text text text text text text text int(60)
+-- File opened in ab mode --
+bool(true)
+bool(true)
+text text text text text text text text text text text text int(60)
+-- File opened in at mode --
+bool(true)
+bool(true)
+text text text text text text text text text text text text int(60)
+-- File opened in a+ mode --
+bool(true)
+bool(true)
+text text text text text text text text text text text text int(60)
+-- File opened in a+b mode --
+bool(true)
+bool(true)
+text text text text text text text text text text text text int(60)
+-- File opened in a+t mode --
+bool(true)
+bool(true)
+text text text text text text text text text text text text int(60)
+-- File opened in x mode --
+bool(true)
+bool(true)
+text text text text text text text text text text int(50)
+-- File opened in xb mode --
+bool(true)
+bool(true)
+text text text text text text text text text text int(50)
+-- File opened in xt mode --
+bool(true)
+bool(true)
+text text text text text text text text text text int(50)
+-- File opened in x+ mode --
+bool(true)
+bool(true)
+text text text text text text text text text text int(50)
+-- File opened in x+b mode --
+bool(true)
+bool(true)
+text text text text text text text text text text int(50)
+-- File opened in x+t mode --
+bool(true)
+bool(true)
+text text text text text text text text text text int(50)
+-- Iteration 4 with file containing text_with_new_line Data--
+-- File opened in w mode --
+bool(true)
+bool(true)
+line
+line of text
+line
+line of text
+line
+line of tint(50)
+-- File opened in wb mode --
+bool(true)
+bool(true)
+line
+line of text
+line
+line of text
+line
+line of tint(50)
+-- File opened in wt mode --
+bool(true)
+bool(true)
+line
+line of text
+line
+line of text
+line
+line of tint(55)
+-- File opened in w+ mode --
+bool(true)
+bool(true)
+line
+line of text
+line
+line of text
+line
+line of tint(50)
+-- File opened in w+b mode --
+bool(true)
+bool(true)
+line
+line of text
+line
+line of text
+line
+line of tint(50)
+-- File opened in w+t mode --
+bool(true)
+bool(true)
+line
+line of text
+line
+line of text
+line
+line of tint(55)
+-- File opened in a mode --
+bool(true)
+bool(true)
+line
+line line
+line of text
+line
+line of text
+line
+line of tint(60)
+-- File opened in ab mode --
+bool(true)
+bool(true)
+line
+line line
+line of text
+line
+line of text
+line
+line of tint(60)
+-- File opened in at mode --
+bool(true)
+bool(true)
+line
+line line
+line of text
+line
+line of text
+line
+line of tint(65)
+-- File opened in a+ mode --
+bool(true)
+bool(true)
+line
+line line
+line of text
+line
+line of text
+line
+line of tint(60)
+-- File opened in a+b mode --
+bool(true)
+bool(true)
+line
+line line
+line of text
+line
+line of text
+line
+line of tint(60)
+-- File opened in a+t mode --
+bool(true)
+bool(true)
+line
+line line
+line of text
+line
+line of text
+line
+line of tint(65)
+-- File opened in x mode --
+bool(true)
+bool(true)
+line
+line of text
+line
+line of text
+line
+line of tint(50)
+-- File opened in xb mode --
+bool(true)
+bool(true)
+line
+line of text
+line
+line of text
+line
+line of tint(50)
+-- File opened in xt mode --
+bool(true)
+bool(true)
+line
+line of text
+line
+line of text
+line
+line of tint(55)
+-- File opened in x+ mode --
+bool(true)
+bool(true)
+line
+line of text
+line
+line of text
+line
+line of tint(50)
+-- File opened in x+b mode --
+bool(true)
+bool(true)
+line
+line of text
+line
+line of text
+line
+line of tint(50)
+-- File opened in x+t mode --
+bool(true)
+bool(true)
+line
+line of text
+line
+line of text
+line
+line of tint(55)
+-- Iteration 5 with file containing alphanumeric Data--
+-- File opened in w mode --
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
+-- File opened in wb mode --
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
+-- File opened in wt mode --
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
+-- File opened in w+ mode --
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
+-- File opened in w+b mode --
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
+-- File opened in w+t mode --
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
+-- File opened in a mode --
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60)
+-- File opened in ab mode --
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60)
+-- File opened in at mode --
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60)
+-- File opened in a+ mode --
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60)
+-- File opened in a+b mode --
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60)
+-- File opened in a+t mode --
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60)
+-- File opened in x mode --
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
+-- File opened in xb mode --
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
+-- File opened in xt mode --
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
+-- File opened in x+ mode --
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
+-- File opened in x+b mode --
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
+-- File opened in x+t mode --
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fflush_variation1.phpt b/ext/standard/tests/file/fflush_variation1.phpt
new file mode 100644
index 0000000..2ecf7ea
--- /dev/null
+++ b/ext/standard/tests/file/fflush_variation1.phpt
@@ -0,0 +1,532 @@
+--TEST--
+Test fflush() function: usage variations - files in different modes
+--SKIPIF--
+<?php
+if( substr(PHP_OS, 0, 3) == "WIN" )
+ die("skip.. only for linux");
+?>
+
+--FILE--
+<?php
+/* Prototype: bool fflush ( resource $handle );
+ Description: Flushes the output to a file
+*/
+
+/* test fflush() with handle of files opened in different modes */
+
+$file_path = dirname(__FILE__);
+require $file_path.'/file.inc';
+
+echo "*** Testing fflush(): with various types of files ***\n";
+$file_types = array("empty", "numeric", "text", "text_with_new_line", "alphanumeric");
+$file_modes = array("w", "wb", "wt", "w+", "w+b", "w+t",
+ "a", "ab", "at", "a+","a+b", "a+t",
+ "x", "xb", "xt", "x+", "x+b", "x+t");
+
+$file_name = "$file_path/fflush_variation1.tmp";
+
+$count = 1;
+
+foreach( $file_types as $type ) {
+ echo "-- Iteration $count with file containing $type Data--\n";
+ foreach( $file_modes as $mode ) {
+ echo "-- File opened in $mode mode --\n";
+
+ // creating the file except for x mode
+ if( substr($mode, 0, 1) != "x" ) {
+ $file_handle = fopen($file_name, "w");
+ if($file_handle == false)
+ exit("Error:failed to open file $file_name");
+
+ // filling the file with some data if mode is append mode
+ if( substr($mode, 0, 1) == "a")
+ fill_file($file_handle, $type, 10);
+ fclose($file_handle);
+
+ }
+
+ // opening the file in different modes
+ $file_handle = fopen($file_name, $mode);
+ if($file_handle == false)
+ exit("Error:failed to open file $file_name");
+
+ // writing data to the file
+ var_dump( fill_file($file_handle, $type, 50) );
+ var_dump( fflush($file_handle) );
+ fclose($file_handle);
+
+ // reading the contents of the file after flushing
+ var_dump( readfile($file_name) );
+ unlink($file_name);
+ }
+ $count++;
+}
+
+echo "\n*** Done ***";
+?>
+--EXPECTF--
+*** Testing fflush(): with various types of files ***
+-- Iteration 1 with file containing empty Data--
+-- File opened in w mode --
+bool(true)
+bool(true)
+int(0)
+-- File opened in wb mode --
+bool(true)
+bool(true)
+int(0)
+-- File opened in wt mode --
+bool(true)
+bool(true)
+int(0)
+-- File opened in w+ mode --
+bool(true)
+bool(true)
+int(0)
+-- File opened in w+b mode --
+bool(true)
+bool(true)
+int(0)
+-- File opened in w+t mode --
+bool(true)
+bool(true)
+int(0)
+-- File opened in a mode --
+bool(true)
+bool(true)
+int(0)
+-- File opened in ab mode --
+bool(true)
+bool(true)
+int(0)
+-- File opened in at mode --
+bool(true)
+bool(true)
+int(0)
+-- File opened in a+ mode --
+bool(true)
+bool(true)
+int(0)
+-- File opened in a+b mode --
+bool(true)
+bool(true)
+int(0)
+-- File opened in a+t mode --
+bool(true)
+bool(true)
+int(0)
+-- File opened in x mode --
+bool(true)
+bool(true)
+int(0)
+-- File opened in xb mode --
+bool(true)
+bool(true)
+int(0)
+-- File opened in xt mode --
+bool(true)
+bool(true)
+int(0)
+-- File opened in x+ mode --
+bool(true)
+bool(true)
+int(0)
+-- File opened in x+b mode --
+bool(true)
+bool(true)
+int(0)
+-- File opened in x+t mode --
+bool(true)
+bool(true)
+int(0)
+-- Iteration 2 with file containing numeric Data--
+-- File opened in w mode --
+bool(true)
+bool(true)
+22222222222222222222222222222222222222222222222222int(50)
+-- File opened in wb mode --
+bool(true)
+bool(true)
+22222222222222222222222222222222222222222222222222int(50)
+-- File opened in wt mode --
+bool(true)
+bool(true)
+22222222222222222222222222222222222222222222222222int(50)
+-- File opened in w+ mode --
+bool(true)
+bool(true)
+22222222222222222222222222222222222222222222222222int(50)
+-- File opened in w+b mode --
+bool(true)
+bool(true)
+22222222222222222222222222222222222222222222222222int(50)
+-- File opened in w+t mode --
+bool(true)
+bool(true)
+22222222222222222222222222222222222222222222222222int(50)
+-- File opened in a mode --
+bool(true)
+bool(true)
+222222222222222222222222222222222222222222222222222222222222int(60)
+-- File opened in ab mode --
+bool(true)
+bool(true)
+222222222222222222222222222222222222222222222222222222222222int(60)
+-- File opened in at mode --
+bool(true)
+bool(true)
+222222222222222222222222222222222222222222222222222222222222int(60)
+-- File opened in a+ mode --
+bool(true)
+bool(true)
+222222222222222222222222222222222222222222222222222222222222int(60)
+-- File opened in a+b mode --
+bool(true)
+bool(true)
+222222222222222222222222222222222222222222222222222222222222int(60)
+-- File opened in a+t mode --
+bool(true)
+bool(true)
+222222222222222222222222222222222222222222222222222222222222int(60)
+-- File opened in x mode --
+bool(true)
+bool(true)
+22222222222222222222222222222222222222222222222222int(50)
+-- File opened in xb mode --
+bool(true)
+bool(true)
+22222222222222222222222222222222222222222222222222int(50)
+-- File opened in xt mode --
+bool(true)
+bool(true)
+22222222222222222222222222222222222222222222222222int(50)
+-- File opened in x+ mode --
+bool(true)
+bool(true)
+22222222222222222222222222222222222222222222222222int(50)
+-- File opened in x+b mode --
+bool(true)
+bool(true)
+22222222222222222222222222222222222222222222222222int(50)
+-- File opened in x+t mode --
+bool(true)
+bool(true)
+22222222222222222222222222222222222222222222222222int(50)
+-- Iteration 3 with file containing text Data--
+-- File opened in w mode --
+bool(true)
+bool(true)
+text text text text text text text text text text int(50)
+-- File opened in wb mode --
+bool(true)
+bool(true)
+text text text text text text text text text text int(50)
+-- File opened in wt mode --
+bool(true)
+bool(true)
+text text text text text text text text text text int(50)
+-- File opened in w+ mode --
+bool(true)
+bool(true)
+text text text text text text text text text text int(50)
+-- File opened in w+b mode --
+bool(true)
+bool(true)
+text text text text text text text text text text int(50)
+-- File opened in w+t mode --
+bool(true)
+bool(true)
+text text text text text text text text text text int(50)
+-- File opened in a mode --
+bool(true)
+bool(true)
+text text text text text text text text text text text text int(60)
+-- File opened in ab mode --
+bool(true)
+bool(true)
+text text text text text text text text text text text text int(60)
+-- File opened in at mode --
+bool(true)
+bool(true)
+text text text text text text text text text text text text int(60)
+-- File opened in a+ mode --
+bool(true)
+bool(true)
+text text text text text text text text text text text text int(60)
+-- File opened in a+b mode --
+bool(true)
+bool(true)
+text text text text text text text text text text text text int(60)
+-- File opened in a+t mode --
+bool(true)
+bool(true)
+text text text text text text text text text text text text int(60)
+-- File opened in x mode --
+bool(true)
+bool(true)
+text text text text text text text text text text int(50)
+-- File opened in xb mode --
+bool(true)
+bool(true)
+text text text text text text text text text text int(50)
+-- File opened in xt mode --
+bool(true)
+bool(true)
+text text text text text text text text text text int(50)
+-- File opened in x+ mode --
+bool(true)
+bool(true)
+text text text text text text text text text text int(50)
+-- File opened in x+b mode --
+bool(true)
+bool(true)
+text text text text text text text text text text int(50)
+-- File opened in x+t mode --
+bool(true)
+bool(true)
+text text text text text text text text text text int(50)
+-- Iteration 4 with file containing text_with_new_line Data--
+-- File opened in w mode --
+bool(true)
+bool(true)
+line
+line of text
+line
+line of text
+line
+line of tint(50)
+-- File opened in wb mode --
+bool(true)
+bool(true)
+line
+line of text
+line
+line of text
+line
+line of tint(50)
+-- File opened in wt mode --
+bool(true)
+bool(true)
+line
+line of text
+line
+line of text
+line
+line of tint(50)
+-- File opened in w+ mode --
+bool(true)
+bool(true)
+line
+line of text
+line
+line of text
+line
+line of tint(50)
+-- File opened in w+b mode --
+bool(true)
+bool(true)
+line
+line of text
+line
+line of text
+line
+line of tint(50)
+-- File opened in w+t mode --
+bool(true)
+bool(true)
+line
+line of text
+line
+line of text
+line
+line of tint(50)
+-- File opened in a mode --
+bool(true)
+bool(true)
+line
+line line
+line of text
+line
+line of text
+line
+line of tint(60)
+-- File opened in ab mode --
+bool(true)
+bool(true)
+line
+line line
+line of text
+line
+line of text
+line
+line of tint(60)
+-- File opened in at mode --
+bool(true)
+bool(true)
+line
+line line
+line of text
+line
+line of text
+line
+line of tint(60)
+-- File opened in a+ mode --
+bool(true)
+bool(true)
+line
+line line
+line of text
+line
+line of text
+line
+line of tint(60)
+-- File opened in a+b mode --
+bool(true)
+bool(true)
+line
+line line
+line of text
+line
+line of text
+line
+line of tint(60)
+-- File opened in a+t mode --
+bool(true)
+bool(true)
+line
+line line
+line of text
+line
+line of text
+line
+line of tint(60)
+-- File opened in x mode --
+bool(true)
+bool(true)
+line
+line of text
+line
+line of text
+line
+line of tint(50)
+-- File opened in xb mode --
+bool(true)
+bool(true)
+line
+line of text
+line
+line of text
+line
+line of tint(50)
+-- File opened in xt mode --
+bool(true)
+bool(true)
+line
+line of text
+line
+line of text
+line
+line of tint(50)
+-- File opened in x+ mode --
+bool(true)
+bool(true)
+line
+line of text
+line
+line of text
+line
+line of tint(50)
+-- File opened in x+b mode --
+bool(true)
+bool(true)
+line
+line of text
+line
+line of text
+line
+line of tint(50)
+-- File opened in x+t mode --
+bool(true)
+bool(true)
+line
+line of text
+line
+line of text
+line
+line of tint(50)
+-- Iteration 5 with file containing alphanumeric Data--
+-- File opened in w mode --
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
+-- File opened in wb mode --
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
+-- File opened in wt mode --
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
+-- File opened in w+ mode --
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
+-- File opened in w+b mode --
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
+-- File opened in w+t mode --
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
+-- File opened in a mode --
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60)
+-- File opened in ab mode --
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60)
+-- File opened in at mode --
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60)
+-- File opened in a+ mode --
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60)
+-- File opened in a+b mode --
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60)
+-- File opened in a+t mode --
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60)
+-- File opened in x mode --
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
+-- File opened in xb mode --
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
+-- File opened in xt mode --
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
+-- File opened in x+ mode --
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
+-- File opened in x+b mode --
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
+-- File opened in x+t mode --
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fflush_variation2.phpt b/ext/standard/tests/file/fflush_variation2.phpt
new file mode 100644
index 0000000..651c716
--- /dev/null
+++ b/ext/standard/tests/file/fflush_variation2.phpt
@@ -0,0 +1,443 @@
+--TEST--
+Test fflush() function: usage variations - links as resource
+--SKIPIF--
+<?php
+if( substr(PHP_OS, 0, 3) == 'WIN')
+ die("skip Links not valid on Windows");
+?>
+--FILE--
+<?php
+/* Prototype: bool fflush ( resource $handle );
+ Description: Flushes the output to a file
+*/
+
+/* test fflush() with handle to symbollic link */
+
+$file_path = dirname(__FILE__);
+require $file_path.'/file.inc';
+
+echo "*** Testing fflush(): with soft links to files opened in diff modes ***\n";
+$file_types = array("empty", "numeric", "text", "text_with_new_line", "alphanumeric");
+$file_modes = array("w", "wb", "wt", "w+", "w+b", "w+t",
+ "a", "ab", "at", "a+","a+b", "a+t");
+
+$file_name = "$file_path/fflush_variation2.tmp";
+$symlink_name = "$file_path/symlnk_fflush_variation2.tmp";
+
+$count = 1;
+
+foreach( $file_types as $type ) {
+ echo "-- Iteration $count with file containing $type data --\n";
+ foreach( $file_modes as $mode ) {
+ echo "-- link opened in $mode mode --\n";
+
+ //creating the file
+ $file_handle = fopen($file_name, "w");
+ if($file_handle == false)
+ exit("Error:failed to open file $file_name");
+
+ //fill the file with some data if mode is append mode
+ if( substr($mode, 0, 1) == "a" )
+ fill_file($file_handle, $type, 10);
+
+ //close the file
+ fclose($file_handle);
+
+ // creating the sym link
+ var_dump( symlink($file_name, $symlink_name) );
+ $file_handle = fopen($symlink_name, $mode);
+ if($file_handle == false)
+ exit("Error:failed to open link $symlink_name");
+
+ // filling data into the file
+ var_dump( fill_file($file_handle, $type, 50) );
+ var_dump( fflush($file_handle) );
+ fclose($file_handle);
+
+ // reading the data from the file
+ var_dump( readfile($symlink_name) );
+
+ unlink($symlink_name);
+ unlink($file_name);
+ }
+ $count++;
+}
+
+echo "\n*** Done ***";
+?>
+--EXPECTF--
+*** Testing fflush(): with soft links to files opened in diff modes ***
+-- Iteration 1 with file containing empty data --
+-- link opened in w mode --
+bool(true)
+bool(true)
+bool(true)
+int(0)
+-- link opened in wb mode --
+bool(true)
+bool(true)
+bool(true)
+int(0)
+-- link opened in wt mode --
+bool(true)
+bool(true)
+bool(true)
+int(0)
+-- link opened in w+ mode --
+bool(true)
+bool(true)
+bool(true)
+int(0)
+-- link opened in w+b mode --
+bool(true)
+bool(true)
+bool(true)
+int(0)
+-- link opened in w+t mode --
+bool(true)
+bool(true)
+bool(true)
+int(0)
+-- link opened in a mode --
+bool(true)
+bool(true)
+bool(true)
+int(0)
+-- link opened in ab mode --
+bool(true)
+bool(true)
+bool(true)
+int(0)
+-- link opened in at mode --
+bool(true)
+bool(true)
+bool(true)
+int(0)
+-- link opened in a+ mode --
+bool(true)
+bool(true)
+bool(true)
+int(0)
+-- link opened in a+b mode --
+bool(true)
+bool(true)
+bool(true)
+int(0)
+-- link opened in a+t mode --
+bool(true)
+bool(true)
+bool(true)
+int(0)
+-- Iteration 2 with file containing numeric data --
+-- link opened in w mode --
+bool(true)
+bool(true)
+bool(true)
+22222222222222222222222222222222222222222222222222int(50)
+-- link opened in wb mode --
+bool(true)
+bool(true)
+bool(true)
+22222222222222222222222222222222222222222222222222int(50)
+-- link opened in wt mode --
+bool(true)
+bool(true)
+bool(true)
+22222222222222222222222222222222222222222222222222int(50)
+-- link opened in w+ mode --
+bool(true)
+bool(true)
+bool(true)
+22222222222222222222222222222222222222222222222222int(50)
+-- link opened in w+b mode --
+bool(true)
+bool(true)
+bool(true)
+22222222222222222222222222222222222222222222222222int(50)
+-- link opened in w+t mode --
+bool(true)
+bool(true)
+bool(true)
+22222222222222222222222222222222222222222222222222int(50)
+-- link opened in a mode --
+bool(true)
+bool(true)
+bool(true)
+222222222222222222222222222222222222222222222222222222222222int(60)
+-- link opened in ab mode --
+bool(true)
+bool(true)
+bool(true)
+222222222222222222222222222222222222222222222222222222222222int(60)
+-- link opened in at mode --
+bool(true)
+bool(true)
+bool(true)
+222222222222222222222222222222222222222222222222222222222222int(60)
+-- link opened in a+ mode --
+bool(true)
+bool(true)
+bool(true)
+222222222222222222222222222222222222222222222222222222222222int(60)
+-- link opened in a+b mode --
+bool(true)
+bool(true)
+bool(true)
+222222222222222222222222222222222222222222222222222222222222int(60)
+-- link opened in a+t mode --
+bool(true)
+bool(true)
+bool(true)
+222222222222222222222222222222222222222222222222222222222222int(60)
+-- Iteration 3 with file containing text data --
+-- link opened in w mode --
+bool(true)
+bool(true)
+bool(true)
+text text text text text text text text text text int(50)
+-- link opened in wb mode --
+bool(true)
+bool(true)
+bool(true)
+text text text text text text text text text text int(50)
+-- link opened in wt mode --
+bool(true)
+bool(true)
+bool(true)
+text text text text text text text text text text int(50)
+-- link opened in w+ mode --
+bool(true)
+bool(true)
+bool(true)
+text text text text text text text text text text int(50)
+-- link opened in w+b mode --
+bool(true)
+bool(true)
+bool(true)
+text text text text text text text text text text int(50)
+-- link opened in w+t mode --
+bool(true)
+bool(true)
+bool(true)
+text text text text text text text text text text int(50)
+-- link opened in a mode --
+bool(true)
+bool(true)
+bool(true)
+text text text text text text text text text text text text int(60)
+-- link opened in ab mode --
+bool(true)
+bool(true)
+bool(true)
+text text text text text text text text text text text text int(60)
+-- link opened in at mode --
+bool(true)
+bool(true)
+bool(true)
+text text text text text text text text text text text text int(60)
+-- link opened in a+ mode --
+bool(true)
+bool(true)
+bool(true)
+text text text text text text text text text text text text int(60)
+-- link opened in a+b mode --
+bool(true)
+bool(true)
+bool(true)
+text text text text text text text text text text text text int(60)
+-- link opened in a+t mode --
+bool(true)
+bool(true)
+bool(true)
+text text text text text text text text text text text text int(60)
+-- Iteration 4 with file containing text_with_new_line data --
+-- link opened in w mode --
+bool(true)
+bool(true)
+bool(true)
+line
+line of text
+line
+line of text
+line
+line of tint(50)
+-- link opened in wb mode --
+bool(true)
+bool(true)
+bool(true)
+line
+line of text
+line
+line of text
+line
+line of tint(50)
+-- link opened in wt mode --
+bool(true)
+bool(true)
+bool(true)
+line
+line of text
+line
+line of text
+line
+line of tint(50)
+-- link opened in w+ mode --
+bool(true)
+bool(true)
+bool(true)
+line
+line of text
+line
+line of text
+line
+line of tint(50)
+-- link opened in w+b mode --
+bool(true)
+bool(true)
+bool(true)
+line
+line of text
+line
+line of text
+line
+line of tint(50)
+-- link opened in w+t mode --
+bool(true)
+bool(true)
+bool(true)
+line
+line of text
+line
+line of text
+line
+line of tint(50)
+-- link opened in a mode --
+bool(true)
+bool(true)
+bool(true)
+line
+line line
+line of text
+line
+line of text
+line
+line of tint(60)
+-- link opened in ab mode --
+bool(true)
+bool(true)
+bool(true)
+line
+line line
+line of text
+line
+line of text
+line
+line of tint(60)
+-- link opened in at mode --
+bool(true)
+bool(true)
+bool(true)
+line
+line line
+line of text
+line
+line of text
+line
+line of tint(60)
+-- link opened in a+ mode --
+bool(true)
+bool(true)
+bool(true)
+line
+line line
+line of text
+line
+line of text
+line
+line of tint(60)
+-- link opened in a+b mode --
+bool(true)
+bool(true)
+bool(true)
+line
+line line
+line of text
+line
+line of text
+line
+line of tint(60)
+-- link opened in a+t mode --
+bool(true)
+bool(true)
+bool(true)
+line
+line line
+line of text
+line
+line of text
+line
+line of tint(60)
+-- Iteration 5 with file containing alphanumeric data --
+-- link opened in w mode --
+bool(true)
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
+-- link opened in wb mode --
+bool(true)
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
+-- link opened in wt mode --
+bool(true)
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
+-- link opened in w+ mode --
+bool(true)
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
+-- link opened in w+b mode --
+bool(true)
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
+-- link opened in w+t mode --
+bool(true)
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
+-- link opened in a mode --
+bool(true)
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60)
+-- link opened in ab mode --
+bool(true)
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60)
+-- link opened in at mode --
+bool(true)
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60)
+-- link opened in a+ mode --
+bool(true)
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60)
+-- link opened in a+b mode --
+bool(true)
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60)
+-- link opened in a+t mode --
+bool(true)
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fflush_variation3.phpt b/ext/standard/tests/file/fflush_variation3.phpt
new file mode 100644
index 0000000..6dfd49b
--- /dev/null
+++ b/ext/standard/tests/file/fflush_variation3.phpt
@@ -0,0 +1,383 @@
+--TEST--
+Test fflush() function: usage variations - hard links as resource
+--SKIPIF--
+<?php
+if( substr(PHP_OS, 0, 3) == 'WIN')
+ die("skip Links not valid on Windows");
+?>
+--FILE--
+<?php
+/* Prototype: bool fflush ( resource $handle );
+ Description: Flushes the output to a file
+*/
+
+/* test fflush() with handle to hard links as resource */
+
+$file_path = dirname(__FILE__);
+require $file_path.'/file.inc';
+
+echo "*** Testing fflush(): with hard links to files opened in diff modes ***\n";
+$file_types = array("empty", "numeric", "text", "text_with_new_line", "alphanumeric");
+$file_modes = array("w", "wb", "wt", "w+", "w+b","w+t",
+ "a", "ab", "at", "a+","a+b", "a+t");
+
+$file_name = "$file_path/fflush_variation3.tmp";
+$link_name = "$file_path/lnk_fflush_variation3.tmp";
+
+$count = 1;
+
+foreach( $file_types as $type ) {
+ echo "-- Iteration $count with file containing $type data --\n";
+ foreach( $file_modes as $mode ) {
+
+ // creating the file
+ $file_handle = fopen($file_name, "w");
+ if($file_handle == false)
+ exit("Error:failed to open file $file_name");
+
+ // fill the fill with some data if mode is append mode
+ if( substr($mode, 0, 1) == "a" )
+ fill_file($file_handle, $type, 10);
+
+ // fclose($file_handle);
+
+ // creating hard link to the file
+ var_dump( link($file_name, $link_name) );
+
+ // opening the file in different modes
+ $file_handle = fopen($link_name, $mode);
+ if($file_handle == false)
+ exit("Error:failed to open link $link_name");
+
+ // writing data to the file
+ var_dump( fill_file($file_handle, $type, 50) );
+ var_dump( fflush($file_handle) );
+ fclose($file_handle);
+
+ // reading data from the file after flushing
+ var_dump( readfile($link_name) );
+
+ unlink($link_name);
+ unlink($file_name);
+ }
+ $count++;
+}
+
+echo "\n*** Done ***";
+?>
+--EXPECTF--
+*** Testing fflush(): with hard links to files opened in diff modes ***
+-- Iteration 1 with file containing empty data --
+bool(true)
+bool(true)
+bool(true)
+int(0)
+bool(true)
+bool(true)
+bool(true)
+int(0)
+bool(true)
+bool(true)
+bool(true)
+int(0)
+bool(true)
+bool(true)
+bool(true)
+int(0)
+bool(true)
+bool(true)
+bool(true)
+int(0)
+bool(true)
+bool(true)
+bool(true)
+int(0)
+bool(true)
+bool(true)
+bool(true)
+int(0)
+bool(true)
+bool(true)
+bool(true)
+int(0)
+bool(true)
+bool(true)
+bool(true)
+int(0)
+bool(true)
+bool(true)
+bool(true)
+int(0)
+bool(true)
+bool(true)
+bool(true)
+int(0)
+bool(true)
+bool(true)
+bool(true)
+int(0)
+-- Iteration 2 with file containing numeric data --
+bool(true)
+bool(true)
+bool(true)
+22222222222222222222222222222222222222222222222222int(50)
+bool(true)
+bool(true)
+bool(true)
+22222222222222222222222222222222222222222222222222int(50)
+bool(true)
+bool(true)
+bool(true)
+22222222222222222222222222222222222222222222222222int(50)
+bool(true)
+bool(true)
+bool(true)
+22222222222222222222222222222222222222222222222222int(50)
+bool(true)
+bool(true)
+bool(true)
+22222222222222222222222222222222222222222222222222int(50)
+bool(true)
+bool(true)
+bool(true)
+22222222222222222222222222222222222222222222222222int(50)
+bool(true)
+bool(true)
+bool(true)
+222222222222222222222222222222222222222222222222222222222222int(60)
+bool(true)
+bool(true)
+bool(true)
+222222222222222222222222222222222222222222222222222222222222int(60)
+bool(true)
+bool(true)
+bool(true)
+222222222222222222222222222222222222222222222222222222222222int(60)
+bool(true)
+bool(true)
+bool(true)
+222222222222222222222222222222222222222222222222222222222222int(60)
+bool(true)
+bool(true)
+bool(true)
+222222222222222222222222222222222222222222222222222222222222int(60)
+bool(true)
+bool(true)
+bool(true)
+222222222222222222222222222222222222222222222222222222222222int(60)
+-- Iteration 3 with file containing text data --
+bool(true)
+bool(true)
+bool(true)
+text text text text text text text text text text int(50)
+bool(true)
+bool(true)
+bool(true)
+text text text text text text text text text text int(50)
+bool(true)
+bool(true)
+bool(true)
+text text text text text text text text text text int(50)
+bool(true)
+bool(true)
+bool(true)
+text text text text text text text text text text int(50)
+bool(true)
+bool(true)
+bool(true)
+text text text text text text text text text text int(50)
+bool(true)
+bool(true)
+bool(true)
+text text text text text text text text text text int(50)
+bool(true)
+bool(true)
+bool(true)
+text text text text text text text text text text text text int(60)
+bool(true)
+bool(true)
+bool(true)
+text text text text text text text text text text text text int(60)
+bool(true)
+bool(true)
+bool(true)
+text text text text text text text text text text text text int(60)
+bool(true)
+bool(true)
+bool(true)
+text text text text text text text text text text text text int(60)
+bool(true)
+bool(true)
+bool(true)
+text text text text text text text text text text text text int(60)
+bool(true)
+bool(true)
+bool(true)
+text text text text text text text text text text text text int(60)
+-- Iteration 4 with file containing text_with_new_line data --
+bool(true)
+bool(true)
+bool(true)
+line
+line of text
+line
+line of text
+line
+line of tint(50)
+bool(true)
+bool(true)
+bool(true)
+line
+line of text
+line
+line of text
+line
+line of tint(50)
+bool(true)
+bool(true)
+bool(true)
+line
+line of text
+line
+line of text
+line
+line of tint(50)
+bool(true)
+bool(true)
+bool(true)
+line
+line of text
+line
+line of text
+line
+line of tint(50)
+bool(true)
+bool(true)
+bool(true)
+line
+line of text
+line
+line of text
+line
+line of tint(50)
+bool(true)
+bool(true)
+bool(true)
+line
+line of text
+line
+line of text
+line
+line of tint(50)
+bool(true)
+bool(true)
+bool(true)
+line
+line line
+line of text
+line
+line of text
+line
+line of tint(60)
+bool(true)
+bool(true)
+bool(true)
+line
+line line
+line of text
+line
+line of text
+line
+line of tint(60)
+bool(true)
+bool(true)
+bool(true)
+line
+line line
+line of text
+line
+line of text
+line
+line of tint(60)
+bool(true)
+bool(true)
+bool(true)
+line
+line line
+line of text
+line
+line of text
+line
+line of tint(60)
+bool(true)
+bool(true)
+bool(true)
+line
+line line
+line of text
+line
+line of text
+line
+line of tint(60)
+bool(true)
+bool(true)
+bool(true)
+line
+line line
+line of text
+line
+line of text
+line
+line of tint(60)
+-- Iteration 5 with file containing alphanumeric data --
+bool(true)
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
+bool(true)
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
+bool(true)
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
+bool(true)
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
+bool(true)
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
+bool(true)
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(50)
+bool(true)
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60)
+bool(true)
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60)
+bool(true)
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60)
+bool(true)
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60)
+bool(true)
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60)
+bool(true)
+bool(true)
+bool(true)
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 int(60)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fflush_variation4.phpt b/ext/standard/tests/file/fflush_variation4.phpt
new file mode 100644
index 0000000..f98616c
--- /dev/null
+++ b/ext/standard/tests/file/fflush_variation4.phpt
@@ -0,0 +1,53 @@
+--TEST--
+Test fflush() function: usage variations - file opened in read-only mode
+--FILE--
+<?php
+/* Prototype: bool fflush ( resource $handle );
+ Description: Flushes the output to a file
+*/
+
+/* test fflush() with handle to a file opened in read-only mode as resource */
+
+$file_path = dirname(__FILE__);
+require $file_path.'/file.inc';
+
+echo "*** Testing fflush(): with file handles of files opened in various read modes ***\n";
+$file_modes = array("r", "rb", "rt");
+
+$file_name = "$file_path/fflush_variation4.tmp";
+
+$count = 1;
+
+foreach( $file_modes as $mode ) {
+ echo "-- Iteration $count with file opened in $mode mode --\n";
+
+ // creating a file
+ $file_handle = fopen($file_name, "w");
+ if($file_handle == false)
+ exit("Error:failed to open file $file_name");
+ fclose($file_handle);
+
+ // opening the file in different read modes
+ $file_handle = fopen($file_name, $mode);
+ if($file_handle == false)
+ exit("Error:failed to open file $file_name");
+ var_dump( fflush($file_handle) );
+ fclose($file_handle);
+
+ unlink($file_name);
+ $count++;
+}
+
+echo "\n*** Done ***";
+?>
+--EXPECTF--
+*** Testing fflush(): with file handles of files opened in various read modes ***
+-- Iteration 1 with file opened in r mode --
+bool(true)
+-- Iteration 2 with file opened in rb mode --
+bool(true)
+-- Iteration 3 with file opened in rt mode --
+bool(true)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fgetc_basic.phpt b/ext/standard/tests/file/fgetc_basic.phpt
new file mode 100644
index 0000000..7851e43
--- /dev/null
+++ b/ext/standard/tests/file/fgetc_basic.phpt
@@ -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], 0755, 1, "w", "fgetc_basic", 1);
+
+ //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__)."/fgetc_basic1.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 at least 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, "fgetc_basic", 1, ".tmp");
+
+} // 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(%d) of type (stream)
+string(1) "2"
+int(2)
+bool(false)
+resource(%d) of type (stream)
+string(1) "2"
+int(3)
+bool(false)
+resource(%d) of type (stream)
+string(1) "2"
+int(4)
+bool(false)
+resource(%d) of type (stream)
+string(1) "2"
+int(5)
+bool(false)
+resource(%d) of type (stream)
+string(1) "2"
+int(6)
+bool(false)
+resource(%d) 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(%d) of type (stream)
+string(1) "2"
+int(2)
+bool(false)
+resource(%d) of type (stream)
+string(1) "2"
+int(3)
+bool(false)
+resource(%d) of type (stream)
+string(1) "2"
+int(4)
+bool(false)
+resource(%d) of type (stream)
+string(1) "2"
+int(5)
+bool(false)
+resource(%d) of type (stream)
+string(1) "2"
+int(6)
+bool(false)
+resource(%d) 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(%d) of type (stream)
+string(1) "2"
+int(2)
+bool(false)
+resource(%d) of type (stream)
+string(1) "2"
+int(3)
+bool(false)
+resource(%d) of type (stream)
+string(1) "2"
+int(4)
+bool(false)
+resource(%d) of type (stream)
+string(1) "2"
+int(5)
+bool(false)
+resource(%d) of type (stream)
+string(1) "2"
+int(6)
+bool(false)
+resource(%d) 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(%d) of type (stream)
+string(1) "2"
+int(2)
+bool(false)
+resource(%d) of type (stream)
+string(1) "2"
+int(3)
+bool(false)
+resource(%d) of type (stream)
+string(1) "2"
+int(4)
+bool(false)
+resource(%d) of type (stream)
+string(1) "2"
+int(5)
+bool(false)
+resource(%d) of type (stream)
+string(1) "2"
+int(6)
+bool(false)
+resource(%d) 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(%d) of type (stream)
+string(1) "2"
+int(2)
+bool(false)
+resource(%d) of type (stream)
+string(1) "2"
+int(3)
+bool(false)
+resource(%d) of type (stream)
+string(1) "2"
+int(4)
+bool(false)
+resource(%d) of type (stream)
+string(1) "2"
+int(5)
+bool(false)
+resource(%d) of type (stream)
+string(1) "2"
+int(6)
+bool(false)
+resource(%d) 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(%d) of type (stream)
+string(1) "2"
+int(2)
+bool(false)
+resource(%d) of type (stream)
+string(1) "2"
+int(3)
+bool(false)
+resource(%d) of type (stream)
+string(1) "2"
+int(4)
+bool(false)
+resource(%d) of type (stream)
+string(1) "2"
+int(5)
+bool(false)
+resource(%d) of type (stream)
+string(1) "2"
+int(6)
+bool(false)
+resource(%d) 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(%d) of type (stream)
+string(1) "e"
+int(2)
+bool(false)
+resource(%d) of type (stream)
+string(1) "x"
+int(3)
+bool(false)
+resource(%d) of type (stream)
+string(1) "t"
+int(4)
+bool(false)
+resource(%d) of type (stream)
+string(1) " "
+int(5)
+bool(false)
+resource(%d) of type (stream)
+string(1) "t"
+int(6)
+bool(false)
+resource(%d) 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(%d) of type (stream)
+string(1) "e"
+int(2)
+bool(false)
+resource(%d) of type (stream)
+string(1) "x"
+int(3)
+bool(false)
+resource(%d) of type (stream)
+string(1) "t"
+int(4)
+bool(false)
+resource(%d) of type (stream)
+string(1) " "
+int(5)
+bool(false)
+resource(%d) of type (stream)
+string(1) "t"
+int(6)
+bool(false)
+resource(%d) 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(%d) of type (stream)
+string(1) "e"
+int(2)
+bool(false)
+resource(%d) of type (stream)
+string(1) "x"
+int(3)
+bool(false)
+resource(%d) of type (stream)
+string(1) "t"
+int(4)
+bool(false)
+resource(%d) of type (stream)
+string(1) " "
+int(5)
+bool(false)
+resource(%d) of type (stream)
+string(1) "t"
+int(6)
+bool(false)
+resource(%d) 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(%d) of type (stream)
+string(1) "e"
+int(2)
+bool(false)
+resource(%d) of type (stream)
+string(1) "x"
+int(3)
+bool(false)
+resource(%d) of type (stream)
+string(1) "t"
+int(4)
+bool(false)
+resource(%d) of type (stream)
+string(1) " "
+int(5)
+bool(false)
+resource(%d) of type (stream)
+string(1) "t"
+int(6)
+bool(false)
+resource(%d) 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(%d) of type (stream)
+string(1) "e"
+int(2)
+bool(false)
+resource(%d) of type (stream)
+string(1) "x"
+int(3)
+bool(false)
+resource(%d) of type (stream)
+string(1) "t"
+int(4)
+bool(false)
+resource(%d) of type (stream)
+string(1) " "
+int(5)
+bool(false)
+resource(%d) of type (stream)
+string(1) "t"
+int(6)
+bool(false)
+resource(%d) 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(%d) of type (stream)
+string(1) "e"
+int(2)
+bool(false)
+resource(%d) of type (stream)
+string(1) "x"
+int(3)
+bool(false)
+resource(%d) of type (stream)
+string(1) "t"
+int(4)
+bool(false)
+resource(%d) of type (stream)
+string(1) " "
+int(5)
+bool(false)
+resource(%d) of type (stream)
+string(1) "t"
+int(6)
+bool(false)
+resource(%d) 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(%d) of type (stream)
+string(1) "i"
+int(2)
+bool(false)
+resource(%d) of type (stream)
+string(1) "n"
+int(3)
+bool(false)
+resource(%d) of type (stream)
+string(1) "e"
+int(4)
+bool(false)
+resource(%d) of type (stream)
+string(1) "
+"
+int(5)
+bool(false)
+resource(%d) of type (stream)
+string(1) "l"
+int(6)
+bool(false)
+resource(%d) 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(%d) of type (stream)
+string(1) "i"
+int(2)
+bool(false)
+resource(%d) of type (stream)
+string(1) "n"
+int(3)
+bool(false)
+resource(%d) of type (stream)
+string(1) "e"
+int(4)
+bool(false)
+resource(%d) of type (stream)
+string(1) "
+"
+int(5)
+bool(false)
+resource(%d) of type (stream)
+string(1) "l"
+int(6)
+bool(false)
+resource(%d) 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(%d) of type (stream)
+string(1) "i"
+int(2)
+bool(false)
+resource(%d) of type (stream)
+string(1) "n"
+int(3)
+bool(false)
+resource(%d) of type (stream)
+string(1) "e"
+int(4)
+bool(false)
+resource(%d) of type (stream)
+string(1) "
+"
+int(5)
+bool(false)
+resource(%d) of type (stream)
+string(1) "l"
+int(6)
+bool(false)
+resource(%d) 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(%d) of type (stream)
+string(1) "i"
+int(2)
+bool(false)
+resource(%d) of type (stream)
+string(1) "n"
+int(3)
+bool(false)
+resource(%d) of type (stream)
+string(1) "e"
+int(4)
+bool(false)
+resource(%d) of type (stream)
+string(1) "
+"
+int(5)
+bool(false)
+resource(%d) of type (stream)
+string(1) "l"
+int(6)
+bool(false)
+resource(%d) 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(%d) of type (stream)
+string(1) "i"
+int(2)
+bool(false)
+resource(%d) of type (stream)
+string(1) "n"
+int(3)
+bool(false)
+resource(%d) of type (stream)
+string(1) "e"
+int(4)
+bool(false)
+resource(%d) of type (stream)
+string(1) "
+"
+int(5)
+bool(false)
+resource(%d) of type (stream)
+string(1) "l"
+int(6)
+bool(false)
+resource(%d) 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(%d) of type (stream)
+string(1) "i"
+int(2)
+bool(false)
+resource(%d) of type (stream)
+string(1) "n"
+int(3)
+bool(false)
+resource(%d) of type (stream)
+string(1) "e"
+int(4)
+bool(false)
+resource(%d) of type (stream)
+string(1) "
+"
+int(5)
+bool(false)
+resource(%d) of type (stream)
+string(1) "l"
+int(6)
+bool(false)
+resource(%d) 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
index 0000000..15292d6
--- /dev/null
+++ b/ext/standard/tests/file/fgetc_error.phpt
@@ -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: fgetc() expects exactly 1 parameter, 0 given in %s on line %d
+bool(false)
+-- Testing fgetc() with more than expected number of arguments --
+
+Warning: fgetc() expects exactly 1 parameter, 2 given in %s on line %d
+bool(false)
+-- Testing fgetc() with invalid arguments --
+-- Iteration 1 --
+
+Warning: fgetc() expects parameter 1 to be resource, string given in %s on line %d
+bool(false)
+-- Iteration 2 --
+
+Warning: fgetc() expects parameter 1 to be resource, integer given in %s on line %d
+bool(false)
+-- Iteration 3 --
+
+Warning: fgetc() expects parameter 1 to be resource, double given in %s on line %d
+bool(false)
+-- Iteration 4 --
+
+Warning: fgetc() expects parameter 1 to be resource, boolean given in %s on line %d
+bool(false)
+-- Iteration 5 --
+
+Warning: fgetc() expects parameter 1 to be resource, array given in %s on line %d
+bool(false)
+-- Iteration 6 --
+
+Warning: fgetc() expects parameter 1 to be resource, object given in %s on line %d
+bool(false)
+Done
diff --git a/ext/standard/tests/file/fgetc_variation1.phpt b/ext/standard/tests/file/fgetc_variation1.phpt
new file mode 100644
index 0000000..007b2e0
--- /dev/null
+++ b/ext/standard/tests/file/fgetc_variation1.phpt
@@ -0,0 +1,94 @@
+--TEST--
+Test fgetc() function : usage variations - read when file pointer at EOF
+--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() : usage variations ***\n";
+echo "-- Testing fgetc() with file whose file pointer is pointing to EOF --\n";
+// create a file
+create_files(dirname(__FILE__), 1, "text_with_new_line", 0755, 1, "w", "fgetc_variation");
+
+$filename = dirname(__FILE__)."/fgetc_variation1.tmp";
+
+// loop to check the file opened in different read modes
+$file_modes = array("r", "rb", "rt", "r+", "r+b", "r+t");
+$loop_counter =0;
+for(; $loop_counter < count($file_modes); $loop_counter++) {
+ // print the hearder
+ echo "-- File opened in mode : $file_modes[$loop_counter] --\n";
+ // open the file
+ $file_handle = fopen ($filename, $file_modes[$loop_counter]);
+ if (!$file_handle) {
+ echo "Error: failed to open file $filename! \n";
+ exit();
+ }
+
+ // seek to end of the file and try fgetc()
+ var_dump( fseek($file_handle, 0, SEEK_END) ); // set file pointer to eof
+ var_dump( feof($file_handle) ); // expected false
+ var_dump( ftell($file_handle) ); // ensure that file pointer is at eof
+ var_dump( fgetc($file_handle) ); // try n read a char, none expected
+ var_dump( feof($file_handle) ); // ensure thta file pointer is at eof
+ var_dump( ftell($file_handle) ); // file pointer position
+
+ // close the file handle
+ fclose($file_handle);
+}
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+unlink( dirname(__FILE__)."/fgetc_variation1.tmp");
+?>
+--EXPECTF--
+*** Testing fgetc() : usage variations ***
+-- Testing fgetc() with file whose file pointer is pointing to EOF --
+-- File opened in mode : r --
+int(0)
+bool(false)
+int(1024)
+bool(false)
+bool(true)
+int(1024)
+-- File opened in mode : rb --
+int(0)
+bool(false)
+int(1024)
+bool(false)
+bool(true)
+int(1024)
+-- File opened in mode : rt --
+int(0)
+bool(false)
+int(1024)
+bool(false)
+bool(true)
+int(1024)
+-- File opened in mode : r+ --
+int(0)
+bool(false)
+int(1024)
+bool(false)
+bool(true)
+int(1024)
+-- File opened in mode : r+b --
+int(0)
+bool(false)
+int(1024)
+bool(false)
+bool(true)
+int(1024)
+-- File opened in mode : r+t --
+int(0)
+bool(false)
+int(1024)
+bool(false)
+bool(true)
+int(1024)
+Done
diff --git a/ext/standard/tests/file/fgetc_variation2.phpt b/ext/standard/tests/file/fgetc_variation2.phpt
new file mode 100644
index 0000000..380c1aa
--- /dev/null
+++ b/ext/standard/tests/file/fgetc_variation2.phpt
@@ -0,0 +1,52 @@
+--TEST--
+Test fgetc() function : usage variations - closed handle
+--FILE--
+<?php
+/*
+ Prototype: string fgetc ( resource $handle );
+ Description: Gets character from file pointer
+*/
+
+/* try reading a char using fgetc() using invalid handles
+ - closed file handle
+ - unset file handle
+*/
+
+// include the header for common test function
+include ("file.inc");
+
+echo "*** Testing fgetc() : usage variations ***\n";
+
+echo "-- Testing fgetc() with closed handle --\n";
+// open the file for reading
+$file_handle = fopen(__FILE__, "r");
+// close the file
+fclose($file_handle);
+
+// read from closed file
+var_dump( fgetc($file_handle) );
+
+echo "-- Testing fgetc() with unset handle --\n";
+// open the file for reading
+$file_handle = fopen(__FILE__, "r");
+// unset the file handle
+unset($file_handle);
+
+//fgetc using unset handle
+var_dump( fgetc($file_handle) );
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing fgetc() : usage variations ***
+-- Testing fgetc() with closed handle --
+
+Warning: fgetc(): %d is not a valid stream resource in %s on line %d
+bool(false)
+-- Testing fgetc() with unset handle --
+
+Notice: Undefined variable: file_handle in %s on line %d
+
+Warning: fgetc() expects parameter 1 to be resource, null given in %s on line %d
+bool(false)
+Done
diff --git a/ext/standard/tests/file/fgetc_variation3.phpt b/ext/standard/tests/file/fgetc_variation3.phpt
new file mode 100644
index 0000000..f834998
--- /dev/null
+++ b/ext/standard/tests/file/fgetc_variation3.phpt
@@ -0,0 +1,117 @@
+--TEST--
+Test fgetc() function : usage variations - write only modes (Bug #42036)
+--FILE--
+<?php
+/*
+ Prototype: string fgetc ( resource $handle );
+ Description: Gets character from file pointer
+*/
+
+/* try fgetc on files which are opened in non readable modes
+ w, wb, wt,
+ a, ab, at,
+ x, xb, xt
+*/
+// include the header for common test function
+include ("file.inc");
+
+echo "*** Testing fgetc() with file opened in write only mode ***\n";
+
+$file_modes = array("w", "wb", "wt", "a", "ab", "at", "x", "xb", "xt");
+$filename = dirname(__FILE__)."/fgetc_variation3.tmp";
+foreach ($file_modes as $file_mode ) {
+ echo "-- File opened in mode : $file_mode --\n";
+
+ $file_handle = fopen($filename, $file_mode);
+ if(!$file_handle) {
+ echo "Error: failed to open file $filename!\n";
+ exit();
+ }
+ $data = "fgetc_variation test";
+ fwrite($file_handle, $data);
+
+ // rewind the file pointer to begining of the file
+ var_dump( rewind($file_handle) );
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ // read from file
+ var_dump( fgetc($file_handle) ); // expected : no chars should be read
+ var_dump( ftell($file_handle) ); // ensure that file pointer position is not changed
+ var_dump( feof($file_handle) ); // check if end of file pointer is set
+
+ // close the file
+ fclose($file_handle);
+
+ // delete the file
+ unlink($filename);
+}
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fgetc() with file opened in write only mode ***
+-- File opened in mode : w --
+bool(true)
+int(0)
+bool(false)
+bool(false)
+int(0)
+bool(false)
+-- File opened in mode : wb --
+bool(true)
+int(0)
+bool(false)
+bool(false)
+int(0)
+bool(false)
+-- File opened in mode : wt --
+bool(true)
+int(0)
+bool(false)
+bool(false)
+int(0)
+bool(false)
+-- File opened in mode : a --
+bool(true)
+int(0)
+bool(false)
+bool(false)
+int(0)
+bool(false)
+-- File opened in mode : ab --
+bool(true)
+int(0)
+bool(false)
+bool(false)
+int(0)
+bool(false)
+-- File opened in mode : at --
+bool(true)
+int(0)
+bool(false)
+bool(false)
+int(0)
+bool(false)
+-- File opened in mode : x --
+bool(true)
+int(0)
+bool(false)
+bool(false)
+int(0)
+bool(false)
+-- File opened in mode : xb --
+bool(true)
+int(0)
+bool(false)
+bool(false)
+int(0)
+bool(false)
+-- File opened in mode : xt --
+bool(true)
+int(0)
+bool(false)
+bool(false)
+int(0)
+bool(false)
+Done
diff --git a/ext/standard/tests/file/fgetc_variation4.phpt b/ext/standard/tests/file/fgetc_variation4.phpt
new file mode 100644
index 0000000..a2bc9e5
--- /dev/null
+++ b/ext/standard/tests/file/fgetc_variation4.phpt
@@ -0,0 +1,290 @@
+--TEST--
+Test fgetc() function : usage variations - different read modes
+--FILE--
+<?php
+/*
+ Prototype: string fgetc ( resource $handle );
+ Description: Gets character from file pointer
+*/
+
+/* read from fie using fgetc, file opened using different
+ read read modes */
+
+echo "*** Testing fgetc() : usage variations ***\n";
+echo "-- Testing fgetc() with files opened with different read modes --\n";
+
+$file_modes = array( "a+", "a+b", "a+t",
+ "x+", "x+b", "x+t",
+ "w+", "w+b", "w+t" );
+
+$filename = dirname(__FILE__)."/fgetc_variation4.tmp";
+foreach ($file_modes as $file_mode ) {
+ echo "-- File opened in mode : $file_mode --\n";
+
+ $file_handle = fopen($filename, $file_mode);
+ if(!$file_handle) {
+ echo "Error: failed to open file $filename!\n";
+ exit();
+ }
+ $data = "fgetc\n test";
+ fwrite($file_handle, $data);
+
+ // rewind the file pointer to begining of the file
+ var_dump( rewind($file_handle) );
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ // read from file, at least 7 chars
+ for($counter =0; $counter < 7; $counter ++) {
+ var_dump( fgetc($file_handle) ); // expected : 1 char
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) ); // check if end of file pointer is set
+ }
+
+ // close the file
+ fclose($file_handle);
+
+ // delete the file
+ unlink($filename);
+}
+
+echo "Done\n";
+?>
+--EXPECTF--
+ *** Testing fgetc() : usage variations ***
+-- Testing fgetc() with files opened with different read modes --
+-- File opened in mode : a+ --
+bool(true)
+int(0)
+bool(false)
+string(1) "f"
+int(1)
+bool(false)
+string(1) "g"
+int(2)
+bool(false)
+string(1) "e"
+int(3)
+bool(false)
+string(1) "t"
+int(4)
+bool(false)
+string(1) "c"
+int(5)
+bool(false)
+string(1) "
+"
+int(6)
+bool(false)
+string(1) " "
+int(7)
+bool(false)
+-- File opened in mode : a+b --
+bool(true)
+int(0)
+bool(false)
+string(1) "f"
+int(1)
+bool(false)
+string(1) "g"
+int(2)
+bool(false)
+string(1) "e"
+int(3)
+bool(false)
+string(1) "t"
+int(4)
+bool(false)
+string(1) "c"
+int(5)
+bool(false)
+string(1) "
+"
+int(6)
+bool(false)
+string(1) " "
+int(7)
+bool(false)
+-- File opened in mode : a+t --
+bool(true)
+int(0)
+bool(false)
+string(1) "f"
+int(1)
+bool(false)
+string(1) "g"
+int(2)
+bool(false)
+string(1) "e"
+int(3)
+bool(false)
+string(1) "t"
+int(4)
+bool(false)
+string(1) "c"
+int(5)
+bool(false)
+string(1) "
+"
+int(6)
+bool(false)
+string(1) " "
+int(7)
+bool(false)
+-- File opened in mode : x+ --
+bool(true)
+int(0)
+bool(false)
+string(1) "f"
+int(1)
+bool(false)
+string(1) "g"
+int(2)
+bool(false)
+string(1) "e"
+int(3)
+bool(false)
+string(1) "t"
+int(4)
+bool(false)
+string(1) "c"
+int(5)
+bool(false)
+string(1) "
+"
+int(6)
+bool(false)
+string(1) " "
+int(7)
+bool(false)
+-- File opened in mode : x+b --
+bool(true)
+int(0)
+bool(false)
+string(1) "f"
+int(1)
+bool(false)
+string(1) "g"
+int(2)
+bool(false)
+string(1) "e"
+int(3)
+bool(false)
+string(1) "t"
+int(4)
+bool(false)
+string(1) "c"
+int(5)
+bool(false)
+string(1) "
+"
+int(6)
+bool(false)
+string(1) " "
+int(7)
+bool(false)
+-- File opened in mode : x+t --
+bool(true)
+int(0)
+bool(false)
+string(1) "f"
+int(1)
+bool(false)
+string(1) "g"
+int(2)
+bool(false)
+string(1) "e"
+int(3)
+bool(false)
+string(1) "t"
+int(4)
+bool(false)
+string(1) "c"
+int(5)
+bool(false)
+string(1) "
+"
+int(6)
+bool(false)
+string(1) " "
+int(7)
+bool(false)
+-- File opened in mode : w+ --
+bool(true)
+int(0)
+bool(false)
+string(1) "f"
+int(1)
+bool(false)
+string(1) "g"
+int(2)
+bool(false)
+string(1) "e"
+int(3)
+bool(false)
+string(1) "t"
+int(4)
+bool(false)
+string(1) "c"
+int(5)
+bool(false)
+string(1) "
+"
+int(6)
+bool(false)
+string(1) " "
+int(7)
+bool(false)
+-- File opened in mode : w+b --
+bool(true)
+int(0)
+bool(false)
+string(1) "f"
+int(1)
+bool(false)
+string(1) "g"
+int(2)
+bool(false)
+string(1) "e"
+int(3)
+bool(false)
+string(1) "t"
+int(4)
+bool(false)
+string(1) "c"
+int(5)
+bool(false)
+string(1) "
+"
+int(6)
+bool(false)
+string(1) " "
+int(7)
+bool(false)
+-- File opened in mode : w+t --
+bool(true)
+int(0)
+bool(false)
+string(1) "f"
+int(1)
+bool(false)
+string(1) "g"
+int(2)
+bool(false)
+string(1) "e"
+int(3)
+bool(false)
+string(1) "t"
+int(4)
+bool(false)
+string(1) "c"
+int(5)
+bool(false)
+string(1) "
+"
+int(6)
+bool(false)
+string(1) " "
+int(7)
+bool(false)
+Done \ No newline at end of file
diff --git a/ext/standard/tests/file/fgetcsv.phpt b/ext/standard/tests/file/fgetcsv.phpt
new file mode 100644
index 0000000..868212c
--- /dev/null
+++ b/ext/standard/tests/file/fgetcsv.phpt
@@ -0,0 +1,158 @@
+--TEST--
+various fgetcsv() functionality tests
+--FILE--
+<?php
+ $list = array(
+ 'aaa,bbb',
+ 'aaa,"bbb"',
+ '"aaa","bbb"',
+ 'aaa,bbb',
+ '"aaa",bbb',
+ '"aaa", "bbb"',
+ ',',
+ 'aaa,',
+ ',"aaa"',
+ '"",""',
+ '"\\"","aaa"',
+ '"""""",',
+ '""""",aaa',
+ '"\\""",aaa',
+ 'aaa,"\\"bbb,ccc',
+ 'aaa,bbb ',
+ 'aaa,"bbb "',
+ 'aaa"aaa","bbb"bbb',
+ 'aaa"aaa""",bbb',
+ 'aaa"\\"a","bbb"'
+ );
+
+ $file = dirname(__FILE__) . 'fgetcsv.csv';
+ @unlink($file);
+ foreach ($list as $v) {
+ $fp = fopen($file, "w");
+ fwrite($fp, $v . "\n");
+ fclose($fp);
+
+ var_dump(fgetcsv(fopen($file, "r"), 1024));
+ }
+ @unlink($file);
+?>
+--EXPECT--
+array(2) {
+ [0]=>
+ string(3) "aaa"
+ [1]=>
+ string(3) "bbb"
+}
+array(2) {
+ [0]=>
+ string(3) "aaa"
+ [1]=>
+ string(3) "bbb"
+}
+array(2) {
+ [0]=>
+ string(3) "aaa"
+ [1]=>
+ string(3) "bbb"
+}
+array(2) {
+ [0]=>
+ string(3) "aaa"
+ [1]=>
+ string(3) "bbb"
+}
+array(2) {
+ [0]=>
+ string(3) "aaa"
+ [1]=>
+ string(3) "bbb"
+}
+array(2) {
+ [0]=>
+ string(3) "aaa"
+ [1]=>
+ string(3) "bbb"
+}
+array(2) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(0) ""
+}
+array(2) {
+ [0]=>
+ string(3) "aaa"
+ [1]=>
+ string(0) ""
+}
+array(2) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(3) "aaa"
+}
+array(2) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(0) ""
+}
+array(2) {
+ [0]=>
+ string(2) "\""
+ [1]=>
+ string(3) "aaa"
+}
+array(2) {
+ [0]=>
+ string(2) """"
+ [1]=>
+ string(0) ""
+}
+array(1) {
+ [0]=>
+ string(7) """,aaa
+"
+}
+array(1) {
+ [0]=>
+ string(8) "\"",aaa
+"
+}
+array(2) {
+ [0]=>
+ string(3) "aaa"
+ [1]=>
+ string(10) "\"bbb,ccc
+"
+}
+array(2) {
+ [0]=>
+ string(3) "aaa"
+ [1]=>
+ string(6) "bbb "
+}
+array(2) {
+ [0]=>
+ string(3) "aaa"
+ [1]=>
+ string(6) "bbb "
+}
+array(2) {
+ [0]=>
+ string(8) "aaa"aaa""
+ [1]=>
+ string(6) "bbbbbb"
+}
+array(2) {
+ [0]=>
+ string(10) "aaa"aaa""""
+ [1]=>
+ string(3) "bbb"
+}
+array(2) {
+ [0]=>
+ string(8) "aaa"\"a""
+ [1]=>
+ string(3) "bbb"
+}
diff --git a/ext/standard/tests/file/fgetcsv_error.phpt b/ext/standard/tests/file/fgetcsv_error.phpt
new file mode 100644
index 0000000..e2db9f8
--- /dev/null
+++ b/ext/standard/tests/file/fgetcsv_error.phpt
@@ -0,0 +1,96 @@
+--TEST--
+Test fgetcsv() function : error conditions
+--FILE--
+<?php
+/*
+ Prototype: array fgetcsv ( resource $handle [, int $length [, string $delimiter [, string $enclosure [, string $escape]]]] );
+ Description: Gets line from file pointer and parse for CSV fields
+*/
+
+echo "*** Testing error conditions ***\n";
+// zero argument
+echo "-- Testing fgetcsv() with zero argument --\n";
+var_dump( fgetcsv() );
+
+// more than expected no. of args
+echo "-- Testing fgetcsv() with more than expected number of arguments --\n";
+$fp = fopen(__FILE__, "r");
+$len = 1024;
+$delim = ";";
+$enclosure ="\"";
+$escape = '"';
+var_dump( fgetcsv($fp, $len, $delim, $enclosure, $escape, $fp) );
+fclose($fp);
+
+// test invalid arguments : non-resources
+echo "-- Testing fgetcsv() with invalid arguments --\n";
+$invalid_args = array (
+ "string",
+ 10,
+ 10.5,
+ true,
+ array(1,2,3),
+ new stdclass,
+);
+/* loop to test fgetcsv() with different invalid type of args */
+for($loop_counter = 1; $loop_counter <= count($invalid_args); $loop_counter++) {
+ echo "-- Iteration $loop_counter --\n";
+ var_dump( fgetcsv($invalid_args[$loop_counter - 1]) ); // with default args
+ var_dump( fgetcsv($invalid_args[$loop_counter - 1], $len, $delim, $enclosure, $escape) ); // all args specified
+}
+
+echo "Done\n";
+--EXPECTF--
+*** Testing error conditions ***
+-- Testing fgetcsv() with zero argument --
+
+Warning: fgetcsv() expects at least 1 parameter, 0 given in %s on line %d
+NULL
+-- Testing fgetcsv() with more than expected number of arguments --
+
+Warning: fgetcsv() expects at most 5 parameters, 6 given in %s on line %d
+NULL
+-- Testing fgetcsv() with invalid arguments --
+-- Iteration 1 --
+
+Warning: fgetcsv() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Warning: fgetcsv() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+-- Iteration 2 --
+
+Warning: fgetcsv() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+
+Warning: fgetcsv() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+-- Iteration 3 --
+
+Warning: fgetcsv() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+
+Warning: fgetcsv() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+-- Iteration 4 --
+
+Warning: fgetcsv() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+
+Warning: fgetcsv() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+-- Iteration 5 --
+
+Warning: fgetcsv() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+
+Warning: fgetcsv() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+-- Iteration 6 --
+
+Warning: fgetcsv() expects parameter 1 to be resource, object given in %s on line %d
+NULL
+
+Warning: fgetcsv() expects parameter 1 to be resource, object given in %s on line %d
+NULL
+Done
diff --git a/ext/standard/tests/file/fgetcsv_variation1.phpt b/ext/standard/tests/file/fgetcsv_variation1.phpt
new file mode 100644
index 0000000..8a698e4
--- /dev/null
+++ b/ext/standard/tests/file/fgetcsv_variation1.phpt
@@ -0,0 +1,1412 @@
+--TEST--
+Test fgetcsv() : usage variations - with all parameters specified
+--FILE--
+<?php
+/*
+ Prototype: array fgetcsv ( resource $handle [, int $length [, string $delimiter [, string $enclosure]]] );
+ Description: Gets line from file pointer and parse for CSV fields
+*/
+
+/* Testing fgetcsv() to read a file when all its parameters are provided */
+
+echo "*** Testing fgetcsv() : with all parameters specified ***\n";
+
+/* the array is with three elements in it. Each element should be read as
+ 1st element is delimiter, 2nd element is enclosure
+ and 3rd element is csv fields
+*/
+$csv_lists = array (
+ array(',', '"', '"water",fruit'),
+ array(',', '"', '"water","fruit"'),
+ array(' ', '^', '^water^ ^fruit^'),
+ array(':', '&', '&water&:&fruit&'),
+ array('=', '=', '=water===fruit='),
+ array('-', '-', '-water--fruit-air'),
+ array('-', '-', '-water---fruit---air-'),
+ array(':', '&', '&""""&:&"&:,:":&,&:,,,,')
+);
+
+$filename = dirname(__FILE__) . '/fgetcsv_variation1.tmp';
+@unlink($filename);
+
+$file_modes = array ("r","rb", "rt", "r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $file_handle = fopen($filename, "w");
+ } else {
+ $file_handle = fopen($filename, $file_modes[$mode_counter] );
+ }
+ if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+ }
+ $delimiter = $csv_list[0];
+ $enclosure = $csv_list[1];
+ $csv_field = $csv_list[2];
+
+ fwrite($file_handle, $csv_field . "\n");
+ // write another line of text and a blank line
+ // this will be used to test, if the fgetcsv() read more than a line and its
+ // working when only a blank line is read
+ fwrite($file_handle, "This is line of text without csv fields\n");
+ fwrite($file_handle, "\n"); // blank line
+
+ // close the file if the mode to be used is read mode and re-open using read mode
+ // else rewind the file pointer to begining of the file
+ if ( strstr($file_modes[$mode_counter], "r" ) ) {
+ fclose($file_handle);
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ } else {
+ // rewind the file pointer to bof
+ rewind($file_handle);
+ }
+
+ echo "\n-- Testing fgetcsv() with file opened using $file_modes[$mode_counter] mode --\n";
+
+ // call fgetcsv() to parse csv fields
+
+ // use the right delimiter and enclosure with max length
+ var_dump( fgetcsv($file_handle, 1024, $delimiter, $enclosure) );
+ // check the file pointer position and if eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ // close the file
+ fclose($file_handle);
+ //delete file
+ unlink($filename);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECT--
+*** Testing fgetcsv() : with all parameters specified ***
+
+-- Testing fgetcsv() with file opened using r mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(2) {
+ [0]=>
+ string(11) "water=fruit"
+ [1]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(2) {
+ [0]=>
+ string(11) "water=fruit"
+ [1]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(2) {
+ [0]=>
+ string(11) "water=fruit"
+ [1]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(2) {
+ [0]=>
+ string(11) "water=fruit"
+ [1]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(2) {
+ [0]=>
+ string(11) "water=fruit"
+ [1]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(2) {
+ [0]=>
+ string(11) "water=fruit"
+ [1]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(2) {
+ [0]=>
+ string(11) "water=fruit"
+ [1]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(2) {
+ [0]=>
+ string(11) "water=fruit"
+ [1]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(2) {
+ [0]=>
+ string(11) "water=fruit"
+ [1]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(2) {
+ [0]=>
+ string(11) "water=fruit"
+ [1]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(2) {
+ [0]=>
+ string(11) "water=fruit"
+ [1]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(2) {
+ [0]=>
+ string(11) "water=fruit"
+ [1]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(2) {
+ [0]=>
+ string(11) "water=fruit"
+ [1]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(2) {
+ [0]=>
+ string(11) "water=fruit"
+ [1]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(2) {
+ [0]=>
+ string(11) "water=fruit"
+ [1]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(3) {
+ [0]=>
+ string(11) "water-fruit"
+ [1]=>
+ string(3) "air"
+ [2]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(3) {
+ [0]=>
+ string(11) "water-fruit"
+ [1]=>
+ string(3) "air"
+ [2]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(3) {
+ [0]=>
+ string(11) "water-fruit"
+ [1]=>
+ string(3) "air"
+ [2]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(3) {
+ [0]=>
+ string(11) "water-fruit"
+ [1]=>
+ string(3) "air"
+ [2]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(3) {
+ [0]=>
+ string(11) "water-fruit"
+ [1]=>
+ string(3) "air"
+ [2]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(3) {
+ [0]=>
+ string(11) "water-fruit"
+ [1]=>
+ string(3) "air"
+ [2]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(3) {
+ [0]=>
+ string(11) "water-fruit"
+ [1]=>
+ string(3) "air"
+ [2]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(3) {
+ [0]=>
+ string(11) "water-fruit"
+ [1]=>
+ string(3) "air"
+ [2]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(3) {
+ [0]=>
+ string(11) "water-fruit"
+ [1]=>
+ string(3) "air"
+ [2]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(3) {
+ [0]=>
+ string(11) "water-fruit"
+ [1]=>
+ string(3) "air"
+ [2]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(3) {
+ [0]=>
+ string(11) "water-fruit"
+ [1]=>
+ string(3) "air"
+ [2]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(3) {
+ [0]=>
+ string(11) "water-fruit"
+ [1]=>
+ string(3) "air"
+ [2]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(3) {
+ [0]=>
+ string(11) "water-fruit"
+ [1]=>
+ string(3) "air"
+ [2]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(3) {
+ [0]=>
+ string(11) "water-fruit"
+ [1]=>
+ string(3) "air"
+ [2]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(3) {
+ [0]=>
+ string(11) "water-fruit"
+ [1]=>
+ string(3) "air"
+ [2]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(6) {
+ [0]=>
+ string(4) """"""
+ [1]=>
+ string(1) """
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(1) ","
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(6) {
+ [0]=>
+ string(4) """"""
+ [1]=>
+ string(1) """
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(1) ","
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(6) {
+ [0]=>
+ string(4) """"""
+ [1]=>
+ string(1) """
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(1) ","
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(6) {
+ [0]=>
+ string(4) """"""
+ [1]=>
+ string(1) """
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(1) ","
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(6) {
+ [0]=>
+ string(4) """"""
+ [1]=>
+ string(1) """
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(1) ","
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(6) {
+ [0]=>
+ string(4) """"""
+ [1]=>
+ string(1) """
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(1) ","
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(6) {
+ [0]=>
+ string(4) """"""
+ [1]=>
+ string(1) """
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(1) ","
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(6) {
+ [0]=>
+ string(4) """"""
+ [1]=>
+ string(1) """
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(1) ","
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(6) {
+ [0]=>
+ string(4) """"""
+ [1]=>
+ string(1) """
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(1) ","
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(6) {
+ [0]=>
+ string(4) """"""
+ [1]=>
+ string(1) """
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(1) ","
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(6) {
+ [0]=>
+ string(4) """"""
+ [1]=>
+ string(1) """
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(1) ","
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(6) {
+ [0]=>
+ string(4) """"""
+ [1]=>
+ string(1) """
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(1) ","
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(6) {
+ [0]=>
+ string(4) """"""
+ [1]=>
+ string(1) """
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(1) ","
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(6) {
+ [0]=>
+ string(4) """"""
+ [1]=>
+ string(1) """
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(1) ","
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(6) {
+ [0]=>
+ string(4) """"""
+ [1]=>
+ string(1) """
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(1) ","
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+Done
diff --git a/ext/standard/tests/file/fgetcsv_variation10.phpt b/ext/standard/tests/file/fgetcsv_variation10.phpt
new file mode 100644
index 0000000..250237c
--- /dev/null
+++ b/ext/standard/tests/file/fgetcsv_variation10.phpt
@@ -0,0 +1,1295 @@
+--TEST--
+Test fgetcsv() : usage variations - file pointer pointing to EOF
+--FILE--
+<?php
+/*
+ Prototype: array fgetcsv ( resource $handle [, int $length [, string $delimiter [, string $enclosure]]] );
+ Description: Gets line from file pointer and parse for CSV fields
+*/
+
+/* Testing fgetcsv() by reading from a file when the file pointer is pointing to end of file */
+
+echo "*** Testing fgetcsv() : with file pointer pointing to EOF ***\n";
+
+/* the array is with three elements in it. Each element should be read as
+ 1st element is delimiter, 2nd element is enclosure
+ and 3rd element is csv fields
+*/
+$csv_lists = array (
+ array(',', '"', '"water",fruit'),
+ array(',', '"', '"water","fruit"'),
+ array(' ', '^', '^water^ ^fruit^'),
+ array(':', '&', '&water&:&fruit&'),
+ array('=', '=', '=water===fruit='),
+ array('-', '-', '-water--fruit-air'),
+ array('-', '-', '-water---fruit---air-'),
+ array(':', '&', '&""""&:&"&:,:":&,&:,,,,')
+);
+
+$filename = dirname(__FILE__) . '/fgetcsv_variation10.tmp';
+@unlink($filename);
+
+$file_modes = array ("r","rb", "rt", "r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $file_handle = fopen($filename, "w");
+ } else {
+ $file_handle = fopen($filename, $file_modes[$mode_counter] );
+ }
+ if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+ }
+ $delimiter = $csv_list[0];
+ $enclosure = $csv_list[1];
+ $csv_field = $csv_list[2];
+ fwrite($file_handle, $csv_field . "\n");
+ // write another line of text and a blank line
+ // this will be used to test, if the fgetcsv() read more than a line and its
+ // working when only a blank line is read
+ fwrite($file_handle, "This is line of text without csv fields\n");
+ fwrite($file_handle, "\n"); // blank line
+
+ // close the file if the mode to be used is read mode and re-open using read mode
+ // else rewind the file pointer to begining of the file
+ if ( strstr($file_modes[$mode_counter], "r" ) ) {
+ fclose($file_handle);
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ }
+ echo "\n-- Testing fgetcsv() with file opened using $file_modes[$mode_counter] mode --\n";
+
+ // set the file pointer to EOF
+ var_dump( fseek($file_handle, 0, SEEK_END) );
+
+ // call fgetcsv() to parse csv fields
+
+ // now file pointer should point to end of the file, try reading again
+ var_dump( feof($file_handle) );
+ var_dump( fgetcsv($file_handle, 1024, $delimiter, $enclosure) );
+ // check the file pointer position and if eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+ var_dump( fgetcsv($file_handle) ); // with default args
+ // check the file pointer position and if eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ // close the file
+ fclose($file_handle);
+ //delete file
+ unlink($filename);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fgetcsv() : with file pointer pointing to EOF ***
+
+-- Testing fgetcsv() with file opened using r mode --
+int(0)
+bool(false)
+bool(false)
+int(55)
+bool(true)
+bool(false)
+int(55)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rb mode --
+int(0)
+bool(false)
+bool(false)
+int(55)
+bool(true)
+bool(false)
+int(55)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rt mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+int(0)
+bool(false)
+bool(false)
+int(55)
+bool(true)
+bool(false)
+int(55)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+int(0)
+bool(false)
+bool(false)
+int(55)
+bool(true)
+bool(false)
+int(55)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+int(0)
+bool(false)
+bool(false)
+int(55)
+bool(true)
+bool(false)
+int(55)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+int(0)
+bool(false)
+bool(false)
+int(55)
+bool(true)
+bool(false)
+int(55)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+int(0)
+bool(false)
+bool(false)
+int(55)
+bool(true)
+bool(false)
+int(55)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+int(0)
+bool(false)
+bool(false)
+int(55)
+bool(true)
+bool(false)
+int(55)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+int(0)
+bool(false)
+bool(false)
+int(55)
+bool(true)
+bool(false)
+int(55)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+int(0)
+bool(false)
+bool(false)
+int(55)
+bool(true)
+bool(false)
+int(55)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rb mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rt mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rb mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rt mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rb mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rt mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rb mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rt mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r mode --
+int(0)
+bool(false)
+bool(false)
+int(59)
+bool(true)
+bool(false)
+int(59)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rb mode --
+int(0)
+bool(false)
+bool(false)
+int(59)
+bool(true)
+bool(false)
+int(59)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rt mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+int(0)
+bool(false)
+bool(false)
+int(59)
+bool(true)
+bool(false)
+int(59)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+int(0)
+bool(false)
+bool(false)
+int(59)
+bool(true)
+bool(false)
+int(59)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+int(0)
+bool(false)
+bool(false)
+int(59)
+bool(true)
+bool(false)
+int(59)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+int(0)
+bool(false)
+bool(false)
+int(59)
+bool(true)
+bool(false)
+int(59)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+int(0)
+bool(false)
+bool(false)
+int(59)
+bool(true)
+bool(false)
+int(59)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+int(0)
+bool(false)
+bool(false)
+int(59)
+bool(true)
+bool(false)
+int(59)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+int(0)
+bool(false)
+bool(false)
+int(59)
+bool(true)
+bool(false)
+int(59)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+int(0)
+bool(false)
+bool(false)
+int(59)
+bool(true)
+bool(false)
+int(59)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r mode --
+int(0)
+bool(false)
+bool(false)
+int(63)
+bool(true)
+bool(false)
+int(63)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rb mode --
+int(0)
+bool(false)
+bool(false)
+int(63)
+bool(true)
+bool(false)
+int(63)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rt mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+int(0)
+bool(false)
+bool(false)
+int(63)
+bool(true)
+bool(false)
+int(63)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+int(0)
+bool(false)
+bool(false)
+int(63)
+bool(true)
+bool(false)
+int(63)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+int(0)
+bool(false)
+bool(false)
+int(63)
+bool(true)
+bool(false)
+int(63)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+int(0)
+bool(false)
+bool(false)
+int(63)
+bool(true)
+bool(false)
+int(63)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+int(0)
+bool(false)
+bool(false)
+int(63)
+bool(true)
+bool(false)
+int(63)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+int(0)
+bool(false)
+bool(false)
+int(63)
+bool(true)
+bool(false)
+int(63)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+int(0)
+bool(false)
+bool(false)
+int(63)
+bool(true)
+bool(false)
+int(63)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+int(0)
+bool(false)
+bool(false)
+int(63)
+bool(true)
+bool(false)
+int(63)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r mode --
+int(0)
+bool(false)
+bool(false)
+int(65)
+bool(true)
+bool(false)
+int(65)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rb mode --
+int(0)
+bool(false)
+bool(false)
+int(65)
+bool(true)
+bool(false)
+int(65)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rt mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+int(0)
+bool(false)
+bool(false)
+int(65)
+bool(true)
+bool(false)
+int(65)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+int(0)
+bool(false)
+bool(false)
+int(65)
+bool(true)
+bool(false)
+int(65)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+int(0)
+bool(false)
+bool(false)
+int(65)
+bool(true)
+bool(false)
+int(65)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+int(0)
+bool(false)
+bool(false)
+int(65)
+bool(true)
+bool(false)
+int(65)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+int(0)
+bool(false)
+bool(false)
+int(65)
+bool(true)
+bool(false)
+int(65)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+int(0)
+bool(false)
+bool(false)
+int(65)
+bool(true)
+bool(false)
+int(65)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+int(0)
+bool(false)
+bool(false)
+int(65)
+bool(true)
+bool(false)
+int(65)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+int(0)
+bool(false)
+bool(false)
+int(65)
+bool(true)
+bool(false)
+int(65)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+bool(false)
+int(%d)
+bool(true)
+Done
diff --git a/ext/standard/tests/file/fgetcsv_variation11.phpt b/ext/standard/tests/file/fgetcsv_variation11.phpt
new file mode 100644
index 0000000..815ede6
--- /dev/null
+++ b/ext/standard/tests/file/fgetcsv_variation11.phpt
@@ -0,0 +1,1835 @@
+--TEST--
+Test fgetcsv() : usage variations - with different enclosure but same delimiter
+--FILE--
+<?php
+/*
+ Prototype: array fgetcsv ( resource $handle [, int $length [, string $delimiter [, string $enclosure]]] );
+ Description: Gets line from file pointer and parse for CSV fields
+*/
+
+/* Testing fgetcsv() by reading from a file when different enclosure that is not
+ present in the data being read and delimiter which is present in the data */
+
+echo "*** Testing fgetcsv() : with different enclosure but same delimiter char ***\n";
+
+/* the array is with three elements in it. Each element should be read as
+ 1st element is delimiter, 2nd element is enclosure
+ and 3rd element is csv fields
+*/
+$csv_lists = array (
+ array(',', '"', '"water",fruit'),
+ array(',', '"', '"water","fruit"'),
+ array(' ', '^', '^water^ ^fruit^'),
+ array(':', '&', '&water&:&fruit&'),
+ array('=', '=', '=water===fruit='),
+ array('-', '-', '-water--fruit-air'),
+ array('-', '-', '-water---fruit---air-'),
+ array(':', '&', '&""""&:&"&:,:":&,&:,,,,')
+);
+
+$filename = dirname(__FILE__) . '/fgetcsv_variation11.tmp';
+@unlink($filename);
+
+$file_modes = array ("r","rb", "rt", "r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $file_handle = fopen($filename, "w");
+ } else {
+ $file_handle = fopen($filename, $file_modes[$mode_counter] );
+ }
+ if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+ }
+ $delimiter = $csv_list[0];
+ $enclosure = $csv_list[1];
+ $csv_field = $csv_list[2];
+ fwrite($file_handle, $csv_field . "\n");
+ // write another line of text and a blank line
+ // this will be used to test, if the fgetcsv() read more than a line and its
+ // working when only a blan line is read
+ fwrite($file_handle, "This is line of text without csv fields\n");
+ fwrite($file_handle, "\n"); // blank line
+
+ // close the file if the mode to be used is read mode and re-open using read mode
+ // else rewind the file pointer to begining of the file
+ if ( strstr($file_modes[$mode_counter], "r" ) ) {
+ fclose($file_handle);
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ } else {
+ // rewind the file pointer to bof
+ rewind($file_handle);
+ }
+
+ echo "\n-- Testing fgetcsv() with file opened using $file_modes[$mode_counter] mode --\n";
+
+ // call fgetcsv() to parse csv fields
+
+
+ // use different delimiter but same enclosure char
+ fseek($file_handle, 0, SEEK_SET);
+ $enc = "+";
+ var_dump( fgetcsv($file_handle, 1024, $delimiter, $enc) );
+ // check the file pointer position and if eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ // close the file
+ fclose($file_handle);
+ //delete file
+ unlink($filename);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECT--
+*** Testing fgetcsv() : with different enclosure but same delimiter char ***
+
+-- Testing fgetcsv() with file opened using r mode --
+array(2) {
+ [0]=>
+ string(7) ""water""
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(2) {
+ [0]=>
+ string(7) ""water""
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(2) {
+ [0]=>
+ string(7) ""water""
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(2) {
+ [0]=>
+ string(7) ""water""
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(2) {
+ [0]=>
+ string(7) ""water""
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(2) {
+ [0]=>
+ string(7) ""water""
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(2) {
+ [0]=>
+ string(7) ""water""
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(2) {
+ [0]=>
+ string(7) ""water""
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(2) {
+ [0]=>
+ string(7) ""water""
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(2) {
+ [0]=>
+ string(7) ""water""
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(2) {
+ [0]=>
+ string(7) ""water""
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(2) {
+ [0]=>
+ string(7) ""water""
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(2) {
+ [0]=>
+ string(7) ""water""
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(2) {
+ [0]=>
+ string(7) ""water""
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(2) {
+ [0]=>
+ string(7) ""water""
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(2) {
+ [0]=>
+ string(7) ""water""
+ [1]=>
+ string(7) ""fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(2) {
+ [0]=>
+ string(7) ""water""
+ [1]=>
+ string(7) ""fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(2) {
+ [0]=>
+ string(7) ""water""
+ [1]=>
+ string(7) ""fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(2) {
+ [0]=>
+ string(7) ""water""
+ [1]=>
+ string(7) ""fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(2) {
+ [0]=>
+ string(7) ""water""
+ [1]=>
+ string(7) ""fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(2) {
+ [0]=>
+ string(7) ""water""
+ [1]=>
+ string(7) ""fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(2) {
+ [0]=>
+ string(7) ""water""
+ [1]=>
+ string(7) ""fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(2) {
+ [0]=>
+ string(7) ""water""
+ [1]=>
+ string(7) ""fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(2) {
+ [0]=>
+ string(7) ""water""
+ [1]=>
+ string(7) ""fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(2) {
+ [0]=>
+ string(7) ""water""
+ [1]=>
+ string(7) ""fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(2) {
+ [0]=>
+ string(7) ""water""
+ [1]=>
+ string(7) ""fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(2) {
+ [0]=>
+ string(7) ""water""
+ [1]=>
+ string(7) ""fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(2) {
+ [0]=>
+ string(7) ""water""
+ [1]=>
+ string(7) ""fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(2) {
+ [0]=>
+ string(7) ""water""
+ [1]=>
+ string(7) ""fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(2) {
+ [0]=>
+ string(7) ""water""
+ [1]=>
+ string(7) ""fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(2) {
+ [0]=>
+ string(7) "^water^"
+ [1]=>
+ string(7) "^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(2) {
+ [0]=>
+ string(7) "^water^"
+ [1]=>
+ string(7) "^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(2) {
+ [0]=>
+ string(7) "^water^"
+ [1]=>
+ string(7) "^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(2) {
+ [0]=>
+ string(7) "^water^"
+ [1]=>
+ string(7) "^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(2) {
+ [0]=>
+ string(7) "^water^"
+ [1]=>
+ string(7) "^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(2) {
+ [0]=>
+ string(7) "^water^"
+ [1]=>
+ string(7) "^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(2) {
+ [0]=>
+ string(7) "^water^"
+ [1]=>
+ string(7) "^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(2) {
+ [0]=>
+ string(7) "^water^"
+ [1]=>
+ string(7) "^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(2) {
+ [0]=>
+ string(7) "^water^"
+ [1]=>
+ string(7) "^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(2) {
+ [0]=>
+ string(7) "^water^"
+ [1]=>
+ string(7) "^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(2) {
+ [0]=>
+ string(7) "^water^"
+ [1]=>
+ string(7) "^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(2) {
+ [0]=>
+ string(7) "^water^"
+ [1]=>
+ string(7) "^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(2) {
+ [0]=>
+ string(7) "^water^"
+ [1]=>
+ string(7) "^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(2) {
+ [0]=>
+ string(7) "^water^"
+ [1]=>
+ string(7) "^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(2) {
+ [0]=>
+ string(7) "^water^"
+ [1]=>
+ string(7) "^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(2) {
+ [0]=>
+ string(7) "&water&"
+ [1]=>
+ string(7) "&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(2) {
+ [0]=>
+ string(7) "&water&"
+ [1]=>
+ string(7) "&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(2) {
+ [0]=>
+ string(7) "&water&"
+ [1]=>
+ string(7) "&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(2) {
+ [0]=>
+ string(7) "&water&"
+ [1]=>
+ string(7) "&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(2) {
+ [0]=>
+ string(7) "&water&"
+ [1]=>
+ string(7) "&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(2) {
+ [0]=>
+ string(7) "&water&"
+ [1]=>
+ string(7) "&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(2) {
+ [0]=>
+ string(7) "&water&"
+ [1]=>
+ string(7) "&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(2) {
+ [0]=>
+ string(7) "&water&"
+ [1]=>
+ string(7) "&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(2) {
+ [0]=>
+ string(7) "&water&"
+ [1]=>
+ string(7) "&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(2) {
+ [0]=>
+ string(7) "&water&"
+ [1]=>
+ string(7) "&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(2) {
+ [0]=>
+ string(7) "&water&"
+ [1]=>
+ string(7) "&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(2) {
+ [0]=>
+ string(7) "&water&"
+ [1]=>
+ string(7) "&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(2) {
+ [0]=>
+ string(7) "&water&"
+ [1]=>
+ string(7) "&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(2) {
+ [0]=>
+ string(7) "&water&"
+ [1]=>
+ string(7) "&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(2) {
+ [0]=>
+ string(7) "&water&"
+ [1]=>
+ string(7) "&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(6) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "water"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(5) "fruit"
+ [5]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(6) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "water"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(5) "fruit"
+ [5]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(6) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "water"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(5) "fruit"
+ [5]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(6) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "water"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(5) "fruit"
+ [5]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(6) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "water"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(5) "fruit"
+ [5]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(6) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "water"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(5) "fruit"
+ [5]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(6) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "water"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(5) "fruit"
+ [5]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(6) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "water"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(5) "fruit"
+ [5]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(6) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "water"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(5) "fruit"
+ [5]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(6) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "water"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(5) "fruit"
+ [5]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(6) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "water"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(5) "fruit"
+ [5]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(6) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "water"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(5) "fruit"
+ [5]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(6) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "water"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(5) "fruit"
+ [5]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(6) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "water"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(5) "fruit"
+ [5]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(6) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "water"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(5) "fruit"
+ [5]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(5) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "water"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(5) "fruit"
+ [4]=>
+ string(3) "air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(5) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "water"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(5) "fruit"
+ [4]=>
+ string(3) "air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(5) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "water"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(5) "fruit"
+ [4]=>
+ string(3) "air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(5) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "water"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(5) "fruit"
+ [4]=>
+ string(3) "air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(5) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "water"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(5) "fruit"
+ [4]=>
+ string(3) "air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(5) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "water"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(5) "fruit"
+ [4]=>
+ string(3) "air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(5) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "water"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(5) "fruit"
+ [4]=>
+ string(3) "air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(5) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "water"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(5) "fruit"
+ [4]=>
+ string(3) "air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(5) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "water"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(5) "fruit"
+ [4]=>
+ string(3) "air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(5) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "water"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(5) "fruit"
+ [4]=>
+ string(3) "air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(5) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "water"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(5) "fruit"
+ [4]=>
+ string(3) "air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(5) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "water"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(5) "fruit"
+ [4]=>
+ string(3) "air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(5) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "water"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(5) "fruit"
+ [4]=>
+ string(3) "air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(5) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "water"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(5) "fruit"
+ [4]=>
+ string(3) "air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(5) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "water"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(5) "fruit"
+ [4]=>
+ string(3) "air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(9) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "water"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(5) "fruit"
+ [5]=>
+ string(0) ""
+ [6]=>
+ string(0) ""
+ [7]=>
+ string(3) "air"
+ [8]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(9) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "water"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(5) "fruit"
+ [5]=>
+ string(0) ""
+ [6]=>
+ string(0) ""
+ [7]=>
+ string(3) "air"
+ [8]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(9) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "water"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(5) "fruit"
+ [5]=>
+ string(0) ""
+ [6]=>
+ string(0) ""
+ [7]=>
+ string(3) "air"
+ [8]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(9) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "water"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(5) "fruit"
+ [5]=>
+ string(0) ""
+ [6]=>
+ string(0) ""
+ [7]=>
+ string(3) "air"
+ [8]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(9) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "water"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(5) "fruit"
+ [5]=>
+ string(0) ""
+ [6]=>
+ string(0) ""
+ [7]=>
+ string(3) "air"
+ [8]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(9) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "water"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(5) "fruit"
+ [5]=>
+ string(0) ""
+ [6]=>
+ string(0) ""
+ [7]=>
+ string(3) "air"
+ [8]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(9) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "water"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(5) "fruit"
+ [5]=>
+ string(0) ""
+ [6]=>
+ string(0) ""
+ [7]=>
+ string(3) "air"
+ [8]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(9) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "water"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(5) "fruit"
+ [5]=>
+ string(0) ""
+ [6]=>
+ string(0) ""
+ [7]=>
+ string(3) "air"
+ [8]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(9) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "water"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(5) "fruit"
+ [5]=>
+ string(0) ""
+ [6]=>
+ string(0) ""
+ [7]=>
+ string(3) "air"
+ [8]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(9) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "water"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(5) "fruit"
+ [5]=>
+ string(0) ""
+ [6]=>
+ string(0) ""
+ [7]=>
+ string(3) "air"
+ [8]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(9) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "water"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(5) "fruit"
+ [5]=>
+ string(0) ""
+ [6]=>
+ string(0) ""
+ [7]=>
+ string(3) "air"
+ [8]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(9) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "water"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(5) "fruit"
+ [5]=>
+ string(0) ""
+ [6]=>
+ string(0) ""
+ [7]=>
+ string(3) "air"
+ [8]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(9) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "water"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(5) "fruit"
+ [5]=>
+ string(0) ""
+ [6]=>
+ string(0) ""
+ [7]=>
+ string(3) "air"
+ [8]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(9) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "water"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(5) "fruit"
+ [5]=>
+ string(0) ""
+ [6]=>
+ string(0) ""
+ [7]=>
+ string(3) "air"
+ [8]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(9) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(5) "water"
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(5) "fruit"
+ [5]=>
+ string(0) ""
+ [6]=>
+ string(0) ""
+ [7]=>
+ string(3) "air"
+ [8]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(6) {
+ [0]=>
+ string(6) "&""""&"
+ [1]=>
+ string(3) "&"&"
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(3) "&,&"
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(6) {
+ [0]=>
+ string(6) "&""""&"
+ [1]=>
+ string(3) "&"&"
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(3) "&,&"
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(6) {
+ [0]=>
+ string(6) "&""""&"
+ [1]=>
+ string(3) "&"&"
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(3) "&,&"
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(6) {
+ [0]=>
+ string(6) "&""""&"
+ [1]=>
+ string(3) "&"&"
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(3) "&,&"
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(6) {
+ [0]=>
+ string(6) "&""""&"
+ [1]=>
+ string(3) "&"&"
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(3) "&,&"
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(6) {
+ [0]=>
+ string(6) "&""""&"
+ [1]=>
+ string(3) "&"&"
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(3) "&,&"
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(6) {
+ [0]=>
+ string(6) "&""""&"
+ [1]=>
+ string(3) "&"&"
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(3) "&,&"
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(6) {
+ [0]=>
+ string(6) "&""""&"
+ [1]=>
+ string(3) "&"&"
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(3) "&,&"
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(6) {
+ [0]=>
+ string(6) "&""""&"
+ [1]=>
+ string(3) "&"&"
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(3) "&,&"
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(6) {
+ [0]=>
+ string(6) "&""""&"
+ [1]=>
+ string(3) "&"&"
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(3) "&,&"
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(6) {
+ [0]=>
+ string(6) "&""""&"
+ [1]=>
+ string(3) "&"&"
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(3) "&,&"
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(6) {
+ [0]=>
+ string(6) "&""""&"
+ [1]=>
+ string(3) "&"&"
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(3) "&,&"
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(6) {
+ [0]=>
+ string(6) "&""""&"
+ [1]=>
+ string(3) "&"&"
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(3) "&,&"
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(6) {
+ [0]=>
+ string(6) "&""""&"
+ [1]=>
+ string(3) "&"&"
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(3) "&,&"
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(6) {
+ [0]=>
+ string(6) "&""""&"
+ [1]=>
+ string(3) "&"&"
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(3) "&,&"
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+Done \ No newline at end of file
diff --git a/ext/standard/tests/file/fgetcsv_variation12.phpt b/ext/standard/tests/file/fgetcsv_variation12.phpt
new file mode 100644
index 0000000..e513fe6
--- /dev/null
+++ b/ext/standard/tests/file/fgetcsv_variation12.phpt
@@ -0,0 +1,957 @@
+--TEST--
+Test fgetcsv() : usage variations - two chars as enclosure & delimiter (various read and append modes)
+--FILE--
+<?php
+/*
+ Prototype: array fgetcsv ( resource $handle [, int $length [, string $delimiter [, string $enclosure]]] );
+ Description: Gets line from file pointer and parse for CSV fields
+*/
+
+/* Testing fgetcsv() by providing two characters for enclosure and delimiter parameters */
+
+echo "*** Testing fgetcsv() : with two chars as enclosure & delimiter ***\n";
+
+/* the array is with three elements in it. Each element should be read as
+ 1st element is delimiter, 2nd element is enclosure
+ and 3rd element is csv fields
+*/
+$csv_lists = array (
+ array(',', '"', '"water",fruit'),
+ array(',', '"', '"water","fruit"'),
+ array(' ', '^', '^water^ ^fruit^'),
+ array(':', '&', '&water&:&fruit&'),
+ array('=', '=', '=water===fruit='),
+ array('-', '-', '-water--fruit-air'),
+ array('-', '-', '-water---fruit---air-'),
+ array(':', '&', '&""""&:&"&:,:":&,&:,,,,')
+);
+
+$filename = dirname(__FILE__) . '/fgetcsv_variation12.tmp';
+@unlink($filename);
+
+$file_modes = array ("r","rb", "rt", "r+", "r+b", "r+t",
+ "a+", "a+b", "a+t");
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $file_handle = fopen($filename, "w");
+ } else {
+ $file_handle = fopen($filename, $file_modes[$mode_counter] );
+ }
+ if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+ }
+ $delimiter = $csv_list[0];
+ $enclosure = $csv_list[1];
+ $csv_field = $csv_list[2];
+ fwrite($file_handle, $csv_field . "\n");
+
+ // write another line of text and a blank line
+ // this will be used to test, if the fgetcsv() read more than a line and its
+ // working when only a blank line is read
+ fwrite($file_handle, "This is line of text without csv fields\n");
+ fwrite($file_handle, "\n"); // blank line
+
+ // close the file if the mode to be used is read mode and re-open using read mode
+ // else rewind the file pointer to begining of the file
+ if ( strstr($file_modes[$mode_counter], "r" ) ) {
+ fclose($file_handle);
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ } else {
+ // rewind the file pointer to bof
+ rewind($file_handle);
+ }
+
+ echo "\n-- Testing fgetcsv() with file opened using $file_modes[$mode_counter] mode --\n";
+
+ // call fgetcsv() to parse csv fields
+
+ // use delimiter & enclosure char of two chars
+ fseek($file_handle, 0, SEEK_SET);
+ $del = "++";
+ $enc = "%%";
+ var_dump( fgetcsv($file_handle, 1024, $del, $enc) );
+ // check the file pointer position and if eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ // close the file
+ fclose($file_handle);
+ //delete file
+ unlink($filename);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fgetcsv() : with two chars as enclosure & delimiter ***
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(13) ""water",fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(13) ""water",fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(13) ""water",fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(13) ""water",fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(13) ""water",fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(13) ""water",fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(13) ""water",fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(13) ""water",fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(13) ""water",fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) ""water","fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) ""water","fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) ""water","fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) ""water","fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) ""water","fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) ""water","fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) ""water","fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) ""water","fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) ""water","fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) "^water^ ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) "^water^ ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) "^water^ ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) "^water^ ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) "^water^ ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) "^water^ ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) "^water^ ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) "^water^ ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) "^water^ ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) "&water&:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) "&water&:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) "&water&:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) "&water&:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) "&water&:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) "&water&:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) "&water&:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) "&water&:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) "&water&:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) "=water===fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) "=water===fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) "=water===fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) "=water===fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) "=water===fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) "=water===fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) "=water===fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) "=water===fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) "=water===fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(17) "-water--fruit-air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(17) "-water--fruit-air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(17) "-water--fruit-air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(17) "-water--fruit-air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(17) "-water--fruit-air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(17) "-water--fruit-air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(17) "-water--fruit-air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(17) "-water--fruit-air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(17) "-water--fruit-air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(21) "-water---fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(21) "-water---fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(21) "-water---fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(21) "-water---fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(21) "-water---fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(21) "-water---fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(21) "-water---fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(21) "-water---fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(21) "-water---fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(23) "&""""&:&"&:,:":&,&:,,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(23) "&""""&:&"&:,:":&,&:,,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(23) "&""""&:&"&:,:":&,&:,,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(23) "&""""&:&"&:,:":&,&:,,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(23) "&""""&:&"&:,:":&,&:,,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(23) "&""""&:&"&:,:":&,&:,,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(23) "&""""&:&"&:,:":&,&:,,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(23) "&""""&:&"&:,:":&,&:,,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(23) "&""""&:&"&:,:":&,&:,,,,"
+}
+int(24)
+bool(false)
+Done
diff --git a/ext/standard/tests/file/fgetcsv_variation13.phpt b/ext/standard/tests/file/fgetcsv_variation13.phpt
new file mode 100644
index 0000000..a00405b
--- /dev/null
+++ b/ext/standard/tests/file/fgetcsv_variation13.phpt
@@ -0,0 +1,189 @@
+--TEST--
+Test fgetcsv() : usage variations - with line without any csv fields
+
+--FILE--
+<?php
+/*
+ Prototype: array fgetcsv ( resource $handle [, int $length [, string $delimiter [, string $enclosure]]] );
+ Description: Gets line from file pointer and parse for CSV fields
+*/
+
+/* Testing fgetcsv() to read a line from a file which doesn't have any CSV field */
+
+echo "*** Testing fgetcsv() : reading the line which is without csv fields ***\n";
+
+
+$filename = dirname(__FILE__) . '/fgetcsv_variation13.tmp';
+@unlink($filename);
+
+$file_modes = array ("r","rb", "rt", "r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $file_handle = fopen($filename, "w");
+ } else {
+ $file_handle = fopen($filename, $file_modes[$mode_counter] );
+ }
+ if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+ }
+ // write line of text
+ fwrite($file_handle, "This is line of text without csv fields\n");
+
+ // close the file if the mode to be used is read mode and re-open using read mode
+ // else rewind the file pointer to begining of the file
+ if ( strstr($file_modes[$mode_counter], "r" ) ) {
+ fclose($file_handle);
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ } else {
+ // rewind the file pointer to bof
+ rewind($file_handle);
+ }
+
+ echo "\n-- Testing fgetcsv() with file opened using $file_modes[$mode_counter] mode --\n";
+
+
+ // read the line which is without csv fields, provide delimiter and see the working of fgetcsv
+ $fp_pos = ftell($file_handle);
+ var_dump( fgetcsv($file_handle) );
+ // check the file pointer position and if eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ // close the file
+ fclose($file_handle);
+ //delete file
+ unlink($filename);
+ } //end of mode loop
+
+echo "Done\n";
+?>
+--EXPECT--
+*** Testing fgetcsv() : reading the line which is without csv fields ***
+
+-- Testing fgetcsv() with file opened using r mode --
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(40)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(40)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(40)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(40)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(40)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(40)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(40)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(40)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(40)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(40)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(40)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(40)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(40)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(40)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(40)
+bool(false)
+Done
diff --git a/ext/standard/tests/file/fgetcsv_variation14.phpt b/ext/standard/tests/file/fgetcsv_variation14.phpt
new file mode 100644
index 0000000..927bf8a
--- /dev/null
+++ b/ext/standard/tests/file/fgetcsv_variation14.phpt
@@ -0,0 +1,239 @@
+--TEST--
+Test fgetcsv() : usage variations - reading the blank line
+--FILE--
+<?php
+/*
+ Prototype: array fgetcsv ( resource $handle [, int $length [, string $delimiter [, string $enclosure]]] );
+ Description: Gets line from file pointer and parse for CSV fields
+*/
+
+/* Testing fgetcsv() by reading a file containing a blank line */
+
+echo "*** Testing fgetcsv() : reading the blank line ***\n";
+
+
+$filename = dirname(__FILE__) . '/fgetcsv_variation14.tmp';
+@unlink($filename);
+
+$file_modes = array ("r","rb", "rt", "r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $file_handle = fopen($filename, "w");
+ } else {
+ $file_handle = fopen($filename, $file_modes[$mode_counter] );
+ }
+ if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+ }
+ // write a blank line
+ fwrite($file_handle, "\n"); // blank line
+
+ // close the file if the mode to be used is read mode and re-open using read mode
+ // else rewind the file pointer to begining of the file
+ if ( strstr($file_modes[$mode_counter], "r" ) ) {
+ fclose($file_handle);
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ } else {
+ // rewind the file pointer to bof
+ rewind($file_handle);
+ }
+
+ echo "\n-- Testing fgetcsv() with file opened using $file_modes[$mode_counter] mode --\n";
+
+ // call fgetcsv() to parse csv fields
+
+ // read the next line which is a blank line to see the working of fgetcsv
+ $fp_pos = ftell($file_handle);
+ var_dump( fgetcsv($file_handle, 1024) );
+ // check the file pointer position and if eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+ // read again to struck EOF
+ var_dump( fgetcsv($file_handle, 1024) );
+ // check the file pointer position and if eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ // close the file
+ fclose($file_handle);
+ //delete file
+ unlink($filename);
+ } //end of mode loop
+
+echo "Done\n";
+?>
+--EXPECT--
+*** Testing fgetcsv() : reading the blank line ***
+
+-- Testing fgetcsv() with file opened using r mode --
+array(1) {
+ [0]=>
+ NULL
+}
+int(1)
+bool(false)
+bool(false)
+int(1)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(1) {
+ [0]=>
+ NULL
+}
+int(1)
+bool(false)
+bool(false)
+int(1)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(1) {
+ [0]=>
+ NULL
+}
+int(1)
+bool(false)
+bool(false)
+int(1)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(1) {
+ [0]=>
+ NULL
+}
+int(1)
+bool(false)
+bool(false)
+int(1)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(1) {
+ [0]=>
+ NULL
+}
+int(1)
+bool(false)
+bool(false)
+int(1)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(1) {
+ [0]=>
+ NULL
+}
+int(1)
+bool(false)
+bool(false)
+int(1)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(1) {
+ [0]=>
+ NULL
+}
+int(1)
+bool(false)
+bool(false)
+int(1)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(1) {
+ [0]=>
+ NULL
+}
+int(1)
+bool(false)
+bool(false)
+int(1)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(1) {
+ [0]=>
+ NULL
+}
+int(1)
+bool(false)
+bool(false)
+int(1)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(1) {
+ [0]=>
+ NULL
+}
+int(1)
+bool(false)
+bool(false)
+int(1)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(1) {
+ [0]=>
+ NULL
+}
+int(1)
+bool(false)
+bool(false)
+int(1)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(1) {
+ [0]=>
+ NULL
+}
+int(1)
+bool(false)
+bool(false)
+int(1)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(1) {
+ [0]=>
+ NULL
+}
+int(1)
+bool(false)
+bool(false)
+int(1)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(1) {
+ [0]=>
+ NULL
+}
+int(1)
+bool(false)
+bool(false)
+int(1)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(1) {
+ [0]=>
+ NULL
+}
+int(1)
+bool(false)
+bool(false)
+int(1)
+bool(true)
+Done
diff --git a/ext/standard/tests/file/fgetcsv_variation15.phpt b/ext/standard/tests/file/fgetcsv_variation15.phpt
new file mode 100644
index 0000000..b36b88e
--- /dev/null
+++ b/ext/standard/tests/file/fgetcsv_variation15.phpt
@@ -0,0 +1,940 @@
+--TEST--
+Test fgetcsv() : usage variations - with default enclosure
+--FILE--
+<?php
+/*
+ Prototype: array fgetcsv ( resource $handle [, int $length [, string $delimiter [, string $enclosure]]] );
+ Description: Gets line from file pointer and parse for CSV fields
+*/
+
+/* Testing fgetcsv() to read a file when provided with default enclosure character */
+
+echo "*** Testing fgetcsv() : with default enclosure ***\n";
+
+/* the array is with two elements in it. Each element should be read as
+ 1st element is delimiter & 2nd element is csv fields
+*/
+$csv_lists = array (
+ array(',', 'water,fruit'),
+ array(' ', 'water fruit'),
+ array(' ', '"water" "fruit"'),
+ array('\\', 'water\\"fruit"\\"air"'),
+ array('\\', '"water"\\"fruit"\\"""'),
+);
+
+$filename = dirname(__FILE__) . '/fgetcsv_variation15.tmp';
+@unlink($filename);
+
+$file_modes = array ("r","rb", "rt", "r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $file_handle = fopen($filename, "w");
+ } else {
+ $file_handle = fopen($filename, $file_modes[$mode_counter] );
+ }
+ if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+ }
+ $delimiter = $csv_list[0];
+ $csv_field = $csv_list[1];
+ fwrite($file_handle, $csv_field . "\n");
+ // write another line of text and a blank line
+ // this will be used to test, if the fgetcsv() read more than a line and its
+ // working when only a blan line is read
+ fwrite($file_handle, "This is line of text without csv fields\n");
+ fwrite($file_handle, "\n"); // blank line
+
+ // close the file if the mode to be used is read mode and re-open using read mode
+ // else rewind the file pointer to begining of the file
+ if ( strstr($file_modes[$mode_counter], "r" ) ) {
+ fclose($file_handle);
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ } else {
+ // rewind the file pointer to bof
+ rewind($file_handle);
+ }
+
+ echo "\n-- Testing fgetcsv() with file opened using $file_modes[$mode_counter] mode --\n";
+
+ // call fgetcsv() to parse csv fields
+
+ var_dump( fgetcsv($file_handle, 1024, $delimiter) );
+ // check the file pointer position and if eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ // close the file
+ fclose($file_handle);
+ //delete file
+ unlink($filename);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECT--
+*** Testing fgetcsv() : with default enclosure ***
+
+-- Testing fgetcsv() with file opened using r mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(3) "air"
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(3) "air"
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(3) "air"
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(3) "air"
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(3) "air"
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(3) "air"
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(3) "air"
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(3) "air"
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(3) "air"
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(3) "air"
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(3) "air"
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(3) "air"
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(3) "air"
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(3) "air"
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(3) "air"
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(43) ""
+This is line of text without csv fields
+
+"
+}
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(43) ""
+This is line of text without csv fields
+
+"
+}
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(43) ""
+This is line of text without csv fields
+
+"
+}
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(43) ""
+This is line of text without csv fields
+
+"
+}
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(43) ""
+This is line of text without csv fields
+
+"
+}
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(43) ""
+This is line of text without csv fields
+
+"
+}
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(43) ""
+This is line of text without csv fields
+
+"
+}
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(43) ""
+This is line of text without csv fields
+
+"
+}
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(43) ""
+This is line of text without csv fields
+
+"
+}
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(43) ""
+This is line of text without csv fields
+
+"
+}
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(43) ""
+This is line of text without csv fields
+
+"
+}
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(43) ""
+This is line of text without csv fields
+
+"
+}
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(43) ""
+This is line of text without csv fields
+
+"
+}
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(43) ""
+This is line of text without csv fields
+
+"
+}
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(43) ""
+This is line of text without csv fields
+
+"
+}
+int(61)
+bool(true)
+Done
diff --git a/ext/standard/tests/file/fgetcsv_variation16.phpt b/ext/standard/tests/file/fgetcsv_variation16.phpt
new file mode 100644
index 0000000..904c422
--- /dev/null
+++ b/ext/standard/tests/file/fgetcsv_variation16.phpt
@@ -0,0 +1,944 @@
+--TEST--
+Test fgetcsv() : usage variations - with default enclosure & length as 0
+--FILE--
+<?php
+/*
+ Prototype: array fgetcsv ( resource $handle [, int $length [, string $delimiter [, string $enclosure]]] );
+ Description: Gets line from file pointer and parse for CSV fields
+*/
+
+/* Testing fgetcsv() to read a file when provided with default enclosure character
+ and length value equal to zero
+*/
+
+echo "*** Testing fgetcsv() : with default enclosure & length as 0 ***\n";
+
+/* the array is with two elements in it. Each element should be read as
+ 1st element is delimiter & 2nd element is csv fields
+*/
+$csv_lists = array (
+ array(',', 'water,fruit'),
+ array(' ', 'water fruit'),
+ array(' ', '"water" "fruit"'),
+ array('\\', 'water\\"fruit"\\"air"'),
+ array('\\', '"water"\\"fruit"\\"""'),
+);
+
+$filename = dirname(__FILE__) . '/fgetcsv_variation16.tmp';
+@unlink($filename);
+
+$file_modes = array ("r","rb", "rt", "r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $file_handle = fopen($filename, "w");
+ } else {
+ $file_handle = fopen($filename, $file_modes[$mode_counter] );
+ }
+ if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+ }
+ $delimiter = $csv_list[0];
+ $csv_field = $csv_list[1];
+ fwrite($file_handle, $csv_field . "\n");
+ // write another line of text and a blank line
+ // this will be used to test, if the fgetcsv() read more than a line and its
+ // working when only a blan line is read
+ fwrite($file_handle, "This is line of text without csv fields\n");
+ fwrite($file_handle, "\n"); // blank line
+
+ // close the file if the mode to be used is read mode and re-open using read mode
+ // else rewind the file pointer to begining of the file
+ if ( strstr($file_modes[$mode_counter], "r" ) ) {
+ fclose($file_handle);
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ } else {
+ // rewind the file pointer to bof
+ rewind($file_handle);
+ }
+
+ echo "\n-- Testing fgetcsv() with file opened using $file_modes[$mode_counter] mode --\n";
+
+ // call fgetcsv() to parse csv fields
+
+ // use length as 0
+ fseek($file_handle, 0, SEEK_SET);
+ var_dump( fgetcsv($file_handle, 0, $delimiter) );
+ // check the file pointer position and if eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ // close the file
+ fclose($file_handle);
+ //delete file
+ unlink($filename);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECT--
+*** Testing fgetcsv() : with default enclosure & length as 0 ***
+
+-- Testing fgetcsv() with file opened using r mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(3) "air"
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(3) "air"
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(3) "air"
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(3) "air"
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(3) "air"
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(3) "air"
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(3) "air"
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(3) "air"
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(3) "air"
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(3) "air"
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(3) "air"
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(3) "air"
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(3) "air"
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(3) "air"
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(3) "air"
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(43) ""
+This is line of text without csv fields
+
+"
+}
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(43) ""
+This is line of text without csv fields
+
+"
+}
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(43) ""
+This is line of text without csv fields
+
+"
+}
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(43) ""
+This is line of text without csv fields
+
+"
+}
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(43) ""
+This is line of text without csv fields
+
+"
+}
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(43) ""
+This is line of text without csv fields
+
+"
+}
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(43) ""
+This is line of text without csv fields
+
+"
+}
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(43) ""
+This is line of text without csv fields
+
+"
+}
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(43) ""
+This is line of text without csv fields
+
+"
+}
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(43) ""
+This is line of text without csv fields
+
+"
+}
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(43) ""
+This is line of text without csv fields
+
+"
+}
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(43) ""
+This is line of text without csv fields
+
+"
+}
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(43) ""
+This is line of text without csv fields
+
+"
+}
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(43) ""
+This is line of text without csv fields
+
+"
+}
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(43) ""
+This is line of text without csv fields
+
+"
+}
+int(61)
+bool(true)
+Done
diff --git a/ext/standard/tests/file/fgetcsv_variation17.phpt b/ext/standard/tests/file/fgetcsv_variation17.phpt
new file mode 100644
index 0000000..a54f8da
--- /dev/null
+++ b/ext/standard/tests/file/fgetcsv_variation17.phpt
@@ -0,0 +1,1565 @@
+--TEST--
+Test fgetcsv() : usage variations - with default enclosure & length less than line size
+--FILE--
+<?php
+/*
+ Prototype: array fgetcsv ( resource $handle [, int $length [, string $delimiter [, string $enclosure]]] );
+ Description: Gets line from file pointer and parse for CSV fields
+*/
+
+/* Testing fgetcsv() to read a file when provided with default enclosure character
+ and length value less than the size of line being read
+ */
+
+echo "*** Testing fgetcsv() : with default enclosure & length less than line size ***\n";
+
+/* the array is with two elements in it. Each element should be read as
+ 1st element is delimiter & 2nd element is csv fields
+*/
+$csv_lists = array (
+ array(',', 'water,fruit'),
+ array(' ', 'water fruit'),
+ array(' ', '"water" "fruit"'),
+ array('\\', 'water\\"fruit"\\"air"'),
+ array('\\', '"water"\\"fruit"\\"""'),
+);
+
+$filename = dirname(__FILE__) . '/fgetcsv_variation17.tmp';
+@unlink($filename);
+
+$file_modes = array ("r","rb", "rt", "r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $file_handle = fopen($filename, "w");
+ } else {
+ $file_handle = fopen($filename, $file_modes[$mode_counter] );
+ }
+ if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+ }
+ $delimiter = $csv_list[0];
+ $csv_field = $csv_list[1];
+ fwrite($file_handle, $csv_field . "\n");
+ // write another line of text and a blank line
+ // this will be used to test, if the fgetcsv() read more than a line and its
+ // working when only a blan line is read
+ fwrite($file_handle, "This is line of text without csv fields\n");
+ fwrite($file_handle, "\n"); // blank line
+
+ // close the file if the mode to be used is read mode and re-open using read mode
+ // else rewind the file pointer to begining of the file
+ if ( strstr($file_modes[$mode_counter], "r" ) ) {
+ fclose($file_handle);
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ } else {
+ // rewind the file pointer to bof
+ rewind($file_handle);
+ }
+
+ echo "\n-- Testing fgetcsv() with file opened using $file_modes[$mode_counter] mode --\n";
+
+ // call fgetcsv() to parse csv fields
+
+ // use length as less than the actual size of the line
+ fseek($file_handle, 0, SEEK_SET);
+ var_dump( fgetcsv($file_handle, 9, $delimiter) );
+ // check the file pointer position and if eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ // read rest of the line
+ var_dump( fgetcsv($file_handle, 1024, $delimiter) );
+ // check the file pointer position and if eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ // close the file
+ fclose($file_handle);
+ //delete file
+ unlink($filename);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECT--
+*** Testing fgetcsv() : with default enclosure & length less than line size ***
+
+-- Testing fgetcsv() with file opened using r mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(3) "fru"
+}
+int(9)
+bool(false)
+array(1) {
+ [0]=>
+ string(2) "it"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(3) "fru"
+}
+int(9)
+bool(false)
+array(1) {
+ [0]=>
+ string(2) "it"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(3) "fru"
+}
+int(9)
+bool(false)
+array(1) {
+ [0]=>
+ string(2) "it"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(3) "fru"
+}
+int(9)
+bool(false)
+array(1) {
+ [0]=>
+ string(2) "it"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(3) "fru"
+}
+int(9)
+bool(false)
+array(1) {
+ [0]=>
+ string(2) "it"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(3) "fru"
+}
+int(9)
+bool(false)
+array(1) {
+ [0]=>
+ string(2) "it"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(3) "fru"
+}
+int(9)
+bool(false)
+array(1) {
+ [0]=>
+ string(2) "it"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(3) "fru"
+}
+int(9)
+bool(false)
+array(1) {
+ [0]=>
+ string(2) "it"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(3) "fru"
+}
+int(9)
+bool(false)
+array(1) {
+ [0]=>
+ string(2) "it"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(3) "fru"
+}
+int(9)
+bool(false)
+array(1) {
+ [0]=>
+ string(2) "it"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(3) "fru"
+}
+int(9)
+bool(false)
+array(1) {
+ [0]=>
+ string(2) "it"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(3) "fru"
+}
+int(9)
+bool(false)
+array(1) {
+ [0]=>
+ string(2) "it"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(3) "fru"
+}
+int(9)
+bool(false)
+array(1) {
+ [0]=>
+ string(2) "it"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(3) "fru"
+}
+int(9)
+bool(false)
+array(1) {
+ [0]=>
+ string(2) "it"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(3) "fru"
+}
+int(9)
+bool(false)
+array(1) {
+ [0]=>
+ string(2) "it"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(3) "fru"
+}
+int(9)
+bool(false)
+array(1) {
+ [0]=>
+ string(2) "it"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(3) "fru"
+}
+int(9)
+bool(false)
+array(1) {
+ [0]=>
+ string(2) "it"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(3) "fru"
+}
+int(9)
+bool(false)
+array(1) {
+ [0]=>
+ string(2) "it"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(3) "fru"
+}
+int(9)
+bool(false)
+array(1) {
+ [0]=>
+ string(2) "it"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(3) "fru"
+}
+int(9)
+bool(false)
+array(1) {
+ [0]=>
+ string(2) "it"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(3) "fru"
+}
+int(9)
+bool(false)
+array(1) {
+ [0]=>
+ string(2) "it"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(3) "fru"
+}
+int(9)
+bool(false)
+array(1) {
+ [0]=>
+ string(2) "it"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(3) "fru"
+}
+int(9)
+bool(false)
+array(1) {
+ [0]=>
+ string(2) "it"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(3) "fru"
+}
+int(9)
+bool(false)
+array(1) {
+ [0]=>
+ string(2) "it"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(3) "fru"
+}
+int(9)
+bool(false)
+array(1) {
+ [0]=>
+ string(2) "it"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(3) "fru"
+}
+int(9)
+bool(false)
+array(1) {
+ [0]=>
+ string(2) "it"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(3) "fru"
+}
+int(9)
+bool(false)
+array(1) {
+ [0]=>
+ string(2) "it"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(3) "fru"
+}
+int(9)
+bool(false)
+array(1) {
+ [0]=>
+ string(2) "it"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(3) "fru"
+}
+int(9)
+bool(false)
+array(1) {
+ [0]=>
+ string(2) "it"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(3) "fru"
+}
+int(9)
+bool(false)
+array(1) {
+ [0]=>
+ string(2) "it"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(8) {
+ [0]=>
+ string(4) "This"
+ [1]=>
+ string(2) "is"
+ [2]=>
+ string(4) "line"
+ [3]=>
+ string(2) "of"
+ [4]=>
+ string(4) "text"
+ [5]=>
+ string(7) "without"
+ [6]=>
+ string(3) "csv"
+ [7]=>
+ string(6) "fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(8) {
+ [0]=>
+ string(4) "This"
+ [1]=>
+ string(2) "is"
+ [2]=>
+ string(4) "line"
+ [3]=>
+ string(2) "of"
+ [4]=>
+ string(4) "text"
+ [5]=>
+ string(7) "without"
+ [6]=>
+ string(3) "csv"
+ [7]=>
+ string(6) "fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(8) {
+ [0]=>
+ string(4) "This"
+ [1]=>
+ string(2) "is"
+ [2]=>
+ string(4) "line"
+ [3]=>
+ string(2) "of"
+ [4]=>
+ string(4) "text"
+ [5]=>
+ string(7) "without"
+ [6]=>
+ string(3) "csv"
+ [7]=>
+ string(6) "fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(8) {
+ [0]=>
+ string(4) "This"
+ [1]=>
+ string(2) "is"
+ [2]=>
+ string(4) "line"
+ [3]=>
+ string(2) "of"
+ [4]=>
+ string(4) "text"
+ [5]=>
+ string(7) "without"
+ [6]=>
+ string(3) "csv"
+ [7]=>
+ string(6) "fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(8) {
+ [0]=>
+ string(4) "This"
+ [1]=>
+ string(2) "is"
+ [2]=>
+ string(4) "line"
+ [3]=>
+ string(2) "of"
+ [4]=>
+ string(4) "text"
+ [5]=>
+ string(7) "without"
+ [6]=>
+ string(3) "csv"
+ [7]=>
+ string(6) "fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(8) {
+ [0]=>
+ string(4) "This"
+ [1]=>
+ string(2) "is"
+ [2]=>
+ string(4) "line"
+ [3]=>
+ string(2) "of"
+ [4]=>
+ string(4) "text"
+ [5]=>
+ string(7) "without"
+ [6]=>
+ string(3) "csv"
+ [7]=>
+ string(6) "fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(8) {
+ [0]=>
+ string(4) "This"
+ [1]=>
+ string(2) "is"
+ [2]=>
+ string(4) "line"
+ [3]=>
+ string(2) "of"
+ [4]=>
+ string(4) "text"
+ [5]=>
+ string(7) "without"
+ [6]=>
+ string(3) "csv"
+ [7]=>
+ string(6) "fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(8) {
+ [0]=>
+ string(4) "This"
+ [1]=>
+ string(2) "is"
+ [2]=>
+ string(4) "line"
+ [3]=>
+ string(2) "of"
+ [4]=>
+ string(4) "text"
+ [5]=>
+ string(7) "without"
+ [6]=>
+ string(3) "csv"
+ [7]=>
+ string(6) "fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(8) {
+ [0]=>
+ string(4) "This"
+ [1]=>
+ string(2) "is"
+ [2]=>
+ string(4) "line"
+ [3]=>
+ string(2) "of"
+ [4]=>
+ string(4) "text"
+ [5]=>
+ string(7) "without"
+ [6]=>
+ string(3) "csv"
+ [7]=>
+ string(6) "fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(8) {
+ [0]=>
+ string(4) "This"
+ [1]=>
+ string(2) "is"
+ [2]=>
+ string(4) "line"
+ [3]=>
+ string(2) "of"
+ [4]=>
+ string(4) "text"
+ [5]=>
+ string(7) "without"
+ [6]=>
+ string(3) "csv"
+ [7]=>
+ string(6) "fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(8) {
+ [0]=>
+ string(4) "This"
+ [1]=>
+ string(2) "is"
+ [2]=>
+ string(4) "line"
+ [3]=>
+ string(2) "of"
+ [4]=>
+ string(4) "text"
+ [5]=>
+ string(7) "without"
+ [6]=>
+ string(3) "csv"
+ [7]=>
+ string(6) "fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(8) {
+ [0]=>
+ string(4) "This"
+ [1]=>
+ string(2) "is"
+ [2]=>
+ string(4) "line"
+ [3]=>
+ string(2) "of"
+ [4]=>
+ string(4) "text"
+ [5]=>
+ string(7) "without"
+ [6]=>
+ string(3) "csv"
+ [7]=>
+ string(6) "fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(8) {
+ [0]=>
+ string(4) "This"
+ [1]=>
+ string(2) "is"
+ [2]=>
+ string(4) "line"
+ [3]=>
+ string(2) "of"
+ [4]=>
+ string(4) "text"
+ [5]=>
+ string(7) "without"
+ [6]=>
+ string(3) "csv"
+ [7]=>
+ string(6) "fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(8) {
+ [0]=>
+ string(4) "This"
+ [1]=>
+ string(2) "is"
+ [2]=>
+ string(4) "line"
+ [3]=>
+ string(2) "of"
+ [4]=>
+ string(4) "text"
+ [5]=>
+ string(7) "without"
+ [6]=>
+ string(3) "csv"
+ [7]=>
+ string(6) "fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(8) {
+ [0]=>
+ string(4) "This"
+ [1]=>
+ string(2) "is"
+ [2]=>
+ string(4) "line"
+ [3]=>
+ string(2) "of"
+ [4]=>
+ string(4) "text"
+ [5]=>
+ string(7) "without"
+ [6]=>
+ string(3) "csv"
+ [7]=>
+ string(6) "fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(3) "air"
+}
+int(20)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(60)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(3) "air"
+}
+int(20)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(60)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(3) "air"
+}
+int(20)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(60)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(3) "air"
+}
+int(20)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(60)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(3) "air"
+}
+int(20)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(60)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(3) "air"
+}
+int(20)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(60)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(3) "air"
+}
+int(20)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(60)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(3) "air"
+}
+int(20)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(60)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(3) "air"
+}
+int(20)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(60)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(3) "air"
+}
+int(20)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(60)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(3) "air"
+}
+int(20)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(60)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(3) "air"
+}
+int(20)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(60)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(3) "air"
+}
+int(20)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(60)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(3) "air"
+}
+int(20)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(60)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(3) "air"
+}
+int(20)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(60)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(43) ""
+This is line of text without csv fields
+
+"
+}
+int(61)
+bool(true)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(43) ""
+This is line of text without csv fields
+
+"
+}
+int(61)
+bool(true)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(43) ""
+This is line of text without csv fields
+
+"
+}
+int(61)
+bool(true)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(43) ""
+This is line of text without csv fields
+
+"
+}
+int(61)
+bool(true)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(43) ""
+This is line of text without csv fields
+
+"
+}
+int(61)
+bool(true)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(43) ""
+This is line of text without csv fields
+
+"
+}
+int(61)
+bool(true)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(43) ""
+This is line of text without csv fields
+
+"
+}
+int(61)
+bool(true)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(43) ""
+This is line of text without csv fields
+
+"
+}
+int(61)
+bool(true)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(43) ""
+This is line of text without csv fields
+
+"
+}
+int(61)
+bool(true)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(43) ""
+This is line of text without csv fields
+
+"
+}
+int(61)
+bool(true)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(43) ""
+This is line of text without csv fields
+
+"
+}
+int(61)
+bool(true)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(43) ""
+This is line of text without csv fields
+
+"
+}
+int(61)
+bool(true)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(43) ""
+This is line of text without csv fields
+
+"
+}
+int(61)
+bool(true)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(43) ""
+This is line of text without csv fields
+
+"
+}
+int(61)
+bool(true)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(3) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+ [2]=>
+ string(43) ""
+This is line of text without csv fields
+
+"
+}
+int(61)
+bool(true)
+bool(false)
+int(61)
+bool(true)
+Done
diff --git a/ext/standard/tests/file/fgetcsv_variation18.phpt b/ext/standard/tests/file/fgetcsv_variation18.phpt
new file mode 100644
index 0000000..19915e8
--- /dev/null
+++ b/ext/standard/tests/file/fgetcsv_variation18.phpt
@@ -0,0 +1,690 @@
+--TEST--
+Test fgetcsv() : usage variations - with default enclosure and different delimiter
+--FILE--
+<?php
+/*
+ Prototype: array fgetcsv ( resource $handle [, int $length [, string $delimiter [, string $enclosure]]] );
+ Description: Gets line from file pointer and parse for CSV fields
+*/
+
+/* Testing fgetcsv() to read a file when provided with default enclosure character
+ and with delimiter character which is not in the line being read by fgetcsv()
+*/
+
+echo "*** Testing fgetcsv() : with default enclosure and different delimiter ***\n";
+
+/* the array is with two elements in it. Each element should be read as
+ 1st element is delimiter & 2nd element is csv fields
+*/
+$csv_lists = array (
+ array(',', 'water,fruit'),
+ array(' ', 'water fruit'),
+ array(' ', '"water" "fruit"'),
+ array('\\', 'water\\"fruit"\\"air"'),
+ array('\\', '"water"\\"fruit"\\"""'),
+);
+
+$filename = dirname(__FILE__) . '/fgetcsv_variation18.tmp';
+@unlink($filename);
+
+$file_modes = array ("r","rb", "rt", "r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $file_handle = fopen($filename, "w");
+ } else {
+ $file_handle = fopen($filename, $file_modes[$mode_counter] );
+ }
+ if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+ }
+ $delimiter = $csv_list[0];
+ $csv_field = $csv_list[1];
+ fwrite($file_handle, $csv_field . "\n");
+ // write another line of text and a blank line
+ // this will be used to test, if the fgetcsv() read more than a line and its
+ // working when only a blank line is read
+ fwrite($file_handle, "This is line of text without csv fields\n");
+ fwrite($file_handle, "\n"); // blank line
+
+ // close the file if the mode to be used is read mode and re-open using read mode
+ // else rewind the file pointer to begining of the file
+ if ( strstr($file_modes[$mode_counter], "r" ) ) {
+ fclose($file_handle);
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ } else {
+ // rewind the file pointer to bof
+ rewind($file_handle);
+ }
+
+ echo "\n-- Testing fgetcsv() with file opened using $file_modes[$mode_counter] mode --\n";
+
+ // call fgetcsv() to parse csv fields
+
+ // use different delimiter than existing in file
+ fseek($file_handle, 0, SEEK_SET);
+ $del = "+";
+ var_dump( fgetcsv($file_handle, 1024, $del) );
+ // check the file pointer position and if eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ // close the file
+ fclose($file_handle);
+ //delete file
+ unlink($filename);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECT--
+*** Testing fgetcsv() : with default enclosure and different delimiter ***
+
+-- Testing fgetcsv() with file opened using r mode --
+array(1) {
+ [0]=>
+ string(11) "water,fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(1) {
+ [0]=>
+ string(11) "water,fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(1) {
+ [0]=>
+ string(11) "water,fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(1) {
+ [0]=>
+ string(11) "water,fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(1) {
+ [0]=>
+ string(11) "water,fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(1) {
+ [0]=>
+ string(11) "water,fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(1) {
+ [0]=>
+ string(11) "water,fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(1) {
+ [0]=>
+ string(11) "water,fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(1) {
+ [0]=>
+ string(11) "water,fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(1) {
+ [0]=>
+ string(11) "water,fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(1) {
+ [0]=>
+ string(11) "water,fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(1) {
+ [0]=>
+ string(11) "water,fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(1) {
+ [0]=>
+ string(11) "water,fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(1) {
+ [0]=>
+ string(11) "water,fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(1) {
+ [0]=>
+ string(11) "water,fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(1) {
+ [0]=>
+ string(11) "water fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(1) {
+ [0]=>
+ string(11) "water fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(1) {
+ [0]=>
+ string(11) "water fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(1) {
+ [0]=>
+ string(11) "water fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(1) {
+ [0]=>
+ string(11) "water fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(1) {
+ [0]=>
+ string(11) "water fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(1) {
+ [0]=>
+ string(11) "water fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(1) {
+ [0]=>
+ string(11) "water fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(1) {
+ [0]=>
+ string(11) "water fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(1) {
+ [0]=>
+ string(11) "water fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(1) {
+ [0]=>
+ string(11) "water fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(1) {
+ [0]=>
+ string(11) "water fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(1) {
+ [0]=>
+ string(11) "water fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(1) {
+ [0]=>
+ string(11) "water fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(1) {
+ [0]=>
+ string(11) "water fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(1) {
+ [0]=>
+ string(13) "water "fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(1) {
+ [0]=>
+ string(13) "water "fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(1) {
+ [0]=>
+ string(13) "water "fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(1) {
+ [0]=>
+ string(13) "water "fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(1) {
+ [0]=>
+ string(13) "water "fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(1) {
+ [0]=>
+ string(13) "water "fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(1) {
+ [0]=>
+ string(13) "water "fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(1) {
+ [0]=>
+ string(13) "water "fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(1) {
+ [0]=>
+ string(13) "water "fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(1) {
+ [0]=>
+ string(13) "water "fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(1) {
+ [0]=>
+ string(13) "water "fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(1) {
+ [0]=>
+ string(13) "water "fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(1) {
+ [0]=>
+ string(13) "water "fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(1) {
+ [0]=>
+ string(13) "water "fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(1) {
+ [0]=>
+ string(13) "water "fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(1) {
+ [0]=>
+ string(19) "water\"fruit"\"air""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(1) {
+ [0]=>
+ string(19) "water\"fruit"\"air""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(1) {
+ [0]=>
+ string(19) "water\"fruit"\"air""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(1) {
+ [0]=>
+ string(19) "water\"fruit"\"air""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(1) {
+ [0]=>
+ string(19) "water\"fruit"\"air""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(1) {
+ [0]=>
+ string(19) "water\"fruit"\"air""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(1) {
+ [0]=>
+ string(19) "water\"fruit"\"air""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(1) {
+ [0]=>
+ string(19) "water\"fruit"\"air""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(1) {
+ [0]=>
+ string(19) "water\"fruit"\"air""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(1) {
+ [0]=>
+ string(19) "water\"fruit"\"air""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(1) {
+ [0]=>
+ string(19) "water\"fruit"\"air""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(1) {
+ [0]=>
+ string(19) "water\"fruit"\"air""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(1) {
+ [0]=>
+ string(19) "water\"fruit"\"air""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(1) {
+ [0]=>
+ string(19) "water\"fruit"\"air""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(1) {
+ [0]=>
+ string(19) "water\"fruit"\"air""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(1) {
+ [0]=>
+ string(17) "water\"fruit"\""""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(1) {
+ [0]=>
+ string(17) "water\"fruit"\""""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(1) {
+ [0]=>
+ string(17) "water\"fruit"\""""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(1) {
+ [0]=>
+ string(17) "water\"fruit"\""""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(1) {
+ [0]=>
+ string(17) "water\"fruit"\""""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(1) {
+ [0]=>
+ string(17) "water\"fruit"\""""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(1) {
+ [0]=>
+ string(17) "water\"fruit"\""""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(1) {
+ [0]=>
+ string(17) "water\"fruit"\""""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(1) {
+ [0]=>
+ string(17) "water\"fruit"\""""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(1) {
+ [0]=>
+ string(17) "water\"fruit"\""""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(1) {
+ [0]=>
+ string(17) "water\"fruit"\""""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(1) {
+ [0]=>
+ string(17) "water\"fruit"\""""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(1) {
+ [0]=>
+ string(17) "water\"fruit"\""""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(1) {
+ [0]=>
+ string(17) "water\"fruit"\""""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(1) {
+ [0]=>
+ string(17) "water\"fruit"\""""
+}
+int(20)
+bool(false)
+Done
diff --git a/ext/standard/tests/file/fgetcsv_variation19.phpt b/ext/standard/tests/file/fgetcsv_variation19.phpt
new file mode 100644
index 0000000..2e282e1
--- /dev/null
+++ b/ext/standard/tests/file/fgetcsv_variation19.phpt
@@ -0,0 +1,841 @@
+--TEST--
+Test fgetcsv() : usage variations - with default enclosure & delimiter of two chars
+--FILE--
+<?php
+/*
+ Prototype: array fgetcsv ( resource $handle [, int $length [, string $delimiter [, string $enclosure]]] );
+ Description: Gets line from file pointer and parse for CSV fields
+*/
+
+/*
+ Testing fgetcsv() to read a file when provided with default enclosure character
+ and with delimiter of two characters
+*/
+
+echo "*** Testing fgetcsv() : with default enclosure & delimiter of two chars ***\n";
+
+/* the array is with two elements in it. Each element should be read as
+ 1st element is delimiter & 2nd element is csv fields
+*/
+$csv_lists = array (
+ array(',', 'water,fruit'),
+ array(' ', 'water fruit'),
+ array(' ', '"water" "fruit"'),
+ array('\\', 'water\\"fruit"\\"air"'),
+ array('\\', '"water"\\"fruit"\\"""'),
+);
+
+$filename = dirname(__FILE__) . '/fgetcsv_variation19.tmp';
+@unlink($filename);
+
+$file_modes = array ("r","rb", "rt", "r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $file_handle = fopen($filename, "w");
+ } else {
+ $file_handle = fopen($filename, $file_modes[$mode_counter] );
+ }
+ if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+ }
+ $delimiter = $csv_list[0];
+ $csv_field = $csv_list[1];
+ fwrite($file_handle, $csv_field . "\n");
+ // write another line of text and a blank line
+ // this will be used to test, if the fgetcsv() read more than a line and its
+ // working when only a blank line is read
+ fwrite($file_handle, "This is line of text without csv fields\n");
+ fwrite($file_handle, "\n"); // blank line
+
+ // close the file if the mode to be used is read mode and re-open using read mode
+ // else rewind the file pointer to begining of the file
+ if ( strstr($file_modes[$mode_counter], "r" ) ) {
+ fclose($file_handle);
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ } else {
+ // rewind the file pointer to bof
+ rewind($file_handle);
+ }
+
+ echo "\n-- Testing fgetcsv() with file opened using $file_modes[$mode_counter] mode --\n";
+
+ // call fgetcsv() to parse csv fields
+
+ // use delimiter & enclosure char of two chars
+ fseek($file_handle, 0, SEEK_SET);
+ $del = "++";
+ var_dump( fgetcsv($file_handle, 1024, $del) );
+ // check the file pointer position and if eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ // close the file
+ fclose($file_handle);
+ //delete file
+ unlink($filename);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fgetcsv() : with default enclosure & delimiter of two chars ***
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(11) "water,fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(11) "water,fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(11) "water,fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(11) "water,fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(11) "water,fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(11) "water,fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(11) "water,fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(11) "water,fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(11) "water,fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(11) "water,fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(11) "water,fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(11) "water,fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(11) "water,fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(11) "water,fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(11) "water,fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(11) "water fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(11) "water fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(11) "water fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(11) "water fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(11) "water fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(11) "water fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(11) "water fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(11) "water fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(11) "water fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(11) "water fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(11) "water fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(11) "water fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(11) "water fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(11) "water fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(11) "water fruit"
+}
+int(12)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(13) "water "fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(13) "water "fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(13) "water "fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(13) "water "fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(13) "water "fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(13) "water "fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(13) "water "fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(13) "water "fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(13) "water "fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(13) "water "fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(13) "water "fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(13) "water "fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(13) "water "fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(13) "water "fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(13) "water "fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(19) "water\"fruit"\"air""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(19) "water\"fruit"\"air""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(19) "water\"fruit"\"air""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(19) "water\"fruit"\"air""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(19) "water\"fruit"\"air""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(19) "water\"fruit"\"air""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(19) "water\"fruit"\"air""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(19) "water\"fruit"\"air""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(19) "water\"fruit"\"air""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(19) "water\"fruit"\"air""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(19) "water\"fruit"\"air""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(19) "water\"fruit"\"air""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(19) "water\"fruit"\"air""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(19) "water\"fruit"\"air""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(19) "water\"fruit"\"air""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(17) "water\"fruit"\""""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(17) "water\"fruit"\""""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(17) "water\"fruit"\""""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(17) "water\"fruit"\""""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(17) "water\"fruit"\""""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(17) "water\"fruit"\""""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(17) "water\"fruit"\""""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(17) "water\"fruit"\""""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(17) "water\"fruit"\""""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(17) "water\"fruit"\""""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(17) "water\"fruit"\""""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(17) "water\"fruit"\""""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(17) "water\"fruit"\""""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(17) "water\"fruit"\""""
+}
+int(20)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(17) "water\"fruit"\""""
+}
+int(20)
+bool(false)
+Done
diff --git a/ext/standard/tests/file/fgetcsv_variation2.phpt b/ext/standard/tests/file/fgetcsv_variation2.phpt
new file mode 100644
index 0000000..7b875b8
--- /dev/null
+++ b/ext/standard/tests/file/fgetcsv_variation2.phpt
@@ -0,0 +1,1413 @@
+--TEST--
+Test fgetcsv() : usage variations - with length as 0
+--FILE--
+<?php
+/*
+ Prototype: array fgetcsv ( resource $handle [, int $length [, string $delimiter [, string $enclosure]]] );
+ Description: Gets line from file pointer and parse for CSV fields
+*/
+
+/* Testing fgetcsv() to rwad from a file with length argument equal to zero */
+
+echo "*** Testing fgetcsv() : with length as 0 ***\n";
+
+/* the array is with three elements in it. Each element should be read as
+ 1st element is delimiter, 2nd element is enclosure
+ and 3rd element is csv fields
+*/
+$csv_lists = array (
+ array(',', '"', '"water",fruit'),
+ array(',', '"', '"water","fruit"'),
+ array(' ', '^', '^water^ ^fruit^'),
+ array(':', '&', '&water&:&fruit&'),
+ array('=', '=', '=water===fruit='),
+ array('-', '-', '-water--fruit-air'),
+ array('-', '-', '-water---fruit---air-'),
+ array(':', '&', '&""""&:&"&:,:":&,&:,,,,')
+);
+
+$filename = dirname(__FILE__) . '/fgetcsv_variation2.tmp';
+@unlink($filename);
+
+$file_modes = array ("r","rb", "rt", "r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $file_handle = fopen($filename, "w");
+ } else {
+ $file_handle = fopen($filename, $file_modes[$mode_counter] );
+ }
+ if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+ }
+ $delimiter = $csv_list[0];
+ $enclosure = $csv_list[1];
+ $csv_field = $csv_list[2];
+
+ fwrite($file_handle, $csv_field . "\n");
+ // write another line of text and a blank line
+ // this will be used to test, if the fgetcsv() read more than a line and its
+ // working when only a blank line is read
+ fwrite($file_handle, "This is line of text without csv fields\n");
+ fwrite($file_handle, "\n"); // blank line
+
+ // close the file if the mode to be used is read mode and re-open using read mode
+ // else rewind the file pointer to begining of the file
+ if ( strstr($file_modes[$mode_counter], "r" ) ) {
+ fclose($file_handle);
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ } else {
+ // rewind the file pointer to bof
+ rewind($file_handle);
+ }
+
+ echo "\n-- Testing fgetcsv() with file opened using $file_modes[$mode_counter] mode --\n";
+
+ // call fgetcsv() to parse csv fields
+
+ // use length as 0
+ fseek($file_handle, 0, SEEK_SET);
+ var_dump( fgetcsv($file_handle, 0, $delimiter, $enclosure) );
+ // check the file pointer position and if eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ // close the file
+ fclose($file_handle);
+ //delete file
+ unlink($filename);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECT--
+*** Testing fgetcsv() : with length as 0 ***
+
+-- Testing fgetcsv() with file opened using r mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(2) {
+ [0]=>
+ string(11) "water=fruit"
+ [1]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(2) {
+ [0]=>
+ string(11) "water=fruit"
+ [1]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(2) {
+ [0]=>
+ string(11) "water=fruit"
+ [1]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(2) {
+ [0]=>
+ string(11) "water=fruit"
+ [1]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(2) {
+ [0]=>
+ string(11) "water=fruit"
+ [1]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(2) {
+ [0]=>
+ string(11) "water=fruit"
+ [1]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(2) {
+ [0]=>
+ string(11) "water=fruit"
+ [1]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(2) {
+ [0]=>
+ string(11) "water=fruit"
+ [1]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(2) {
+ [0]=>
+ string(11) "water=fruit"
+ [1]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(2) {
+ [0]=>
+ string(11) "water=fruit"
+ [1]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(2) {
+ [0]=>
+ string(11) "water=fruit"
+ [1]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(2) {
+ [0]=>
+ string(11) "water=fruit"
+ [1]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(2) {
+ [0]=>
+ string(11) "water=fruit"
+ [1]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(2) {
+ [0]=>
+ string(11) "water=fruit"
+ [1]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(2) {
+ [0]=>
+ string(11) "water=fruit"
+ [1]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(3) {
+ [0]=>
+ string(11) "water-fruit"
+ [1]=>
+ string(3) "air"
+ [2]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(3) {
+ [0]=>
+ string(11) "water-fruit"
+ [1]=>
+ string(3) "air"
+ [2]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(3) {
+ [0]=>
+ string(11) "water-fruit"
+ [1]=>
+ string(3) "air"
+ [2]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(3) {
+ [0]=>
+ string(11) "water-fruit"
+ [1]=>
+ string(3) "air"
+ [2]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(3) {
+ [0]=>
+ string(11) "water-fruit"
+ [1]=>
+ string(3) "air"
+ [2]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(3) {
+ [0]=>
+ string(11) "water-fruit"
+ [1]=>
+ string(3) "air"
+ [2]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(3) {
+ [0]=>
+ string(11) "water-fruit"
+ [1]=>
+ string(3) "air"
+ [2]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(3) {
+ [0]=>
+ string(11) "water-fruit"
+ [1]=>
+ string(3) "air"
+ [2]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(3) {
+ [0]=>
+ string(11) "water-fruit"
+ [1]=>
+ string(3) "air"
+ [2]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(3) {
+ [0]=>
+ string(11) "water-fruit"
+ [1]=>
+ string(3) "air"
+ [2]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(3) {
+ [0]=>
+ string(11) "water-fruit"
+ [1]=>
+ string(3) "air"
+ [2]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(3) {
+ [0]=>
+ string(11) "water-fruit"
+ [1]=>
+ string(3) "air"
+ [2]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(3) {
+ [0]=>
+ string(11) "water-fruit"
+ [1]=>
+ string(3) "air"
+ [2]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(3) {
+ [0]=>
+ string(11) "water-fruit"
+ [1]=>
+ string(3) "air"
+ [2]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(3) {
+ [0]=>
+ string(11) "water-fruit"
+ [1]=>
+ string(3) "air"
+ [2]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(6) {
+ [0]=>
+ string(4) """"""
+ [1]=>
+ string(1) """
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(1) ","
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(6) {
+ [0]=>
+ string(4) """"""
+ [1]=>
+ string(1) """
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(1) ","
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(6) {
+ [0]=>
+ string(4) """"""
+ [1]=>
+ string(1) """
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(1) ","
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(6) {
+ [0]=>
+ string(4) """"""
+ [1]=>
+ string(1) """
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(1) ","
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(6) {
+ [0]=>
+ string(4) """"""
+ [1]=>
+ string(1) """
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(1) ","
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(6) {
+ [0]=>
+ string(4) """"""
+ [1]=>
+ string(1) """
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(1) ","
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(6) {
+ [0]=>
+ string(4) """"""
+ [1]=>
+ string(1) """
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(1) ","
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(6) {
+ [0]=>
+ string(4) """"""
+ [1]=>
+ string(1) """
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(1) ","
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(6) {
+ [0]=>
+ string(4) """"""
+ [1]=>
+ string(1) """
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(1) ","
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(6) {
+ [0]=>
+ string(4) """"""
+ [1]=>
+ string(1) """
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(1) ","
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(6) {
+ [0]=>
+ string(4) """"""
+ [1]=>
+ string(1) """
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(1) ","
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(6) {
+ [0]=>
+ string(4) """"""
+ [1]=>
+ string(1) """
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(1) ","
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(6) {
+ [0]=>
+ string(4) """"""
+ [1]=>
+ string(1) """
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(1) ","
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(6) {
+ [0]=>
+ string(4) """"""
+ [1]=>
+ string(1) """
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(1) ","
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(6) {
+ [0]=>
+ string(4) """"""
+ [1]=>
+ string(1) """
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(1) ","
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+Done
diff --git a/ext/standard/tests/file/fgetcsv_variation20.phpt b/ext/standard/tests/file/fgetcsv_variation20.phpt
new file mode 100644
index 0000000..e96089e
--- /dev/null
+++ b/ext/standard/tests/file/fgetcsv_variation20.phpt
@@ -0,0 +1,191 @@
+--TEST--
+Test fgetcsv() : usage variations - with default enclosure, line without any csv fields
+--FILE--
+<?php
+/*
+ Prototype: array fgetcsv ( resource $handle [, int $length [, string $delimiter [, string $enclosure]]] );
+ Description: Gets line from file pointer and parse for CSV fields
+*/
+
+/*
+ Testing fgetcsv() to read a line without any csv fields from a file
+ when provided with default enclosure value
+*/
+
+echo "*** Testing fgetcsv() : with default enclosure, line without any csv fields ***\n";
+
+$filename = dirname(__FILE__) . '/fgetcsv_variation20.tmp';
+@unlink($filename);
+
+$file_modes = array ("r","rb", "rt", "r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $file_handle = fopen($filename, "w");
+ } else {
+ $file_handle = fopen($filename, $file_modes[$mode_counter] );
+ }
+ if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+ }
+ // write line of text
+ fwrite($file_handle, "This is line of text without csv fields\n");
+
+ // close the file if the mode to be used is read mode and re-open using read mode
+ // else rewind the file pointer to begining of the file
+ if ( strstr($file_modes[$mode_counter], "r" ) ) {
+ fclose($file_handle);
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ } else {
+ // rewind the file pointer to bof
+ rewind($file_handle);
+ }
+
+ echo "\n-- Testing fgetcsv() with file opened using $file_modes[$mode_counter] mode --\n";
+
+ // call fgetcsv() to parse csv fields
+
+ // read the line which is without csv fields, provide delimiter and see the working of fgetcsv
+ $fp_pos = ftell($file_handle);
+ var_dump( fgetcsv($file_handle, 1024) );
+ // check the file pointer position and if eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ // close the file
+ fclose($file_handle);
+ //delete file
+ unlink($filename);
+ } //end of mode loop
+
+echo "Done\n";
+?>
+--EXPECT--
+*** Testing fgetcsv() : with default enclosure, line without any csv fields ***
+
+-- Testing fgetcsv() with file opened using r mode --
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(40)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(40)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(40)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(40)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(40)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(40)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(40)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(40)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(40)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(40)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(40)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(40)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(40)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(40)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(40)
+bool(false)
+Done \ No newline at end of file
diff --git a/ext/standard/tests/file/fgetcsv_variation21.phpt b/ext/standard/tests/file/fgetcsv_variation21.phpt
new file mode 100644
index 0000000..e6a9ee5
--- /dev/null
+++ b/ext/standard/tests/file/fgetcsv_variation21.phpt
@@ -0,0 +1,191 @@
+--TEST--
+Test fgetcsv() : usage variations - with default enclosure, blank line
+--FILE--
+<?php
+/*
+ Prototype: array fgetcsv ( resource $handle [, int $length [, string $delimiter [, string $enclosure]]] );
+ Description: Gets line from file pointer and parse for CSV fields
+*/
+
+/*
+ Testing fgetcsv() to read a file containing blank line when provided with
+ default enclosure argument
+*/
+
+echo "*** Testing fgetcsv() : with default enclosure, blank line ***\n";
+
+$filename = dirname(__FILE__) . '/fgetcsv_variation21.tmp';
+@unlink($filename);
+
+$file_modes = array ("r","rb", "rt", "r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $file_handle = fopen($filename, "w");
+ } else {
+ $file_handle = fopen($filename, $file_modes[$mode_counter] );
+ }
+ if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+ }
+ // write a blank line
+ fwrite($file_handle, "\n"); // blank line
+
+ // close the file if the mode to be used is read mode and re-open using read mode
+ // else rewind the file pointer to begining of the file
+ if ( strstr($file_modes[$mode_counter], "r" ) ) {
+ fclose($file_handle);
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ } else {
+ // rewind the file pointer to bof
+ rewind($file_handle);
+ }
+
+ echo "\n-- Testing fgetcsv() with file opened using $file_modes[$mode_counter] mode --\n";
+
+ // call fgetcsv() to parse csv fields
+
+ // read the line which is a blank line to see the working of fgetcsv
+ $fp_pos = ftell($file_handle);
+ var_dump( fgetcsv($file_handle, 1024, '+') );
+ // check the file pointer position and if eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ // close the file
+ fclose($file_handle);
+ //delete file
+ unlink($filename);
+ } //end of mode loop
+
+echo "Done\n";
+?>
+--EXPECT--
+*** Testing fgetcsv() : with default enclosure, blank line ***
+
+-- Testing fgetcsv() with file opened using r mode --
+array(1) {
+ [0]=>
+ NULL
+}
+int(1)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(1) {
+ [0]=>
+ NULL
+}
+int(1)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(1) {
+ [0]=>
+ NULL
+}
+int(1)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(1) {
+ [0]=>
+ NULL
+}
+int(1)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(1) {
+ [0]=>
+ NULL
+}
+int(1)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(1) {
+ [0]=>
+ NULL
+}
+int(1)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(1) {
+ [0]=>
+ NULL
+}
+int(1)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(1) {
+ [0]=>
+ NULL
+}
+int(1)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(1) {
+ [0]=>
+ NULL
+}
+int(1)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(1) {
+ [0]=>
+ NULL
+}
+int(1)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(1) {
+ [0]=>
+ NULL
+}
+int(1)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(1) {
+ [0]=>
+ NULL
+}
+int(1)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(1) {
+ [0]=>
+ NULL
+}
+int(1)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(1) {
+ [0]=>
+ NULL
+}
+int(1)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(1) {
+ [0]=>
+ NULL
+}
+int(1)
+bool(false)
+Done
diff --git a/ext/standard/tests/file/fgetcsv_variation22.phpt b/ext/standard/tests/file/fgetcsv_variation22.phpt
new file mode 100644
index 0000000..9f35c1c
--- /dev/null
+++ b/ext/standard/tests/file/fgetcsv_variation22.phpt
@@ -0,0 +1,614 @@
+--TEST--
+Test fgetcsv() : usage variations - with default enclosure, file pointer pointing at end of file
+--FILE--
+<?php
+/*
+ Prototype: array fgetcsv ( resource $handle [, int $length [, string $delimiter [, string $enclosure]]] );
+ Description: Gets line from file pointer and parse for CSV fields
+*/
+
+/*
+ Testing fgetcsv() to read a file whose file pointer is pointing to end of file
+ and fgetcsv() provided with default enclosure argument
+*/
+
+echo "*** Testing fgetcsv() : with default enclosure, file pointer pointing at end of file ***\n";
+
+/* the array is with two elements in it. Each element should be read as
+ 1st element is delimiter & 2nd element is csv fields
+*/
+$csv_lists = array (
+ array(',', 'water,fruit'),
+ array(' ', 'water fruit'),
+ array(' ', '"water" "fruit"'),
+ array('\\', 'water\\"fruit"\\"air"'),
+ array('\\', '"water"\\"fruit"\\"""'),
+);
+
+$filename = dirname(__FILE__) . '/fgetcsv_variation22.tmp';
+@unlink($filename);
+
+$file_modes = array ("r","rb", "rt", "r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $file_handle = fopen($filename, "w");
+ } else {
+ $file_handle = fopen($filename, $file_modes[$mode_counter] );
+ }
+ if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+ }
+ $delimiter = $csv_list[0];
+ $csv_field = $csv_list[1];
+
+ fwrite($file_handle, $csv_field . "\n");
+ // write another line of text and a blank line
+ // this will be used to test, if the fgetcsv() read more than a line and its
+ // working when only a blan line is read
+ fwrite($file_handle, "This is line of text without csv fields\n");
+ fwrite($file_handle, "\n"); // blank line
+
+ // close the file if the mode to be used is read mode and re-open using read mode
+ if ( strstr($file_modes[$mode_counter], "r" ) ) {
+ fclose($file_handle);
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ }
+
+ echo "\n-- Testing fgetcsv() with file opened using $file_modes[$mode_counter] mode --\n";
+
+ // set the file pointer to EOF
+ var_dump( fseek($file_handle, 0, SEEK_END) );
+
+ // call fgetcsv() to parse csv fields
+
+ // now file pointer should point to end of the file, try reading again
+ var_dump( feof($file_handle) );
+ var_dump( fgetcsv($file_handle, 1024, $delimiter) ); // with length, delimiter
+ // check the file pointer position and if eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+ // close the file
+ fclose($file_handle);
+ //delete file
+ unlink($filename);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fgetcsv() : with default enclosure, file pointer pointing at end of file ***
+
+-- Testing fgetcsv() with file opened using r mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rb mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rt mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rb mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rt mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rb mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rt mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rb mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rt mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rb mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rt mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+Done
diff --git a/ext/standard/tests/file/fgetcsv_variation23.phpt b/ext/standard/tests/file/fgetcsv_variation23.phpt
new file mode 100644
index 0000000..b766f1e
--- /dev/null
+++ b/ext/standard/tests/file/fgetcsv_variation23.phpt
@@ -0,0 +1,48 @@
+--TEST--
+Test fgetcsv() : usage variations - empty file
+--FILE--
+<?php
+/*
+ Prototype: array fgetcsv ( resource $handle [, int $length [, string $delimiter [, string $enclosure]]] );
+ Description: Gets line from file pointer and parse for CSV fields
+*/
+
+/* Testing fgetcsv() to read from an empty file */
+
+echo "*** Testing fgetcsv() : reading from file which is having zero content ***\n";
+
+// try reading from file which is having zero content
+// create the file and then open in read mode and try reading
+$filename = dirname(__FILE__) . '/fgetcsv_variation23.tmp';
+$fp = fopen ($filename, "w");
+fclose($fp);
+$fp = fopen ($filename, "r");
+if (!$fp) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+}
+var_dump( fgetcsv($fp) );
+var_dump( ftell($fp) );
+var_dump( fgetcsv($fp, 1024) );
+var_dump( ftell($fp) );
+var_dump( fgetcsv($fp, 1024, "+" ) );
+var_dump( ftell($fp) );
+var_dump( fgetcsv($fp, 1024, "+", "%") );
+var_dump( ftell($fp) );
+
+// close and delete the file
+fclose($fp);
+unlink($filename);
+echo "Done\n";
+?>
+--EXPECT--
+*** Testing fgetcsv() : reading from file which is having zero content ***
+bool(false)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(0)
+Done
diff --git a/ext/standard/tests/file/fgetcsv_variation24.phpt b/ext/standard/tests/file/fgetcsv_variation24.phpt
new file mode 100644
index 0000000..89b6d03
--- /dev/null
+++ b/ext/standard/tests/file/fgetcsv_variation24.phpt
@@ -0,0 +1,671 @@
+--TEST--
+Test fgetcsv() : usage variations - two chars as enclosure & delimiter (various write modes)
+--FILE--
+<?php
+/*
+ Prototype: array fgetcsv ( resource $handle [, int $length [, string $delimiter [, string $enclosure]]] );
+ Description: Gets line from file pointer and parse for CSV fields
+*/
+
+/*
+ Testing fgetcsv() to read from a file opened in various write modes and
+ enclosure argument with two characters
+*/
+
+echo "*** Testing fgetcsv() : with two chars as enclosure & delimiter ***\n";
+
+/* the array is with three elements in it. Each element should be read as
+ 1st element is delimiter, 2nd element is enclosure
+ and 3rd element is csv fields
+*/
+$csv_lists = array (
+ array(',', '"', '"water",fruit'),
+ array(',', '"', '"water","fruit"'),
+ array(' ', '^', '^water^ ^fruit^'),
+ array(':', '&', '&water&:&fruit&'),
+ array('=', '=', '=water===fruit='),
+ array('-', '-', '-water--fruit-air'),
+ array('-', '-', '-water---fruit---air-'),
+ array(':', '&', '&""""&:&"&:,:":&,&:,,,,')
+);
+
+$filename = dirname(__FILE__) . '/fgetcsv_variation24.tmp';
+@unlink($filename);
+
+$file_modes = array ("w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $file_handle = fopen($filename, "w");
+ } else {
+ $file_handle = fopen($filename, $file_modes[$mode_counter] );
+ }
+ if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+ }
+ $delimiter = $csv_list[0];
+ $enclosure = $csv_list[1];
+ $csv_field = $csv_list[2];
+ fwrite($file_handle, $csv_field . "\n");
+ // write another line of text and a blank line
+ // this will be used to test, if the fgetcsv() read more than a line and its
+ // working when only a blank line is read
+ fwrite($file_handle, "This is line of text without csv fields\n");
+ fwrite($file_handle, "\n"); // blank line
+
+ // close the file if the mode to be used is read mode and re-open using read mode
+ // else rewind the file pointer to begining of the file
+ if ( strstr($file_modes[$mode_counter], "r" ) ) {
+ fclose($file_handle);
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ } else {
+ // rewind the file pointer to bof
+ rewind($file_handle);
+ }
+
+ echo "\n-- Testing fgetcsv() with file opened using $file_modes[$mode_counter] mode --\n";
+
+ // call fgetcsv() to parse csv fields
+
+ // use delimiter & enclosure char of two chars
+ fseek($file_handle, 0, SEEK_SET);
+ $del = "++";
+ $enc = "%%";
+ var_dump( fgetcsv($file_handle, 1024, $del, $enc) );
+ // check the file pointer position and if eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ // close the file
+ fclose($file_handle);
+ //delete file
+ unlink($filename);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fgetcsv() : with two chars as enclosure & delimiter ***
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(13) ""water",fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(13) ""water",fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(13) ""water",fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(13) ""water",fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(13) ""water",fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(13) ""water",fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) ""water","fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) ""water","fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) ""water","fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) ""water","fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) ""water","fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) ""water","fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) "^water^ ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) "^water^ ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) "^water^ ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) "^water^ ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) "^water^ ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) "^water^ ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) "&water&:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) "&water&:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) "&water&:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) "&water&:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) "&water&:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) "&water&:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) "=water===fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) "=water===fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) "=water===fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) "=water===fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) "=water===fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(15) "=water===fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(17) "-water--fruit-air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(17) "-water--fruit-air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(17) "-water--fruit-air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(17) "-water--fruit-air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(17) "-water--fruit-air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(17) "-water--fruit-air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(21) "-water---fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(21) "-water---fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(21) "-water---fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(21) "-water---fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(21) "-water---fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(21) "-water---fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(23) "&""""&:&"&:,:":&,&:,,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(23) "&""""&:&"&:,:":&,&:,,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(23) "&""""&:&"&:,:":&,&:,,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(23) "&""""&:&"&:,:":&,&:,,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(23) "&""""&:&"&:,:":&,&:,,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Notice: fgetcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fgetcsv(): enclosure must be a single character in %s on line %d
+array(1) {
+ [0]=>
+ string(23) "&""""&:&"&:,:":&,&:,,,,"
+}
+int(24)
+bool(false)
+Done
diff --git a/ext/standard/tests/file/fgetcsv_variation25.phpt b/ext/standard/tests/file/fgetcsv_variation25.phpt
new file mode 100644
index 0000000..1877bc0
--- /dev/null
+++ b/ext/standard/tests/file/fgetcsv_variation25.phpt
@@ -0,0 +1,935 @@
+--TEST--
+Test fgetcsv() : usage variations - with negative length value along with enclosure and delimiter
+--FILE--
+<?php
+/*
+ Prototype: array fgetcsv ( resource $handle [, int $length [, string $delimiter [, string $enclosure]]] );
+ Description: Gets line from file pointer and parse for CSV fields
+*/
+
+/*
+ Testing fgetcsv() to read from a file when provided with negative length argument
+ along with delimiter and enclosure arguments
+*/
+
+echo "*** Testing fgetcsv() : with negative length value ***\n";
+
+/* the array is with three elements in it. Each element should be read as
+ 1st element is delimiter, 2nd element is enclosure
+ and 3rd element is csv fields
+*/
+$csv_lists = array (
+ array(',', '"', '"water",fruit'),
+ array(',', '"', '"water","fruit"'),
+ array(' ', '^', '^water^ ^fruit^'),
+ array(':', '&', '&water&:&fruit&'),
+ array('=', '=', '=water===fruit='),
+ array('-', '-', '-water--fruit-air'),
+ array('-', '-', '-water---fruit---air-'),
+ array(':', '&', '&""""&:&"&:,:":&,&:,,,,')
+);
+
+$filename = dirname(__FILE__) . '/fgetcsv_variation25.tmp';
+@unlink($filename);
+
+$file_modes = array ("r","rb", "rt", "r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $file_handle = fopen($filename, "w");
+ } else {
+ $file_handle = fopen($filename, $file_modes[$mode_counter] );
+ }
+ if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+ }
+ $delimiter = $csv_list[0];
+ $enclosure = $csv_list[1];
+ $csv_field = $csv_list[2];
+
+ fwrite($file_handle, $csv_field . "\n");
+ // write another line of text and a blank line
+ // this will be used to test, if the fgetcsv() read more than a line and its
+ // working when only a blank line is read
+ fwrite($file_handle, "This is line of text without csv fields\n");
+ fwrite($file_handle, "\n"); // blank line
+
+ // close the file if the mode to be used is read mode and re-open using read mode
+ // else rewind the file pointer to begining of the file
+ if ( strstr($file_modes[$mode_counter], "r" ) ) {
+ fclose($file_handle);
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ } else {
+ // rewind the file pointer to bof
+ rewind($file_handle);
+ }
+
+ echo "\n-- Testing fgetcsv() with file opened using $file_modes[$mode_counter] mode --\n";
+
+ // call fgetcsv() to parse csv fields
+
+ // use the right delimiter and enclosure with negative length
+ var_dump( fgetcsv($file_handle, -10, $delimiter, $enclosure) );
+ // check the file pointer position and if eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ // close the file
+ fclose($file_handle);
+ //delete file
+ unlink($filename);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fgetcsv() : with negative length value ***
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+Done
diff --git a/ext/standard/tests/file/fgetcsv_variation26.phpt b/ext/standard/tests/file/fgetcsv_variation26.phpt
new file mode 100644
index 0000000..c042eb4
--- /dev/null
+++ b/ext/standard/tests/file/fgetcsv_variation26.phpt
@@ -0,0 +1,441 @@
+--TEST--
+Test fgetcsv() : usage variations - reading files opened in write only mode (Bug #42036)
+--FILE--
+<?php
+/*
+ Prototype: array fgetcsv ( resource $handle [, int $length [, string $delimiter [, string $enclosure]]] );
+ Description: Gets line from file pointer and parse for CSV fields
+*/
+
+/* Testing fgetcsv() to read from files opened in write only mode */
+
+echo "*** Testing fgetcsv() : reading the files opened in write only mode ***\n";
+
+/* the array is with three elements in it. Each element should be read as
+ 1st element is delimiter, 2nd element is enclosure
+ and 3rd element is csv fields
+*/
+$csv_lists = array (
+ array(',', '"', '"water",fruit'),
+ array(',', '"', '"water","fruit"'),
+ array(' ', '^', '^water^ ^fruit^'),
+ array(':', '&', '&water&:&fruit&'),
+ array('=', '=', '=water===fruit='),
+ array('-', '-', '-water--fruit-air'),
+ array('-', '-', '-water---fruit---air-'),
+ array(':', '&', '&""""&:&"&:,:":&,&:,,,,')
+);
+
+$filename = dirname(__FILE__) . '/fgetcsv_variation26.tmp';
+@unlink($filename);
+
+$file_modes = array ("w", "wb", "wt",
+ "a", "ab", "at",
+ "x", "xb", "xt");
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ // create the file and add the content with has csv fields
+ $file_handle = fopen($filename, $file_modes[$mode_counter] );
+
+ if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+ }
+ $delimiter = $csv_list[0];
+ $enclosure = $csv_list[1];
+ $csv_field = $csv_list[2];
+
+ fwrite($file_handle, $csv_field . "\n");
+ // write another line of text and a blank line
+ // this will be used to test, if the fgetcsv() read more than a line and its
+ // working when only a blank line is read
+ fwrite($file_handle, "This is line of text without csv fields\n");
+ fwrite($file_handle, "\n"); // blank line
+
+ // rewind the file pointer to bof
+ rewind($file_handle);
+
+ echo "\n-- Testing fgetcsv() with file opened using $file_modes[$mode_counter] mode --\n";
+
+ // call fgetcsv() to parse csv fields
+
+ // use the right delimiter and enclosure with max length
+ var_dump( fgetcsv($file_handle, 1024, $delimiter, $enclosure) );
+ // check the file pointer position and if eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ // close the file
+ fclose($file_handle);
+ //delete file
+ unlink($filename);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECT--
+*** Testing fgetcsv() : reading the files opened in write only mode ***
+
+-- Testing fgetcsv() with file opened using w mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using wb mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using wt mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using ab mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using at mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using xb mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using xt mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using wb mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using wt mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using ab mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using at mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using xb mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using xt mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using wb mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using wt mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using ab mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using at mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using xb mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using xt mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using wb mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using wt mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using ab mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using at mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using xb mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using xt mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using wb mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using wt mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using ab mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using at mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using xb mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using xt mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using wb mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using wt mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using ab mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using at mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using xb mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using xt mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using wb mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using wt mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using ab mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using at mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using xb mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using xt mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using wb mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using wt mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using ab mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using at mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using xb mode --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using xt mode --
+bool(false)
+int(0)
+bool(false)
+Done
diff --git a/ext/standard/tests/file/fgetcsv_variation27.phpt b/ext/standard/tests/file/fgetcsv_variation27.phpt
new file mode 100644
index 0000000..aafc3ab
--- /dev/null
+++ b/ext/standard/tests/file/fgetcsv_variation27.phpt
@@ -0,0 +1,935 @@
+--TEST--
+Test fgetcsv() : usage variations - with negative length value along with delimiter and no enclosure
+--FILE--
+<?php
+/*
+ Prototype: array fgetcsv ( resource $handle [, int $length [, string $delimiter [, string $enclosure]]] );
+ Description: Gets line from file pointer and parse for CSV fields
+*/
+
+/*
+ Testing fgetcsv() to read from a file when provided with negative length argument
+ along with delimiter and no enclosure arguments
+*/
+
+echo "*** Testing fgetcsv() : with negative length value ***\n";
+
+/* the array is with three elements in it. Each element should be read as
+ 1st element is delimiter, 2nd element is enclosure
+ and 3rd element is csv fields
+*/
+$csv_lists = array (
+ array(',', '"', '"water",fruit'),
+ array(',', '"', '"water","fruit"'),
+ array(' ', '^', '^water^ ^fruit^'),
+ array(':', '&', '&water&:&fruit&'),
+ array('=', '=', '=water===fruit='),
+ array('-', '-', '-water--fruit-air'),
+ array('-', '-', '-water---fruit---air-'),
+ array(':', '&', '&""""&:&"&:,:":&,&:,,,,')
+);
+
+$filename = dirname(__FILE__) . '/fgetcsv_variation27.tmp';
+@unlink($filename);
+
+$file_modes = array ("r","rb", "rt", "r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $file_handle = fopen($filename, "w");
+ } else {
+ $file_handle = fopen($filename, $file_modes[$mode_counter] );
+ }
+ if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+ }
+ $delimiter = $csv_list[0];
+ $enclosure = $csv_list[1];
+ $csv_field = $csv_list[2];
+
+ fwrite($file_handle, $csv_field . "\n");
+ // write another line of text and a blank line
+ // this will be used to test, if the fgetcsv() read more than a line and its
+ // working when only a blank line is read
+ fwrite($file_handle, "This is line of text without csv fields\n");
+ fwrite($file_handle, "\n"); // blank line
+
+ // close the file if the mode to be used is read mode and re-open using read mode
+ // else rewind the file pointer to begining of the file
+ if ( strstr($file_modes[$mode_counter], "r" ) ) {
+ fclose($file_handle);
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ } else {
+ // rewind the file pointer to bof
+ rewind($file_handle);
+ }
+
+ echo "\n-- Testing fgetcsv() with file opened using $file_modes[$mode_counter] mode --\n";
+
+ // call fgetcsv() to parse csv fields
+
+ // use the right delimiter and enclosure with negative length
+ var_dump( fgetcsv($file_handle, -10, $delimiter) );
+ // check the file pointer position and if eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ // close the file
+ fclose($file_handle);
+ //delete file
+ unlink($filename);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fgetcsv() : with negative length value ***
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+Done
diff --git a/ext/standard/tests/file/fgetcsv_variation28.phpt b/ext/standard/tests/file/fgetcsv_variation28.phpt
new file mode 100644
index 0000000..56dd538
--- /dev/null
+++ b/ext/standard/tests/file/fgetcsv_variation28.phpt
@@ -0,0 +1,935 @@
+--TEST--
+Test fgetcsv() : usage variations - with negative length value along with neither enclosure and nor delimiter
+--FILE--
+<?php
+/*
+ Prototype: array fgetcsv ( resource $handle [, int $length [, string $delimiter [, string $enclosure]]] );
+ Description: Gets line from file pointer and parse for CSV fields
+*/
+
+/*
+ Testing fgetcsv() to read from a file when provided with negative length argument
+ along with neither delimiter nor enclosure argument
+*/
+
+echo "*** Testing fgetcsv() : with negative length value ***\n";
+
+/* the array is with three elements in it. Each element should be read as
+ 1st element is delimiter, 2nd element is enclosure
+ and 3rd element is csv fields
+*/
+$csv_lists = array (
+ array(',', '"', '"water",fruit'),
+ array(',', '"', '"water","fruit"'),
+ array(' ', '^', '^water^ ^fruit^'),
+ array(':', '&', '&water&:&fruit&'),
+ array('=', '=', '=water===fruit='),
+ array('-', '-', '-water--fruit-air'),
+ array('-', '-', '-water---fruit---air-'),
+ array(':', '&', '&""""&:&"&:,:":&,&:,,,,')
+);
+
+$filename = dirname(__FILE__) . '/fgetcsv_variation28.tmp';
+@unlink($filename);
+
+$file_modes = array ("r","rb", "rt", "r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $file_handle = fopen($filename, "w");
+ } else {
+ $file_handle = fopen($filename, $file_modes[$mode_counter] );
+ }
+ if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+ }
+ $delimiter = $csv_list[0];
+ $enclosure = $csv_list[1];
+ $csv_field = $csv_list[2];
+
+ fwrite($file_handle, $csv_field . "\n");
+ // write another line of text and a blank line
+ // this will be used to test, if the fgetcsv() read more than a line and its
+ // working when only a blank line is read
+ fwrite($file_handle, "This is line of text without csv fields\n");
+ fwrite($file_handle, "\n"); // blank line
+
+ // close the file if the mode to be used is read mode and re-open using read mode
+ // else rewind the file pointer to begining of the file
+ if ( strstr($file_modes[$mode_counter], "r" ) ) {
+ fclose($file_handle);
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ } else {
+ // rewind the file pointer to bof
+ rewind($file_handle);
+ }
+
+ echo "\n-- Testing fgetcsv() with file opened using $file_modes[$mode_counter] mode --\n";
+
+ // call fgetcsv() to parse csv fields
+
+ // use the right delimiter and enclosure with negative length
+ var_dump( fgetcsv($file_handle, -10) );
+ // check the file pointer position and if eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ // close the file
+ fclose($file_handle);
+ //delete file
+ unlink($filename);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fgetcsv() : with negative length value ***
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): Length parameter may not be negative in %s on line %d
+bool(false)
+int(0)
+bool(false)
+Done
diff --git a/ext/standard/tests/file/fgetcsv_variation29.phpt b/ext/standard/tests/file/fgetcsv_variation29.phpt
new file mode 100644
index 0000000..08c7503
--- /dev/null
+++ b/ext/standard/tests/file/fgetcsv_variation29.phpt
@@ -0,0 +1,615 @@
+--TEST--
+Test fgetcsv() : usage variations - with only file handle as argument, file pointer pointing at end of file
+--FILE--
+<?php
+/*
+ Prototype: array fgetcsv ( resource $handle [, int $length [, string $delimiter [, string $enclosure]]] );
+ Description: Gets line from file pointer and parse for CSV fields
+*/
+
+/*
+ Testing fgetcsv() to read a file whose file pointer is pointing to end of file
+ and fgetcsv() provided with only file handle in its argument
+*/
+
+echo "*** Testing fgetcsv() : with file handle as only argument and file pointer pointing at end of file ***\n";
+
+/* the array is with two elements in it. Each element should be read as
+ 1st element is delimiter & 2nd element is csv fields
+*/
+$csv_lists = array (
+ array(',', 'water,fruit'),
+ array(' ', 'water fruit'),
+ array(' ', '"water" "fruit"'),
+ array('\\', 'water\\"fruit"\\"air"'),
+ array('\\', '"water"\\"fruit"\\"""'),
+);
+
+$filename = dirname(__FILE__) . '/fgetcsv_variation29.tmp';
+@unlink($filename);
+
+$file_modes = array ("r","rb", "rt", "r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $file_handle = fopen($filename, "w");
+ } else {
+ $file_handle = fopen($filename, $file_modes[$mode_counter] );
+ }
+ if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+ }
+ $delimiter = $csv_list[0];
+ $csv_field = $csv_list[1];
+
+ fwrite($file_handle, $csv_field . "\n");
+ // write another line of text and a blank line
+ // this will be used to test, if the fgetcsv() read more than a line and its
+ // working when only a blan line is read
+ fwrite($file_handle, "This is line of text without csv fields\n");
+ fwrite($file_handle, "\n"); // blank line
+
+ // close the file if the mode to be used is read mode and re-open using read mode
+ // else rewind the file pointer to begining of the file
+ if ( strstr($file_modes[$mode_counter], "r" ) ) {
+ fclose($file_handle);
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ }
+
+ echo "\n-- Testing fgetcsv() with file opened using $file_modes[$mode_counter] mode --\n";
+
+ // set the file pointer to EOF
+ var_dump( fseek($file_handle, 0, SEEK_END) );
+
+ // call fgetcsv() to parse csv fields
+
+ // now file pointer should point to end of the file, try reading again
+ var_dump( feof($file_handle) );
+ var_dump( fgetcsv($file_handle) );
+ // check the file pointer position and if eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+ // close the file
+ fclose($file_handle);
+ //delete file
+ unlink($filename);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fgetcsv() : with file handle as only argument and file pointer pointing at end of file ***
+
+-- Testing fgetcsv() with file opened using r mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rb mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rt mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rb mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rt mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rb mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rt mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rb mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rt mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rb mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rt mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+Done
diff --git a/ext/standard/tests/file/fgetcsv_variation3.phpt b/ext/standard/tests/file/fgetcsv_variation3.phpt
new file mode 100644
index 0000000..52c094f
--- /dev/null
+++ b/ext/standard/tests/file/fgetcsv_variation3.phpt
@@ -0,0 +1,933 @@
+--TEST--
+Test fgetcsv() : usage variations - with delimiter as NULL
+--FILE--
+<?php
+/*
+ Prototype: array fgetcsv ( resource $handle [, int $length [, string $delimiter [, string $enclosure]]] );
+ Description: Gets line from file pointer and parse for CSV fields
+*/
+
+/* Testing fgetcsv() to read from a file when provided with delimiter value as NULL */
+
+echo "*** Testing fgetcsv() : with delimiter as NULL ***\n";
+
+/* the array is with three elements in it. Each element should be read as
+ 1st element is delimiter, 2nd element is enclosure
+ and 3rd element is csv fields
+*/
+$csv_lists = array (
+ array(',', '"', '"water",fruit'),
+ array(',', '"', '"water","fruit"'),
+ array(' ', '^', '^water^ ^fruit^'),
+ array(':', '&', '&water&:&fruit&'),
+ array('=', '=', '=water===fruit='),
+ array('-', '-', '-water--fruit-air'),
+ array('-', '-', '-water---fruit---air-'),
+ array(':', '&', '&""""&:&"&:,:":&,&:,,,,')
+);
+
+$filename = dirname(__FILE__) . '/fgetcsv_variation3.tmp';
+@unlink($filename);
+
+$file_modes = array ("r","rb", "rt", "r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $file_handle = fopen($filename, "w");
+ } else {
+ $file_handle = fopen($filename, $file_modes[$mode_counter] );
+ }
+ if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+ }
+ $delimiter = $csv_list[0];
+ $enclosure = $csv_list[1];
+ $csv_field = $csv_list[2];
+
+ fwrite($file_handle, $csv_field . "\n");
+ // write another line of text and a blank line
+ // this will be used to test, if the fgetcsv() read more than a line and its
+ // working when only a blank line is read
+ fwrite($file_handle, "This is line of text without csv fields\n");
+ fwrite($file_handle, "\n"); // blank line
+
+ // close the file if the mode to be used is read mode and re-open using read mode
+ // else rewind the file pointer to begining of the file
+ if ( strstr($file_modes[$mode_counter], "r" ) ) {
+ fclose($file_handle);
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ } else {
+ // rewind the file pointer to bof
+ rewind($file_handle);
+ }
+
+ echo "\n-- Testing fgetcsv() with file opened using $file_modes[$mode_counter] mode --\n";
+
+ // call fgetcsv() to parse csv fields
+
+ // use length as 0
+ fseek($file_handle, 0, SEEK_SET);
+ var_dump( fgetcsv($file_handle, 1024, NULL, $enclosure) );
+ // check the file pointer position and if eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ // close the file
+ fclose($file_handle);
+ //delete file
+ unlink($filename);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fgetcsv() : with delimiter as NULL ***
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+Done
diff --git a/ext/standard/tests/file/fgetcsv_variation30.phpt b/ext/standard/tests/file/fgetcsv_variation30.phpt
new file mode 100644
index 0000000..e474b2d
--- /dev/null
+++ b/ext/standard/tests/file/fgetcsv_variation30.phpt
@@ -0,0 +1,614 @@
+--TEST--
+Test fgetcsv() : usage variations - with file handle and length, file pointer pointing at end of file
+--FILE--
+<?php
+/*
+ Prototype: array fgetcsv ( resource $handle [, int $length [, string $delimiter [, string $enclosure]]] );
+ Description: Gets line from file pointer and parse for CSV fields
+*/
+
+/*
+ Testing fgetcsv() to read a file whose file pointer is pointing to end of file
+ and fgetcsv() provided with file handle and length arguments
+*/
+
+echo "*** Testing fgetcsv() : with file handle and length arguments, file pointer pointing at end of file ***\n";
+
+/* the array is with two elements in it. Each element should be read as
+ 1st element is delimiter & 2nd element is csv fields
+*/
+$csv_lists = array (
+ array(',', 'water,fruit'),
+ array(' ', 'water fruit'),
+ array(' ', '"water" "fruit"'),
+ array('\\', 'water\\"fruit"\\"air"'),
+ array('\\', '"water"\\"fruit"\\"""'),
+);
+
+$filename = dirname(__FILE__) . '/fgetcsv_variation30.tmp';
+@unlink($filename);
+
+$file_modes = array ("r","rb", "rt", "r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $file_handle = fopen($filename, "w");
+ } else {
+ $file_handle = fopen($filename, $file_modes[$mode_counter] );
+ }
+ if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+ }
+ $delimiter = $csv_list[0];
+ $csv_field = $csv_list[1];
+
+ fwrite($file_handle, $csv_field . "\n");
+ // write another line of text and a blank line
+ // this will be used to test, if the fgetcsv() read more than a line and its
+ // working when only a blan line is read
+ fwrite($file_handle, "This is line of text without csv fields\n");
+ fwrite($file_handle, "\n"); // blank line
+
+ // close the file if the mode to be used is read mode and re-open using read mode
+ if ( strstr($file_modes[$mode_counter], "r" ) ) {
+ fclose($file_handle);
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ }
+
+ echo "\n-- Testing fgetcsv() with file opened using $file_modes[$mode_counter] mode --\n";
+
+ // set the file pointer to EOF
+ var_dump( fseek($file_handle, 0, SEEK_END) );
+
+ // call fgetcsv() to parse csv fields
+
+ // now file pointer should point to end of the file, try reading again
+ var_dump( feof($file_handle) );
+ var_dump( fgetcsv($file_handle, 1024) );
+ // check the file pointer position and if eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+ // close the file
+ fclose($file_handle);
+ //delete file
+ unlink($filename);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fgetcsv() : with file handle and length arguments, file pointer pointing at end of file ***
+
+-- Testing fgetcsv() with file opened using r mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rb mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rt mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rb mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rt mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rb mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rt mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rb mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rt mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rb mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rt mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+Done
diff --git a/ext/standard/tests/file/fgetcsv_variation31.phpt b/ext/standard/tests/file/fgetcsv_variation31.phpt
new file mode 100644
index 0000000..1d896b7
--- /dev/null
+++ b/ext/standard/tests/file/fgetcsv_variation31.phpt
@@ -0,0 +1,616 @@
+--TEST--
+Test fgetcsv() : usage variations - with length and enclosure, file pointer pointing at end of file
+--FILE--
+<?php
+/*
+ Prototype: array fgetcsv ( resource $handle [, int $length [, string $delimiter [, string $enclosure]]] );
+ Description: Gets line from file pointer and parse for CSV fields
+*/
+
+/*
+ Testing fgetcsv() to read a file whose file pointer is pointing to end of file
+ and fgetcsv() provided with enclosure argument
+*/
+
+echo "*** Testing fgetcsv() : with enclosure argument, file pointer pointing at end of file ***\n";
+
+/* the array is with two elements in it. Each element should be read as
+ 1st element is delimiter & 2nd element is csv fields
+*/
+$csv_lists = array (
+ array(',', 'water,fruit'),
+ array(' ', 'water fruit'),
+ array(' ', '"water" "fruit"'),
+ array('\\', 'water\\"fruit"\\"air"'),
+ array('\\', '"water"\\"fruit"\\"""'),
+);
+
+$filename = dirname(__FILE__) . '/fgetcsv_variation31.tmp';
+@unlink($filename);
+
+$file_modes = array ("r","rb", "rt", "r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $file_handle = fopen($filename, "w");
+ } else {
+ $file_handle = fopen($filename, $file_modes[$mode_counter] );
+ }
+ if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+ }
+ $delimiter = $csv_list[0];
+ $csv_field = $csv_list[1];
+
+ fwrite($file_handle, $csv_field . "\n");
+ // write another line of text and a blank line
+ // this will be used to test, if the fgetcsv() read more than a line and its
+ // working when only a blan line is read
+ fwrite($file_handle, "This is line of text without csv fields\n");
+ fwrite($file_handle, "\n"); // blank line
+
+ // close the file if the mode to be used is read mode and re-open using read mode
+ // else rewind the file pointer to begining of the file
+ if ( strstr($file_modes[$mode_counter], "r" ) ) {
+ fclose($file_handle);
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ }
+
+ echo "\n-- Testing fgetcsv() with file opened using $file_modes[$mode_counter] mode --\n";
+
+ // set the file pointer to EOF
+ var_dump( fseek($file_handle, 0, SEEK_END) );
+
+ // call fgetcsv() to parse csv fields
+
+ // now file pointer should point to end of the file, try reading again
+ var_dump( feof($file_handle) );
+ $enc = 'z';
+ var_dump( fgetcsv($file_handle, 1024, $delimiter, $enc ) ); // with length, delimiter
+ // check the file pointer position and if eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+ // close the file
+ fclose($file_handle);
+ //delete file
+ unlink($filename);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fgetcsv() : with enclosure argument, file pointer pointing at end of file ***
+
+-- Testing fgetcsv() with file opened using r mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rb mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rt mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rb mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rt mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+int(0)
+bool(false)
+bool(false)
+int(53)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rb mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rt mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+int(0)
+bool(false)
+bool(false)
+int(57)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rb mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rt mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rb mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using rt mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+int(0)
+bool(false)
+bool(false)
+int(61)
+bool(true)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+int(0)
+bool(false)
+bool(false)
+int(%d)
+bool(true)
+Done
diff --git a/ext/standard/tests/file/fgetcsv_variation4.phpt b/ext/standard/tests/file/fgetcsv_variation4.phpt
new file mode 100644
index 0000000..0c84484
--- /dev/null
+++ b/ext/standard/tests/file/fgetcsv_variation4.phpt
@@ -0,0 +1,932 @@
+--TEST--
+Test fgetcsv() : usage variations - with enclosure as NULL
+--FILE--
+<?php
+/*
+ Prototype: array fgetcsv ( resource $handle [, int $length [, string $delimiter [, string $enclosure]]] );
+ Description: Gets line from file pointer and parse for CSV fields
+*/
+
+/* Testing fgetcsv() to read from a file when provided with enclosure value as NULL */
+
+echo "*** Testing fgetcsv() : with enclosure as NULL ***\n";
+
+/* the array is with three elements in it. Each element should be read as
+ 1st element is delimiter, 2nd element is enclosure
+ and 3rd element is csv fields
+*/
+$csv_lists = array (
+ array(',', '"', '"water",fruit'),
+ array(',', '"', '"water","fruit"'),
+ array(' ', '^', '^water^ ^fruit^'),
+ array(':', '&', '&water&:&fruit&'),
+ array('=', '=', '=water===fruit='),
+ array('-', '-', '-water--fruit-air'),
+ array('-', '-', '-water---fruit---air-'),
+ array(':', '&', '&""""&:&"&:,:":&,&:,,,,')
+);
+
+$filename = dirname(__FILE__) . '/fgetcsv_variation4.tmp';
+@unlink($filename);
+
+$file_modes = array ("r","rb", "rt", "r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $file_handle = fopen($filename, "w");
+ } else {
+ $file_handle = fopen($filename, $file_modes[$mode_counter] );
+ }
+ if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+ }
+ $delimiter = $csv_list[0];
+ $enclosure = $csv_list[1];
+ $csv_field = $csv_list[2];
+ fwrite($file_handle, $csv_field . "\n");
+ // write another line of text and a blank line
+ // this will be used to test, if the fgetcsv() read more than a line and its
+ // working when only a blan line is read
+ fwrite($file_handle, "This is line of text without csv fields\n");
+ fwrite($file_handle, "\n"); // blank line
+
+ // close the file if the mode to be used is read mode and re-open using read mode
+ // else rewind the file pointer to begining of the file
+ if ( strstr($file_modes[$mode_counter], "r" ) ) {
+ fclose($file_handle);
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ } else {
+ // rewind the file pointer to bof
+ rewind($file_handle);
+ }
+
+ echo "\n-- Testing fgetcsv() with file opened using $file_modes[$mode_counter] mode --\n";
+
+ // call fgetcsv() to parse csv fields
+
+ // use length as 0
+ fseek($file_handle, 0, SEEK_SET);
+ var_dump( fgetcsv($file_handle, 0, $delimiter, NULL) );
+ // check the file pointer position and if eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ // close the file
+ fclose($file_handle);
+ //delete file
+ unlink($filename);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fgetcsv() : with enclosure as NULL ***
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+Done
diff --git a/ext/standard/tests/file/fgetcsv_variation5.phpt b/ext/standard/tests/file/fgetcsv_variation5.phpt
new file mode 100644
index 0000000..283fa40
--- /dev/null
+++ b/ext/standard/tests/file/fgetcsv_variation5.phpt
@@ -0,0 +1,934 @@
+--TEST--
+Test fgetcsv() : usage variations - with delimiter & enclosure as NULL
+--FILE--
+<?php
+/*
+ Prototype: array fgetcsv ( resource $handle [, int $length [, string $delimiter [, string $enclosure]]] );
+ Description: Gets line from file pointer and parse for CSV fields
+*/
+
+/*
+ Testing fgetcsv() to read from a file when provided with delimiter and
+ enclosure values both as NULL
+ */
+
+echo "*** Testing fgetcsv() : with delimiter & enclosure as NULL ***\n";
+
+/* the array is with three elements in it. Each element should be read as
+ 1st element is delimiter, 2nd element is enclosure
+ and 3rd element is csv fields
+*/
+$csv_lists = array (
+ array(',', '"', '"water",fruit'),
+ array(',', '"', '"water","fruit"'),
+ array(' ', '^', '^water^ ^fruit^'),
+ array(':', '&', '&water&:&fruit&'),
+ array('=', '=', '=water===fruit='),
+ array('-', '-', '-water--fruit-air'),
+ array('-', '-', '-water---fruit---air-'),
+ array(':', '&', '&""""&:&"&:,:":&,&:,,,,')
+);
+
+$filename = dirname(__FILE__) . '/fgetcsv_variation5.tmp';
+@unlink($filename);
+
+$file_modes = array ("r","rb", "rt", "r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $file_handle = fopen($filename, "w");
+ } else {
+ $file_handle = fopen($filename, $file_modes[$mode_counter] );
+ }
+ if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+ }
+ $delimiter = $csv_list[0];
+ $enclosure = $csv_list[1];
+ $csv_field = $csv_list[2];
+ fwrite($file_handle, $csv_field . "\n");
+ // write another line of text and a blank line
+ // this will be used to test, if the fgetcsv() read more than a line and its
+ // working when only a blank line is read
+ fwrite($file_handle, "This is line of text without csv fields\n");
+ fwrite($file_handle, "\n"); // blank line
+
+ // close the file if the mode to be used is read mode and re-open using read mode
+ // else rewind the file pointer to begining of the file
+ if ( strstr($file_modes[$mode_counter], "r" ) ) {
+ fclose($file_handle);
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ } else {
+ // rewind the file pointer to bof
+ rewind($file_handle);
+ }
+
+ echo "\n-- Testing fgetcsv() with file opened using $file_modes[$mode_counter] mode --\n";
+
+ // call fgetcsv() to parse csv fields
+
+ fseek($file_handle, 0, SEEK_SET);
+ var_dump( fgetcsv($file_handle, 1024, NULL, NULL) );
+ // check the file pointer position and if eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ // close the file
+ fclose($file_handle);
+ //delete file
+ unlink($filename);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fgetcsv() : with delimiter & enclosure as NULL ***
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+
+Warning: fgetcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+Done
diff --git a/ext/standard/tests/file/fgetcsv_variation6.phpt b/ext/standard/tests/file/fgetcsv_variation6.phpt
new file mode 100644
index 0000000..9878cb9
--- /dev/null
+++ b/ext/standard/tests/file/fgetcsv_variation6.phpt
@@ -0,0 +1,2350 @@
+--TEST--
+Test fgetcsv() : usage variations - with length less than line size
+--FILE--
+<?php
+/*
+ Prototype: array fgetcsv ( resource $handle [, int $length [, string $delimiter [, string $enclosure]]] );
+ Description: Gets line from file pointer and parse for CSV fields
+*/
+
+/*
+ Testing fgetcsv() to read from a file when provided with the length argument
+ value less than the line size
+*/
+
+echo "*** Testing fgetcsv() : with length less than line size ***\n";
+
+/* the array is with three elements in it. Each element should be read as
+ 1st element is delimiter, 2nd element is enclosure
+ and 3rd element is csv fields
+*/
+$csv_lists = array (
+ array(',', '"', '"water",fruit'),
+ array(',', '"', '"water","fruit"'),
+ array(' ', '^', '^water^ ^fruit^'),
+ array(':', '&', '&water&:&fruit&'),
+ array('=', '=', '=water===fruit='),
+ array('-', '-', '-water--fruit-air'),
+ array('-', '-', '-water---fruit---air-'),
+ array(':', '&', '&""""&:&"&:,:":&,&:,,,,')
+);
+
+$filename = dirname(__FILE__) . '/fgetcsv_variation6.tmp';
+@unlink($filename);
+
+$file_modes = array ("r","rb", "rt", "r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $file_handle = fopen($filename, "w");
+ } else {
+ $file_handle = fopen($filename, $file_modes[$mode_counter] );
+ }
+ if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+ }
+ $delimiter = $csv_list[0];
+ $enclosure = $csv_list[1];
+ $csv_field = $csv_list[2];
+ fwrite($file_handle, $csv_field . "\n");
+ // write another line of text and a blank line
+ // this will be used to test, if the fgetcsv() read more than a line and its
+ // working when only a blan line is read
+ fwrite($file_handle, "This is line of text without csv fields\n");
+ fwrite($file_handle, "\n"); // blank line
+
+ // close the file if the mode to be used is read mode and re-open using read mode
+ // else rewind the file pointer to begining of the file
+ if ( strstr($file_modes[$mode_counter], "r" ) ) {
+ fclose($file_handle);
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ } else {
+ // rewind the file pointer to bof
+ rewind($file_handle);
+ }
+
+ echo "\n-- Testing fgetcsv() with file opened using $file_modes[$mode_counter] mode --\n";
+
+ // call fgetcsv() to parse csv fields
+
+ // use length as less than the actual size of the line
+ fseek($file_handle, 0, SEEK_SET);
+ var_dump( fgetcsv($file_handle, 9, $delimiter, $enclosure) );
+ // check the file pointer position and if eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+ // read rest of the line
+ var_dump( fgetcsv($file_handle, 1024, $delimiter, $enclosure) );
+ // check the file pointer position and if eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ // close the file
+ fclose($file_handle);
+ //delete file
+ unlink($filename);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECT--
+*** Testing fgetcsv() : with length less than line size ***
+
+-- Testing fgetcsv() with file opened using r mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(1) "f"
+}
+int(9)
+bool(false)
+array(1) {
+ [0]=>
+ string(4) "ruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(1) "f"
+}
+int(9)
+bool(false)
+array(1) {
+ [0]=>
+ string(4) "ruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(1) "f"
+}
+int(9)
+bool(false)
+array(1) {
+ [0]=>
+ string(4) "ruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(1) "f"
+}
+int(9)
+bool(false)
+array(1) {
+ [0]=>
+ string(4) "ruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(1) "f"
+}
+int(9)
+bool(false)
+array(1) {
+ [0]=>
+ string(4) "ruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(1) "f"
+}
+int(9)
+bool(false)
+array(1) {
+ [0]=>
+ string(4) "ruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(1) "f"
+}
+int(9)
+bool(false)
+array(1) {
+ [0]=>
+ string(4) "ruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(1) "f"
+}
+int(9)
+bool(false)
+array(1) {
+ [0]=>
+ string(4) "ruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(1) "f"
+}
+int(9)
+bool(false)
+array(1) {
+ [0]=>
+ string(4) "ruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(1) "f"
+}
+int(9)
+bool(false)
+array(1) {
+ [0]=>
+ string(4) "ruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(1) "f"
+}
+int(9)
+bool(false)
+array(1) {
+ [0]=>
+ string(4) "ruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(1) "f"
+}
+int(9)
+bool(false)
+array(1) {
+ [0]=>
+ string(4) "ruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(1) "f"
+}
+int(9)
+bool(false)
+array(1) {
+ [0]=>
+ string(4) "ruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(1) "f"
+}
+int(9)
+bool(false)
+array(1) {
+ [0]=>
+ string(4) "ruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(1) "f"
+}
+int(9)
+bool(false)
+array(1) {
+ [0]=>
+ string(4) "ruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(8) {
+ [0]=>
+ string(4) "This"
+ [1]=>
+ string(2) "is"
+ [2]=>
+ string(4) "line"
+ [3]=>
+ string(2) "of"
+ [4]=>
+ string(4) "text"
+ [5]=>
+ string(7) "without"
+ [6]=>
+ string(3) "csv"
+ [7]=>
+ string(6) "fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(8) {
+ [0]=>
+ string(4) "This"
+ [1]=>
+ string(2) "is"
+ [2]=>
+ string(4) "line"
+ [3]=>
+ string(2) "of"
+ [4]=>
+ string(4) "text"
+ [5]=>
+ string(7) "without"
+ [6]=>
+ string(3) "csv"
+ [7]=>
+ string(6) "fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(8) {
+ [0]=>
+ string(4) "This"
+ [1]=>
+ string(2) "is"
+ [2]=>
+ string(4) "line"
+ [3]=>
+ string(2) "of"
+ [4]=>
+ string(4) "text"
+ [5]=>
+ string(7) "without"
+ [6]=>
+ string(3) "csv"
+ [7]=>
+ string(6) "fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(8) {
+ [0]=>
+ string(4) "This"
+ [1]=>
+ string(2) "is"
+ [2]=>
+ string(4) "line"
+ [3]=>
+ string(2) "of"
+ [4]=>
+ string(4) "text"
+ [5]=>
+ string(7) "without"
+ [6]=>
+ string(3) "csv"
+ [7]=>
+ string(6) "fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(8) {
+ [0]=>
+ string(4) "This"
+ [1]=>
+ string(2) "is"
+ [2]=>
+ string(4) "line"
+ [3]=>
+ string(2) "of"
+ [4]=>
+ string(4) "text"
+ [5]=>
+ string(7) "without"
+ [6]=>
+ string(3) "csv"
+ [7]=>
+ string(6) "fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(8) {
+ [0]=>
+ string(4) "This"
+ [1]=>
+ string(2) "is"
+ [2]=>
+ string(4) "line"
+ [3]=>
+ string(2) "of"
+ [4]=>
+ string(4) "text"
+ [5]=>
+ string(7) "without"
+ [6]=>
+ string(3) "csv"
+ [7]=>
+ string(6) "fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(8) {
+ [0]=>
+ string(4) "This"
+ [1]=>
+ string(2) "is"
+ [2]=>
+ string(4) "line"
+ [3]=>
+ string(2) "of"
+ [4]=>
+ string(4) "text"
+ [5]=>
+ string(7) "without"
+ [6]=>
+ string(3) "csv"
+ [7]=>
+ string(6) "fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(8) {
+ [0]=>
+ string(4) "This"
+ [1]=>
+ string(2) "is"
+ [2]=>
+ string(4) "line"
+ [3]=>
+ string(2) "of"
+ [4]=>
+ string(4) "text"
+ [5]=>
+ string(7) "without"
+ [6]=>
+ string(3) "csv"
+ [7]=>
+ string(6) "fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(8) {
+ [0]=>
+ string(4) "This"
+ [1]=>
+ string(2) "is"
+ [2]=>
+ string(4) "line"
+ [3]=>
+ string(2) "of"
+ [4]=>
+ string(4) "text"
+ [5]=>
+ string(7) "without"
+ [6]=>
+ string(3) "csv"
+ [7]=>
+ string(6) "fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(8) {
+ [0]=>
+ string(4) "This"
+ [1]=>
+ string(2) "is"
+ [2]=>
+ string(4) "line"
+ [3]=>
+ string(2) "of"
+ [4]=>
+ string(4) "text"
+ [5]=>
+ string(7) "without"
+ [6]=>
+ string(3) "csv"
+ [7]=>
+ string(6) "fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(8) {
+ [0]=>
+ string(4) "This"
+ [1]=>
+ string(2) "is"
+ [2]=>
+ string(4) "line"
+ [3]=>
+ string(2) "of"
+ [4]=>
+ string(4) "text"
+ [5]=>
+ string(7) "without"
+ [6]=>
+ string(3) "csv"
+ [7]=>
+ string(6) "fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(8) {
+ [0]=>
+ string(4) "This"
+ [1]=>
+ string(2) "is"
+ [2]=>
+ string(4) "line"
+ [3]=>
+ string(2) "of"
+ [4]=>
+ string(4) "text"
+ [5]=>
+ string(7) "without"
+ [6]=>
+ string(3) "csv"
+ [7]=>
+ string(6) "fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(8) {
+ [0]=>
+ string(4) "This"
+ [1]=>
+ string(2) "is"
+ [2]=>
+ string(4) "line"
+ [3]=>
+ string(2) "of"
+ [4]=>
+ string(4) "text"
+ [5]=>
+ string(7) "without"
+ [6]=>
+ string(3) "csv"
+ [7]=>
+ string(6) "fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(8) {
+ [0]=>
+ string(4) "This"
+ [1]=>
+ string(2) "is"
+ [2]=>
+ string(4) "line"
+ [3]=>
+ string(2) "of"
+ [4]=>
+ string(4) "text"
+ [5]=>
+ string(7) "without"
+ [6]=>
+ string(3) "csv"
+ [7]=>
+ string(6) "fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(8) {
+ [0]=>
+ string(4) "This"
+ [1]=>
+ string(2) "is"
+ [2]=>
+ string(4) "line"
+ [3]=>
+ string(2) "of"
+ [4]=>
+ string(4) "text"
+ [5]=>
+ string(7) "without"
+ [6]=>
+ string(3) "csv"
+ [7]=>
+ string(6) "fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(56)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(1) {
+ [0]=>
+ string(6) "water="
+}
+int(9)
+bool(false)
+array(2) {
+ [0]=>
+ string(5) "fruit"
+ [1]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(1) {
+ [0]=>
+ string(6) "water="
+}
+int(9)
+bool(false)
+array(2) {
+ [0]=>
+ string(5) "fruit"
+ [1]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(1) {
+ [0]=>
+ string(6) "water="
+}
+int(9)
+bool(false)
+array(2) {
+ [0]=>
+ string(5) "fruit"
+ [1]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(1) {
+ [0]=>
+ string(6) "water="
+}
+int(9)
+bool(false)
+array(2) {
+ [0]=>
+ string(5) "fruit"
+ [1]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(1) {
+ [0]=>
+ string(6) "water="
+}
+int(9)
+bool(false)
+array(2) {
+ [0]=>
+ string(5) "fruit"
+ [1]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(1) {
+ [0]=>
+ string(6) "water="
+}
+int(9)
+bool(false)
+array(2) {
+ [0]=>
+ string(5) "fruit"
+ [1]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(1) {
+ [0]=>
+ string(6) "water="
+}
+int(9)
+bool(false)
+array(2) {
+ [0]=>
+ string(5) "fruit"
+ [1]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(1) {
+ [0]=>
+ string(6) "water="
+}
+int(9)
+bool(false)
+array(2) {
+ [0]=>
+ string(5) "fruit"
+ [1]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(1) {
+ [0]=>
+ string(6) "water="
+}
+int(9)
+bool(false)
+array(2) {
+ [0]=>
+ string(5) "fruit"
+ [1]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(1) {
+ [0]=>
+ string(6) "water="
+}
+int(9)
+bool(false)
+array(2) {
+ [0]=>
+ string(5) "fruit"
+ [1]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(1) {
+ [0]=>
+ string(6) "water="
+}
+int(9)
+bool(false)
+array(2) {
+ [0]=>
+ string(5) "fruit"
+ [1]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(1) {
+ [0]=>
+ string(6) "water="
+}
+int(9)
+bool(false)
+array(2) {
+ [0]=>
+ string(5) "fruit"
+ [1]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(1) {
+ [0]=>
+ string(6) "water="
+}
+int(9)
+bool(false)
+array(2) {
+ [0]=>
+ string(5) "fruit"
+ [1]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(1) {
+ [0]=>
+ string(6) "water="
+}
+int(9)
+bool(false)
+array(2) {
+ [0]=>
+ string(5) "fruit"
+ [1]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(1) {
+ [0]=>
+ string(6) "water="
+}
+int(9)
+bool(false)
+array(2) {
+ [0]=>
+ string(5) "fruit"
+ [1]=>
+ string(0) ""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(58)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(58)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(58)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(58)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(58)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(58)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(58)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(58)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(58)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(58)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(58)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(58)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(58)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(58)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(58)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(1) {
+ [0]=>
+ string(6) "water-"
+}
+int(9)
+bool(false)
+array(3) {
+ [0]=>
+ string(5) "fruit"
+ [1]=>
+ string(3) "air"
+ [2]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(1) {
+ [0]=>
+ string(6) "water-"
+}
+int(9)
+bool(false)
+array(3) {
+ [0]=>
+ string(5) "fruit"
+ [1]=>
+ string(3) "air"
+ [2]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(1) {
+ [0]=>
+ string(6) "water-"
+}
+int(9)
+bool(false)
+array(3) {
+ [0]=>
+ string(5) "fruit"
+ [1]=>
+ string(3) "air"
+ [2]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(1) {
+ [0]=>
+ string(6) "water-"
+}
+int(9)
+bool(false)
+array(3) {
+ [0]=>
+ string(5) "fruit"
+ [1]=>
+ string(3) "air"
+ [2]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(1) {
+ [0]=>
+ string(6) "water-"
+}
+int(9)
+bool(false)
+array(3) {
+ [0]=>
+ string(5) "fruit"
+ [1]=>
+ string(3) "air"
+ [2]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(1) {
+ [0]=>
+ string(6) "water-"
+}
+int(9)
+bool(false)
+array(3) {
+ [0]=>
+ string(5) "fruit"
+ [1]=>
+ string(3) "air"
+ [2]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(1) {
+ [0]=>
+ string(6) "water-"
+}
+int(9)
+bool(false)
+array(3) {
+ [0]=>
+ string(5) "fruit"
+ [1]=>
+ string(3) "air"
+ [2]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(1) {
+ [0]=>
+ string(6) "water-"
+}
+int(9)
+bool(false)
+array(3) {
+ [0]=>
+ string(5) "fruit"
+ [1]=>
+ string(3) "air"
+ [2]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(1) {
+ [0]=>
+ string(6) "water-"
+}
+int(9)
+bool(false)
+array(3) {
+ [0]=>
+ string(5) "fruit"
+ [1]=>
+ string(3) "air"
+ [2]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(1) {
+ [0]=>
+ string(6) "water-"
+}
+int(9)
+bool(false)
+array(3) {
+ [0]=>
+ string(5) "fruit"
+ [1]=>
+ string(3) "air"
+ [2]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(1) {
+ [0]=>
+ string(6) "water-"
+}
+int(9)
+bool(false)
+array(3) {
+ [0]=>
+ string(5) "fruit"
+ [1]=>
+ string(3) "air"
+ [2]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(1) {
+ [0]=>
+ string(6) "water-"
+}
+int(9)
+bool(false)
+array(3) {
+ [0]=>
+ string(5) "fruit"
+ [1]=>
+ string(3) "air"
+ [2]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(1) {
+ [0]=>
+ string(6) "water-"
+}
+int(9)
+bool(false)
+array(3) {
+ [0]=>
+ string(5) "fruit"
+ [1]=>
+ string(3) "air"
+ [2]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(1) {
+ [0]=>
+ string(6) "water-"
+}
+int(9)
+bool(false)
+array(3) {
+ [0]=>
+ string(5) "fruit"
+ [1]=>
+ string(3) "air"
+ [2]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(1) {
+ [0]=>
+ string(6) "water-"
+}
+int(9)
+bool(false)
+array(3) {
+ [0]=>
+ string(5) "fruit"
+ [1]=>
+ string(3) "air"
+ [2]=>
+ string(0) ""
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(6) {
+ [0]=>
+ string(4) """"""
+ [1]=>
+ string(1) """
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(1) ","
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(64)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(6) {
+ [0]=>
+ string(4) """"""
+ [1]=>
+ string(1) """
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(1) ","
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(64)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(6) {
+ [0]=>
+ string(4) """"""
+ [1]=>
+ string(1) """
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(1) ","
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(64)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(6) {
+ [0]=>
+ string(4) """"""
+ [1]=>
+ string(1) """
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(1) ","
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(64)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(6) {
+ [0]=>
+ string(4) """"""
+ [1]=>
+ string(1) """
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(1) ","
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(64)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(6) {
+ [0]=>
+ string(4) """"""
+ [1]=>
+ string(1) """
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(1) ","
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(64)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(6) {
+ [0]=>
+ string(4) """"""
+ [1]=>
+ string(1) """
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(1) ","
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(64)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(6) {
+ [0]=>
+ string(4) """"""
+ [1]=>
+ string(1) """
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(1) ","
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(64)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(6) {
+ [0]=>
+ string(4) """"""
+ [1]=>
+ string(1) """
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(1) ","
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(64)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(6) {
+ [0]=>
+ string(4) """"""
+ [1]=>
+ string(1) """
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(1) ","
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(64)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(6) {
+ [0]=>
+ string(4) """"""
+ [1]=>
+ string(1) """
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(1) ","
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(64)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(6) {
+ [0]=>
+ string(4) """"""
+ [1]=>
+ string(1) """
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(1) ","
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(64)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(6) {
+ [0]=>
+ string(4) """"""
+ [1]=>
+ string(1) """
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(1) ","
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(64)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(6) {
+ [0]=>
+ string(4) """"""
+ [1]=>
+ string(1) """
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(1) ","
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(64)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(6) {
+ [0]=>
+ string(4) """"""
+ [1]=>
+ string(1) """
+ [2]=>
+ string(1) ","
+ [3]=>
+ string(1) """
+ [4]=>
+ string(1) ","
+ [5]=>
+ string(4) ",,,,"
+}
+int(24)
+bool(false)
+array(1) {
+ [0]=>
+ string(39) "This is line of text without csv fields"
+}
+int(64)
+bool(false)
+Done
diff --git a/ext/standard/tests/file/fgetcsv_variation7.phpt b/ext/standard/tests/file/fgetcsv_variation7.phpt
new file mode 100644
index 0000000..723328e
--- /dev/null
+++ b/ext/standard/tests/file/fgetcsv_variation7.phpt
@@ -0,0 +1,1292 @@
+--TEST--
+Test fgetcsv() : usage variations - with default arguments value
+--FILE--
+<?php
+/*
+ Prototype: array fgetcsv ( resource $handle [, int $length [, string $delimiter [, string $enclosure]]] );
+ Description: Gets line from file pointer and parse for CSV fields
+*/
+
+/* Testing fgetcsv() to read from a file when provided with default value of arguments */
+
+echo "*** Testing fgetcsv() : with default arguments value ***\n";
+
+/* the array is with three elements in it. Each element should be read as
+ 1st element is delimiter, 2nd element is enclosure
+ and 3rd element is csv fields
+*/
+$csv_lists = array (
+ array(',', '"', '"water",fruit'),
+ array(',', '"', '"water","fruit"'),
+ array(' ', '^', '^water^ ^fruit^'),
+ array(':', '&', '&water&:&fruit&'),
+ array('=', '=', '=water===fruit='),
+ array('-', '-', '-water--fruit-air'),
+ array('-', '-', '-water---fruit---air-'),
+ array(':', '&', '&""""&:&"&:,:":&,&:,,,,')
+);
+
+$filename = dirname(__FILE__) . '/fgetcsv_variation7.tmp';
+@unlink($filename);
+
+$file_modes = array ("r","rb", "rt", "r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $file_handle = fopen($filename, "w");
+ } else {
+ $file_handle = fopen($filename, $file_modes[$mode_counter] );
+ }
+ if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+ }
+ $delimiter = $csv_list[0];
+ $enclosure = $csv_list[1];
+ $csv_field = $csv_list[2];
+ fwrite($file_handle, $csv_field . "\n");
+ // write another line of text and a blank line
+ // this will be used to test, if the fgetcsv() read more than a line and its
+ // working when only a blank line is read
+ fwrite($file_handle, "This is line of text without csv fields\n");
+ fwrite($file_handle, "\n"); // blank line
+
+ // close the file if the mode to be used is read mode and re-open using read mode
+ // else rewind the file pointer to begining of the file
+ if ( strstr($file_modes[$mode_counter], "r" ) ) {
+ fclose($file_handle);
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ } else {
+ // rewind the file pointer to bof
+ rewind($file_handle);
+ }
+
+ echo "\n-- Testing fgetcsv() with file opened using $file_modes[$mode_counter] mode --\n";
+
+ // call fgetcsv() to parse csv fields
+
+ // use only default arguments
+ fseek($file_handle, 0, SEEK_SET);
+ var_dump( fgetcsv($file_handle) );
+ // check the file pointer position and if eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ // close the file
+ fclose($file_handle);
+ //delete file
+ unlink($filename);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECT--
+*** Testing fgetcsv() : with default arguments value ***
+
+-- Testing fgetcsv() with file opened using r mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(2) {
+ [0]=>
+ string(5) "water"
+ [1]=>
+ string(5) "fruit"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(1) {
+ [0]=>
+ string(15) "^water^ ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(1) {
+ [0]=>
+ string(15) "^water^ ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(1) {
+ [0]=>
+ string(15) "^water^ ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(1) {
+ [0]=>
+ string(15) "^water^ ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(1) {
+ [0]=>
+ string(15) "^water^ ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(1) {
+ [0]=>
+ string(15) "^water^ ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(1) {
+ [0]=>
+ string(15) "^water^ ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(1) {
+ [0]=>
+ string(15) "^water^ ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(1) {
+ [0]=>
+ string(15) "^water^ ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(1) {
+ [0]=>
+ string(15) "^water^ ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(1) {
+ [0]=>
+ string(15) "^water^ ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(1) {
+ [0]=>
+ string(15) "^water^ ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(1) {
+ [0]=>
+ string(15) "^water^ ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(1) {
+ [0]=>
+ string(15) "^water^ ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(1) {
+ [0]=>
+ string(15) "^water^ ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(1) {
+ [0]=>
+ string(15) "&water&:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(1) {
+ [0]=>
+ string(15) "&water&:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(1) {
+ [0]=>
+ string(15) "&water&:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(1) {
+ [0]=>
+ string(15) "&water&:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(1) {
+ [0]=>
+ string(15) "&water&:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(1) {
+ [0]=>
+ string(15) "&water&:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(1) {
+ [0]=>
+ string(15) "&water&:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(1) {
+ [0]=>
+ string(15) "&water&:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(1) {
+ [0]=>
+ string(15) "&water&:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(1) {
+ [0]=>
+ string(15) "&water&:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(1) {
+ [0]=>
+ string(15) "&water&:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(1) {
+ [0]=>
+ string(15) "&water&:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(1) {
+ [0]=>
+ string(15) "&water&:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(1) {
+ [0]=>
+ string(15) "&water&:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(1) {
+ [0]=>
+ string(15) "&water&:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(1) {
+ [0]=>
+ string(15) "=water===fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(1) {
+ [0]=>
+ string(15) "=water===fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(1) {
+ [0]=>
+ string(15) "=water===fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(1) {
+ [0]=>
+ string(15) "=water===fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(1) {
+ [0]=>
+ string(15) "=water===fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(1) {
+ [0]=>
+ string(15) "=water===fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(1) {
+ [0]=>
+ string(15) "=water===fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(1) {
+ [0]=>
+ string(15) "=water===fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(1) {
+ [0]=>
+ string(15) "=water===fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(1) {
+ [0]=>
+ string(15) "=water===fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(1) {
+ [0]=>
+ string(15) "=water===fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(1) {
+ [0]=>
+ string(15) "=water===fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(1) {
+ [0]=>
+ string(15) "=water===fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(1) {
+ [0]=>
+ string(15) "=water===fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(1) {
+ [0]=>
+ string(15) "=water===fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(1) {
+ [0]=>
+ string(17) "-water--fruit-air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(1) {
+ [0]=>
+ string(17) "-water--fruit-air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(1) {
+ [0]=>
+ string(17) "-water--fruit-air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(1) {
+ [0]=>
+ string(17) "-water--fruit-air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(1) {
+ [0]=>
+ string(17) "-water--fruit-air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(1) {
+ [0]=>
+ string(17) "-water--fruit-air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(1) {
+ [0]=>
+ string(17) "-water--fruit-air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(1) {
+ [0]=>
+ string(17) "-water--fruit-air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(1) {
+ [0]=>
+ string(17) "-water--fruit-air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(1) {
+ [0]=>
+ string(17) "-water--fruit-air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(1) {
+ [0]=>
+ string(17) "-water--fruit-air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(1) {
+ [0]=>
+ string(17) "-water--fruit-air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(1) {
+ [0]=>
+ string(17) "-water--fruit-air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(1) {
+ [0]=>
+ string(17) "-water--fruit-air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(1) {
+ [0]=>
+ string(17) "-water--fruit-air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(1) {
+ [0]=>
+ string(21) "-water---fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(1) {
+ [0]=>
+ string(21) "-water---fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(1) {
+ [0]=>
+ string(21) "-water---fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(1) {
+ [0]=>
+ string(21) "-water---fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(1) {
+ [0]=>
+ string(21) "-water---fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(1) {
+ [0]=>
+ string(21) "-water---fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(1) {
+ [0]=>
+ string(21) "-water---fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(1) {
+ [0]=>
+ string(21) "-water---fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(1) {
+ [0]=>
+ string(21) "-water---fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(1) {
+ [0]=>
+ string(21) "-water---fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(1) {
+ [0]=>
+ string(21) "-water---fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(1) {
+ [0]=>
+ string(21) "-water---fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(1) {
+ [0]=>
+ string(21) "-water---fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(1) {
+ [0]=>
+ string(21) "-water---fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(1) {
+ [0]=>
+ string(21) "-water---fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(7) {
+ [0]=>
+ string(11) "&""""&:&"&:"
+ [1]=>
+ string(4) ":":&"
+ [2]=>
+ string(2) "&:"
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(0) ""
+ [5]=>
+ string(0) ""
+ [6]=>
+ string(0) ""
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(7) {
+ [0]=>
+ string(11) "&""""&:&"&:"
+ [1]=>
+ string(4) ":":&"
+ [2]=>
+ string(2) "&:"
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(0) ""
+ [5]=>
+ string(0) ""
+ [6]=>
+ string(0) ""
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(7) {
+ [0]=>
+ string(11) "&""""&:&"&:"
+ [1]=>
+ string(4) ":":&"
+ [2]=>
+ string(2) "&:"
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(0) ""
+ [5]=>
+ string(0) ""
+ [6]=>
+ string(0) ""
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(7) {
+ [0]=>
+ string(11) "&""""&:&"&:"
+ [1]=>
+ string(4) ":":&"
+ [2]=>
+ string(2) "&:"
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(0) ""
+ [5]=>
+ string(0) ""
+ [6]=>
+ string(0) ""
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(7) {
+ [0]=>
+ string(11) "&""""&:&"&:"
+ [1]=>
+ string(4) ":":&"
+ [2]=>
+ string(2) "&:"
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(0) ""
+ [5]=>
+ string(0) ""
+ [6]=>
+ string(0) ""
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(7) {
+ [0]=>
+ string(11) "&""""&:&"&:"
+ [1]=>
+ string(4) ":":&"
+ [2]=>
+ string(2) "&:"
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(0) ""
+ [5]=>
+ string(0) ""
+ [6]=>
+ string(0) ""
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(7) {
+ [0]=>
+ string(11) "&""""&:&"&:"
+ [1]=>
+ string(4) ":":&"
+ [2]=>
+ string(2) "&:"
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(0) ""
+ [5]=>
+ string(0) ""
+ [6]=>
+ string(0) ""
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(7) {
+ [0]=>
+ string(11) "&""""&:&"&:"
+ [1]=>
+ string(4) ":":&"
+ [2]=>
+ string(2) "&:"
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(0) ""
+ [5]=>
+ string(0) ""
+ [6]=>
+ string(0) ""
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(7) {
+ [0]=>
+ string(11) "&""""&:&"&:"
+ [1]=>
+ string(4) ":":&"
+ [2]=>
+ string(2) "&:"
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(0) ""
+ [5]=>
+ string(0) ""
+ [6]=>
+ string(0) ""
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(7) {
+ [0]=>
+ string(11) "&""""&:&"&:"
+ [1]=>
+ string(4) ":":&"
+ [2]=>
+ string(2) "&:"
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(0) ""
+ [5]=>
+ string(0) ""
+ [6]=>
+ string(0) ""
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(7) {
+ [0]=>
+ string(11) "&""""&:&"&:"
+ [1]=>
+ string(4) ":":&"
+ [2]=>
+ string(2) "&:"
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(0) ""
+ [5]=>
+ string(0) ""
+ [6]=>
+ string(0) ""
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(7) {
+ [0]=>
+ string(11) "&""""&:&"&:"
+ [1]=>
+ string(4) ":":&"
+ [2]=>
+ string(2) "&:"
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(0) ""
+ [5]=>
+ string(0) ""
+ [6]=>
+ string(0) ""
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(7) {
+ [0]=>
+ string(11) "&""""&:&"&:"
+ [1]=>
+ string(4) ":":&"
+ [2]=>
+ string(2) "&:"
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(0) ""
+ [5]=>
+ string(0) ""
+ [6]=>
+ string(0) ""
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(7) {
+ [0]=>
+ string(11) "&""""&:&"&:"
+ [1]=>
+ string(4) ":":&"
+ [2]=>
+ string(2) "&:"
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(0) ""
+ [5]=>
+ string(0) ""
+ [6]=>
+ string(0) ""
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(7) {
+ [0]=>
+ string(11) "&""""&:&"&:"
+ [1]=>
+ string(4) ":":&"
+ [2]=>
+ string(2) "&:"
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(0) ""
+ [5]=>
+ string(0) ""
+ [6]=>
+ string(0) ""
+}
+int(24)
+bool(false)
+Done
diff --git a/ext/standard/tests/file/fgetcsv_variation8.phpt b/ext/standard/tests/file/fgetcsv_variation8.phpt
new file mode 100644
index 0000000..21b6c88
--- /dev/null
+++ b/ext/standard/tests/file/fgetcsv_variation8.phpt
@@ -0,0 +1,1058 @@
+--TEST--
+Test fgetcsv() : usage variations - with different delimiter and enclosure
+--FILE--
+<?php
+/*
+ Prototype: array fgetcsv ( resource $handle [, int $length [, string $delimiter [, string $enclosure]]] );
+ Description: Gets line from file pointer and parse for CSV fields
+*/
+
+/*
+ Testing fgetcsv() to read from a file when provided with values of delimiter and
+ enclosure that are not present in the line read by fgetcsv()
+*/
+
+echo "*** Testing fgetcsv() : with different delimiter and enclosure ***\n";
+
+/* the array is with three elements in it. Each element should be read as
+ 1st element is delimiter, 2nd element is enclosure
+ and 3rd element is csv fields
+*/
+$csv_lists = array (
+ array(',', '"', '"water",fruit'),
+ array(',', '"', '"water","fruit"'),
+ array(' ', '^', '^water^ ^fruit^'),
+ array(':', '&', '&water&:&fruit&'),
+ array('=', '=', '=water===fruit='),
+ array('-', '-', '-water--fruit-air'),
+ array('-', '-', '-water---fruit---air-'),
+ array(':', '&', '&""""&:&"&:,:":&,&:,,,,')
+);
+
+$filename = dirname(__FILE__) . '/fgetcsv_variation8.tmp';
+@unlink($filename);
+
+$file_modes = array ("r","rb", "rt", "r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $file_handle = fopen($filename, "w");
+ } else {
+ $file_handle = fopen($filename, $file_modes[$mode_counter] );
+ }
+ if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+ }
+ $delimiter = $csv_list[0];
+ $enclosure = $csv_list[1];
+ $csv_field = $csv_list[2];
+
+ fwrite($file_handle, $csv_field . "\n");
+ // write another line of text and a blank line
+ // this will be used to test, if the fgetcsv() read more than a line and its
+ // working when only a blank line is read
+ fwrite($file_handle, "This is line of text without csv fields\n");
+ fwrite($file_handle, "\n"); // blank line
+
+ // close the file if the mode to be used is read mode and re-open using read mode
+ // else rewind the file pointer to begining of the file
+ if ( strstr($file_modes[$mode_counter], "r" ) ) {
+ fclose($file_handle);
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ } else {
+ // rewind the file pointer to bof
+ rewind($file_handle);
+ }
+
+ echo "\n-- Testing fgetcsv() with file opened using $file_modes[$mode_counter] mode --\n";
+
+ // call fgetcsv() to parse csv fields
+
+ // use different delimiter and enclosure than existing in file
+ fseek($file_handle, 0, SEEK_SET);
+ $del = "+";
+ $enc = "%";
+ var_dump( fgetcsv($file_handle, 1024, $del, $enc) );
+ // check the file pointer position and if eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ // close the file
+ fclose($file_handle);
+ //delete file
+ unlink($filename);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECT--
+*** Testing fgetcsv() : with different delimiter and enclosure ***
+
+-- Testing fgetcsv() with file opened using r mode --
+array(1) {
+ [0]=>
+ string(13) ""water",fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(1) {
+ [0]=>
+ string(13) ""water",fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(1) {
+ [0]=>
+ string(13) ""water",fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(1) {
+ [0]=>
+ string(13) ""water",fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(1) {
+ [0]=>
+ string(13) ""water",fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(1) {
+ [0]=>
+ string(13) ""water",fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(1) {
+ [0]=>
+ string(13) ""water",fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(1) {
+ [0]=>
+ string(13) ""water",fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(1) {
+ [0]=>
+ string(13) ""water",fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(1) {
+ [0]=>
+ string(13) ""water",fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(1) {
+ [0]=>
+ string(13) ""water",fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(1) {
+ [0]=>
+ string(13) ""water",fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(1) {
+ [0]=>
+ string(13) ""water",fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(1) {
+ [0]=>
+ string(13) ""water",fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(1) {
+ [0]=>
+ string(13) ""water",fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(1) {
+ [0]=>
+ string(15) ""water","fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(1) {
+ [0]=>
+ string(15) ""water","fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(1) {
+ [0]=>
+ string(15) ""water","fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(1) {
+ [0]=>
+ string(15) ""water","fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(1) {
+ [0]=>
+ string(15) ""water","fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(1) {
+ [0]=>
+ string(15) ""water","fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(1) {
+ [0]=>
+ string(15) ""water","fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(1) {
+ [0]=>
+ string(15) ""water","fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(1) {
+ [0]=>
+ string(15) ""water","fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(1) {
+ [0]=>
+ string(15) ""water","fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(1) {
+ [0]=>
+ string(15) ""water","fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(1) {
+ [0]=>
+ string(15) ""water","fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(1) {
+ [0]=>
+ string(15) ""water","fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(1) {
+ [0]=>
+ string(15) ""water","fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(1) {
+ [0]=>
+ string(15) ""water","fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(1) {
+ [0]=>
+ string(15) "^water^ ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(1) {
+ [0]=>
+ string(15) "^water^ ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(1) {
+ [0]=>
+ string(15) "^water^ ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(1) {
+ [0]=>
+ string(15) "^water^ ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(1) {
+ [0]=>
+ string(15) "^water^ ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(1) {
+ [0]=>
+ string(15) "^water^ ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(1) {
+ [0]=>
+ string(15) "^water^ ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(1) {
+ [0]=>
+ string(15) "^water^ ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(1) {
+ [0]=>
+ string(15) "^water^ ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(1) {
+ [0]=>
+ string(15) "^water^ ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(1) {
+ [0]=>
+ string(15) "^water^ ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(1) {
+ [0]=>
+ string(15) "^water^ ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(1) {
+ [0]=>
+ string(15) "^water^ ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(1) {
+ [0]=>
+ string(15) "^water^ ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(1) {
+ [0]=>
+ string(15) "^water^ ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(1) {
+ [0]=>
+ string(15) "&water&:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(1) {
+ [0]=>
+ string(15) "&water&:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(1) {
+ [0]=>
+ string(15) "&water&:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(1) {
+ [0]=>
+ string(15) "&water&:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(1) {
+ [0]=>
+ string(15) "&water&:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(1) {
+ [0]=>
+ string(15) "&water&:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(1) {
+ [0]=>
+ string(15) "&water&:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(1) {
+ [0]=>
+ string(15) "&water&:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(1) {
+ [0]=>
+ string(15) "&water&:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(1) {
+ [0]=>
+ string(15) "&water&:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(1) {
+ [0]=>
+ string(15) "&water&:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(1) {
+ [0]=>
+ string(15) "&water&:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(1) {
+ [0]=>
+ string(15) "&water&:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(1) {
+ [0]=>
+ string(15) "&water&:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(1) {
+ [0]=>
+ string(15) "&water&:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(1) {
+ [0]=>
+ string(15) "=water===fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(1) {
+ [0]=>
+ string(15) "=water===fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(1) {
+ [0]=>
+ string(15) "=water===fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(1) {
+ [0]=>
+ string(15) "=water===fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(1) {
+ [0]=>
+ string(15) "=water===fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(1) {
+ [0]=>
+ string(15) "=water===fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(1) {
+ [0]=>
+ string(15) "=water===fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(1) {
+ [0]=>
+ string(15) "=water===fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(1) {
+ [0]=>
+ string(15) "=water===fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(1) {
+ [0]=>
+ string(15) "=water===fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(1) {
+ [0]=>
+ string(15) "=water===fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(1) {
+ [0]=>
+ string(15) "=water===fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(1) {
+ [0]=>
+ string(15) "=water===fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(1) {
+ [0]=>
+ string(15) "=water===fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(1) {
+ [0]=>
+ string(15) "=water===fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(1) {
+ [0]=>
+ string(17) "-water--fruit-air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(1) {
+ [0]=>
+ string(17) "-water--fruit-air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(1) {
+ [0]=>
+ string(17) "-water--fruit-air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(1) {
+ [0]=>
+ string(17) "-water--fruit-air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(1) {
+ [0]=>
+ string(17) "-water--fruit-air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(1) {
+ [0]=>
+ string(17) "-water--fruit-air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(1) {
+ [0]=>
+ string(17) "-water--fruit-air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(1) {
+ [0]=>
+ string(17) "-water--fruit-air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(1) {
+ [0]=>
+ string(17) "-water--fruit-air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(1) {
+ [0]=>
+ string(17) "-water--fruit-air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(1) {
+ [0]=>
+ string(17) "-water--fruit-air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(1) {
+ [0]=>
+ string(17) "-water--fruit-air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(1) {
+ [0]=>
+ string(17) "-water--fruit-air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(1) {
+ [0]=>
+ string(17) "-water--fruit-air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(1) {
+ [0]=>
+ string(17) "-water--fruit-air"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(1) {
+ [0]=>
+ string(21) "-water---fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(1) {
+ [0]=>
+ string(21) "-water---fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(1) {
+ [0]=>
+ string(21) "-water---fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(1) {
+ [0]=>
+ string(21) "-water---fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(1) {
+ [0]=>
+ string(21) "-water---fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(1) {
+ [0]=>
+ string(21) "-water---fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(1) {
+ [0]=>
+ string(21) "-water---fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(1) {
+ [0]=>
+ string(21) "-water---fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(1) {
+ [0]=>
+ string(21) "-water---fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(1) {
+ [0]=>
+ string(21) "-water---fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(1) {
+ [0]=>
+ string(21) "-water---fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(1) {
+ [0]=>
+ string(21) "-water---fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(1) {
+ [0]=>
+ string(21) "-water---fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(1) {
+ [0]=>
+ string(21) "-water---fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(1) {
+ [0]=>
+ string(21) "-water---fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(1) {
+ [0]=>
+ string(23) "&""""&:&"&:,:":&,&:,,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(1) {
+ [0]=>
+ string(23) "&""""&:&"&:,:":&,&:,,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(1) {
+ [0]=>
+ string(23) "&""""&:&"&:,:":&,&:,,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(1) {
+ [0]=>
+ string(23) "&""""&:&"&:,:":&,&:,,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(1) {
+ [0]=>
+ string(23) "&""""&:&"&:,:":&,&:,,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(1) {
+ [0]=>
+ string(23) "&""""&:&"&:,:":&,&:,,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(1) {
+ [0]=>
+ string(23) "&""""&:&"&:,:":&,&:,,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(1) {
+ [0]=>
+ string(23) "&""""&:&"&:,:":&,&:,,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(1) {
+ [0]=>
+ string(23) "&""""&:&"&:,:":&,&:,,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(1) {
+ [0]=>
+ string(23) "&""""&:&"&:,:":&,&:,,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(1) {
+ [0]=>
+ string(23) "&""""&:&"&:,:":&,&:,,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(1) {
+ [0]=>
+ string(23) "&""""&:&"&:,:":&,&:,,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(1) {
+ [0]=>
+ string(23) "&""""&:&"&:,:":&,&:,,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(1) {
+ [0]=>
+ string(23) "&""""&:&"&:,:":&,&:,,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(1) {
+ [0]=>
+ string(23) "&""""&:&"&:,:":&,&:,,,,"
+}
+int(24)
+bool(false)
+Done
diff --git a/ext/standard/tests/file/fgetcsv_variation9.phpt b/ext/standard/tests/file/fgetcsv_variation9.phpt
new file mode 100644
index 0000000..6400fc8
--- /dev/null
+++ b/ext/standard/tests/file/fgetcsv_variation9.phpt
@@ -0,0 +1,1056 @@
+--TEST--
+Test fgetcsv() : usage variations - with different delimiter but same enclosure
+--FILE--
+<?php
+/*
+ Prototype: array fgetcsv ( resource $handle [, int $length [, string $delimiter [, string $enclosure]]] );
+ Description: Gets line from file pointer and parse for CSV fields
+*/
+
+/*
+ Testing fgetcsv() to read from a file when the delimiter argument value is not
+ present in the line being read by the fgetcsv()
+*/
+
+echo "*** Testing fgetcsv() : with different delimiter but same enclosure ***\n";
+
+/* the array is with three elements in it. Each element should be read as
+ 1st element is delimiter, 2nd element is enclosure
+ and 3rd element is csv fields
+*/
+$csv_lists = array (
+ array(',', '"', '"water",fruit'),
+ array(',', '"', '"water","fruit"'),
+ array(' ', '^', '^water^ ^fruit^'),
+ array(':', '&', '&water&:&fruit&'),
+ array('=', '=', '=water===fruit='),
+ array('-', '-', '-water--fruit-air'),
+ array('-', '-', '-water---fruit---air-'),
+ array(':', '&', '&""""&:&"&:,:":&,&:,,,,')
+);
+
+$filename = dirname(__FILE__) . '/fgetcsv_variation9.tmp';
+@unlink($filename);
+
+$file_modes = array ("r","rb", "rt", "r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $file_handle = fopen($filename, "w");
+ } else {
+ $file_handle = fopen($filename, $file_modes[$mode_counter] );
+ }
+ if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+ }
+ $delimiter = $csv_list[0];
+ $enclosure = $csv_list[1];
+ $csv_field = $csv_list[2];
+ fwrite($file_handle, $csv_field . "\n");
+ // write another line of text and a blank line
+ // this will be used to test, if the fgetcsv() read more than a line and its
+ // working when only a blan line is read
+ fwrite($file_handle, "This is line of text without csv fields\n");
+ fwrite($file_handle, "\n"); // blank line
+
+ // close the file if the mode to be used is read mode and re-open using read mode
+ // else rewind the file pointer to begining of the file
+ if ( strstr($file_modes[$mode_counter], "r" ) ) {
+ fclose($file_handle);
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ } else {
+ // rewind the file pointer to bof
+ rewind($file_handle);
+ }
+
+ echo "\n-- Testing fgetcsv() with file opened using $file_modes[$mode_counter] mode --\n";
+
+ // call fgetcsv() to parse csv fields
+
+ // use different delimiter but same enclosure char
+ fseek($file_handle, 0, SEEK_SET);
+ $del = "+";
+ var_dump( fgetcsv($file_handle, 1024, $del, $enclosure) );
+ // check the file pointer position and if eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ // close the file
+ fclose($file_handle);
+ //delete file
+ unlink($filename);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECT--
+*** Testing fgetcsv() : with different delimiter but same enclosure ***
+
+-- Testing fgetcsv() with file opened using r mode --
+array(1) {
+ [0]=>
+ string(11) "water,fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(1) {
+ [0]=>
+ string(11) "water,fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(1) {
+ [0]=>
+ string(11) "water,fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(1) {
+ [0]=>
+ string(11) "water,fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(1) {
+ [0]=>
+ string(11) "water,fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(1) {
+ [0]=>
+ string(11) "water,fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(1) {
+ [0]=>
+ string(11) "water,fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(1) {
+ [0]=>
+ string(11) "water,fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(1) {
+ [0]=>
+ string(11) "water,fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(1) {
+ [0]=>
+ string(11) "water,fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(1) {
+ [0]=>
+ string(11) "water,fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(1) {
+ [0]=>
+ string(11) "water,fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(1) {
+ [0]=>
+ string(11) "water,fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(1) {
+ [0]=>
+ string(11) "water,fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(1) {
+ [0]=>
+ string(11) "water,fruit"
+}
+int(14)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(1) {
+ [0]=>
+ string(13) "water,"fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(1) {
+ [0]=>
+ string(13) "water,"fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(1) {
+ [0]=>
+ string(13) "water,"fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(1) {
+ [0]=>
+ string(13) "water,"fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(1) {
+ [0]=>
+ string(13) "water,"fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(1) {
+ [0]=>
+ string(13) "water,"fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(1) {
+ [0]=>
+ string(13) "water,"fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(1) {
+ [0]=>
+ string(13) "water,"fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(1) {
+ [0]=>
+ string(13) "water,"fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(1) {
+ [0]=>
+ string(13) "water,"fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(1) {
+ [0]=>
+ string(13) "water,"fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(1) {
+ [0]=>
+ string(13) "water,"fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(1) {
+ [0]=>
+ string(13) "water,"fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(1) {
+ [0]=>
+ string(13) "water,"fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(1) {
+ [0]=>
+ string(13) "water,"fruit""
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(1) {
+ [0]=>
+ string(13) "water ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(1) {
+ [0]=>
+ string(13) "water ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(1) {
+ [0]=>
+ string(13) "water ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(1) {
+ [0]=>
+ string(13) "water ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(1) {
+ [0]=>
+ string(13) "water ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(1) {
+ [0]=>
+ string(13) "water ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(1) {
+ [0]=>
+ string(13) "water ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(1) {
+ [0]=>
+ string(13) "water ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(1) {
+ [0]=>
+ string(13) "water ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(1) {
+ [0]=>
+ string(13) "water ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(1) {
+ [0]=>
+ string(13) "water ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(1) {
+ [0]=>
+ string(13) "water ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(1) {
+ [0]=>
+ string(13) "water ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(1) {
+ [0]=>
+ string(13) "water ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(1) {
+ [0]=>
+ string(13) "water ^fruit^"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(1) {
+ [0]=>
+ string(13) "water:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(1) {
+ [0]=>
+ string(13) "water:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(1) {
+ [0]=>
+ string(13) "water:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(1) {
+ [0]=>
+ string(13) "water:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(1) {
+ [0]=>
+ string(13) "water:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(1) {
+ [0]=>
+ string(13) "water:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(1) {
+ [0]=>
+ string(13) "water:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(1) {
+ [0]=>
+ string(13) "water:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(1) {
+ [0]=>
+ string(13) "water:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(1) {
+ [0]=>
+ string(13) "water:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(1) {
+ [0]=>
+ string(13) "water:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(1) {
+ [0]=>
+ string(13) "water:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(1) {
+ [0]=>
+ string(13) "water:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(1) {
+ [0]=>
+ string(13) "water:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(1) {
+ [0]=>
+ string(13) "water:&fruit&"
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(1) {
+ [0]=>
+ string(12) "water=fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(1) {
+ [0]=>
+ string(12) "water=fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(1) {
+ [0]=>
+ string(12) "water=fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(1) {
+ [0]=>
+ string(12) "water=fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(1) {
+ [0]=>
+ string(12) "water=fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(1) {
+ [0]=>
+ string(12) "water=fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(1) {
+ [0]=>
+ string(12) "water=fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(1) {
+ [0]=>
+ string(12) "water=fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(1) {
+ [0]=>
+ string(12) "water=fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(1) {
+ [0]=>
+ string(12) "water=fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(1) {
+ [0]=>
+ string(12) "water=fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(1) {
+ [0]=>
+ string(12) "water=fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(1) {
+ [0]=>
+ string(12) "water=fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(1) {
+ [0]=>
+ string(12) "water=fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(1) {
+ [0]=>
+ string(12) "water=fruit="
+}
+int(16)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(1) {
+ [0]=>
+ string(14) "water-fruitair"
+}
+int(18)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(1) {
+ [0]=>
+ string(18) "water-fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(1) {
+ [0]=>
+ string(18) "water-fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(1) {
+ [0]=>
+ string(18) "water-fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(1) {
+ [0]=>
+ string(18) "water-fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(1) {
+ [0]=>
+ string(18) "water-fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(1) {
+ [0]=>
+ string(18) "water-fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(1) {
+ [0]=>
+ string(18) "water-fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(1) {
+ [0]=>
+ string(18) "water-fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(1) {
+ [0]=>
+ string(18) "water-fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(1) {
+ [0]=>
+ string(18) "water-fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(1) {
+ [0]=>
+ string(18) "water-fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(1) {
+ [0]=>
+ string(18) "water-fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(1) {
+ [0]=>
+ string(18) "water-fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(1) {
+ [0]=>
+ string(18) "water-fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(1) {
+ [0]=>
+ string(18) "water-fruit---air-"
+}
+int(22)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r mode --
+array(1) {
+ [0]=>
+ string(21) """"":&"&:,:":&,&:,,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rb mode --
+array(1) {
+ [0]=>
+ string(21) """"":&"&:,:":&,&:,,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using rt mode --
+array(1) {
+ [0]=>
+ string(21) """"":&"&:,:":&,&:,,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+ mode --
+array(1) {
+ [0]=>
+ string(21) """"":&"&:,:":&,&:,,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+b mode --
+array(1) {
+ [0]=>
+ string(21) """"":&"&:,:":&,&:,,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using r+t mode --
+array(1) {
+ [0]=>
+ string(21) """"":&"&:,:":&,&:,,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+ mode --
+array(1) {
+ [0]=>
+ string(21) """"":&"&:,:":&,&:,,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+b mode --
+array(1) {
+ [0]=>
+ string(21) """"":&"&:,:":&,&:,,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using a+t mode --
+array(1) {
+ [0]=>
+ string(21) """"":&"&:,:":&,&:,,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+ mode --
+array(1) {
+ [0]=>
+ string(21) """"":&"&:,:":&,&:,,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+b mode --
+array(1) {
+ [0]=>
+ string(21) """"":&"&:,:":&,&:,,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using w+t mode --
+array(1) {
+ [0]=>
+ string(21) """"":&"&:,:":&,&:,,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+ mode --
+array(1) {
+ [0]=>
+ string(21) """"":&"&:,:":&,&:,,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+b mode --
+array(1) {
+ [0]=>
+ string(21) """"":&"&:,:":&,&:,,,,"
+}
+int(24)
+bool(false)
+
+-- Testing fgetcsv() with file opened using x+t mode --
+array(1) {
+ [0]=>
+ string(21) """"":&"&:,:":&,&:,,,,"
+}
+int(24)
+bool(false)
+Done
diff --git a/ext/standard/tests/file/fgets_basic.phpt b/ext/standard/tests/file/fgets_basic.phpt
new file mode 100644
index 0000000..9865f1f
--- /dev/null
+++ b/ext/standard/tests/file/fgets_basic.phpt
@@ -0,0 +1,318 @@
+--TEST--
+Test fgets() function : basic functionality
+--FILE--
+<?php
+/*
+ Prototype: string fgets ( resource $handle [, int $length] );
+ Description: Gets a line from file pointer
+*/
+
+// include the file.inc for common test funcitons
+include ("file.inc");
+
+$file_modes = array("r", "rb", "rt", "r+", "r+b", "r+t");
+
+$file_content_types = array("numeric", "text", "text_with_new_line", "alphanumeric");
+
+echo "*** Testing fgets() : basic functionality ***\n";
+foreach($file_modes as $file_mode) {
+ echo "\n-- Testing fgets() with file opened using mode $file_mode --\n";
+ foreach($file_content_types as $file_content_type) {
+ echo "-- File content type : $file_content_type --\n";
+ /* create files with $file_content_type */
+ create_files ( dirname(__FILE__), 1, $file_content_type, 0755, 50, "w", "fgets_basic", 1, "bytes"); //create a file
+ $filename = dirname(__FILE__)."/fgets_basic1.tmp"; // this is name of the file created by create_files()
+ $file_handle = fopen($filename, $file_mode);
+ if ( !$file_handle ) {
+ echo "Error: failed to open file $filename!";
+ exit();
+ }
+
+ echo "-- fgets() with default length, file pointer at 0 --\n";
+ var_dump( fgets($file_handle) ); // with default length
+ var_dump( ftell($file_handle) ); // ensure the file pointer position
+ var_dump( feof($file_handle) ); // enusre if eof set
+
+ echo "-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --\n";
+ var_dump( rewind($file_handle) );
+ var_dump( fgets($file_handle, 23) ); // expected: 22 chars
+ var_dump( ftell($file_handle) ); // ensure the file pointer position
+ var_dump( feof($file_handle) ); // enusre if eof set
+
+ //close file
+ fclose($file_handle);
+
+ // delete file
+ delete_file($filename);
+ } // file_content_type loop
+} // file_mode loop
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fgets() : basic functionality ***
+
+-- Testing fgets() with file opened using mode r --
+-- File content type : numeric --
+-- fgets() with default length, file pointer at 0 --
+string(50) "22222222222222222222222222222222222222222222222222"
+int(50)
+bool(true)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+bool(true)
+string(22) "2222222222222222222222"
+int(22)
+bool(false)
+-- File content type : text --
+-- fgets() with default length, file pointer at 0 --
+string(50) "text text text text text text text text text text "
+int(50)
+bool(true)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+bool(true)
+string(22) "text text text text te"
+int(22)
+bool(false)
+-- File content type : text_with_new_line --
+-- fgets() with default length, file pointer at 0 --
+string(5) "line
+"
+int(5)
+bool(false)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+bool(true)
+string(5) "line
+"
+int(5)
+bool(false)
+-- File content type : alphanumeric --
+-- fgets() with default length, file pointer at 0 --
+string(50) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+int(50)
+bool(true)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+bool(true)
+string(22) "ab12 ab12 ab12 ab12 ab"
+int(22)
+bool(false)
+
+-- Testing fgets() with file opened using mode rb --
+-- File content type : numeric --
+-- fgets() with default length, file pointer at 0 --
+string(50) "22222222222222222222222222222222222222222222222222"
+int(50)
+bool(true)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+bool(true)
+string(22) "2222222222222222222222"
+int(22)
+bool(false)
+-- File content type : text --
+-- fgets() with default length, file pointer at 0 --
+string(50) "text text text text text text text text text text "
+int(50)
+bool(true)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+bool(true)
+string(22) "text text text text te"
+int(22)
+bool(false)
+-- File content type : text_with_new_line --
+-- fgets() with default length, file pointer at 0 --
+string(5) "line
+"
+int(5)
+bool(false)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+bool(true)
+string(5) "line
+"
+int(5)
+bool(false)
+-- File content type : alphanumeric --
+-- fgets() with default length, file pointer at 0 --
+string(50) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+int(50)
+bool(true)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+bool(true)
+string(22) "ab12 ab12 ab12 ab12 ab"
+int(22)
+bool(false)
+
+-- Testing fgets() with file opened using mode rt --
+-- File content type : numeric --
+-- fgets() with default length, file pointer at 0 --
+string(50) "22222222222222222222222222222222222222222222222222"
+int(50)
+bool(true)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+bool(true)
+string(22) "2222222222222222222222"
+int(22)
+bool(false)
+-- File content type : text --
+-- fgets() with default length, file pointer at 0 --
+string(50) "text text text text text text text text text text "
+int(50)
+bool(true)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+bool(true)
+string(22) "text text text text te"
+int(22)
+bool(false)
+-- File content type : text_with_new_line --
+-- fgets() with default length, file pointer at 0 --
+string(5) "line
+"
+int(5)
+bool(false)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+bool(true)
+string(5) "line
+"
+int(5)
+bool(false)
+-- File content type : alphanumeric --
+-- fgets() with default length, file pointer at 0 --
+string(50) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+int(50)
+bool(true)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+bool(true)
+string(22) "ab12 ab12 ab12 ab12 ab"
+int(22)
+bool(false)
+
+-- Testing fgets() with file opened using mode r+ --
+-- File content type : numeric --
+-- fgets() with default length, file pointer at 0 --
+string(50) "22222222222222222222222222222222222222222222222222"
+int(50)
+bool(true)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+bool(true)
+string(22) "2222222222222222222222"
+int(22)
+bool(false)
+-- File content type : text --
+-- fgets() with default length, file pointer at 0 --
+string(50) "text text text text text text text text text text "
+int(50)
+bool(true)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+bool(true)
+string(22) "text text text text te"
+int(22)
+bool(false)
+-- File content type : text_with_new_line --
+-- fgets() with default length, file pointer at 0 --
+string(5) "line
+"
+int(5)
+bool(false)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+bool(true)
+string(5) "line
+"
+int(5)
+bool(false)
+-- File content type : alphanumeric --
+-- fgets() with default length, file pointer at 0 --
+string(50) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+int(50)
+bool(true)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+bool(true)
+string(22) "ab12 ab12 ab12 ab12 ab"
+int(22)
+bool(false)
+
+-- Testing fgets() with file opened using mode r+b --
+-- File content type : numeric --
+-- fgets() with default length, file pointer at 0 --
+string(50) "22222222222222222222222222222222222222222222222222"
+int(50)
+bool(true)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+bool(true)
+string(22) "2222222222222222222222"
+int(22)
+bool(false)
+-- File content type : text --
+-- fgets() with default length, file pointer at 0 --
+string(50) "text text text text text text text text text text "
+int(50)
+bool(true)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+bool(true)
+string(22) "text text text text te"
+int(22)
+bool(false)
+-- File content type : text_with_new_line --
+-- fgets() with default length, file pointer at 0 --
+string(5) "line
+"
+int(5)
+bool(false)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+bool(true)
+string(5) "line
+"
+int(5)
+bool(false)
+-- File content type : alphanumeric --
+-- fgets() with default length, file pointer at 0 --
+string(50) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+int(50)
+bool(true)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+bool(true)
+string(22) "ab12 ab12 ab12 ab12 ab"
+int(22)
+bool(false)
+
+-- Testing fgets() with file opened using mode r+t --
+-- File content type : numeric --
+-- fgets() with default length, file pointer at 0 --
+string(50) "22222222222222222222222222222222222222222222222222"
+int(50)
+bool(true)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+bool(true)
+string(22) "2222222222222222222222"
+int(22)
+bool(false)
+-- File content type : text --
+-- fgets() with default length, file pointer at 0 --
+string(50) "text text text text text text text text text text "
+int(50)
+bool(true)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+bool(true)
+string(22) "text text text text te"
+int(22)
+bool(false)
+-- File content type : text_with_new_line --
+-- fgets() with default length, file pointer at 0 --
+string(5) "line
+"
+int(5)
+bool(false)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+bool(true)
+string(5) "line
+"
+int(5)
+bool(false)
+-- File content type : alphanumeric --
+-- fgets() with default length, file pointer at 0 --
+string(50) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+int(50)
+bool(true)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+bool(true)
+string(22) "ab12 ab12 ab12 ab12 ab"
+int(22)
+bool(false)
+Done \ No newline at end of file
diff --git a/ext/standard/tests/file/fgets_error.phpt b/ext/standard/tests/file/fgets_error.phpt
new file mode 100644
index 0000000..51ae3c6
--- /dev/null
+++ b/ext/standard/tests/file/fgets_error.phpt
@@ -0,0 +1,108 @@
+--TEST--
+Test fgets() function : error conditions
+--FILE--
+<?php
+/*
+ Prototype: string fgets ( resource $handle [, int $length] );
+ Description: Gets line from file pointer
+*/
+
+echo "*** Testing error conditions ***\n";
+// zero argument
+echo "-- Testing fgets() with zero argument --\n";
+var_dump( fgets() );
+
+// more than expected no. of args
+echo "-- Testing fgets() with more than expected number of arguments --\n";
+$fp = fopen(__FILE__, "r");
+var_dump( fgets($fp, 10, $fp) );
+
+// invalid length argument
+echo "-- Testing fgets() with invalid length arguments --\n";
+$len = 0;
+var_dump( fgets($fp, $len) );
+$len = -10;
+var_dump( fgets($fp, $len) );
+$len = 1;
+var_dump( fgets($fp, $len) ); // return length - 1 always, expect false
+
+
+// test invalid arguments : non-resources
+echo "-- Testing fgets() with invalid arguments --\n";
+$invalid_args = array (
+ "string",
+ 10,
+ 10.5,
+ true,
+ array(1,2,3),
+ new stdclass,
+);
+/* loop to test fgets() with different invalid type of args */
+for($loop_counter = 1; $loop_counter <= count($invalid_args); $loop_counter++) {
+ echo "-- Iteration $loop_counter --\n";
+ var_dump( fgets($invalid_args[$loop_counter - 1], 10) );
+}
+
+// fgets() on a file handle which is already closed
+echo "-- Testing fgets() with closed/unset file handle --";
+fclose($fp);
+var_dump(fgets($fp,10));
+
+// fgets() on a file handle which is unset
+$file_handle = fopen(__FILE__, "r");
+unset($file_handle); //unset file handle
+var_dump( fgets(@$file_handle,10));
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing error conditions ***
+-- Testing fgets() with zero argument --
+
+Warning: fgets() expects at least 1 parameter, 0 given in %s on line %d
+bool(false)
+-- Testing fgets() with more than expected number of arguments --
+
+Warning: fgets() expects at most 2 parameters, 3 given in %s on line %d
+bool(false)
+-- Testing fgets() with invalid length arguments --
+
+Warning: fgets(): Length parameter must be greater than 0 in %s on line %d
+bool(false)
+
+Warning: fgets(): Length parameter must be greater than 0 in %s on line %d
+bool(false)
+bool(false)
+-- Testing fgets() with invalid arguments --
+-- Iteration 1 --
+
+Warning: fgets() expects parameter 1 to be resource, string given in %s on line %d
+bool(false)
+-- Iteration 2 --
+
+Warning: fgets() expects parameter 1 to be resource, integer given in %s on line %d
+bool(false)
+-- Iteration 3 --
+
+Warning: fgets() expects parameter 1 to be resource, double given in %s on line %d
+bool(false)
+-- Iteration 4 --
+
+Warning: fgets() expects parameter 1 to be resource, boolean given in %s on line %d
+bool(false)
+-- Iteration 5 --
+
+Warning: fgets() expects parameter 1 to be resource, array given in %s on line %d
+bool(false)
+-- Iteration 6 --
+
+Warning: fgets() expects parameter 1 to be resource, object given in %s on line %d
+bool(false)
+-- Testing fgets() with closed/unset file handle --
+Warning: fgets(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: fgets() expects parameter 1 to be resource, null given in %s on line %d
+bool(false)
+Done
+
diff --git a/ext/standard/tests/file/fgets_socket_variation1.phpt b/ext/standard/tests/file/fgets_socket_variation1.phpt
new file mode 100644
index 0000000..57944d8
--- /dev/null
+++ b/ext/standard/tests/file/fgets_socket_variation1.phpt
@@ -0,0 +1,56 @@
+--TEST--
+fgets() with a socket stream
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+
+/* Setup socket server */
+$server = stream_socket_server('tcp://127.0.0.1:31337');
+
+/* Connect to it */
+$client = fsockopen('tcp://127.0.0.1:31337');
+
+if (!$client) {
+ die("Unable to create socket");
+}
+
+/* Accept that connection */
+$socket = stream_socket_accept($server);
+
+echo "Write some data:\n";
+fwrite($socket, "line1\nline2\nline3\n");
+
+
+echo "\n\nRead a line from the client:\n";
+var_dump(fgets($client));
+
+echo "\n\nRead another line from the client:\n";
+var_dump(fgets($client));
+
+echo "\n\nClose the server side socket and read the remaining data from the client\n";
+fclose($socket);
+fclose($server);
+while(!feof($client)) {
+ fread($client, 1);
+}
+
+echo "done\n";
+
+?>
+--EXPECT--
+Write some data:
+
+
+Read a line from the client:
+string(6) "line1
+"
+
+
+Read another line from the client:
+string(6) "line2
+"
+
+
+Close the server side socket and read the remaining data from the client
+done
diff --git a/ext/standard/tests/file/fgets_socket_variation2.phpt b/ext/standard/tests/file/fgets_socket_variation2.phpt
new file mode 100644
index 0000000..3500837
--- /dev/null
+++ b/ext/standard/tests/file/fgets_socket_variation2.phpt
@@ -0,0 +1,63 @@
+--TEST--
+fgets() over a socket with more than a buffer's worth of data
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+
+// create a file
+$filename = __FILE__ . ".tmp";
+$fd = fopen($filename, "w+");
+
+// populate the file with lines of data
+define("LINE_OF_DATA", "12345678\n");
+for ($i = 0; $i < 1000; $i++) {
+ fwrite($fd, LINE_OF_DATA);
+}
+fclose($fd);
+
+/* Setup socket server */
+$server = stream_socket_server('tcp://127.0.0.1:31337');
+
+/* Connect to it */
+$client = fsockopen('tcp://127.0.0.1:31337');
+
+if (!$client) {
+ die("Unable to create socket");
+}
+
+/* Accept that connection */
+$socket = stream_socket_accept($server);
+
+echo "Write data from the file:\n";
+$data = file_get_contents($filename);
+unlink($filename);
+
+var_dump(fwrite($socket, $data));
+fclose($socket);
+
+echo "\nRead lines from the client\n";
+while ($line = fgets($client,256)) {
+ if (strcmp($line, LINE_OF_DATA) != 0) {
+ echo "Error - $line does not match " . LINE_OF_DATA;
+ break;
+ }
+}
+
+echo "\nClose the server side socket and read the remaining data from the client\n";
+fclose($server);
+while(!feof($client)) {
+ fread($client, 1);
+}
+
+echo "done\n";
+
+?>
+--EXPECT--
+Write data from the file:
+int(9000)
+
+Read lines from the client
+
+Close the server side socket and read the remaining data from the client
+done
diff --git a/ext/standard/tests/file/fgets_variation1.phpt b/ext/standard/tests/file/fgets_variation1.phpt
new file mode 100644
index 0000000..48ea231
--- /dev/null
+++ b/ext/standard/tests/file/fgets_variation1.phpt
@@ -0,0 +1,116 @@
+--TEST--
+Test fgets() function : usage variations - write only modes (Bug #42036)
+--FILE--
+<?php
+/*
+ Prototype: string fgets ( resource $handle [, int $length] );
+ Description: Gets a line from file pointer
+*/
+/* try fgets on files which are opened in non readable modes
+ w, wb, wt,
+ a, ab, at,
+ x, xb, xt
+*/
+// include the header for common test function
+include ("file.inc");
+
+echo "*** Testing fgets() with file opened in write only mode ***\n";
+
+$file_modes = array("w", "wb", "wt", "a", "ab", "at", "x", "xb", "xt");
+$filename = dirname(__FILE__)."/fgets_variation1.tmp";
+foreach ($file_modes as $file_mode ) {
+ echo "-- File opened in mode : $file_mode --\n";
+
+ $file_handle = fopen($filename, $file_mode);
+ if(!$file_handle) {
+ echo "Error: failed to open file $filename!\n";
+ exit();
+ }
+ $data = "fgets_variation test";
+ fwrite($file_handle, $data);
+
+ // rewind the file pointer to begining of the file
+ var_dump( rewind($file_handle) );
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ // read from file
+ var_dump( fgets($file_handle) ); // expected : no chars should be read
+ var_dump( ftell($file_handle) ); // ensure that file pointer position is not changed
+ var_dump( feof($file_handle) ); // check if end of file pointer is set
+
+ // close the file
+ fclose($file_handle);
+
+ // delete the file
+ unlink($filename);
+}
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fgets() with file opened in write only mode ***
+-- File opened in mode : w --
+bool(true)
+int(0)
+bool(false)
+bool(false)
+int(0)
+bool(false)
+-- File opened in mode : wb --
+bool(true)
+int(0)
+bool(false)
+bool(false)
+int(0)
+bool(false)
+-- File opened in mode : wt --
+bool(true)
+int(0)
+bool(false)
+bool(false)
+int(0)
+bool(false)
+-- File opened in mode : a --
+bool(true)
+int(0)
+bool(false)
+bool(false)
+int(0)
+bool(false)
+-- File opened in mode : ab --
+bool(true)
+int(0)
+bool(false)
+bool(false)
+int(0)
+bool(false)
+-- File opened in mode : at --
+bool(true)
+int(0)
+bool(false)
+bool(false)
+int(0)
+bool(false)
+-- File opened in mode : x --
+bool(true)
+int(0)
+bool(false)
+bool(false)
+int(0)
+bool(false)
+-- File opened in mode : xb --
+bool(true)
+int(0)
+bool(false)
+bool(false)
+int(0)
+bool(false)
+-- File opened in mode : xt --
+bool(true)
+int(0)
+bool(false)
+bool(false)
+int(0)
+bool(false)
+Done
diff --git a/ext/standard/tests/file/fgets_variation2.phpt b/ext/standard/tests/file/fgets_variation2.phpt
new file mode 100644
index 0000000..964216b
--- /dev/null
+++ b/ext/standard/tests/file/fgets_variation2.phpt
@@ -0,0 +1,63 @@
+--TEST--
+Test fgets() function : usage variations - closed handle
+--FILE--
+<?php
+/*
+ Prototype: string fgets ( resource $handle [, int $length] );
+ Description: Gets a line from file pointer
+*/
+
+/* try reading a line using fgets() using invalid handles
+ - closed file handle
+ - unset file handle
+*/
+
+// include the header for common test function
+include ("file.inc");
+
+echo "*** Testing fgets() : usage variations ***\n";
+
+echo "-- Testing fgets() with closed handle --\n";
+// open the file for reading
+$file_handle = fopen(__FILE__, "r");
+// close the file
+fclose($file_handle);
+
+// read from closed file
+var_dump( fgets($file_handle) ); // default length
+var_dump( fgets($file_handle, 10) ); // with specific length
+
+echo "-- Testing fgets() with unset handle --\n";
+// open the file for reading
+$file_handle = fopen(__FILE__, "r");
+// unset the file handle
+unset($file_handle);
+
+//fgets using unset handle
+var_dump( fgets($file_handle) ); // default length
+var_dump( fgets($file_handle, 10) ); // with specific length
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing fgets() : usage variations ***
+-- Testing fgets() with closed handle --
+
+Warning: fgets(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: fgets(): %d is not a valid stream resource in %s on line %d
+bool(false)
+-- Testing fgets() with unset handle --
+
+Notice: Undefined variable: file_handle in %s on line %d
+
+Warning: fgets() expects parameter 1 to be resource, null given in %s on line %d
+bool(false)
+
+Notice: Undefined variable: file_handle in %s on line %d
+
+Warning: fgets() expects parameter 1 to be resource, null given in %s on line %d
+bool(false)
+Done
+
diff --git a/ext/standard/tests/file/fgets_variation3.phpt b/ext/standard/tests/file/fgets_variation3.phpt
new file mode 100644
index 0000000..4f03641
--- /dev/null
+++ b/ext/standard/tests/file/fgets_variation3.phpt
@@ -0,0 +1,500 @@
+--TEST--
+Test fgets() function : usage variations - read with/without length
+--FILE--
+<?php
+/*
+ Prototype: string fgets ( resource $handle [, int $length] );
+ Description: Gets a line from file pointer
+*/
+
+// include the file.inc for common test funcitons
+include ("file.inc");
+
+$file_modes = array("w+", "w+b", "w+t",
+ "a+", "a+b", "a+t",
+ "x+", "x+b", "x+t");
+
+$file_content_types = array("numeric", "text", "text_with_new_line", "alphanumeric");
+
+echo "*** Testing fgets() : usage variations ***\n";
+
+$filename = dirname(__FILE__)."/fgets_variation3.tmp";
+
+foreach($file_modes as $file_mode) {
+ echo "\n-- Testing fgets() with file opened using mode $file_mode --\n";
+
+ foreach($file_content_types as $file_content_type) {
+ echo "-- File content type : $file_content_type --\n";
+
+ /* create files with $file_content_type */
+ $file_handle = fopen($filename, $file_mode);
+ $data = fill_file($file_handle, $file_content_type, 50);
+
+ if ( !$file_handle ) {
+ echo "Error: failed to open file $filename!";
+ exit();
+ }
+
+ echo "-- fgets() with default length, file pointer at 0 --\n";
+ // get the file pointer to begining of the file
+ rewind($file_handle);
+
+ var_dump( ftell($file_handle) );
+ var_dump( fgets($file_handle) ); // with default length
+ var_dump( ftell($file_handle) ); // ensure the file pointer position
+ var_dump( feof($file_handle) ); // enusre if eof set
+
+ echo "-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --\n";
+ // get the file pointer to begining of the file
+ rewind($file_handle);
+
+ var_dump( ftell($file_handle) );
+ var_dump( fgets($file_handle, 23) ); // expected: 22 chars
+ var_dump( ftell($file_handle) ); // ensure the file pointer position
+ var_dump( feof($file_handle) ); // enusre if eof set
+
+ //close file
+ fclose($file_handle);
+
+ // delete file
+ delete_file($filename);
+ } // file_content_type loop
+} // file_mode loop
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fgets() : usage variations ***
+
+-- Testing fgets() with file opened using mode w+ --
+-- File content type : numeric --
+-- fgets() with default length, file pointer at 0 --
+int(0)
+string(50) "22222222222222222222222222222222222222222222222222"
+int(50)
+bool(true)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+int(0)
+string(22) "2222222222222222222222"
+int(22)
+bool(false)
+-- File content type : text --
+-- fgets() with default length, file pointer at 0 --
+int(0)
+string(50) "text text text text text text text text text text "
+int(50)
+bool(true)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+int(0)
+string(22) "text text text text te"
+int(22)
+bool(false)
+-- File content type : text_with_new_line --
+-- fgets() with default length, file pointer at 0 --
+int(0)
+string(5) "line
+"
+int(5)
+bool(false)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+int(0)
+string(5) "line
+"
+int(5)
+bool(false)
+-- File content type : alphanumeric --
+-- fgets() with default length, file pointer at 0 --
+int(0)
+string(50) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+int(50)
+bool(true)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+int(0)
+string(22) "ab12 ab12 ab12 ab12 ab"
+int(22)
+bool(false)
+
+-- Testing fgets() with file opened using mode w+b --
+-- File content type : numeric --
+-- fgets() with default length, file pointer at 0 --
+int(0)
+string(50) "22222222222222222222222222222222222222222222222222"
+int(50)
+bool(true)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+int(0)
+string(22) "2222222222222222222222"
+int(22)
+bool(false)
+-- File content type : text --
+-- fgets() with default length, file pointer at 0 --
+int(0)
+string(50) "text text text text text text text text text text "
+int(50)
+bool(true)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+int(0)
+string(22) "text text text text te"
+int(22)
+bool(false)
+-- File content type : text_with_new_line --
+-- fgets() with default length, file pointer at 0 --
+int(0)
+string(5) "line
+"
+int(5)
+bool(false)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+int(0)
+string(5) "line
+"
+int(5)
+bool(false)
+-- File content type : alphanumeric --
+-- fgets() with default length, file pointer at 0 --
+int(0)
+string(50) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+int(50)
+bool(true)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+int(0)
+string(22) "ab12 ab12 ab12 ab12 ab"
+int(22)
+bool(false)
+
+-- Testing fgets() with file opened using mode w+t --
+-- File content type : numeric --
+-- fgets() with default length, file pointer at 0 --
+int(0)
+string(50) "22222222222222222222222222222222222222222222222222"
+int(50)
+bool(true)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+int(0)
+string(22) "2222222222222222222222"
+int(22)
+bool(false)
+-- File content type : text --
+-- fgets() with default length, file pointer at 0 --
+int(0)
+string(50) "text text text text text text text text text text "
+int(50)
+bool(true)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+int(0)
+string(22) "text text text text te"
+int(22)
+bool(false)
+-- File content type : text_with_new_line --
+-- fgets() with default length, file pointer at 0 --
+int(0)
+string(5) "line
+"
+int(5)
+bool(false)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+int(0)
+string(5) "line
+"
+int(5)
+bool(false)
+-- File content type : alphanumeric --
+-- fgets() with default length, file pointer at 0 --
+int(0)
+string(50) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+int(50)
+bool(true)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+int(0)
+string(22) "ab12 ab12 ab12 ab12 ab"
+int(22)
+bool(false)
+
+-- Testing fgets() with file opened using mode a+ --
+-- File content type : numeric --
+-- fgets() with default length, file pointer at 0 --
+int(0)
+string(50) "22222222222222222222222222222222222222222222222222"
+int(50)
+bool(true)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+int(0)
+string(22) "2222222222222222222222"
+int(22)
+bool(false)
+-- File content type : text --
+-- fgets() with default length, file pointer at 0 --
+int(0)
+string(50) "text text text text text text text text text text "
+int(50)
+bool(true)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+int(0)
+string(22) "text text text text te"
+int(22)
+bool(false)
+-- File content type : text_with_new_line --
+-- fgets() with default length, file pointer at 0 --
+int(0)
+string(5) "line
+"
+int(5)
+bool(false)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+int(0)
+string(5) "line
+"
+int(5)
+bool(false)
+-- File content type : alphanumeric --
+-- fgets() with default length, file pointer at 0 --
+int(0)
+string(50) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+int(50)
+bool(true)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+int(0)
+string(22) "ab12 ab12 ab12 ab12 ab"
+int(22)
+bool(false)
+
+-- Testing fgets() with file opened using mode a+b --
+-- File content type : numeric --
+-- fgets() with default length, file pointer at 0 --
+int(0)
+string(50) "22222222222222222222222222222222222222222222222222"
+int(50)
+bool(true)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+int(0)
+string(22) "2222222222222222222222"
+int(22)
+bool(false)
+-- File content type : text --
+-- fgets() with default length, file pointer at 0 --
+int(0)
+string(50) "text text text text text text text text text text "
+int(50)
+bool(true)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+int(0)
+string(22) "text text text text te"
+int(22)
+bool(false)
+-- File content type : text_with_new_line --
+-- fgets() with default length, file pointer at 0 --
+int(0)
+string(5) "line
+"
+int(5)
+bool(false)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+int(0)
+string(5) "line
+"
+int(5)
+bool(false)
+-- File content type : alphanumeric --
+-- fgets() with default length, file pointer at 0 --
+int(0)
+string(50) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+int(50)
+bool(true)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+int(0)
+string(22) "ab12 ab12 ab12 ab12 ab"
+int(22)
+bool(false)
+
+-- Testing fgets() with file opened using mode a+t --
+-- File content type : numeric --
+-- fgets() with default length, file pointer at 0 --
+int(0)
+string(50) "22222222222222222222222222222222222222222222222222"
+int(50)
+bool(true)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+int(0)
+string(22) "2222222222222222222222"
+int(22)
+bool(false)
+-- File content type : text --
+-- fgets() with default length, file pointer at 0 --
+int(0)
+string(50) "text text text text text text text text text text "
+int(50)
+bool(true)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+int(0)
+string(22) "text text text text te"
+int(22)
+bool(false)
+-- File content type : text_with_new_line --
+-- fgets() with default length, file pointer at 0 --
+int(0)
+string(5) "line
+"
+int(5)
+bool(false)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+int(0)
+string(5) "line
+"
+int(5)
+bool(false)
+-- File content type : alphanumeric --
+-- fgets() with default length, file pointer at 0 --
+int(0)
+string(50) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+int(50)
+bool(true)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+int(0)
+string(22) "ab12 ab12 ab12 ab12 ab"
+int(22)
+bool(false)
+
+-- Testing fgets() with file opened using mode x+ --
+-- File content type : numeric --
+-- fgets() with default length, file pointer at 0 --
+int(0)
+string(50) "22222222222222222222222222222222222222222222222222"
+int(50)
+bool(true)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+int(0)
+string(22) "2222222222222222222222"
+int(22)
+bool(false)
+-- File content type : text --
+-- fgets() with default length, file pointer at 0 --
+int(0)
+string(50) "text text text text text text text text text text "
+int(50)
+bool(true)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+int(0)
+string(22) "text text text text te"
+int(22)
+bool(false)
+-- File content type : text_with_new_line --
+-- fgets() with default length, file pointer at 0 --
+int(0)
+string(5) "line
+"
+int(5)
+bool(false)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+int(0)
+string(5) "line
+"
+int(5)
+bool(false)
+-- File content type : alphanumeric --
+-- fgets() with default length, file pointer at 0 --
+int(0)
+string(50) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+int(50)
+bool(true)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+int(0)
+string(22) "ab12 ab12 ab12 ab12 ab"
+int(22)
+bool(false)
+
+-- Testing fgets() with file opened using mode x+b --
+-- File content type : numeric --
+-- fgets() with default length, file pointer at 0 --
+int(0)
+string(50) "22222222222222222222222222222222222222222222222222"
+int(50)
+bool(true)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+int(0)
+string(22) "2222222222222222222222"
+int(22)
+bool(false)
+-- File content type : text --
+-- fgets() with default length, file pointer at 0 --
+int(0)
+string(50) "text text text text text text text text text text "
+int(50)
+bool(true)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+int(0)
+string(22) "text text text text te"
+int(22)
+bool(false)
+-- File content type : text_with_new_line --
+-- fgets() with default length, file pointer at 0 --
+int(0)
+string(5) "line
+"
+int(5)
+bool(false)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+int(0)
+string(5) "line
+"
+int(5)
+bool(false)
+-- File content type : alphanumeric --
+-- fgets() with default length, file pointer at 0 --
+int(0)
+string(50) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+int(50)
+bool(true)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+int(0)
+string(22) "ab12 ab12 ab12 ab12 ab"
+int(22)
+bool(false)
+
+-- Testing fgets() with file opened using mode x+t --
+-- File content type : numeric --
+-- fgets() with default length, file pointer at 0 --
+int(0)
+string(50) "22222222222222222222222222222222222222222222222222"
+int(50)
+bool(true)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+int(0)
+string(22) "2222222222222222222222"
+int(22)
+bool(false)
+-- File content type : text --
+-- fgets() with default length, file pointer at 0 --
+int(0)
+string(50) "text text text text text text text text text text "
+int(50)
+bool(true)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+int(0)
+string(22) "text text text text te"
+int(22)
+bool(false)
+-- File content type : text_with_new_line --
+-- fgets() with default length, file pointer at 0 --
+int(0)
+string(5) "line
+"
+int(5)
+bool(false)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+int(0)
+string(5) "line
+"
+int(5)
+bool(false)
+-- File content type : alphanumeric --
+-- fgets() with default length, file pointer at 0 --
+int(0)
+string(50) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+int(50)
+bool(true)
+-- fgets() with length = 23, Expected: 22 chars, file pointer at 0 --
+int(0)
+string(22) "ab12 ab12 ab12 ab12 ab"
+int(22)
+bool(false)
+Done \ No newline at end of file
diff --git a/ext/standard/tests/file/fgets_variation4-win32.phpt b/ext/standard/tests/file/fgets_variation4-win32.phpt
new file mode 100644
index 0000000..6d2bbf6
--- /dev/null
+++ b/ext/standard/tests/file/fgets_variation4-win32.phpt
@@ -0,0 +1,574 @@
+--TEST--
+Test fgets() function : usage variations - seek n read
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip only valid for Windows');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: string fgets ( resource $handle [, int $length] );
+ Description: Gets a line from file pointer
+*/
+
+// include the file.inc for common test funcitons
+include ("file.inc");
+
+$file_modes = array("w+", "w+b", "w+t",
+ "a+", "a+b", "a+t",
+ "x+", "x+b", "x+t");
+
+$file_content_types = array("numeric", "text", "text_with_new_line", "alphanumeric");
+
+echo "*** Testing fgets() : usage variations ***\n";
+
+$filename = dirname(__FILE__)."/fgets_variation4.tmp";
+
+foreach($file_modes as $file_mode) {
+ echo "\n-- Testing fgets() with file opened using mode $file_mode --\n";
+
+ foreach($file_content_types as $file_content_type) {
+ echo "-- File content type : $file_content_type --\n";
+
+ /* create files with $file_content_type */
+ $file_handle = fopen($filename, $file_mode);
+ $data = fill_file($file_handle, $file_content_type, 50);
+
+ if ( !$file_handle ) {
+ echo "Error: failed to open file $filename!";
+ exit();
+ }
+
+ echo "-- fgets() with location set by fseek() with default length --\n";
+ var_dump( fseek($file_handle, 5, SEEK_SET) );
+ var_dump( ftell($file_handle) );
+ var_dump( fgets($file_handle ) );
+ var_dump( ftell($file_handle) ); // ensure the file pointer position
+ var_dump( feof($file_handle) ); // enusre if eof set
+
+ echo "-- fgets() with location set by fseek() with length = 20 --\n";
+ var_dump( fseek($file_handle, 25, SEEK_SET) );
+ var_dump( ftell($file_handle) );
+ var_dump( fgets($file_handle, 20 ) ); // expected 19 chars
+ var_dump( ftell($file_handle) ); // ensure the file pointer position
+ var_dump( feof($file_handle) ); // enusre if eof set
+
+ //close file
+ fclose($file_handle);
+
+ // delete file
+ delete_file($filename);
+ } // file_content_type loop
+} // file_mode loop
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fgets() : usage variations ***
+
+-- Testing fgets() with file opened using mode w+ --
+-- File content type : numeric --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "222222222222222222222222222222222222222222222"
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "2222222222222222222"
+int(44)
+bool(false)
+-- File content type : text --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "text text text text text text text text text "
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "text text text text"
+int(44)
+bool(false)
+-- File content type : text_with_new_line --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(13) "line of text
+"
+int(18)
+bool(false)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(11) "ne of text
+"
+int(36)
+bool(false)
+-- File content type : alphanumeric --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "ab12 ab12 ab12 ab12"
+int(44)
+bool(false)
+
+-- Testing fgets() with file opened using mode w+b --
+-- File content type : numeric --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "222222222222222222222222222222222222222222222"
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "2222222222222222222"
+int(44)
+bool(false)
+-- File content type : text --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "text text text text text text text text text "
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "text text text text"
+int(44)
+bool(false)
+-- File content type : text_with_new_line --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(13) "line of text
+"
+int(18)
+bool(false)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(11) "ne of text
+"
+int(36)
+bool(false)
+-- File content type : alphanumeric --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "ab12 ab12 ab12 ab12"
+int(44)
+bool(false)
+
+-- Testing fgets() with file opened using mode w+t --
+-- File content type : numeric --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "222222222222222222222222222222222222222222222"
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "2222222222222222222"
+int(44)
+bool(false)
+-- File content type : text --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "text text text text text text text text text "
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "text text text text"
+int(44)
+bool(false)
+-- File content type : text_with_new_line --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(1) "
+"
+int(6)
+bool(false)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(12) "ine of text
+"
+int(37)
+bool(false)
+-- File content type : alphanumeric --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "ab12 ab12 ab12 ab12"
+int(44)
+bool(false)
+
+-- Testing fgets() with file opened using mode a+ --
+-- File content type : numeric --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "222222222222222222222222222222222222222222222"
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "2222222222222222222"
+int(44)
+bool(false)
+-- File content type : text --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "text text text text text text text text text "
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "text text text text"
+int(44)
+bool(false)
+-- File content type : text_with_new_line --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(13) "line of text
+"
+int(18)
+bool(false)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(11) "ne of text
+"
+int(36)
+bool(false)
+-- File content type : alphanumeric --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "ab12 ab12 ab12 ab12"
+int(44)
+bool(false)
+
+-- Testing fgets() with file opened using mode a+b --
+-- File content type : numeric --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "222222222222222222222222222222222222222222222"
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "2222222222222222222"
+int(44)
+bool(false)
+-- File content type : text --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "text text text text text text text text text "
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "text text text text"
+int(44)
+bool(false)
+-- File content type : text_with_new_line --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(13) "line of text
+"
+int(18)
+bool(false)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(11) "ne of text
+"
+int(36)
+bool(false)
+-- File content type : alphanumeric --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "ab12 ab12 ab12 ab12"
+int(44)
+bool(false)
+
+-- Testing fgets() with file opened using mode a+t --
+-- File content type : numeric --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "222222222222222222222222222222222222222222222"
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "2222222222222222222"
+int(44)
+bool(false)
+-- File content type : text --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "text text text text text text text text text "
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "text text text text"
+int(44)
+bool(false)
+-- File content type : text_with_new_line --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(1) "
+"
+int(6)
+bool(false)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(12) "ine of text
+"
+int(37)
+bool(false)
+-- File content type : alphanumeric --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "ab12 ab12 ab12 ab12"
+int(44)
+bool(false)
+
+-- Testing fgets() with file opened using mode x+ --
+-- File content type : numeric --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "222222222222222222222222222222222222222222222"
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "2222222222222222222"
+int(44)
+bool(false)
+-- File content type : text --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "text text text text text text text text text "
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "text text text text"
+int(44)
+bool(false)
+-- File content type : text_with_new_line --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(13) "line of text
+"
+int(18)
+bool(false)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(11) "ne of text
+"
+int(36)
+bool(false)
+-- File content type : alphanumeric --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "ab12 ab12 ab12 ab12"
+int(44)
+bool(false)
+
+-- Testing fgets() with file opened using mode x+b --
+-- File content type : numeric --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "222222222222222222222222222222222222222222222"
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "2222222222222222222"
+int(44)
+bool(false)
+-- File content type : text --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "text text text text text text text text text "
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "text text text text"
+int(44)
+bool(false)
+-- File content type : text_with_new_line --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(13) "line of text
+"
+int(18)
+bool(false)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(11) "ne of text
+"
+int(36)
+bool(false)
+-- File content type : alphanumeric --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "ab12 ab12 ab12 ab12"
+int(44)
+bool(false)
+
+-- Testing fgets() with file opened using mode x+t --
+-- File content type : numeric --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "222222222222222222222222222222222222222222222"
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "2222222222222222222"
+int(44)
+bool(false)
+-- File content type : text --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "text text text text text text text text text "
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "text text text text"
+int(44)
+bool(false)
+-- File content type : text_with_new_line --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(1) "
+"
+int(6)
+bool(false)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(12) "ine of text
+"
+int(37)
+bool(false)
+-- File content type : alphanumeric --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "ab12 ab12 ab12 ab12"
+int(44)
+bool(false)
+Done
diff --git a/ext/standard/tests/file/fgets_variation4.phpt b/ext/standard/tests/file/fgets_variation4.phpt
new file mode 100644
index 0000000..4ffa3f1
--- /dev/null
+++ b/ext/standard/tests/file/fgets_variation4.phpt
@@ -0,0 +1,574 @@
+--TEST--
+Test fgets() function : usage variations - seek n read
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip Not valid for Windows');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: string fgets ( resource $handle [, int $length] );
+ Description: Gets a line from file pointer
+*/
+
+// include the file.inc for common test funcitons
+include ("file.inc");
+
+$file_modes = array("w+", "w+b", "w+t",
+ "a+", "a+b", "a+t",
+ "x+", "x+b", "x+t");
+
+$file_content_types = array("numeric", "text", "text_with_new_line", "alphanumeric");
+
+echo "*** Testing fgets() : usage variations ***\n";
+
+$filename = dirname(__FILE__)."/fgets_variation4.tmp";
+
+foreach($file_modes as $file_mode) {
+ echo "\n-- Testing fgets() with file opened using mode $file_mode --\n";
+
+ foreach($file_content_types as $file_content_type) {
+ echo "-- File content type : $file_content_type --\n";
+
+ /* create files with $file_content_type */
+ $file_handle = fopen($filename, $file_mode);
+ $data = fill_file($file_handle, $file_content_type, 50);
+
+ if ( !$file_handle ) {
+ echo "Error: failed to open file $filename!";
+ exit();
+ }
+
+ echo "-- fgets() with location set by fseek() with default length --\n";
+ var_dump( fseek($file_handle, 5, SEEK_SET) );
+ var_dump( ftell($file_handle) );
+ var_dump( fgets($file_handle ) );
+ var_dump( ftell($file_handle) ); // ensure the file pointer position
+ var_dump( feof($file_handle) ); // enusre if eof set
+
+ echo "-- fgets() with location set by fseek() with length = 20 --\n";
+ var_dump( fseek($file_handle, 25, SEEK_SET) );
+ var_dump( ftell($file_handle) );
+ var_dump( fgets($file_handle, 20 ) ); // expected 19 chars
+ var_dump( ftell($file_handle) ); // ensure the file pointer position
+ var_dump( feof($file_handle) ); // enusre if eof set
+
+ //close file
+ fclose($file_handle);
+
+ // delete file
+ delete_file($filename);
+ } // file_content_type loop
+} // file_mode loop
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fgets() : usage variations ***
+
+-- Testing fgets() with file opened using mode w+ --
+-- File content type : numeric --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "222222222222222222222222222222222222222222222"
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "2222222222222222222"
+int(44)
+bool(false)
+-- File content type : text --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "text text text text text text text text text "
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "text text text text"
+int(44)
+bool(false)
+-- File content type : text_with_new_line --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(13) "line of text
+"
+int(18)
+bool(false)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(11) "ne of text
+"
+int(36)
+bool(false)
+-- File content type : alphanumeric --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "ab12 ab12 ab12 ab12"
+int(44)
+bool(false)
+
+-- Testing fgets() with file opened using mode w+b --
+-- File content type : numeric --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "222222222222222222222222222222222222222222222"
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "2222222222222222222"
+int(44)
+bool(false)
+-- File content type : text --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "text text text text text text text text text "
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "text text text text"
+int(44)
+bool(false)
+-- File content type : text_with_new_line --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(13) "line of text
+"
+int(18)
+bool(false)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(11) "ne of text
+"
+int(36)
+bool(false)
+-- File content type : alphanumeric --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "ab12 ab12 ab12 ab12"
+int(44)
+bool(false)
+
+-- Testing fgets() with file opened using mode w+t --
+-- File content type : numeric --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "222222222222222222222222222222222222222222222"
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "2222222222222222222"
+int(44)
+bool(false)
+-- File content type : text --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "text text text text text text text text text "
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "text text text text"
+int(44)
+bool(false)
+-- File content type : text_with_new_line --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(13) "line of text
+"
+int(18)
+bool(false)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(11) "ne of text
+"
+int(36)
+bool(false)
+-- File content type : alphanumeric --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "ab12 ab12 ab12 ab12"
+int(44)
+bool(false)
+
+-- Testing fgets() with file opened using mode a+ --
+-- File content type : numeric --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "222222222222222222222222222222222222222222222"
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "2222222222222222222"
+int(44)
+bool(false)
+-- File content type : text --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "text text text text text text text text text "
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "text text text text"
+int(44)
+bool(false)
+-- File content type : text_with_new_line --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(13) "line of text
+"
+int(18)
+bool(false)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(11) "ne of text
+"
+int(36)
+bool(false)
+-- File content type : alphanumeric --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "ab12 ab12 ab12 ab12"
+int(44)
+bool(false)
+
+-- Testing fgets() with file opened using mode a+b --
+-- File content type : numeric --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "222222222222222222222222222222222222222222222"
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "2222222222222222222"
+int(44)
+bool(false)
+-- File content type : text --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "text text text text text text text text text "
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "text text text text"
+int(44)
+bool(false)
+-- File content type : text_with_new_line --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(13) "line of text
+"
+int(18)
+bool(false)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(11) "ne of text
+"
+int(36)
+bool(false)
+-- File content type : alphanumeric --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "ab12 ab12 ab12 ab12"
+int(44)
+bool(false)
+
+-- Testing fgets() with file opened using mode a+t --
+-- File content type : numeric --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "222222222222222222222222222222222222222222222"
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "2222222222222222222"
+int(44)
+bool(false)
+-- File content type : text --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "text text text text text text text text text "
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "text text text text"
+int(44)
+bool(false)
+-- File content type : text_with_new_line --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(13) "line of text
+"
+int(18)
+bool(false)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(11) "ne of text
+"
+int(36)
+bool(false)
+-- File content type : alphanumeric --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "ab12 ab12 ab12 ab12"
+int(44)
+bool(false)
+
+-- Testing fgets() with file opened using mode x+ --
+-- File content type : numeric --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "222222222222222222222222222222222222222222222"
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "2222222222222222222"
+int(44)
+bool(false)
+-- File content type : text --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "text text text text text text text text text "
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "text text text text"
+int(44)
+bool(false)
+-- File content type : text_with_new_line --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(13) "line of text
+"
+int(18)
+bool(false)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(11) "ne of text
+"
+int(36)
+bool(false)
+-- File content type : alphanumeric --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "ab12 ab12 ab12 ab12"
+int(44)
+bool(false)
+
+-- Testing fgets() with file opened using mode x+b --
+-- File content type : numeric --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "222222222222222222222222222222222222222222222"
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "2222222222222222222"
+int(44)
+bool(false)
+-- File content type : text --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "text text text text text text text text text "
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "text text text text"
+int(44)
+bool(false)
+-- File content type : text_with_new_line --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(13) "line of text
+"
+int(18)
+bool(false)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(11) "ne of text
+"
+int(36)
+bool(false)
+-- File content type : alphanumeric --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "ab12 ab12 ab12 ab12"
+int(44)
+bool(false)
+
+-- Testing fgets() with file opened using mode x+t --
+-- File content type : numeric --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "222222222222222222222222222222222222222222222"
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "2222222222222222222"
+int(44)
+bool(false)
+-- File content type : text --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "text text text text text text text text text "
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "text text text text"
+int(44)
+bool(false)
+-- File content type : text_with_new_line --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(13) "line of text
+"
+int(18)
+bool(false)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(11) "ne of text
+"
+int(36)
+bool(false)
+-- File content type : alphanumeric --
+-- fgets() with location set by fseek() with default length --
+int(0)
+int(5)
+string(45) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+int(50)
+bool(true)
+-- fgets() with location set by fseek() with length = 20 --
+int(0)
+int(25)
+string(19) "ab12 ab12 ab12 ab12"
+int(44)
+bool(false)
+Done \ No newline at end of file
diff --git a/ext/standard/tests/file/fgets_variation5.phpt b/ext/standard/tests/file/fgets_variation5.phpt
new file mode 100644
index 0000000..4a1ed9f
--- /dev/null
+++ b/ext/standard/tests/file/fgets_variation5.phpt
@@ -0,0 +1,302 @@
+--TEST--
+Test fgets() function : usage variations - read beyond filesize
+--FILE--
+<?php
+/*
+ Prototype: string fgets ( resource $handle [, int $length] );
+ Description: Gets a line from file pointer
+*/
+
+// include the file.inc for common test funcitons
+include ("file.inc");
+
+$file_modes = array("w+", "w+b", "w+t",
+ "a+", "a+b", "a+t",
+ "x+", "x+b", "x+t");
+
+$file_content_types = array("numeric", "text", "text_with_new_line", "alphanumeric");
+
+echo "*** Testing fgets() : usage variations ***\n";
+
+$filename = dirname(__FILE__)."/fgets_variation5.tmp";
+
+foreach($file_modes as $file_mode) {
+ echo "\n-- Testing fgets() with file opened using mode $file_mode --\n";
+
+ foreach($file_content_types as $file_content_type) {
+ echo "-- File content type : $file_content_type --\n";
+
+ /* create files with $file_content_type */
+ $file_handle = fopen($filename, $file_mode);
+ $data = fill_file($file_handle, $file_content_type, 50);
+
+ if ( !$file_handle ) {
+ echo "Error: failed to open file $filename!";
+ exit();
+ }
+
+ /* read with length beyong file size */
+ echo "-- fgets() with length > filesize --\n";
+ rewind($file_handle);
+
+ var_dump( ftell($file_handle) );
+ var_dump( fgets($file_handle, 50 + 23) ); // expected: 50
+ var_dump( ftell($file_handle) ); // ensure the file pointer position
+ var_dump( feof($file_handle) ); // enusre if eof set
+
+ //close file
+ fclose($file_handle);
+
+ // delete file
+ delete_file($filename);
+ } // file_content_type loop
+} // file_mode loop
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fgets() : usage variations ***
+
+-- Testing fgets() with file opened using mode w+ --
+-- File content type : numeric --
+-- fgets() with length > filesize --
+int(0)
+string(50) "22222222222222222222222222222222222222222222222222"
+int(50)
+bool(true)
+-- File content type : text --
+-- fgets() with length > filesize --
+int(0)
+string(50) "text text text text text text text text text text "
+int(50)
+bool(true)
+-- File content type : text_with_new_line --
+-- fgets() with length > filesize --
+int(0)
+string(5) "line
+"
+int(5)
+bool(false)
+-- File content type : alphanumeric --
+-- fgets() with length > filesize --
+int(0)
+string(50) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+int(50)
+bool(true)
+
+-- Testing fgets() with file opened using mode w+b --
+-- File content type : numeric --
+-- fgets() with length > filesize --
+int(0)
+string(50) "22222222222222222222222222222222222222222222222222"
+int(50)
+bool(true)
+-- File content type : text --
+-- fgets() with length > filesize --
+int(0)
+string(50) "text text text text text text text text text text "
+int(50)
+bool(true)
+-- File content type : text_with_new_line --
+-- fgets() with length > filesize --
+int(0)
+string(5) "line
+"
+int(5)
+bool(false)
+-- File content type : alphanumeric --
+-- fgets() with length > filesize --
+int(0)
+string(50) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+int(50)
+bool(true)
+
+-- Testing fgets() with file opened using mode w+t --
+-- File content type : numeric --
+-- fgets() with length > filesize --
+int(0)
+string(50) "22222222222222222222222222222222222222222222222222"
+int(50)
+bool(true)
+-- File content type : text --
+-- fgets() with length > filesize --
+int(0)
+string(50) "text text text text text text text text text text "
+int(50)
+bool(true)
+-- File content type : text_with_new_line --
+-- fgets() with length > filesize --
+int(0)
+string(5) "line
+"
+int(5)
+bool(false)
+-- File content type : alphanumeric --
+-- fgets() with length > filesize --
+int(0)
+string(50) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+int(50)
+bool(true)
+
+-- Testing fgets() with file opened using mode a+ --
+-- File content type : numeric --
+-- fgets() with length > filesize --
+int(0)
+string(50) "22222222222222222222222222222222222222222222222222"
+int(50)
+bool(true)
+-- File content type : text --
+-- fgets() with length > filesize --
+int(0)
+string(50) "text text text text text text text text text text "
+int(50)
+bool(true)
+-- File content type : text_with_new_line --
+-- fgets() with length > filesize --
+int(0)
+string(5) "line
+"
+int(5)
+bool(false)
+-- File content type : alphanumeric --
+-- fgets() with length > filesize --
+int(0)
+string(50) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+int(50)
+bool(true)
+
+-- Testing fgets() with file opened using mode a+b --
+-- File content type : numeric --
+-- fgets() with length > filesize --
+int(0)
+string(50) "22222222222222222222222222222222222222222222222222"
+int(50)
+bool(true)
+-- File content type : text --
+-- fgets() with length > filesize --
+int(0)
+string(50) "text text text text text text text text text text "
+int(50)
+bool(true)
+-- File content type : text_with_new_line --
+-- fgets() with length > filesize --
+int(0)
+string(5) "line
+"
+int(5)
+bool(false)
+-- File content type : alphanumeric --
+-- fgets() with length > filesize --
+int(0)
+string(50) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+int(50)
+bool(true)
+
+-- Testing fgets() with file opened using mode a+t --
+-- File content type : numeric --
+-- fgets() with length > filesize --
+int(0)
+string(50) "22222222222222222222222222222222222222222222222222"
+int(50)
+bool(true)
+-- File content type : text --
+-- fgets() with length > filesize --
+int(0)
+string(50) "text text text text text text text text text text "
+int(50)
+bool(true)
+-- File content type : text_with_new_line --
+-- fgets() with length > filesize --
+int(0)
+string(5) "line
+"
+int(5)
+bool(false)
+-- File content type : alphanumeric --
+-- fgets() with length > filesize --
+int(0)
+string(50) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+int(50)
+bool(true)
+
+-- Testing fgets() with file opened using mode x+ --
+-- File content type : numeric --
+-- fgets() with length > filesize --
+int(0)
+string(50) "22222222222222222222222222222222222222222222222222"
+int(50)
+bool(true)
+-- File content type : text --
+-- fgets() with length > filesize --
+int(0)
+string(50) "text text text text text text text text text text "
+int(50)
+bool(true)
+-- File content type : text_with_new_line --
+-- fgets() with length > filesize --
+int(0)
+string(5) "line
+"
+int(5)
+bool(false)
+-- File content type : alphanumeric --
+-- fgets() with length > filesize --
+int(0)
+string(50) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+int(50)
+bool(true)
+
+-- Testing fgets() with file opened using mode x+b --
+-- File content type : numeric --
+-- fgets() with length > filesize --
+int(0)
+string(50) "22222222222222222222222222222222222222222222222222"
+int(50)
+bool(true)
+-- File content type : text --
+-- fgets() with length > filesize --
+int(0)
+string(50) "text text text text text text text text text text "
+int(50)
+bool(true)
+-- File content type : text_with_new_line --
+-- fgets() with length > filesize --
+int(0)
+string(5) "line
+"
+int(5)
+bool(false)
+-- File content type : alphanumeric --
+-- fgets() with length > filesize --
+int(0)
+string(50) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+int(50)
+bool(true)
+
+-- Testing fgets() with file opened using mode x+t --
+-- File content type : numeric --
+-- fgets() with length > filesize --
+int(0)
+string(50) "22222222222222222222222222222222222222222222222222"
+int(50)
+bool(true)
+-- File content type : text --
+-- fgets() with length > filesize --
+int(0)
+string(50) "text text text text text text text text text text "
+int(50)
+bool(true)
+-- File content type : text_with_new_line --
+-- fgets() with length > filesize --
+int(0)
+string(5) "line
+"
+int(5)
+bool(false)
+-- File content type : alphanumeric --
+-- fgets() with length > filesize --
+int(0)
+string(50) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+int(50)
+bool(true)
+Done \ No newline at end of file
diff --git a/ext/standard/tests/file/fgets_variation6-win32.phpt b/ext/standard/tests/file/fgets_variation6-win32.phpt
new file mode 100644
index 0000000..14cb46f
--- /dev/null
+++ b/ext/standard/tests/file/fgets_variation6-win32.phpt
@@ -0,0 +1,372 @@
+--TEST--
+Test fgets() function : usage variations - read when file pointer at EOF
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip only valid for Windows');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: string fgets ( resource $handle [, int $length] );
+ Description: Gets a line from file pointer
+*/
+
+// include the file.inc for common test funcitons
+include ("file.inc");
+
+$file_modes = array("w+", "w+b", "w+t",
+ "a+", "a+b", "a+t",
+ "x+", "x+b", "x+t");
+
+$file_content_types = array("numeric", "text", "text_with_new_line", "alphanumeric");
+
+echo "*** Testing fgets() : usage variations ***\n";
+
+$filename = dirname(__FILE__)."/fgets_variation4.tmp";
+
+foreach($file_modes as $file_mode) {
+ echo "\n-- Testing fgets() with file opened using mode $file_mode --\n";
+
+ foreach($file_content_types as $file_content_type) {
+ echo "-- File content type : $file_content_type --\n";
+
+ /* create files with $file_content_type */
+ $file_handle = fopen($filename, $file_mode);
+ $data = fill_file($file_handle, $file_content_type, 50);
+
+ if ( !$file_handle ) {
+ echo "Error: failed to open file $filename!";
+ exit();
+ }
+
+ echo "-- fgets() with file pointer pointing at EOF --\n";
+ // seek to end of the file and try fgets()
+ var_dump( fseek($file_handle, 0, SEEK_END) ); // set file pointer to eof
+ var_dump( ftell($file_handle) ); // ensure that file pointer is at eof
+ var_dump( feof($file_handle) ); // expected false
+
+ var_dump( fgets($file_handle) ); // try n read a line, none expected
+ var_dump( ftell($file_handle) ); // file pointer position
+ var_dump( feof($file_handle) ); // ensure thta file pointer is at eof
+
+ //close file
+ fclose($file_handle);
+
+ // delete file
+ delete_file($filename);
+ } // file_content_type loop
+} // file_mode loop
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fgets() : usage variations ***
+
+-- Testing fgets() with file opened using mode w+ --
+-- File content type : numeric --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : text --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : text_with_new_line --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : alphanumeric --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+
+-- Testing fgets() with file opened using mode w+b --
+-- File content type : numeric --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : text --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : text_with_new_line --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : alphanumeric --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+
+-- Testing fgets() with file opened using mode w+t --
+-- File content type : numeric --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : text --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : text_with_new_line --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(55)
+bool(false)
+bool(false)
+int(55)
+bool(true)
+-- File content type : alphanumeric --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+
+-- Testing fgets() with file opened using mode a+ --
+-- File content type : numeric --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : text --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : text_with_new_line --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : alphanumeric --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+
+-- Testing fgets() with file opened using mode a+b --
+-- File content type : numeric --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : text --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : text_with_new_line --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : alphanumeric --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+
+-- Testing fgets() with file opened using mode a+t --
+-- File content type : numeric --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : text --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : text_with_new_line --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(55)
+bool(false)
+bool(false)
+int(55)
+bool(true)
+-- File content type : alphanumeric --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+
+-- Testing fgets() with file opened using mode x+ --
+-- File content type : numeric --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : text --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : text_with_new_line --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : alphanumeric --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+
+-- Testing fgets() with file opened using mode x+b --
+-- File content type : numeric --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : text --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : text_with_new_line --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : alphanumeric --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+
+-- Testing fgets() with file opened using mode x+t --
+-- File content type : numeric --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : text --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : text_with_new_line --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(55)
+bool(false)
+bool(false)
+int(55)
+bool(true)
+-- File content type : alphanumeric --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+Done
diff --git a/ext/standard/tests/file/fgets_variation6.phpt b/ext/standard/tests/file/fgets_variation6.phpt
new file mode 100644
index 0000000..da6c214
--- /dev/null
+++ b/ext/standard/tests/file/fgets_variation6.phpt
@@ -0,0 +1,372 @@
+--TEST--
+Test fgets() function : usage variations - read when file pointer at EOF
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip Not valid for Windows');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: string fgets ( resource $handle [, int $length] );
+ Description: Gets a line from file pointer
+*/
+
+// include the file.inc for common test funcitons
+include ("file.inc");
+
+$file_modes = array("w+", "w+b", "w+t",
+ "a+", "a+b", "a+t",
+ "x+", "x+b", "x+t");
+
+$file_content_types = array("numeric", "text", "text_with_new_line", "alphanumeric");
+
+echo "*** Testing fgets() : usage variations ***\n";
+
+$filename = dirname(__FILE__)."/fgets_variation4.tmp";
+
+foreach($file_modes as $file_mode) {
+ echo "\n-- Testing fgets() with file opened using mode $file_mode --\n";
+
+ foreach($file_content_types as $file_content_type) {
+ echo "-- File content type : $file_content_type --\n";
+
+ /* create files with $file_content_type */
+ $file_handle = fopen($filename, $file_mode);
+ $data = fill_file($file_handle, $file_content_type, 50);
+
+ if ( !$file_handle ) {
+ echo "Error: failed to open file $filename!";
+ exit();
+ }
+
+ echo "-- fgets() with file pointer pointing at EOF --\n";
+ // seek to end of the file and try fgets()
+ var_dump( fseek($file_handle, 0, SEEK_END) ); // set file pointer to eof
+ var_dump( ftell($file_handle) ); // ensure that file pointer is at eof
+ var_dump( feof($file_handle) ); // expected false
+
+ var_dump( fgets($file_handle) ); // try n read a line, none expected
+ var_dump( ftell($file_handle) ); // file pointer position
+ var_dump( feof($file_handle) ); // ensure thta file pointer is at eof
+
+ //close file
+ fclose($file_handle);
+
+ // delete file
+ delete_file($filename);
+ } // file_content_type loop
+} // file_mode loop
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fgets() : usage variations ***
+
+-- Testing fgets() with file opened using mode w+ --
+-- File content type : numeric --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : text --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : text_with_new_line --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : alphanumeric --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+
+-- Testing fgets() with file opened using mode w+b --
+-- File content type : numeric --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : text --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : text_with_new_line --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : alphanumeric --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+
+-- Testing fgets() with file opened using mode w+t --
+-- File content type : numeric --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : text --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : text_with_new_line --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : alphanumeric --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+
+-- Testing fgets() with file opened using mode a+ --
+-- File content type : numeric --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : text --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : text_with_new_line --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : alphanumeric --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+
+-- Testing fgets() with file opened using mode a+b --
+-- File content type : numeric --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : text --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : text_with_new_line --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : alphanumeric --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+
+-- Testing fgets() with file opened using mode a+t --
+-- File content type : numeric --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : text --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : text_with_new_line --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : alphanumeric --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+
+-- Testing fgets() with file opened using mode x+ --
+-- File content type : numeric --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : text --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : text_with_new_line --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : alphanumeric --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+
+-- Testing fgets() with file opened using mode x+b --
+-- File content type : numeric --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : text --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : text_with_new_line --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : alphanumeric --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+
+-- Testing fgets() with file opened using mode x+t --
+-- File content type : numeric --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : text --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : text_with_new_line --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+-- File content type : alphanumeric --
+-- fgets() with file pointer pointing at EOF --
+int(0)
+int(50)
+bool(false)
+bool(false)
+int(50)
+bool(true)
+Done \ No newline at end of file
diff --git a/ext/standard/tests/file/fgetss.phpt b/ext/standard/tests/file/fgetss.phpt
new file mode 100644
index 0000000..b4ac211
--- /dev/null
+++ b/ext/standard/tests/file/fgetss.phpt
@@ -0,0 +1,83 @@
+--TEST--
+fgetss() tests
+--FILE--
+<?php
+
+$filename = dirname(__FILE__)."/fgetss.html";
+
+$array = array(
+ "askasdfasdf<b>aaaaaa\n</b>dddddd",
+ "asdqw<i onClick=\"hello();\">\naaaa<>qqqq",
+ "aaa<script>function foo() {}</script>qqq",
+ "asdasd<a\n asdjeje",
+ "",
+ "some text \n<b>blah</i>",
+ "some another text <> hoho </>"
+ );
+
+foreach ($array as $str) {
+ file_put_contents($filename, $str);
+ $fp = fopen($filename, "r");
+ var_dump(fgetss($fp));
+ var_dump(fgetss($fp));
+}
+
+foreach ($array as $str) {
+ file_put_contents($filename, $str);
+ $fp = fopen($filename, "r");
+ var_dump(fgetss($fp, 10));
+ var_dump(fgetss($fp, 10));
+}
+
+var_dump(fgetss($fp, -10));
+var_dump(fgetss($fp, 0));
+fclose($fp);
+var_dump(fgetss($fp, 0));
+
+@unlink($filename);
+
+echo "Done\n";
+?>
+--EXPECTF--
+string(18) "askasdfasdfaaaaaa
+"
+string(6) "dddddd"
+string(6) "asdqw
+"
+string(8) "aaaaqqqq"
+string(23) "aaafunction foo() {}qqq"
+bool(false)
+string(6) "asdasd"
+string(0) ""
+bool(false)
+bool(false)
+string(11) "some text
+"
+string(4) "blah"
+string(24) "some another text hoho "
+bool(false)
+string(9) "askasdfas"
+string(6) "dfaaaa"
+string(5) "asdqw"
+string(0) ""
+string(3) "aaa"
+string(7) "functio"
+string(6) "asdasd"
+string(0) ""
+bool(false)
+bool(false)
+string(9) "some text"
+string(2) "
+"
+string(9) "some anot"
+string(9) "her text "
+
+Warning: fgetss(): Length parameter must be greater than 0 in %s on line %d
+bool(false)
+
+Warning: fgetss(): Length parameter must be greater than 0 in %s on line %d
+bool(false)
+
+Warning: fgetss(): %d is not a valid stream resource in %s on line %d
+bool(false)
+Done
diff --git a/ext/standard/tests/file/fgetss1.phpt b/ext/standard/tests/file/fgetss1.phpt
new file mode 100644
index 0000000..96b8b6f
--- /dev/null
+++ b/ext/standard/tests/file/fgetss1.phpt
@@ -0,0 +1,69 @@
+--TEST--
+more fgetss() tests
+--FILE--
+<?php
+
+$filename = dirname(__FILE__)."/fgetss1.html";
+
+$array = array(
+ "askasdfasdf<b>aaaaaa\n</b>dddddd",
+ "asdqw<i onClick=\"hello();\">\naaaa<>qqqq",
+ "aaa<script>function foo() {}</script>qqq",
+ "asdasd<a\n asdjeje",
+ "",
+ "some text \n<b>blah</i>",
+ "some another text <> hoho </>"
+ );
+
+foreach ($array as $str) {
+ file_put_contents($filename, $str);
+ $fp = fopen($filename, "r");
+ var_dump(fgetss($fp, 1000, "<i>,<b>,<a>"));
+ var_dump(fgetss($fp));
+}
+
+foreach ($array as $str) {
+ file_put_contents($filename, $str);
+ $fp = fopen($filename, "r");
+ var_dump(fgetss($fp, 10));
+ var_dump(fgetss($fp, 10, "<script>,<a>"));
+}
+
+@unlink($filename);
+
+echo "Done\n";
+?>
+--EXPECTF--
+string(21) "askasdfasdf<b>aaaaaa
+"
+string(6) "dddddd"
+string(28) "asdqw<i onClick="hello();">
+"
+string(8) "aaaaqqqq"
+string(23) "aaafunction foo() {}qqq"
+bool(false)
+string(6) "asdasd"
+string(0) ""
+bool(false)
+bool(false)
+string(11) "some text
+"
+string(4) "blah"
+string(24) "some another text hoho "
+bool(false)
+string(9) "askasdfas"
+string(6) "dfaaaa"
+string(5) "asdqw"
+string(0) ""
+string(3) "aaa"
+string(9) "t>functio"
+string(6) "asdasd"
+string(0) ""
+bool(false)
+bool(false)
+string(9) "some text"
+string(2) "
+"
+string(9) "some anot"
+string(9) "her text "
+Done
diff --git a/ext/standard/tests/file/fgetss_basic1.phpt b/ext/standard/tests/file/fgetss_basic1.phpt
new file mode 100644
index 0000000..4c5881d
--- /dev/null
+++ b/ext/standard/tests/file/fgetss_basic1.phpt
@@ -0,0 +1,135 @@
+--TEST--
+Test fgetss() function : Basic functionality - read modes only
+--FILE--
+<?php
+/*
+ Prototype: string fgetss ( resource $handle [, int $length [, string $allowable_tags]] );
+ Description: Gets line from file pointer and strip HTML tags
+*/
+
+/* test fgetss with all read modes */
+
+// include the common file related test functions
+include ("file.inc");
+
+echo "*** Testing fgetss() : Basic operations ***\n";
+
+/* string with html and php tags */
+$string_with_tags = <<<EOT
+<test>Testing fgetss() functions</test>
+<?php echo "this string is within php tag"; ?> {;}<{> this
+is a heredoc string. <pg>ksklnm@@$$&$&^%&^%&^%&</pg>
+<html> html </html> <?php echo "php"; ?>
+EOT;
+
+if(substr(PHP_OS, 0, 3) == "WIN") {
+ $string_with_tags = str_replace("\r",'', $string_with_tags);
+}
+/* try reading the file opened in different modes of reading */
+$file_modes = array("r","rb", "rt","r+", "r+b", "r+t");
+
+for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ echo "\n-- Testing fgetss() with file opened using $file_modes[$mode_counter] mode --\n";
+
+ /* create an empty file and write the strings with tags */
+ $filename = dirname(__FILE__)."/fgetss_basic1.tmp";
+ create_file ($filename); //create an empty file
+ file_put_contents($filename, $string_with_tags);
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ if(!$file_handle) {
+ echo "Error: failed to open file $filename!\n";
+ exit();
+ }
+
+ rewind($file_handle);
+ /* read entire file and strip tags */
+ echo "-- fgetss() with default length, file pointer at 0 --\n";
+ var_dump( fgetss($file_handle) ); // no length and allowable tags provided, reads entire file
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ rewind($file_handle);
+ /* read entire file and strip tags tags */
+ echo "-- fgets() with length = 30, file pointer at 0 --\n";
+ var_dump( fgetss($file_handle ,30) ); // length parameter given,not reading entire file
+ var_dump( ftell($file_handle) ); // checking file pointer position initially
+ var_dump( feof($file_handle) ); // confirm file pointer is not at eof
+
+ // close the file
+ fclose($file_handle);
+
+ // delete the file
+ delete_file($filename);
+} // end of for - mode_counter
+
+echo "Done\n";
+?>
+--EXPECT--
+*** Testing fgetss() : Basic operations ***
+
+-- Testing fgetss() with file opened using r mode --
+-- fgetss() with default length, file pointer at 0 --
+string(27) "Testing fgetss() functions
+"
+int(40)
+bool(false)
+-- fgets() with length = 30, file pointer at 0 --
+string(23) "Testing fgetss() functi"
+int(29)
+bool(false)
+
+-- Testing fgetss() with file opened using rb mode --
+-- fgetss() with default length, file pointer at 0 --
+string(27) "Testing fgetss() functions
+"
+int(40)
+bool(false)
+-- fgets() with length = 30, file pointer at 0 --
+string(23) "Testing fgetss() functi"
+int(29)
+bool(false)
+
+-- Testing fgetss() with file opened using rt mode --
+-- fgetss() with default length, file pointer at 0 --
+string(27) "Testing fgetss() functions
+"
+int(40)
+bool(false)
+-- fgets() with length = 30, file pointer at 0 --
+string(23) "Testing fgetss() functi"
+int(29)
+bool(false)
+
+-- Testing fgetss() with file opened using r+ mode --
+-- fgetss() with default length, file pointer at 0 --
+string(27) "Testing fgetss() functions
+"
+int(40)
+bool(false)
+-- fgets() with length = 30, file pointer at 0 --
+string(23) "Testing fgetss() functi"
+int(29)
+bool(false)
+
+-- Testing fgetss() with file opened using r+b mode --
+-- fgetss() with default length, file pointer at 0 --
+string(27) "Testing fgetss() functions
+"
+int(40)
+bool(false)
+-- fgets() with length = 30, file pointer at 0 --
+string(23) "Testing fgetss() functi"
+int(29)
+bool(false)
+
+-- Testing fgetss() with file opened using r+t mode --
+-- fgetss() with default length, file pointer at 0 --
+string(27) "Testing fgetss() functions
+"
+int(40)
+bool(false)
+-- fgets() with length = 30, file pointer at 0 --
+string(23) "Testing fgetss() functi"
+int(29)
+bool(false)
+Done
diff --git a/ext/standard/tests/file/fgetss_basic2-win32.phpt b/ext/standard/tests/file/fgetss_basic2-win32.phpt
new file mode 100644
index 0000000..9187fe5
--- /dev/null
+++ b/ext/standard/tests/file/fgetss_basic2-win32.phpt
@@ -0,0 +1,216 @@
+--TEST--
+Test fgetss() function : Basic functionality - read/write modes
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip.. only on Windows');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: string fgetss ( resource $handle [, int $length [, string $allowable_tags]] );
+ Description: Gets line from file pointer and strip HTML tags
+*/
+
+/* try fgetss on files which are opened in read/write modes
+ w+, w+b, w+t,
+ a+, a+b, a+t,
+ x+, x+b, x+t
+*/
+
+
+echo "*** Testing fgetss() : basic operations ***\n";
+
+/* string with html and php tags */
+$string_with_tags = <<<EOT
+<test>Testing fgetss() functions</test>
+<?php echo "this string is within php tag"; ?> {;}<{> this
+is a heredoc string. <pg>ksklnm@@$$&$&^%&^%&^%&</pg>
+<html> html </html> <?php echo "php"; ?>
+EOT;
+if(substr(PHP_OS, 0, 3) == "WIN") {
+ $string_with_tags = str_replace("\r",'', $string_with_tags);
+}
+$filename = dirname(__FILE__)."/fgetss_basic2.tmp";
+
+/* try reading the file opened in different modes of reading */
+$file_modes = array("w+","w+b", "w+t","a+", "a+b", "a+t","x+","x+b","x+t");
+
+for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ echo "\n-- Testing fgetss() with file opened using $file_modes[$mode_counter] mode --\n";
+
+ /* create an empty file and write the strings with tags */
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ fwrite($file_handle,$string_with_tags); //writing data to the file
+ if(!$file_handle) {
+ echo "Error: failed to open file $filename!\n";
+ exit();
+ }
+
+ // rewind the file pointer to begining of the file
+ var_dump( filesize($filename) );
+ var_dump( rewind($file_handle) );
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ /* read entire file and strip tags */
+ echo "-- fgetss() with default length, file pointer at 0 --\n";
+ var_dump( fgetss($file_handle) ); // no length and allowable tags provided, reads entire file
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ rewind($file_handle);
+ /* read entire file and strip tags tags */
+ echo "-- fgets() with length = 30, file pointer at 0 --\n";
+ var_dump( fgetss($file_handle ,30) ); // length parameter given,not reading entire file
+ var_dump( ftell($file_handle) ); // checking file pointer position initially
+ var_dump( feof($file_handle) ); // confirm file pointer is not at eof
+
+ // close the file
+ fclose($file_handle);
+
+ // delete the file
+ unlink($filename);
+} // end of for - mode_counter
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fgetss() : basic operations ***
+
+-- Testing fgetss() with file opened using w+ mode --
+int(192)
+bool(true)
+int(0)
+bool(false)
+-- fgetss() with default length, file pointer at 0 --
+string(27) "Testing fgetss() functions
+"
+int(40)
+bool(false)
+-- fgets() with length = 30, file pointer at 0 --
+string(23) "Testing fgetss() functi"
+int(29)
+bool(false)
+
+-- Testing fgetss() with file opened using w+b mode --
+int(192)
+bool(true)
+int(0)
+bool(false)
+-- fgetss() with default length, file pointer at 0 --
+string(27) "Testing fgetss() functions
+"
+int(40)
+bool(false)
+-- fgets() with length = 30, file pointer at 0 --
+string(23) "Testing fgetss() functi"
+int(29)
+bool(false)
+
+-- Testing fgetss() with file opened using w+t mode --
+int(195)
+bool(true)
+int(0)
+bool(false)
+-- fgetss() with default length, file pointer at 0 --
+string(27) "Testing fgetss() functions
+"
+int(40)
+bool(false)
+-- fgets() with length = 30, file pointer at 0 --
+string(23) "Testing fgetss() functi"
+int(29)
+bool(false)
+
+-- Testing fgetss() with file opened using a+ mode --
+int(192)
+bool(true)
+int(0)
+bool(false)
+-- fgetss() with default length, file pointer at 0 --
+string(27) "Testing fgetss() functions
+"
+int(40)
+bool(false)
+-- fgets() with length = 30, file pointer at 0 --
+string(23) "Testing fgetss() functi"
+int(29)
+bool(false)
+
+-- Testing fgetss() with file opened using a+b mode --
+int(192)
+bool(true)
+int(0)
+bool(false)
+-- fgetss() with default length, file pointer at 0 --
+string(27) "Testing fgetss() functions
+"
+int(40)
+bool(false)
+-- fgets() with length = 30, file pointer at 0 --
+string(23) "Testing fgetss() functi"
+int(29)
+bool(false)
+
+-- Testing fgetss() with file opened using a+t mode --
+int(195)
+bool(true)
+int(0)
+bool(false)
+-- fgetss() with default length, file pointer at 0 --
+string(27) "Testing fgetss() functions
+"
+int(40)
+bool(false)
+-- fgets() with length = 30, file pointer at 0 --
+string(23) "Testing fgetss() functi"
+int(29)
+bool(false)
+
+-- Testing fgetss() with file opened using x+ mode --
+int(192)
+bool(true)
+int(0)
+bool(false)
+-- fgetss() with default length, file pointer at 0 --
+string(27) "Testing fgetss() functions
+"
+int(40)
+bool(false)
+-- fgets() with length = 30, file pointer at 0 --
+string(23) "Testing fgetss() functi"
+int(29)
+bool(false)
+
+-- Testing fgetss() with file opened using x+b mode --
+int(192)
+bool(true)
+int(0)
+bool(false)
+-- fgetss() with default length, file pointer at 0 --
+string(27) "Testing fgetss() functions
+"
+int(40)
+bool(false)
+-- fgets() with length = 30, file pointer at 0 --
+string(23) "Testing fgetss() functi"
+int(29)
+bool(false)
+
+-- Testing fgetss() with file opened using x+t mode --
+int(195)
+bool(true)
+int(0)
+bool(false)
+-- fgetss() with default length, file pointer at 0 --
+string(27) "Testing fgetss() functions
+"
+int(40)
+bool(false)
+-- fgets() with length = 30, file pointer at 0 --
+string(23) "Testing fgetss() functi"
+int(29)
+bool(false)
+Done
diff --git a/ext/standard/tests/file/fgetss_basic2.phpt b/ext/standard/tests/file/fgetss_basic2.phpt
new file mode 100644
index 0000000..63fdde8
--- /dev/null
+++ b/ext/standard/tests/file/fgetss_basic2.phpt
@@ -0,0 +1,214 @@
+--TEST--
+Test fgetss() function : Basic functionality - read/write modes
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. Not valid for Windows');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: string fgetss ( resource $handle [, int $length [, string $allowable_tags]] );
+ Description: Gets line from file pointer and strip HTML tags
+*/
+
+/* try fgetss on files which are opened in read/write modes
+ w+, w+b, w+t,
+ a+, a+b, a+t,
+ x+, x+b, x+t
+*/
+
+
+echo "*** Testing fgetss() : basic operations ***\n";
+
+/* string with html and php tags */
+$string_with_tags = <<<EOT
+<test>Testing fgetss() functions</test>
+<?php echo "this string is within php tag"; ?> {;}<{> this
+is a heredoc string. <pg>ksklnm@@$$&$&^%&^%&^%&</pg>
+<html> html </html> <?php echo "php"; ?>
+EOT;
+
+$filename = dirname(__FILE__)."/fgetss_basic2.tmp";
+
+/* try reading the file opened in different modes of reading */
+$file_modes = array("w+","w+b", "w+t","a+", "a+b", "a+t","x+","x+b","x+t");
+
+for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ echo "\n-- Testing fgetss() with file opened using $file_modes[$mode_counter] mode --\n";
+
+ /* create an empty file and write the strings with tags */
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ fwrite($file_handle,$string_with_tags); //writing data to the file
+ if(!$file_handle) {
+ echo "Error: failed to open file $filename!\n";
+ exit();
+ }
+
+ // rewind the file pointer to begining of the file
+ var_dump( filesize($filename) );
+ var_dump( rewind($file_handle) );
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ /* read entire file and strip tags */
+ echo "-- fgetss() with default length, file pointer at 0 --\n";
+ var_dump( fgetss($file_handle) ); // no length and allowable tags provided, reads entire file
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ rewind($file_handle);
+ /* read entire file and strip tags tags */
+ echo "-- fgets() with length = 30, file pointer at 0 --\n";
+ var_dump( fgetss($file_handle ,30) ); // length parameter given,not reading entire file
+ var_dump( ftell($file_handle) ); // checking file pointer position initially
+ var_dump( feof($file_handle) ); // confirm file pointer is not at eof
+
+ // close the file
+ fclose($file_handle);
+
+ // delete the file
+ unlink($filename);
+} // end of for - mode_counter
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fgetss() : basic operations ***
+
+-- Testing fgetss() with file opened using w+ mode --
+int(192)
+bool(true)
+int(0)
+bool(false)
+-- fgetss() with default length, file pointer at 0 --
+string(27) "Testing fgetss() functions
+"
+int(40)
+bool(false)
+-- fgets() with length = 30, file pointer at 0 --
+string(23) "Testing fgetss() functi"
+int(29)
+bool(false)
+
+-- Testing fgetss() with file opened using w+b mode --
+int(192)
+bool(true)
+int(0)
+bool(false)
+-- fgetss() with default length, file pointer at 0 --
+string(27) "Testing fgetss() functions
+"
+int(40)
+bool(false)
+-- fgets() with length = 30, file pointer at 0 --
+string(23) "Testing fgetss() functi"
+int(29)
+bool(false)
+
+-- Testing fgetss() with file opened using w+t mode --
+int(192)
+bool(true)
+int(0)
+bool(false)
+-- fgetss() with default length, file pointer at 0 --
+string(27) "Testing fgetss() functions
+"
+int(40)
+bool(false)
+-- fgets() with length = 30, file pointer at 0 --
+string(23) "Testing fgetss() functi"
+int(29)
+bool(false)
+
+-- Testing fgetss() with file opened using a+ mode --
+int(192)
+bool(true)
+int(0)
+bool(false)
+-- fgetss() with default length, file pointer at 0 --
+string(27) "Testing fgetss() functions
+"
+int(40)
+bool(false)
+-- fgets() with length = 30, file pointer at 0 --
+string(23) "Testing fgetss() functi"
+int(29)
+bool(false)
+
+-- Testing fgetss() with file opened using a+b mode --
+int(192)
+bool(true)
+int(0)
+bool(false)
+-- fgetss() with default length, file pointer at 0 --
+string(27) "Testing fgetss() functions
+"
+int(40)
+bool(false)
+-- fgets() with length = 30, file pointer at 0 --
+string(23) "Testing fgetss() functi"
+int(29)
+bool(false)
+
+-- Testing fgetss() with file opened using a+t mode --
+int(192)
+bool(true)
+int(0)
+bool(false)
+-- fgetss() with default length, file pointer at 0 --
+string(27) "Testing fgetss() functions
+"
+int(40)
+bool(false)
+-- fgets() with length = 30, file pointer at 0 --
+string(23) "Testing fgetss() functi"
+int(29)
+bool(false)
+
+-- Testing fgetss() with file opened using x+ mode --
+int(192)
+bool(true)
+int(0)
+bool(false)
+-- fgetss() with default length, file pointer at 0 --
+string(27) "Testing fgetss() functions
+"
+int(40)
+bool(false)
+-- fgets() with length = 30, file pointer at 0 --
+string(23) "Testing fgetss() functi"
+int(29)
+bool(false)
+
+-- Testing fgetss() with file opened using x+b mode --
+int(192)
+bool(true)
+int(0)
+bool(false)
+-- fgetss() with default length, file pointer at 0 --
+string(27) "Testing fgetss() functions
+"
+int(40)
+bool(false)
+-- fgets() with length = 30, file pointer at 0 --
+string(23) "Testing fgetss() functi"
+int(29)
+bool(false)
+
+-- Testing fgetss() with file opened using x+t mode --
+int(192)
+bool(true)
+int(0)
+bool(false)
+-- fgetss() with default length, file pointer at 0 --
+string(27) "Testing fgetss() functions
+"
+int(40)
+bool(false)
+-- fgets() with length = 30, file pointer at 0 --
+string(23) "Testing fgetss() functi"
+int(29)
+bool(false)
+Done
diff --git a/ext/standard/tests/file/fgetss_error.phpt b/ext/standard/tests/file/fgetss_error.phpt
new file mode 100644
index 0000000..3691e96
--- /dev/null
+++ b/ext/standard/tests/file/fgetss_error.phpt
@@ -0,0 +1,106 @@
+--TEST--
+Test fgetss() function : error conditions
+--FILE--
+<?php
+/*
+ Prototype: string fgetss ( resource $handle [, int $length [, string $allowable_tags]] );
+ Description: Gets line from file pointer and strip HTML tags
+*/
+
+echo "*** Testing error conditions ***\n";
+// zero argument
+echo "-- Testing fgetss() with zero argument --\n";
+var_dump( fgetss() );
+
+// more than expected no. of args
+echo "-- Testing fgetss() with more than expected number of arguments --\n";
+$fp = fopen(__FILE__, "r");
+var_dump( fgetss($fp, 100, '<p><a>', $fp) );
+
+// invalid length argument
+echo "-- Testing fgetss() with invalid length arguments --\n";
+$len = 0;
+$allowable_tags = '<p><a>';
+var_dump( fgetss($fp, $len, $allowable_tags) );
+$len = -10;
+var_dump( fgetss($fp, $len, $allowable_tags) );
+$len = 1;
+var_dump( fgetss($fp, $len, $allowable_tags) ); // return length - 1 always, expect false
+
+// test invalid arguments : non-resources
+echo "-- Testing fgetss() with invalid arguments --\n";
+$invalid_args = array (
+ "string",
+ 10,
+ 10.5,
+ true,
+ array(1,2,3),
+ new stdclass,
+);
+/* loop to test fgetss() with different invalid type of args */
+for($loop_counter = 1; $loop_counter <= count($invalid_args); $loop_counter++) {
+ echo "-- Iteration $loop_counter --\n";
+ var_dump( fgetss($invalid_args[$loop_counter - 1], 10, $allowable_tags) );
+}
+// fgetss() on a file handle which is already closed
+echo "-- Testing fgetss() with closed/unset file handle --";
+fclose($fp);
+var_dump(fgetss($fp,10,$allowable_tags));
+
+// fgetss() on a file handle which is unset
+$file_handle = fopen(__FILE__, "r");
+unset($file_handle); //unset file handle
+var_dump( fgetss(@$file_handle,10));
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing error conditions ***
+-- Testing fgetss() with zero argument --
+
+Warning: fgetss() expects at least 1 parameter, 0 given in %s on line %d
+bool(false)
+-- Testing fgetss() with more than expected number of arguments --
+
+Warning: fgetss() expects at most 3 parameters, 4 given in %s on line %d
+bool(false)
+-- Testing fgetss() with invalid length arguments --
+
+Warning: fgetss(): Length parameter must be greater than 0 in %s on line %d
+bool(false)
+
+Warning: fgetss(): Length parameter must be greater than 0 in %s on line %d
+bool(false)
+bool(false)
+-- Testing fgetss() with invalid arguments --
+-- Iteration 1 --
+
+Warning: fgetss() expects parameter 1 to be resource, string given in %s on line %d
+bool(false)
+-- Iteration 2 --
+
+Warning: fgetss() expects parameter 1 to be resource, integer given in %s on line %d
+bool(false)
+-- Iteration 3 --
+
+Warning: fgetss() expects parameter 1 to be resource, double given in %s on line %d
+bool(false)
+-- Iteration 4 --
+
+Warning: fgetss() expects parameter 1 to be resource, boolean given in %s on line %d
+bool(false)
+-- Iteration 5 --
+
+Warning: fgetss() expects parameter 1 to be resource, array given in %s on line %d
+bool(false)
+-- Iteration 6 --
+
+Warning: fgetss() expects parameter 1 to be resource, object given in %s on line %d
+bool(false)
+-- Testing fgetss() with closed/unset file handle --
+Warning: fgetss(): 5 is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: fgetss() expects parameter 1 to be resource, null given in %s on line %d
+bool(false)
+Done
diff --git a/ext/standard/tests/file/fgetss_variation1-win32.phpt b/ext/standard/tests/file/fgetss_variation1-win32.phpt
new file mode 100644
index 0000000..0aca5d3
--- /dev/null
+++ b/ext/standard/tests/file/fgetss_variation1-win32.phpt
@@ -0,0 +1,172 @@
+--TEST--
+Test fgetss() function : usage variations - write only modes
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip.. only on Windows');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: string fgetss ( resource $handle [, int $length [, string $allowable_tags]] );
+ Description: Gets line from file pointer and strip HTML tags
+*/
+
+/* try fgets on files which are opened in non readable modes
+ w, wb, wt,
+ a, ab, at,
+ x, xb, xt
+*/
+
+// include the common file related test functions
+include ("file.inc");
+
+echo "*** Testing fgetss() : usage variations ***\n";
+
+/* string with html and php tags */
+$string_with_tags = <<<EOT
+<test>Testing fgetss() functions</test>
+<?php echo "this string is within php tag"; ?> {;}<{> this
+is a heredoc string. <pg>ksklnm@@$$&$&^%&^%&^%&</pg>
+<html> html </html> <?php echo "php"; ?>
+this line is without any html and php tags
+this is a line with more than eighty character,want to check line splitting correctly after 80 characters
+this text contains some html tags <body> body </body> <br> br </br>
+this is the line with \n character.
+EOT;
+
+if(substr(PHP_OS, 0, 3) == "WIN") {
+ $string_with_tags = str_replace("\r",'', $string_with_tags);
+}
+
+$filename = dirname(__FILE__)."/fgetss_variation1.tmp";
+
+/* try reading the file opened in different modes of reading */
+$file_modes = array("w","wb", "wt","a", "ab", "at","x","xb","xt");
+
+for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ echo "\n-- Testing fgetss() with file opened using $file_modes[$mode_counter] mode --\n";
+
+ /* create an empty file and write the strings with tags */
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ fwrite($file_handle,$string_with_tags);
+ if(!$file_handle) {
+ echo "Error: failed to open file $filename!\n";
+ exit();
+ }
+
+ // rewind the file pointer to begining of the file
+ var_dump( filesize($filename) );
+ var_dump( rewind($file_handle) );
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ /* read entire file and strip tags */
+ echo "-- fgetss() with default length, file pointer at 0 , expected : no character should be read --\n";
+ var_dump( fgetss($file_handle) ); // expected : no character should be read
+ var_dump( ftell($file_handle) ); //ensure that file pointer position is not changed
+ var_dump( feof($file_handle) ); // check if end of file pointer is set
+
+ // close the file
+ fclose($file_handle);
+
+ // delete the file
+ delete_file($filename);
+} // end of for - mode_counter
+
+echo "Done\n";
+?>
+--EXPECT--
+*** Testing fgetss() : usage variations ***
+
+-- Testing fgetss() with file opened using w mode --
+int(445)
+bool(true)
+int(0)
+bool(false)
+-- fgetss() with default length, file pointer at 0 , expected : no character should be read --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetss() with file opened using wb mode --
+int(445)
+bool(true)
+int(0)
+bool(false)
+-- fgetss() with default length, file pointer at 0 , expected : no character should be read --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetss() with file opened using wt mode --
+int(453)
+bool(true)
+int(0)
+bool(false)
+-- fgetss() with default length, file pointer at 0 , expected : no character should be read --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetss() with file opened using a mode --
+int(445)
+bool(true)
+int(0)
+bool(false)
+-- fgetss() with default length, file pointer at 0 , expected : no character should be read --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetss() with file opened using ab mode --
+int(445)
+bool(true)
+int(0)
+bool(false)
+-- fgetss() with default length, file pointer at 0 , expected : no character should be read --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetss() with file opened using at mode --
+int(453)
+bool(true)
+int(0)
+bool(false)
+-- fgetss() with default length, file pointer at 0 , expected : no character should be read --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetss() with file opened using x mode --
+int(445)
+bool(true)
+int(0)
+bool(false)
+-- fgetss() with default length, file pointer at 0 , expected : no character should be read --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetss() with file opened using xb mode --
+int(445)
+bool(true)
+int(0)
+bool(false)
+-- fgetss() with default length, file pointer at 0 , expected : no character should be read --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetss() with file opened using xt mode --
+int(453)
+bool(true)
+int(0)
+bool(false)
+-- fgetss() with default length, file pointer at 0 , expected : no character should be read --
+bool(false)
+int(0)
+bool(false)
+Done
diff --git a/ext/standard/tests/file/fgetss_variation1.phpt b/ext/standard/tests/file/fgetss_variation1.phpt
new file mode 100644
index 0000000..d85b095
--- /dev/null
+++ b/ext/standard/tests/file/fgetss_variation1.phpt
@@ -0,0 +1,168 @@
+--TEST--
+Test fgetss() function : usage variations - write only modes
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. Not valid for Windows');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: string fgetss ( resource $handle [, int $length [, string $allowable_tags]] );
+ Description: Gets line from file pointer and strip HTML tags
+*/
+
+/* try fgets on files which are opened in non readable modes
+ w, wb, wt,
+ a, ab, at,
+ x, xb, xt
+*/
+
+// include the common file related test functions
+include ("file.inc");
+
+echo "*** Testing fgetss() : usage variations ***\n";
+
+/* string with html and php tags */
+$string_with_tags = <<<EOT
+<test>Testing fgetss() functions</test>
+<?php echo "this string is within php tag"; ?> {;}<{> this
+is a heredoc string. <pg>ksklnm@@$$&$&^%&^%&^%&</pg>
+<html> html </html> <?php echo "php"; ?>
+this line is without any html and php tags
+this is a line with more than eighty character,want to check line splitting correctly after 80 characters
+this text contains some html tags <body> body </body> <br> br </br>
+this is the line with \n character.
+EOT;
+
+$filename = dirname(__FILE__)."/fgetss_variation1.tmp";
+
+/* try reading the file opened in different modes of reading */
+$file_modes = array("w","wb", "wt","a", "ab", "at","x","xb","xt");
+
+for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ echo "\n-- Testing fgetss() with file opened using $file_modes[$mode_counter] mode --\n";
+
+ /* create an empty file and write the strings with tags */
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ fwrite($file_handle,$string_with_tags);
+ if(!$file_handle) {
+ echo "Error: failed to open file $filename!\n";
+ exit();
+ }
+
+ // rewind the file pointer to begining of the file
+ var_dump( filesize($filename) );
+ var_dump( rewind($file_handle) );
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ /* read entire file and strip tags */
+ echo "-- fgetss() with default length, file pointer at 0 , expected : no character should be read --\n";
+ var_dump( fgetss($file_handle) ); // expected : no character should be read
+ var_dump( ftell($file_handle) ); //ensure that file pointer position is not changed
+ var_dump( feof($file_handle) ); // check if end of file pointer is set
+
+ // close the file
+ fclose($file_handle);
+
+ // delete the file
+ delete_file($filename);
+} // end of for - mode_counter
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fgetss() : usage variations ***
+
+-- Testing fgetss() with file opened using w mode --
+int(445)
+bool(true)
+int(0)
+bool(false)
+-- fgetss() with default length, file pointer at 0 , expected : no character should be read --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetss() with file opened using wb mode --
+int(445)
+bool(true)
+int(0)
+bool(false)
+-- fgetss() with default length, file pointer at 0 , expected : no character should be read --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetss() with file opened using wt mode --
+int(445)
+bool(true)
+int(0)
+bool(false)
+-- fgetss() with default length, file pointer at 0 , expected : no character should be read --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetss() with file opened using a mode --
+int(445)
+bool(true)
+int(0)
+bool(false)
+-- fgetss() with default length, file pointer at 0 , expected : no character should be read --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetss() with file opened using ab mode --
+int(445)
+bool(true)
+int(0)
+bool(false)
+-- fgetss() with default length, file pointer at 0 , expected : no character should be read --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetss() with file opened using at mode --
+int(445)
+bool(true)
+int(0)
+bool(false)
+-- fgetss() with default length, file pointer at 0 , expected : no character should be read --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetss() with file opened using x mode --
+int(445)
+bool(true)
+int(0)
+bool(false)
+-- fgetss() with default length, file pointer at 0 , expected : no character should be read --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetss() with file opened using xb mode --
+int(445)
+bool(true)
+int(0)
+bool(false)
+-- fgetss() with default length, file pointer at 0 , expected : no character should be read --
+bool(false)
+int(0)
+bool(false)
+
+-- Testing fgetss() with file opened using xt mode --
+int(445)
+bool(true)
+int(0)
+bool(false)
+-- fgetss() with default length, file pointer at 0 , expected : no character should be read --
+bool(false)
+int(0)
+bool(false)
+Done
diff --git a/ext/standard/tests/file/fgetss_variation2.phpt b/ext/standard/tests/file/fgetss_variation2.phpt
new file mode 100644
index 0000000..d155f08
--- /dev/null
+++ b/ext/standard/tests/file/fgetss_variation2.phpt
@@ -0,0 +1,434 @@
+--TEST--
+Test fgetss() function : usage variations - read modes
+--FILE--
+<?php
+/*
+ Prototype: string fgetss ( resource $handle [, int $length [, string $allowable_tags]] );
+ Description: Gets line from file pointer and strip HTML tags
+*/
+
+// include the common file related test functions
+include ("file.inc");
+
+/*Test fgetss() with all read modes , reading line by line with allowable tags: <test>, <html>, <?> */
+
+echo "*** Testing fgetss() : usage variations ***\n";
+
+/* string with html and php tags */
+$string_with_tags = <<<EOT
+<test>Testing fgetss() functions</test>
+<?php echo "this string is within php tag"; ?> {;}<{> this
+is a heredoc string. <pg>ksklnm@@$$&$&^%&^%&^%&</pg>
+<html> html </html> <?php echo "php"; ?>
+this line is without any html and php tags
+this is a line with more than eighty character,want to check line splitting correctly after 80 characters
+this is the text containing \r character
+this text contains some html tags <body> body </body> <br> br </br>
+this is the line with \n character.
+EOT;
+
+$filename = dirname(__FILE__)."/fgetss_variation2.tmp";
+
+/* try reading the file opened in different modes of reading */
+$file_modes = array("r","rb", "rt","r+", "r+b", "r+t");
+
+for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ echo "\n-- Testing fgetss() with file opened using $file_modes[$mode_counter] mode --\n";
+
+ /* create an empty file and write the strings with tags */
+ create_file ($filename); //create an empty file
+ file_put_contents($filename, $string_with_tags);
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ if(!$file_handle) {
+ echo "Error: failed to open file $filename!\n";
+ exit();
+ }
+
+ // rewind the file pointer to begining of the file
+ var_dump( filesize($filename) );
+ var_dump( rewind($file_handle) );
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ /* rewind the file and read the file line by line with allowable tags */
+ echo "-- Reading line by line with allowable tags: <test>, <html>, <?> --\n";
+ rewind($file_handle);
+ $line = 1;
+ while( !feof($file_handle) ) {
+ echo "-- Line $line --\n"; $line++;
+ var_dump( fgetss($file_handle, 80, "<test>, <html>, <?>") );
+ var_dump( ftell($file_handle) ); // check the file pointer position
+ var_dump( feof($file_handle) ); // check if eof reached
+ }
+
+ // close the file
+ fclose($file_handle);
+ // delete the file
+ delete_file($filename);
+} // end of for - mode_counter
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fgetss() : usage variations ***
+
+-- Testing fgetss() with file opened using r mode --
+int(486)
+bool(true)
+int(0)
+bool(false)
+-- Reading line by line with allowable tags: <test>, <html>, <?> --
+-- Line 1 --
+string(40) "<test>Testing fgetss() functions</test>
+"
+int(40)
+bool(false)
+-- Line 2 --
+string(10) " {;} this
+"
+int(99)
+bool(false)
+-- Line 3 --
+string(44) "is a heredoc string. ksklnm@@$$&$&^%&^%&^%&
+"
+int(152)
+bool(false)
+-- Line 4 --
+string(21) "<html> html </html>
+"
+int(193)
+bool(false)
+-- Line 5 --
+string(43) "this line is without any html and php tags
+"
+int(236)
+bool(false)
+-- Line 6 --
+string(79) "this is a line with more than eighty character,want to check line splitting cor"
+int(315)
+bool(false)
+-- Line 7 --
+string(27) "rectly after 80 characters
+"
+int(342)
+bool(false)
+-- Line 8 --
+string(41) "this is the text containing character
+"
+int(383)
+bool(false)
+-- Line 9 --
+string(46) "this text contains some html tags body br
+"
+int(451)
+bool(false)
+-- Line 10 --
+string(23) "this is the line with
+"
+int(474)
+bool(false)
+-- Line 11 --
+string(12) " character. "
+int(486)
+bool(true)
+
+-- Testing fgetss() with file opened using rb mode --
+int(486)
+bool(true)
+int(0)
+bool(false)
+-- Reading line by line with allowable tags: <test>, <html>, <?> --
+-- Line 1 --
+string(40) "<test>Testing fgetss() functions</test>
+"
+int(40)
+bool(false)
+-- Line 2 --
+string(10) " {;} this
+"
+int(99)
+bool(false)
+-- Line 3 --
+string(44) "is a heredoc string. ksklnm@@$$&$&^%&^%&^%&
+"
+int(152)
+bool(false)
+-- Line 4 --
+string(21) "<html> html </html>
+"
+int(193)
+bool(false)
+-- Line 5 --
+string(43) "this line is without any html and php tags
+"
+int(236)
+bool(false)
+-- Line 6 --
+string(79) "this is a line with more than eighty character,want to check line splitting cor"
+int(315)
+bool(false)
+-- Line 7 --
+string(27) "rectly after 80 characters
+"
+int(342)
+bool(false)
+-- Line 8 --
+string(41) "this is the text containing character
+"
+int(383)
+bool(false)
+-- Line 9 --
+string(46) "this text contains some html tags body br
+"
+int(451)
+bool(false)
+-- Line 10 --
+string(23) "this is the line with
+"
+int(474)
+bool(false)
+-- Line 11 --
+string(12) " character. "
+int(486)
+bool(true)
+
+-- Testing fgetss() with file opened using rt mode --
+int(486)
+bool(true)
+int(0)
+bool(false)
+-- Reading line by line with allowable tags: <test>, <html>, <?> --
+-- Line 1 --
+string(40) "<test>Testing fgetss() functions</test>
+"
+int(40)
+bool(false)
+-- Line 2 --
+string(10) " {;} this
+"
+int(99)
+bool(false)
+-- Line 3 --
+string(44) "is a heredoc string. ksklnm@@$$&$&^%&^%&^%&
+"
+int(152)
+bool(false)
+-- Line 4 --
+string(21) "<html> html </html>
+"
+int(193)
+bool(false)
+-- Line 5 --
+string(43) "this line is without any html and php tags
+"
+int(236)
+bool(false)
+-- Line 6 --
+string(79) "this is a line with more than eighty character,want to check line splitting cor"
+int(315)
+bool(false)
+-- Line 7 --
+string(27) "rectly after 80 characters
+"
+int(342)
+bool(false)
+-- Line 8 --
+string(41) "this is the text containing character
+"
+int(383)
+bool(false)
+-- Line 9 --
+string(46) "this text contains some html tags body br
+"
+int(451)
+bool(false)
+-- Line 10 --
+string(23) "this is the line with
+"
+int(474)
+bool(false)
+-- Line 11 --
+string(12) " character. "
+int(486)
+bool(true)
+
+-- Testing fgetss() with file opened using r+ mode --
+int(486)
+bool(true)
+int(0)
+bool(false)
+-- Reading line by line with allowable tags: <test>, <html>, <?> --
+-- Line 1 --
+string(40) "<test>Testing fgetss() functions</test>
+"
+int(40)
+bool(false)
+-- Line 2 --
+string(10) " {;} this
+"
+int(99)
+bool(false)
+-- Line 3 --
+string(44) "is a heredoc string. ksklnm@@$$&$&^%&^%&^%&
+"
+int(152)
+bool(false)
+-- Line 4 --
+string(21) "<html> html </html>
+"
+int(193)
+bool(false)
+-- Line 5 --
+string(43) "this line is without any html and php tags
+"
+int(236)
+bool(false)
+-- Line 6 --
+string(79) "this is a line with more than eighty character,want to check line splitting cor"
+int(315)
+bool(false)
+-- Line 7 --
+string(27) "rectly after 80 characters
+"
+int(342)
+bool(false)
+-- Line 8 --
+string(41) "this is the text containing character
+"
+int(383)
+bool(false)
+-- Line 9 --
+string(46) "this text contains some html tags body br
+"
+int(451)
+bool(false)
+-- Line 10 --
+string(23) "this is the line with
+"
+int(474)
+bool(false)
+-- Line 11 --
+string(12) " character. "
+int(486)
+bool(true)
+
+-- Testing fgetss() with file opened using r+b mode --
+int(486)
+bool(true)
+int(0)
+bool(false)
+-- Reading line by line with allowable tags: <test>, <html>, <?> --
+-- Line 1 --
+string(40) "<test>Testing fgetss() functions</test>
+"
+int(40)
+bool(false)
+-- Line 2 --
+string(10) " {;} this
+"
+int(99)
+bool(false)
+-- Line 3 --
+string(44) "is a heredoc string. ksklnm@@$$&$&^%&^%&^%&
+"
+int(152)
+bool(false)
+-- Line 4 --
+string(21) "<html> html </html>
+"
+int(193)
+bool(false)
+-- Line 5 --
+string(43) "this line is without any html and php tags
+"
+int(236)
+bool(false)
+-- Line 6 --
+string(79) "this is a line with more than eighty character,want to check line splitting cor"
+int(315)
+bool(false)
+-- Line 7 --
+string(27) "rectly after 80 characters
+"
+int(342)
+bool(false)
+-- Line 8 --
+string(41) "this is the text containing character
+"
+int(383)
+bool(false)
+-- Line 9 --
+string(46) "this text contains some html tags body br
+"
+int(451)
+bool(false)
+-- Line 10 --
+string(23) "this is the line with
+"
+int(474)
+bool(false)
+-- Line 11 --
+string(12) " character. "
+int(486)
+bool(true)
+
+-- Testing fgetss() with file opened using r+t mode --
+int(486)
+bool(true)
+int(0)
+bool(false)
+-- Reading line by line with allowable tags: <test>, <html>, <?> --
+-- Line 1 --
+string(40) "<test>Testing fgetss() functions</test>
+"
+int(40)
+bool(false)
+-- Line 2 --
+string(10) " {;} this
+"
+int(99)
+bool(false)
+-- Line 3 --
+string(44) "is a heredoc string. ksklnm@@$$&$&^%&^%&^%&
+"
+int(152)
+bool(false)
+-- Line 4 --
+string(21) "<html> html </html>
+"
+int(193)
+bool(false)
+-- Line 5 --
+string(43) "this line is without any html and php tags
+"
+int(236)
+bool(false)
+-- Line 6 --
+string(79) "this is a line with more than eighty character,want to check line splitting cor"
+int(315)
+bool(false)
+-- Line 7 --
+string(27) "rectly after 80 characters
+"
+int(342)
+bool(false)
+-- Line 8 --
+string(41) "this is the text containing character
+"
+int(383)
+bool(false)
+-- Line 9 --
+string(46) "this text contains some html tags body br
+"
+int(451)
+bool(false)
+-- Line 10 --
+string(23) "this is the line with
+"
+int(474)
+bool(false)
+-- Line 11 --
+string(12) " character. "
+int(486)
+bool(true)
+Done
diff --git a/ext/standard/tests/file/fgetss_variation3-win32.phpt b/ext/standard/tests/file/fgetss_variation3-win32.phpt
new file mode 100644
index 0000000..7539b36
--- /dev/null
+++ b/ext/standard/tests/file/fgetss_variation3-win32.phpt
@@ -0,0 +1,571 @@
+--TEST--
+Test fgetss() function : usage variations - read/write modes
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip.. only valid for Windows');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: string fgetss ( resource $handle [, int $length [, string $allowable_tags]] );
+ Description: Gets line from file pointer and strip HTML tags
+*/
+
+/* try fgetss on files which are opened in read/write modes
+ w+, w+b, w+t,
+ a+, a+b, a+t,
+ x+, x+b, x+t
+ reading line by line with allowable tags: <test>, <html>, <?>
+*/
+
+
+echo "*** Testing fgetss() : usage variations ***\n";
+
+/* string with html and php tags */
+$string_with_tags = <<<EOT
+<test>Testing fgetss() functions</test>
+<?php echo "this string is within php tag"; ?> {;}<{> this
+is a heredoc string. <pg>ksklnm@@$$&$&^%&^%&^%&</pg>
+<html> html </html> <?php echo "php"; ?>
+this line is without any html and php tags
+this is a line with more than eighty character,want to check line splitting correctly after 80 characters
+this text contains some html tags <body> body </body> <br> br </br>
+this is the line with \n character.
+EOT;
+
+if(substr(PHP_OS, 0, 3) == "WIN") {
+ $string_with_tags = str_replace("\r",'', $string_with_tags);
+}
+
+$filename = dirname(__FILE__)."/fgetss_variation3.tmp";
+
+/* try reading the file opened in different modes of reading */
+$file_modes = array("w+","w+b", "w+t","a+", "a+b", "a+t","x+","x+b","x+t");
+
+for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ echo "\n-- Testing fgetss() with file opened using $file_modes[$mode_counter] mode --\n";
+
+ /* create an empty file and write the strings with tags */
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ fwrite($file_handle,$string_with_tags); //writing data to the file
+ if(!$file_handle) {
+ echo "Error: failed to open file $filename!\n";
+ exit();
+ }
+
+ // rewind the file pointer to begining of the file
+ rewind($file_handle);
+ var_dump( ftell($file_handle) );
+ var_dump( filesize($filename) );
+ var_dump( feof($file_handle) );
+
+ /* rewind the file and read the file line by line with allowable tags */
+ echo "-- Reading line by line with allowable tags: <test>, <html>, <?> --\n";
+ $line = 1;
+ while( !feof($file_handle) ) {
+ echo "-- Line $line --\n"; $line++;
+ var_dump( fgetss($file_handle, 80, "<test>, <html>, <?>") );
+ var_dump( ftell($file_handle) ); // check the file pointer position
+ var_dump( feof($file_handle) ); // check if eof reached
+ }
+
+ // close the file
+ fclose($file_handle);
+
+ // delete the file
+ unlink($filename);
+} // end of for - mode_counter
+
+echo "Done\n";
+?>
+--EXPECT--
+*** Testing fgetss() : usage variations ***
+
+-- Testing fgetss() with file opened using w+ mode --
+int(0)
+int(445)
+bool(false)
+-- Reading line by line with allowable tags: <test>, <html>, <?> --
+-- Line 1 --
+string(40) "<test>Testing fgetss() functions</test>
+"
+int(40)
+bool(false)
+-- Line 2 --
+string(10) " {;} this
+"
+int(99)
+bool(false)
+-- Line 3 --
+string(44) "is a heredoc string. ksklnm@@$$&$&^%&^%&^%&
+"
+int(152)
+bool(false)
+-- Line 4 --
+string(21) "<html> html </html>
+"
+int(193)
+bool(false)
+-- Line 5 --
+string(43) "this line is without any html and php tags
+"
+int(236)
+bool(false)
+-- Line 6 --
+string(79) "this is a line with more than eighty character,want to check line splitting cor"
+int(315)
+bool(false)
+-- Line 7 --
+string(27) "rectly after 80 characters
+"
+int(342)
+bool(false)
+-- Line 8 --
+string(46) "this text contains some html tags body br
+"
+int(410)
+bool(false)
+-- Line 9 --
+string(23) "this is the line with
+"
+int(433)
+bool(false)
+-- Line 10 --
+string(12) " character. "
+int(445)
+bool(true)
+
+-- Testing fgetss() with file opened using w+b mode --
+int(0)
+int(445)
+bool(false)
+-- Reading line by line with allowable tags: <test>, <html>, <?> --
+-- Line 1 --
+string(40) "<test>Testing fgetss() functions</test>
+"
+int(40)
+bool(false)
+-- Line 2 --
+string(10) " {;} this
+"
+int(99)
+bool(false)
+-- Line 3 --
+string(44) "is a heredoc string. ksklnm@@$$&$&^%&^%&^%&
+"
+int(152)
+bool(false)
+-- Line 4 --
+string(21) "<html> html </html>
+"
+int(193)
+bool(false)
+-- Line 5 --
+string(43) "this line is without any html and php tags
+"
+int(236)
+bool(false)
+-- Line 6 --
+string(79) "this is a line with more than eighty character,want to check line splitting cor"
+int(315)
+bool(false)
+-- Line 7 --
+string(27) "rectly after 80 characters
+"
+int(342)
+bool(false)
+-- Line 8 --
+string(46) "this text contains some html tags body br
+"
+int(410)
+bool(false)
+-- Line 9 --
+string(23) "this is the line with
+"
+int(433)
+bool(false)
+-- Line 10 --
+string(12) " character. "
+int(445)
+bool(true)
+
+-- Testing fgetss() with file opened using w+t mode --
+int(0)
+int(453)
+bool(false)
+-- Reading line by line with allowable tags: <test>, <html>, <?> --
+-- Line 1 --
+string(40) "<test>Testing fgetss() functions</test>
+"
+int(40)
+bool(false)
+-- Line 2 --
+string(10) " {;} this
+"
+int(99)
+bool(false)
+-- Line 3 --
+string(44) "is a heredoc string. ksklnm@@$$&$&^%&^%&^%&
+"
+int(152)
+bool(false)
+-- Line 4 --
+string(21) "<html> html </html>
+"
+int(193)
+bool(false)
+-- Line 5 --
+string(43) "this line is without any html and php tags
+"
+int(236)
+bool(false)
+-- Line 6 --
+string(79) "this is a line with more than eighty character,want to check line splitting cor"
+int(315)
+bool(false)
+-- Line 7 --
+string(27) "rectly after 80 characters
+"
+int(342)
+bool(false)
+-- Line 8 --
+string(46) "this text contains some html tags body br
+"
+int(410)
+bool(false)
+-- Line 9 --
+string(23) "this is the line with
+"
+int(433)
+bool(false)
+-- Line 10 --
+string(12) " character. "
+int(445)
+bool(true)
+
+-- Testing fgetss() with file opened using a+ mode --
+int(0)
+int(445)
+bool(false)
+-- Reading line by line with allowable tags: <test>, <html>, <?> --
+-- Line 1 --
+string(40) "<test>Testing fgetss() functions</test>
+"
+int(40)
+bool(false)
+-- Line 2 --
+string(10) " {;} this
+"
+int(99)
+bool(false)
+-- Line 3 --
+string(44) "is a heredoc string. ksklnm@@$$&$&^%&^%&^%&
+"
+int(152)
+bool(false)
+-- Line 4 --
+string(21) "<html> html </html>
+"
+int(193)
+bool(false)
+-- Line 5 --
+string(43) "this line is without any html and php tags
+"
+int(236)
+bool(false)
+-- Line 6 --
+string(79) "this is a line with more than eighty character,want to check line splitting cor"
+int(315)
+bool(false)
+-- Line 7 --
+string(27) "rectly after 80 characters
+"
+int(342)
+bool(false)
+-- Line 8 --
+string(46) "this text contains some html tags body br
+"
+int(410)
+bool(false)
+-- Line 9 --
+string(23) "this is the line with
+"
+int(433)
+bool(false)
+-- Line 10 --
+string(12) " character. "
+int(445)
+bool(true)
+
+-- Testing fgetss() with file opened using a+b mode --
+int(0)
+int(445)
+bool(false)
+-- Reading line by line with allowable tags: <test>, <html>, <?> --
+-- Line 1 --
+string(40) "<test>Testing fgetss() functions</test>
+"
+int(40)
+bool(false)
+-- Line 2 --
+string(10) " {;} this
+"
+int(99)
+bool(false)
+-- Line 3 --
+string(44) "is a heredoc string. ksklnm@@$$&$&^%&^%&^%&
+"
+int(152)
+bool(false)
+-- Line 4 --
+string(21) "<html> html </html>
+"
+int(193)
+bool(false)
+-- Line 5 --
+string(43) "this line is without any html and php tags
+"
+int(236)
+bool(false)
+-- Line 6 --
+string(79) "this is a line with more than eighty character,want to check line splitting cor"
+int(315)
+bool(false)
+-- Line 7 --
+string(27) "rectly after 80 characters
+"
+int(342)
+bool(false)
+-- Line 8 --
+string(46) "this text contains some html tags body br
+"
+int(410)
+bool(false)
+-- Line 9 --
+string(23) "this is the line with
+"
+int(433)
+bool(false)
+-- Line 10 --
+string(12) " character. "
+int(445)
+bool(true)
+
+-- Testing fgetss() with file opened using a+t mode --
+int(0)
+int(453)
+bool(false)
+-- Reading line by line with allowable tags: <test>, <html>, <?> --
+-- Line 1 --
+string(40) "<test>Testing fgetss() functions</test>
+"
+int(40)
+bool(false)
+-- Line 2 --
+string(10) " {;} this
+"
+int(99)
+bool(false)
+-- Line 3 --
+string(44) "is a heredoc string. ksklnm@@$$&$&^%&^%&^%&
+"
+int(152)
+bool(false)
+-- Line 4 --
+string(21) "<html> html </html>
+"
+int(193)
+bool(false)
+-- Line 5 --
+string(43) "this line is without any html and php tags
+"
+int(236)
+bool(false)
+-- Line 6 --
+string(79) "this is a line with more than eighty character,want to check line splitting cor"
+int(315)
+bool(false)
+-- Line 7 --
+string(27) "rectly after 80 characters
+"
+int(342)
+bool(false)
+-- Line 8 --
+string(46) "this text contains some html tags body br
+"
+int(410)
+bool(false)
+-- Line 9 --
+string(23) "this is the line with
+"
+int(433)
+bool(false)
+-- Line 10 --
+string(12) " character. "
+int(445)
+bool(true)
+
+-- Testing fgetss() with file opened using x+ mode --
+int(0)
+int(445)
+bool(false)
+-- Reading line by line with allowable tags: <test>, <html>, <?> --
+-- Line 1 --
+string(40) "<test>Testing fgetss() functions</test>
+"
+int(40)
+bool(false)
+-- Line 2 --
+string(10) " {;} this
+"
+int(99)
+bool(false)
+-- Line 3 --
+string(44) "is a heredoc string. ksklnm@@$$&$&^%&^%&^%&
+"
+int(152)
+bool(false)
+-- Line 4 --
+string(21) "<html> html </html>
+"
+int(193)
+bool(false)
+-- Line 5 --
+string(43) "this line is without any html and php tags
+"
+int(236)
+bool(false)
+-- Line 6 --
+string(79) "this is a line with more than eighty character,want to check line splitting cor"
+int(315)
+bool(false)
+-- Line 7 --
+string(27) "rectly after 80 characters
+"
+int(342)
+bool(false)
+-- Line 8 --
+string(46) "this text contains some html tags body br
+"
+int(410)
+bool(false)
+-- Line 9 --
+string(23) "this is the line with
+"
+int(433)
+bool(false)
+-- Line 10 --
+string(12) " character. "
+int(445)
+bool(true)
+
+-- Testing fgetss() with file opened using x+b mode --
+int(0)
+int(445)
+bool(false)
+-- Reading line by line with allowable tags: <test>, <html>, <?> --
+-- Line 1 --
+string(40) "<test>Testing fgetss() functions</test>
+"
+int(40)
+bool(false)
+-- Line 2 --
+string(10) " {;} this
+"
+int(99)
+bool(false)
+-- Line 3 --
+string(44) "is a heredoc string. ksklnm@@$$&$&^%&^%&^%&
+"
+int(152)
+bool(false)
+-- Line 4 --
+string(21) "<html> html </html>
+"
+int(193)
+bool(false)
+-- Line 5 --
+string(43) "this line is without any html and php tags
+"
+int(236)
+bool(false)
+-- Line 6 --
+string(79) "this is a line with more than eighty character,want to check line splitting cor"
+int(315)
+bool(false)
+-- Line 7 --
+string(27) "rectly after 80 characters
+"
+int(342)
+bool(false)
+-- Line 8 --
+string(46) "this text contains some html tags body br
+"
+int(410)
+bool(false)
+-- Line 9 --
+string(23) "this is the line with
+"
+int(433)
+bool(false)
+-- Line 10 --
+string(12) " character. "
+int(445)
+bool(true)
+
+-- Testing fgetss() with file opened using x+t mode --
+int(0)
+int(453)
+bool(false)
+-- Reading line by line with allowable tags: <test>, <html>, <?> --
+-- Line 1 --
+string(40) "<test>Testing fgetss() functions</test>
+"
+int(40)
+bool(false)
+-- Line 2 --
+string(10) " {;} this
+"
+int(99)
+bool(false)
+-- Line 3 --
+string(44) "is a heredoc string. ksklnm@@$$&$&^%&^%&^%&
+"
+int(152)
+bool(false)
+-- Line 4 --
+string(21) "<html> html </html>
+"
+int(193)
+bool(false)
+-- Line 5 --
+string(43) "this line is without any html and php tags
+"
+int(236)
+bool(false)
+-- Line 6 --
+string(79) "this is a line with more than eighty character,want to check line splitting cor"
+int(315)
+bool(false)
+-- Line 7 --
+string(27) "rectly after 80 characters
+"
+int(342)
+bool(false)
+-- Line 8 --
+string(46) "this text contains some html tags body br
+"
+int(410)
+bool(false)
+-- Line 9 --
+string(23) "this is the line with
+"
+int(433)
+bool(false)
+-- Line 10 --
+string(12) " character. "
+int(445)
+bool(true)
+Done
diff --git a/ext/standard/tests/file/fgetss_variation3.phpt b/ext/standard/tests/file/fgetss_variation3.phpt
new file mode 100644
index 0000000..5b339a1
--- /dev/null
+++ b/ext/standard/tests/file/fgetss_variation3.phpt
@@ -0,0 +1,567 @@
+--TEST--
+Test fgetss() function : usage variations - read/write modes
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. Not valid for Windows');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: string fgetss ( resource $handle [, int $length [, string $allowable_tags]] );
+ Description: Gets line from file pointer and strip HTML tags
+*/
+
+/* try fgetss on files which are opened in read/write modes
+ w+, w+b, w+t,
+ a+, a+b, a+t,
+ x+, x+b, x+t
+ reading line by line with allowable tags: <test>, <html>, <?>
+*/
+
+
+echo "*** Testing fgetss() : usage variations ***\n";
+
+/* string with html and php tags */
+$string_with_tags = <<<EOT
+<test>Testing fgetss() functions</test>
+<?php echo "this string is within php tag"; ?> {;}<{> this
+is a heredoc string. <pg>ksklnm@@$$&$&^%&^%&^%&</pg>
+<html> html </html> <?php echo "php"; ?>
+this line is without any html and php tags
+this is a line with more than eighty character,want to check line splitting correctly after 80 characters
+this text contains some html tags <body> body </body> <br> br </br>
+this is the line with \n character.
+EOT;
+
+$filename = dirname(__FILE__)."/fgetss_variation3.tmp";
+
+/* try reading the file opened in different modes of reading */
+$file_modes = array("w+","w+b", "w+t","a+", "a+b", "a+t","x+","x+b","x+t");
+
+for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ echo "\n-- Testing fgetss() with file opened using $file_modes[$mode_counter] mode --\n";
+
+ /* create an empty file and write the strings with tags */
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ fwrite($file_handle,$string_with_tags); //writing data to the file
+ if(!$file_handle) {
+ echo "Error: failed to open file $filename!\n";
+ exit();
+ }
+
+ // rewind the file pointer to begining of the file
+ rewind($file_handle);
+ var_dump( ftell($file_handle) );
+ var_dump( filesize($filename) );
+ var_dump( feof($file_handle) );
+
+ /* rewind the file and read the file line by line with allowable tags */
+ echo "-- Reading line by line with allowable tags: <test>, <html>, <?> --\n";
+ $line = 1;
+ while( !feof($file_handle) ) {
+ echo "-- Line $line --\n"; $line++;
+ var_dump( fgetss($file_handle, 80, "<test>, <html>, <?>") );
+ var_dump( ftell($file_handle) ); // check the file pointer position
+ var_dump( feof($file_handle) ); // check if eof reached
+ }
+
+ // close the file
+ fclose($file_handle);
+
+ // delete the file
+ unlink($filename);
+} // end of for - mode_counter
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fgetss() : usage variations ***
+
+-- Testing fgetss() with file opened using w+ mode --
+int(0)
+int(445)
+bool(false)
+-- Reading line by line with allowable tags: <test>, <html>, <?> --
+-- Line 1 --
+string(40) "<test>Testing fgetss() functions</test>
+"
+int(40)
+bool(false)
+-- Line 2 --
+string(10) " {;} this
+"
+int(99)
+bool(false)
+-- Line 3 --
+string(44) "is a heredoc string. ksklnm@@$$&$&^%&^%&^%&
+"
+int(152)
+bool(false)
+-- Line 4 --
+string(21) "<html> html </html>
+"
+int(193)
+bool(false)
+-- Line 5 --
+string(43) "this line is without any html and php tags
+"
+int(236)
+bool(false)
+-- Line 6 --
+string(79) "this is a line with more than eighty character,want to check line splitting cor"
+int(315)
+bool(false)
+-- Line 7 --
+string(27) "rectly after 80 characters
+"
+int(342)
+bool(false)
+-- Line 8 --
+string(46) "this text contains some html tags body br
+"
+int(410)
+bool(false)
+-- Line 9 --
+string(23) "this is the line with
+"
+int(433)
+bool(false)
+-- Line 10 --
+string(12) " character. "
+int(445)
+bool(true)
+
+-- Testing fgetss() with file opened using w+b mode --
+int(0)
+int(445)
+bool(false)
+-- Reading line by line with allowable tags: <test>, <html>, <?> --
+-- Line 1 --
+string(40) "<test>Testing fgetss() functions</test>
+"
+int(40)
+bool(false)
+-- Line 2 --
+string(10) " {;} this
+"
+int(99)
+bool(false)
+-- Line 3 --
+string(44) "is a heredoc string. ksklnm@@$$&$&^%&^%&^%&
+"
+int(152)
+bool(false)
+-- Line 4 --
+string(21) "<html> html </html>
+"
+int(193)
+bool(false)
+-- Line 5 --
+string(43) "this line is without any html and php tags
+"
+int(236)
+bool(false)
+-- Line 6 --
+string(79) "this is a line with more than eighty character,want to check line splitting cor"
+int(315)
+bool(false)
+-- Line 7 --
+string(27) "rectly after 80 characters
+"
+int(342)
+bool(false)
+-- Line 8 --
+string(46) "this text contains some html tags body br
+"
+int(410)
+bool(false)
+-- Line 9 --
+string(23) "this is the line with
+"
+int(433)
+bool(false)
+-- Line 10 --
+string(12) " character. "
+int(445)
+bool(true)
+
+-- Testing fgetss() with file opened using w+t mode --
+int(0)
+int(445)
+bool(false)
+-- Reading line by line with allowable tags: <test>, <html>, <?> --
+-- Line 1 --
+string(40) "<test>Testing fgetss() functions</test>
+"
+int(40)
+bool(false)
+-- Line 2 --
+string(10) " {;} this
+"
+int(99)
+bool(false)
+-- Line 3 --
+string(44) "is a heredoc string. ksklnm@@$$&$&^%&^%&^%&
+"
+int(152)
+bool(false)
+-- Line 4 --
+string(21) "<html> html </html>
+"
+int(193)
+bool(false)
+-- Line 5 --
+string(43) "this line is without any html and php tags
+"
+int(236)
+bool(false)
+-- Line 6 --
+string(79) "this is a line with more than eighty character,want to check line splitting cor"
+int(315)
+bool(false)
+-- Line 7 --
+string(27) "rectly after 80 characters
+"
+int(342)
+bool(false)
+-- Line 8 --
+string(46) "this text contains some html tags body br
+"
+int(410)
+bool(false)
+-- Line 9 --
+string(23) "this is the line with
+"
+int(433)
+bool(false)
+-- Line 10 --
+string(12) " character. "
+int(445)
+bool(true)
+
+-- Testing fgetss() with file opened using a+ mode --
+int(0)
+int(445)
+bool(false)
+-- Reading line by line with allowable tags: <test>, <html>, <?> --
+-- Line 1 --
+string(40) "<test>Testing fgetss() functions</test>
+"
+int(40)
+bool(false)
+-- Line 2 --
+string(10) " {;} this
+"
+int(99)
+bool(false)
+-- Line 3 --
+string(44) "is a heredoc string. ksklnm@@$$&$&^%&^%&^%&
+"
+int(152)
+bool(false)
+-- Line 4 --
+string(21) "<html> html </html>
+"
+int(193)
+bool(false)
+-- Line 5 --
+string(43) "this line is without any html and php tags
+"
+int(236)
+bool(false)
+-- Line 6 --
+string(79) "this is a line with more than eighty character,want to check line splitting cor"
+int(315)
+bool(false)
+-- Line 7 --
+string(27) "rectly after 80 characters
+"
+int(342)
+bool(false)
+-- Line 8 --
+string(46) "this text contains some html tags body br
+"
+int(410)
+bool(false)
+-- Line 9 --
+string(23) "this is the line with
+"
+int(433)
+bool(false)
+-- Line 10 --
+string(12) " character. "
+int(445)
+bool(true)
+
+-- Testing fgetss() with file opened using a+b mode --
+int(0)
+int(445)
+bool(false)
+-- Reading line by line with allowable tags: <test>, <html>, <?> --
+-- Line 1 --
+string(40) "<test>Testing fgetss() functions</test>
+"
+int(40)
+bool(false)
+-- Line 2 --
+string(10) " {;} this
+"
+int(99)
+bool(false)
+-- Line 3 --
+string(44) "is a heredoc string. ksklnm@@$$&$&^%&^%&^%&
+"
+int(152)
+bool(false)
+-- Line 4 --
+string(21) "<html> html </html>
+"
+int(193)
+bool(false)
+-- Line 5 --
+string(43) "this line is without any html and php tags
+"
+int(236)
+bool(false)
+-- Line 6 --
+string(79) "this is a line with more than eighty character,want to check line splitting cor"
+int(315)
+bool(false)
+-- Line 7 --
+string(27) "rectly after 80 characters
+"
+int(342)
+bool(false)
+-- Line 8 --
+string(46) "this text contains some html tags body br
+"
+int(410)
+bool(false)
+-- Line 9 --
+string(23) "this is the line with
+"
+int(433)
+bool(false)
+-- Line 10 --
+string(12) " character. "
+int(445)
+bool(true)
+
+-- Testing fgetss() with file opened using a+t mode --
+int(0)
+int(445)
+bool(false)
+-- Reading line by line with allowable tags: <test>, <html>, <?> --
+-- Line 1 --
+string(40) "<test>Testing fgetss() functions</test>
+"
+int(40)
+bool(false)
+-- Line 2 --
+string(10) " {;} this
+"
+int(99)
+bool(false)
+-- Line 3 --
+string(44) "is a heredoc string. ksklnm@@$$&$&^%&^%&^%&
+"
+int(152)
+bool(false)
+-- Line 4 --
+string(21) "<html> html </html>
+"
+int(193)
+bool(false)
+-- Line 5 --
+string(43) "this line is without any html and php tags
+"
+int(236)
+bool(false)
+-- Line 6 --
+string(79) "this is a line with more than eighty character,want to check line splitting cor"
+int(315)
+bool(false)
+-- Line 7 --
+string(27) "rectly after 80 characters
+"
+int(342)
+bool(false)
+-- Line 8 --
+string(46) "this text contains some html tags body br
+"
+int(410)
+bool(false)
+-- Line 9 --
+string(23) "this is the line with
+"
+int(433)
+bool(false)
+-- Line 10 --
+string(12) " character. "
+int(445)
+bool(true)
+
+-- Testing fgetss() with file opened using x+ mode --
+int(0)
+int(445)
+bool(false)
+-- Reading line by line with allowable tags: <test>, <html>, <?> --
+-- Line 1 --
+string(40) "<test>Testing fgetss() functions</test>
+"
+int(40)
+bool(false)
+-- Line 2 --
+string(10) " {;} this
+"
+int(99)
+bool(false)
+-- Line 3 --
+string(44) "is a heredoc string. ksklnm@@$$&$&^%&^%&^%&
+"
+int(152)
+bool(false)
+-- Line 4 --
+string(21) "<html> html </html>
+"
+int(193)
+bool(false)
+-- Line 5 --
+string(43) "this line is without any html and php tags
+"
+int(236)
+bool(false)
+-- Line 6 --
+string(79) "this is a line with more than eighty character,want to check line splitting cor"
+int(315)
+bool(false)
+-- Line 7 --
+string(27) "rectly after 80 characters
+"
+int(342)
+bool(false)
+-- Line 8 --
+string(46) "this text contains some html tags body br
+"
+int(410)
+bool(false)
+-- Line 9 --
+string(23) "this is the line with
+"
+int(433)
+bool(false)
+-- Line 10 --
+string(12) " character. "
+int(445)
+bool(true)
+
+-- Testing fgetss() with file opened using x+b mode --
+int(0)
+int(445)
+bool(false)
+-- Reading line by line with allowable tags: <test>, <html>, <?> --
+-- Line 1 --
+string(40) "<test>Testing fgetss() functions</test>
+"
+int(40)
+bool(false)
+-- Line 2 --
+string(10) " {;} this
+"
+int(99)
+bool(false)
+-- Line 3 --
+string(44) "is a heredoc string. ksklnm@@$$&$&^%&^%&^%&
+"
+int(152)
+bool(false)
+-- Line 4 --
+string(21) "<html> html </html>
+"
+int(193)
+bool(false)
+-- Line 5 --
+string(43) "this line is without any html and php tags
+"
+int(236)
+bool(false)
+-- Line 6 --
+string(79) "this is a line with more than eighty character,want to check line splitting cor"
+int(315)
+bool(false)
+-- Line 7 --
+string(27) "rectly after 80 characters
+"
+int(342)
+bool(false)
+-- Line 8 --
+string(46) "this text contains some html tags body br
+"
+int(410)
+bool(false)
+-- Line 9 --
+string(23) "this is the line with
+"
+int(433)
+bool(false)
+-- Line 10 --
+string(12) " character. "
+int(445)
+bool(true)
+
+-- Testing fgetss() with file opened using x+t mode --
+int(0)
+int(445)
+bool(false)
+-- Reading line by line with allowable tags: <test>, <html>, <?> --
+-- Line 1 --
+string(40) "<test>Testing fgetss() functions</test>
+"
+int(40)
+bool(false)
+-- Line 2 --
+string(10) " {;} this
+"
+int(99)
+bool(false)
+-- Line 3 --
+string(44) "is a heredoc string. ksklnm@@$$&$&^%&^%&^%&
+"
+int(152)
+bool(false)
+-- Line 4 --
+string(21) "<html> html </html>
+"
+int(193)
+bool(false)
+-- Line 5 --
+string(43) "this line is without any html and php tags
+"
+int(236)
+bool(false)
+-- Line 6 --
+string(79) "this is a line with more than eighty character,want to check line splitting cor"
+int(315)
+bool(false)
+-- Line 7 --
+string(27) "rectly after 80 characters
+"
+int(342)
+bool(false)
+-- Line 8 --
+string(46) "this text contains some html tags body br
+"
+int(410)
+bool(false)
+-- Line 9 --
+string(23) "this is the line with
+"
+int(433)
+bool(false)
+-- Line 10 --
+string(12) " character. "
+int(445)
+bool(true)
+Done
diff --git a/ext/standard/tests/file/fgetss_variation4.phpt b/ext/standard/tests/file/fgetss_variation4.phpt
new file mode 100644
index 0000000..6c201d1
--- /dev/null
+++ b/ext/standard/tests/file/fgetss_variation4.phpt
@@ -0,0 +1,168 @@
+--TEST--
+Test fgetss() function : usage variations - read modes, file pointer at EOF
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+ die("skip not for Windows");
+?>
+--FILE--
+<?php
+/*
+ Prototype: string fgetss ( resource $handle [, int $length [, string $allowable_tags]] );
+ Description: Gets line from file pointer and strip HTML tags
+*/
+
+// include the common file related test functions
+include ("file.inc");
+
+echo "*** Testing fgetss() : usage variations ***\n";
+
+/* string with html and php tags */
+$string_with_tags = <<<EOT
+<test>Testing fgetss() functions</test>
+<?php echo "this string is within php tag"; ?> {;}<{> this
+is a heredoc string. <pg>ksklnm@@$$&$&^%&^%&^%&</pg>
+<html> html </html> <?php echo "php"; ?>
+this line is without any html and php tags
+this is a line with more than eighty character,want to check line splitting correctly after 80 characters
+this is the text containing \r character
+this text contains some html tags <body> body </body> <br> br </br>
+this is the line with \n character.
+EOT;
+
+$filename = dirname(__FILE__)."/fgetss_variation4.tmp";
+
+/* try reading the file opened in different modes of reading */
+$file_modes = array("r","rb", "rt","r+", "r+b", "r+t");
+
+for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ echo "\n-- Testing fgetss() with file opened using $file_modes[$mode_counter] mode --\n";
+
+ /* create an empty file and write the strings with tags */
+ create_file ($filename); //create an empty file
+ file_put_contents($filename, $string_with_tags);
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ if(!$file_handle) {
+ echo "Error: failed to open file $filename!\n";
+ exit();
+ }
+
+ // rewind the file pointer to begining of the file
+ var_dump( filesize($filename) );
+ var_dump( rewind($file_handle) );
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ echo "-- Reading when file pointer points to EOF --\n";
+ var_dump( fseek($file_handle,0,SEEK_END) ); // now file pointer at end
+ var_dump( ftell($file_handle) ); //ensure file pointer at end
+ var_dump( fgetss($file_handle) ); // try to read
+ var_dump( ftell($file_handle) ); // find out file position
+ var_dump( feof($file_handle) ); // ensure that file pointer is at eof
+
+ // now file is at the end try reading with length and allowable tags,expecting false
+ var_dump( fgetss($file_handle, 80, "<test>, <html>, <?>") );
+ var_dump( ftell($file_handle) ); // find out file position
+ var_dump( feof($file_handle) ); // ensure that file pointer is at eof
+
+ // close the file
+ fclose($file_handle);
+ // delete the file
+ delete_file($filename);
+} // end of for - mode_counter
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fgetss() : usage variations ***
+
+-- Testing fgetss() with file opened using r mode --
+int(486)
+bool(true)
+int(0)
+bool(false)
+-- Reading when file pointer points to EOF --
+int(0)
+int(486)
+bool(false)
+int(486)
+bool(true)
+bool(false)
+int(486)
+bool(true)
+
+-- Testing fgetss() with file opened using rb mode --
+int(486)
+bool(true)
+int(0)
+bool(false)
+-- Reading when file pointer points to EOF --
+int(0)
+int(486)
+bool(false)
+int(486)
+bool(true)
+bool(false)
+int(486)
+bool(true)
+
+-- Testing fgetss() with file opened using rt mode --
+int(486)
+bool(true)
+int(0)
+bool(false)
+-- Reading when file pointer points to EOF --
+int(0)
+int(486)
+bool(false)
+int(486)
+bool(true)
+bool(false)
+int(486)
+bool(true)
+
+-- Testing fgetss() with file opened using r+ mode --
+int(486)
+bool(true)
+int(0)
+bool(false)
+-- Reading when file pointer points to EOF --
+int(0)
+int(486)
+bool(false)
+int(486)
+bool(true)
+bool(false)
+int(486)
+bool(true)
+
+-- Testing fgetss() with file opened using r+b mode --
+int(486)
+bool(true)
+int(0)
+bool(false)
+-- Reading when file pointer points to EOF --
+int(0)
+int(486)
+bool(false)
+int(486)
+bool(true)
+bool(false)
+int(486)
+bool(true)
+
+-- Testing fgetss() with file opened using r+t mode --
+int(486)
+bool(true)
+int(0)
+bool(false)
+-- Reading when file pointer points to EOF --
+int(0)
+int(486)
+bool(false)
+int(486)
+bool(true)
+bool(false)
+int(486)
+bool(true)
+Done
diff --git a/ext/standard/tests/file/fgetss_variation5-win32.phpt b/ext/standard/tests/file/fgetss_variation5-win32.phpt
new file mode 100644
index 0000000..cedc7b9
--- /dev/null
+++ b/ext/standard/tests/file/fgetss_variation5-win32.phpt
@@ -0,0 +1,220 @@
+--TEST--
+Test fgetss() function : usage variations - read/write modes, file pointer at EOF
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip.. only valid for Windows');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: string fgetss ( resource $handle [, int $length [, string $allowable_tags]] );
+ Description: Gets line from file pointer and strip HTML tags
+*/
+
+/* try fgetss on files which are opened in read/write modes
+ w+, w+b, w+t,
+ a+, a+b, a+t,
+ x+, x+b, x+t
+*/
+
+
+echo "*** Testing fgetss() : usage variations ***\n";
+
+/* string with html and php tags */
+$string_with_tags = <<<EOT
+<test>Testing fgetss() functions</test>
+<?php echo "this string is within php tag"; ?> {;}<{> this
+is a heredoc string. <pg>ksklnm@@$$&$&^%&^%&^%&</pg>
+<html> html </html> <?php echo "php"; ?>
+this line is without any html and php tags
+this is a line with more than eighty character,want to check line splitting correctly after 80 characters
+this text contains some html tags <body> body </body> <br> br </br>
+this is the line with \n character.
+EOT;
+if(substr(PHP_OS, 0, 3) == "WIN") {
+ $string_with_tags = str_replace("\r",'', $string_with_tags);
+}
+
+$filename = dirname(__FILE__)."/fgetss_variation5.tmp";
+
+/* try reading the file opened in different modes of reading */
+$file_modes = array("w+","w+b", "w+t","a+", "a+b", "a+t","x+","x+b","x+t");
+
+for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ echo "\n-- Testing fgetss() with file opened using $file_modes[$mode_counter] mode --\n";
+
+ /* create an empty file and write the strings with tags */
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ fwrite($file_handle,$string_with_tags); //writing data to the file
+ if(!$file_handle) {
+ echo "Error: failed to open file $filename!\n";
+ exit();
+ }
+ // rewind the file pointer to begining of the file
+ var_dump( filesize($filename) );
+ var_dump( rewind($file_handle) );
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ echo "-- Reading when file pointer points to EOF --\n";
+ var_dump( fseek($file_handle,0,SEEK_END) ); // now file pointer at end
+ var_dump( ftell($file_handle) ); //ensure file pointer at end
+ var_dump( fgetss($file_handle) ); // try to read
+ var_dump( ftell($file_handle) ); // find out file position
+ var_dump( feof($file_handle) ); // ensure that file pointer is at eof
+
+ // now file is at the end try reading with length and allowable tags,expecting false
+ var_dump( fgetss($file_handle, 80, "<test>, <html>, <?>") );
+ var_dump( ftell($file_handle) ); // find out file position
+ var_dump( feof($file_handle) ); // ensure that file pointer is at eof
+
+
+ // close the file
+ fclose($file_handle);
+
+ // delete the file
+ unlink($filename);
+} // end of for - mode_counter
+
+echo "Done\n";
+?>
+--EXPECT--
+*** Testing fgetss() : usage variations ***
+
+-- Testing fgetss() with file opened using w+ mode --
+int(445)
+bool(true)
+int(0)
+bool(false)
+-- Reading when file pointer points to EOF --
+int(0)
+int(445)
+bool(false)
+int(445)
+bool(true)
+bool(false)
+int(445)
+bool(true)
+
+-- Testing fgetss() with file opened using w+b mode --
+int(445)
+bool(true)
+int(0)
+bool(false)
+-- Reading when file pointer points to EOF --
+int(0)
+int(445)
+bool(false)
+int(445)
+bool(true)
+bool(false)
+int(445)
+bool(true)
+
+-- Testing fgetss() with file opened using w+t mode --
+int(453)
+bool(true)
+int(0)
+bool(false)
+-- Reading when file pointer points to EOF --
+int(0)
+int(453)
+bool(false)
+int(453)
+bool(true)
+bool(false)
+int(453)
+bool(true)
+
+-- Testing fgetss() with file opened using a+ mode --
+int(445)
+bool(true)
+int(0)
+bool(false)
+-- Reading when file pointer points to EOF --
+int(0)
+int(445)
+bool(false)
+int(445)
+bool(true)
+bool(false)
+int(445)
+bool(true)
+
+-- Testing fgetss() with file opened using a+b mode --
+int(445)
+bool(true)
+int(0)
+bool(false)
+-- Reading when file pointer points to EOF --
+int(0)
+int(445)
+bool(false)
+int(445)
+bool(true)
+bool(false)
+int(445)
+bool(true)
+
+-- Testing fgetss() with file opened using a+t mode --
+int(453)
+bool(true)
+int(0)
+bool(false)
+-- Reading when file pointer points to EOF --
+int(0)
+int(453)
+bool(false)
+int(453)
+bool(true)
+bool(false)
+int(453)
+bool(true)
+
+-- Testing fgetss() with file opened using x+ mode --
+int(445)
+bool(true)
+int(0)
+bool(false)
+-- Reading when file pointer points to EOF --
+int(0)
+int(445)
+bool(false)
+int(445)
+bool(true)
+bool(false)
+int(445)
+bool(true)
+
+-- Testing fgetss() with file opened using x+b mode --
+int(445)
+bool(true)
+int(0)
+bool(false)
+-- Reading when file pointer points to EOF --
+int(0)
+int(445)
+bool(false)
+int(445)
+bool(true)
+bool(false)
+int(445)
+bool(true)
+
+-- Testing fgetss() with file opened using x+t mode --
+int(453)
+bool(true)
+int(0)
+bool(false)
+-- Reading when file pointer points to EOF --
+int(0)
+int(453)
+bool(false)
+int(453)
+bool(true)
+bool(false)
+int(453)
+bool(true)
+Done
diff --git a/ext/standard/tests/file/fgetss_variation5.phpt b/ext/standard/tests/file/fgetss_variation5.phpt
new file mode 100644
index 0000000..ea53382
--- /dev/null
+++ b/ext/standard/tests/file/fgetss_variation5.phpt
@@ -0,0 +1,217 @@
+--TEST--
+Test fgetss() function : usage variations - read/write modes, file pointer at EOF
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. Not valid for Windows');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: string fgetss ( resource $handle [, int $length [, string $allowable_tags]] );
+ Description: Gets line from file pointer and strip HTML tags
+*/
+
+/* try fgetss on files which are opened in read/write modes
+ w+, w+b, w+t,
+ a+, a+b, a+t,
+ x+, x+b, x+t
+*/
+
+
+echo "*** Testing fgetss() : usage variations ***\n";
+
+/* string with html and php tags */
+$string_with_tags = <<<EOT
+<test>Testing fgetss() functions</test>
+<?php echo "this string is within php tag"; ?> {;}<{> this
+is a heredoc string. <pg>ksklnm@@$$&$&^%&^%&^%&</pg>
+<html> html </html> <?php echo "php"; ?>
+this line is without any html and php tags
+this is a line with more than eighty character,want to check line splitting correctly after 80 characters
+this text contains some html tags <body> body </body> <br> br </br>
+this is the line with \n character.
+EOT;
+
+$filename = dirname(__FILE__)."/fgetss_variation5.tmp";
+
+/* try reading the file opened in different modes of reading */
+$file_modes = array("w+","w+b", "w+t","a+", "a+b", "a+t","x+","x+b","x+t");
+
+for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ echo "\n-- Testing fgetss() with file opened using $file_modes[$mode_counter] mode --\n";
+
+ /* create an empty file and write the strings with tags */
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ fwrite($file_handle,$string_with_tags); //writing data to the file
+ if(!$file_handle) {
+ echo "Error: failed to open file $filename!\n";
+ exit();
+ }
+ // rewind the file pointer to begining of the file
+ var_dump( filesize($filename) );
+ var_dump( rewind($file_handle) );
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ echo "-- Reading when file pointer points to EOF --\n";
+ var_dump( fseek($file_handle,0,SEEK_END) ); // now file pointer at end
+ var_dump( ftell($file_handle) ); //ensure file pointer at end
+ var_dump( fgetss($file_handle) ); // try to read
+ var_dump( ftell($file_handle) ); // find out file position
+ var_dump( feof($file_handle) ); // ensure that file pointer is at eof
+
+ // now file is at the end try reading with length and allowable tags,expecting false
+ var_dump( fgetss($file_handle, 80, "<test>, <html>, <?>") );
+ var_dump( ftell($file_handle) ); // find out file position
+ var_dump( feof($file_handle) ); // ensure that file pointer is at eof
+
+
+ // close the file
+ fclose($file_handle);
+
+ // delete the file
+ unlink($filename);
+} // end of for - mode_counter
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fgetss() : usage variations ***
+
+-- Testing fgetss() with file opened using w+ mode --
+int(445)
+bool(true)
+int(0)
+bool(false)
+-- Reading when file pointer points to EOF --
+int(0)
+int(445)
+bool(false)
+int(445)
+bool(true)
+bool(false)
+int(445)
+bool(true)
+
+-- Testing fgetss() with file opened using w+b mode --
+int(445)
+bool(true)
+int(0)
+bool(false)
+-- Reading when file pointer points to EOF --
+int(0)
+int(445)
+bool(false)
+int(445)
+bool(true)
+bool(false)
+int(445)
+bool(true)
+
+-- Testing fgetss() with file opened using w+t mode --
+int(445)
+bool(true)
+int(0)
+bool(false)
+-- Reading when file pointer points to EOF --
+int(0)
+int(445)
+bool(false)
+int(445)
+bool(true)
+bool(false)
+int(445)
+bool(true)
+
+-- Testing fgetss() with file opened using a+ mode --
+int(445)
+bool(true)
+int(0)
+bool(false)
+-- Reading when file pointer points to EOF --
+int(0)
+int(445)
+bool(false)
+int(445)
+bool(true)
+bool(false)
+int(445)
+bool(true)
+
+-- Testing fgetss() with file opened using a+b mode --
+int(445)
+bool(true)
+int(0)
+bool(false)
+-- Reading when file pointer points to EOF --
+int(0)
+int(445)
+bool(false)
+int(445)
+bool(true)
+bool(false)
+int(445)
+bool(true)
+
+-- Testing fgetss() with file opened using a+t mode --
+int(445)
+bool(true)
+int(0)
+bool(false)
+-- Reading when file pointer points to EOF --
+int(0)
+int(445)
+bool(false)
+int(445)
+bool(true)
+bool(false)
+int(445)
+bool(true)
+
+-- Testing fgetss() with file opened using x+ mode --
+int(445)
+bool(true)
+int(0)
+bool(false)
+-- Reading when file pointer points to EOF --
+int(0)
+int(445)
+bool(false)
+int(445)
+bool(true)
+bool(false)
+int(445)
+bool(true)
+
+-- Testing fgetss() with file opened using x+b mode --
+int(445)
+bool(true)
+int(0)
+bool(false)
+-- Reading when file pointer points to EOF --
+int(0)
+int(445)
+bool(false)
+int(445)
+bool(true)
+bool(false)
+int(445)
+bool(true)
+
+-- Testing fgetss() with file opened using x+t mode --
+int(445)
+bool(true)
+int(0)
+bool(false)
+-- Reading when file pointer points to EOF --
+int(0)
+int(445)
+bool(false)
+int(445)
+bool(true)
+bool(false)
+int(445)
+bool(true)
+Done
diff --git a/ext/standard/tests/file/file.inc b/ext/standard/tests/file/file.inc
new file mode 100644
index 0000000..c0f86e7
--- /dev/null
+++ b/ext/standard/tests/file/file.inc
@@ -0,0 +1,650 @@
+<?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
+ fill_buffer() : fills buffer with specified contents
+ compare_self_stat() : compares the first 13 elements of the
+ stat with the corresponding named key values of
+ the same stat.
+ compare_stats() : Compares two stat values
+
+*/
+
+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_buffer(string &$buffer, string $fill_type, int $fill_size);
+ Description: Fills the $buffer with data as specified with requested size.
+ $buffer = buffer to be filled
+ $fill_type:
+ "text" = fills with string of size $file_size
+ "numeric" = fills with numeric value of size $file_size
+ "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 invalid fill type
+*/
+function fill_buffer(&$buffer, $fill_type, $fill_size) {
+
+ 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;
+ }
+
+ $tmp_buff = str_repeat($data, ($fill_size/$size_divider) + $add_value );
+
+ if ( strlen($tmp_buff) > $fill_size ) {
+ $buffer = substr($tmp_buff, 0, $fill_size);
+ } else {
+ $buffer = $tmp_buff;
+ }
+
+ 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 != $file_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;
+ } else {
+ // 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;
+}
+
+
+
+/*
+ Prototype:
+ function compare_self_stat( array $stat );
+ Description:
+ Compares the each of the first 13 values of the stat array with the
+ corresponding next 13 values of the same stat for equality
+ $stat = stat array
+
+ Retuns: true when all of them match, false otherwise
+*/
+function compare_self_stat( array $stat )
+{
+ //return value
+ $return_value = true;
+
+ // named keys present in a stat
+ $string_keys = array("dev", "ino", "mode", "nlink", "uid", "gid",
+ "rdev", "size", "atime", "mtime", "ctime",
+ "blksize", "blocks");
+
+ // first numeric key
+ $key = 0;
+
+ // compare the values in the stat, which are accessed using numeric key with
+ // values accessed using string keys
+ foreach($string_keys as $str_key)
+ {
+ if($stat[$key] != $stat[$str_key]) {
+ echo "Error: stat[$key] doesn't match with stat[$str_key]\n";
+ $flag = false;
+ $key++;
+ }
+ else {
+ $key++;
+ }
+ } // end of foreach
+
+ // if the $return_value is false, i.e all the element do not match then
+ // dump the stat array so that its easy to figure out the error
+ if ($return_value == false ) {
+ echo "\n Dumping stat array ...\n";
+ var_dump($stat);
+ }
+
+ return $return_value;
+}// end of compare_self_stat
+
+/*
+Prototype:
+ function compare_stats( array $stat1, array $stat2, array $fields,
+ [string $op = "==", [ bool $flag = false] ]);
+Description:
+ Compares two stat values, stat value should be obtained by stat/lstat
+ $stat1 = first stat array
+ $stat2 = second stat array
+ $op = type of the comparision to be perform between elements of stat1 and stat2
+ "!=" compare for not equal
+ "==" compare for equality
+ ">" if each element of stat1 is > than stat2
+ "<" if each element of stat1 is < than stat2
+ $fields = contains the key of the elements that needs to be compared.
+ type of the comparision is based on $op argument value
+ $flag = specify true to dump the stat1 and stat2
+*/
+
+$all_stat_keys = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
+ "dev", "ino", "mode", "nlink", "uid", "gid",
+ "rdev", "size", "atime", "mtime", "ctime",
+ "blksize", "blocks");
+
+function compare_stats($stat1, $stat2, $fields, $op = "==", $flag = false ) {
+ // dump the stat if requested
+ if ( $flag == true ) {
+ var_dump($stat1);
+ var_dump($stat2);
+ }
+
+ $result = true;
+
+ // compare values of given key from each stat array
+ for($index = 0; $index < count($fields); $index++)
+ {
+ switch( $op )
+ {
+ case "==":
+ if ( $stat1[ $fields[$index] ] != $stat2[ $fields[$index] ] ) {
+ $result = false;
+ echo "Error: stat1 do not match with stat2 at key value: $fields[$index]\n";
+ }
+ break;
+
+ case "!=":
+ if ( $stat1[ $fields[$index] ] != $stat2[ $fields[$index] ] ) {
+ // do nothing as its not equal, else will take care of if equal
+ } else {
+ $result = false;
+ echo "Error: stat1 equals stat2 at key value: $fields[$index]\n";
+ }
+ break;
+
+ case ">":
+ if ( $stat1[ $fields[$index] ] <= $stat2[ $fields[$index] ] ) {
+ $result = false;
+ echo "Error: stat1 is not greater than stat2 at key value: $fields[$index]\n";
+ }
+ break;
+
+ case "<":
+ if ( $stat1[ $fields[$index] ] >= $stat2[ $fields[$index] ] ) {
+ $result = false;
+ echo "Error: stat1 is not lesser than stat2 at key value: $fields[$index]\n";
+ }
+ break;
+ }
+ }
+ // if the result is false(i.e values are not as expected),
+ // dump the stat array so that easy to figure out the error
+ if ( $result == false ) {
+ echo "\n Dumping stat array 1...\n";
+ var_dump($stat1);
+ echo "\n Dumping stat array 2...\n";
+ var_dump($stat2);
+ }
+
+ return $result;
+}
+
+?>
diff --git a/ext/standard/tests/file/file_basic.phpt b/ext/standard/tests/file/file_basic.phpt
new file mode 100644
index 0000000..97a592f
--- /dev/null
+++ b/ext/standard/tests/file/file_basic.phpt
@@ -0,0 +1,77 @@
+--TEST--
+Test file() function : basic functionality
+--FILE--
+<?php
+/*
+ * Prototype: array file ( string filename [,int use-include_path [,resource context]] );
+ * Description: Reads entire file into an array
+ * Returns the file in an array
+ */
+require(dirname(__FILE__) . '/file.inc');
+$file_path = dirname(__FILE__);
+echo "*** Testing file() with basic types of files ***\n";
+$filetypes = array("numeric", "text", "empty", "text_with_new_line");
+
+foreach( $filetypes as $type ) {
+ create_files($file_path, 1, $type, 0755, 100, "w", "file_basic", 1, "byte");
+ print_r( file($file_path."/file_basic1.tmp") );
+ delete_files($file_path, 1, "file_basic");
+}
+
+echo "*** Testing for return type of file() function ***\n";
+foreach( $filetypes as $type ) {
+ create_files($file_path, 1, $type, 0755, 1, "w", "file_basic");
+ $ret_arr = file($file_path."/file_basic1.tmp");
+ var_dump( is_array($ret_arr) );
+ delete_files($file_path, 1, "file_basic");
+}
+
+echo "\n--- Done ---";
+?>
+--EXPECTF--
+*** Testing file() with basic types of files ***
+Array
+(
+ [0] => 2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
+)
+Array
+(
+ [0] => text text text text text text text text text text text text text text text text text text text text
+)
+Array
+(
+)
+Array
+(
+ [0] => line
+
+ [1] => line of text
+
+ [2] => line
+
+ [3] => line of text
+
+ [4] => line
+
+ [5] => line of text
+
+ [6] => line
+
+ [7] => line of text
+
+ [8] => line
+
+ [9] => line of text
+
+ [10] => line
+
+ [11] => line
+)
+*** Testing for return type of file() function ***
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+
+--- Done ---
+
diff --git a/ext/standard/tests/file/file_error.phpt b/ext/standard/tests/file/file_error.phpt
new file mode 100644
index 0000000..c3130c3
--- /dev/null
+++ b/ext/standard/tests/file/file_error.phpt
@@ -0,0 +1,48 @@
+--TEST--
+Test file() function : error conditions
+--FILE--
+<?php
+/*
+ Prototype: array file ( string filename [,int use-include_path [,resource context]] );
+ Description: Reads entire file into an array
+ Returns the file in an array
+*/
+$file_path = dirname(__FILE__);
+echo "\n*** Testing error conditions ***";
+$file_handle = fopen($file_path."/file.tmp", "w");
+var_dump( file() ); // Zero No. of args
+
+$filename = $file_path."/file.tmp";
+var_dump( file($filename, $filename, $filename, $filename) ); // more than expected number of arguments
+
+var_dump( file($filename, "INCORRECT_FLAG", NULL) ); // Incorrect flag
+var_dump( file($filename, 10, NULL) ); // Incorrect flag
+
+var_dump( file("temp.tmp") ); // non existing filename
+fclose($file_handle);
+
+echo "\n--- Done ---";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/file.tmp");
+?>
+--EXPECTF--
+*** Testing error conditions ***
+Warning: file() expects at least 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: file() expects at most 3 parameters, 4 given in %s on line %d
+NULL
+
+Warning: file() expects parameter 2 to be long, string given in %s on line %d
+NULL
+array(0) {
+}
+
+Warning: file(temp.tmp): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+--- Done ---
+
diff --git a/ext/standard/tests/file/file_exists_error.phpt b/ext/standard/tests/file/file_exists_error.phpt
new file mode 100644
index 0000000..b20b2fe
--- /dev/null
+++ b/ext/standard/tests/file/file_exists_error.phpt
@@ -0,0 +1,40 @@
+--TEST--
+Test file_exists() function : error conditions
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : proto bool file_exists(string filename)
+ * Description: Returns true if filename exists
+ * Source code: ext/standard/filestat.c
+ * Alias to functions:
+ */
+
+echo "*** Testing file_exists() : error conditions ***\n";
+
+// Zero arguments
+echo "\n-- Testing file_exists() function with Zero arguments --\n";
+var_dump( file_exists() );
+
+//Test file_exists with one more than the expected number of arguments
+echo "\n-- Testing file_exists() function with more than expected no. of arguments --\n";
+$filename = 'string_val';
+$extra_arg = 10;
+var_dump( file_exists($filename, $extra_arg) );
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing file_exists() : error conditions ***
+
+-- Testing file_exists() function with Zero arguments --
+
+Warning: file_exists() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+-- Testing file_exists() function with more than expected no. of arguments --
+
+Warning: file_exists() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+Done
+
diff --git a/ext/standard/tests/file/file_exists_variation1.phpt b/ext/standard/tests/file/file_exists_variation1.phpt
new file mode 100644
index 0000000..35c86a2
--- /dev/null
+++ b/ext/standard/tests/file/file_exists_variation1.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Test file_exists() function : usage variations
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : proto bool file_exists(string filename)
+ * Description: Returns true if filename exists
+ * Source code: ext/standard/filestat.c
+ * Alias to functions:
+ */
+
+echo "*** Testing file_exists() : usage variations ***\n";
+
+var_dump(file_exists(NULL));
+var_dump(file_exists(false));
+var_dump(file_exists(''));
+var_dump(file_exists(' '));
+var_dump(file_exists('|'));
+echo "Done";
+?>
+
+--EXPECTF--
+*** Testing file_exists() : usage variations ***
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+Done \ No newline at end of file
diff --git a/ext/standard/tests/file/file_get_contents_basic.phpt b/ext/standard/tests/file/file_get_contents_basic.phpt
new file mode 100644
index 0000000..413909b
--- /dev/null
+++ b/ext/standard/tests/file/file_get_contents_basic.phpt
@@ -0,0 +1,41 @@
+--TEST--
+file_get_contents() function : basic functionality
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+
+/* Prototype: string file_get_contents( string $filename[, bool $use_include_path[,
+ * resource $context[, int $offset[, int $maxlen]]]] )
+ * Description: Reads entire file into a string
+ */
+
+$file_path = dirname(__FILE__);
+include($file_path."/file.inc");
+
+echo "*** Testing the basic functionality of the file_get_contents() function ***\n";
+
+echo "-- Testing with simple valid data file --\n";
+
+
+create_files($file_path, 1, "text", 0755, 100, "w", "file", 1, "byte");
+var_dump( file_get_contents($file_path."/file1.tmp") );
+delete_files($file_path, 1);
+
+echo "\n-- Testing with empty file --\n";
+
+create_files($file_path, 1, "empty", 0755, 100, "w", "file", 1, "byte");
+var_dump( file_get_contents($file_path."/file1.tmp") );
+delete_files($file_path, 1);
+
+echo "\n*** Done ***";
+?>
+--EXPECTF--
+*** Testing the basic functionality of the file_get_contents() function ***
+-- Testing with simple valid data file --
+string(100) "text text text text text text text text text text text text text text text text text text text text "
+
+-- Testing with empty file --
+string(0) ""
+
+*** Done ***
diff --git a/ext/standard/tests/file/file_get_contents_basic001.phpt b/ext/standard/tests/file/file_get_contents_basic001.phpt
new file mode 100644
index 0000000..71b6963
--- /dev/null
+++ b/ext/standard/tests/file/file_get_contents_basic001.phpt
@@ -0,0 +1,21 @@
+--TEST--
+file_get_contents() test using basic syntax
+--CREDITS--
+"Blanche V.N." <valerie_nare@yahoo.fr>
+--FILE--
+<?php
+ $file_content = "Bienvenue au CodeFest a Montreal";
+ $temp_filename = dirname(__FILE__)."/fichier_a_lire.txt";
+ $handle = fopen($temp_filename,"w");
+ fwrite($handle,$file_content);
+ fclose($handle);
+ $var = file_get_contents($temp_filename);
+ echo $var;
+?>
+--CLEAN--
+<?php
+ $temp_filename = dirname(__FILE__)."/fichier_a_lire.txt";
+ unlink($temp_filename);
+?>
+--EXPECT--
+Bienvenue au CodeFest a Montreal
diff --git a/ext/standard/tests/file/file_get_contents_error.phpt b/ext/standard/tests/file/file_get_contents_error.phpt
new file mode 100644
index 0000000..631a138
--- /dev/null
+++ b/ext/standard/tests/file/file_get_contents_error.phpt
@@ -0,0 +1,67 @@
+--TEST--
+Test file_get_contents() function : error conditions
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype: string file_get_contents( string $filename{, bool $use_include_path[,
+ * resource $context[, int $offset[, int $maxlen]]]] )
+ * Description: Reads entire file into a string
+ */
+
+echo "*** Testing error conditions ***\n";
+
+$file_path = dirname(__FILE__);
+include($file_path."/file.inc");
+
+echo "\n-- Testing with Non-existing file --\n";
+print( file_get_contents("/no/such/file/or/dir") );
+
+echo "\n-- Testing No.of arguments less than expected --\n";
+print( file_get_contents() );
+
+echo "\n-- Testing No.of arguments greater than expected --\n";
+
+create_files($file_path, 1, "text", 0755, 100, "w", "file", 1, "byte");
+$file_handle = fopen($file_path."/file_put_contents_error.tmp", "w");
+print( file_get_contents($file_path."/file1.tmp", false, $file_handle, 1, 2, "extra_argument") );
+
+echo "\n-- Testing for invalid negative maxlen values --";
+var_dump( file_get_contents($file_path."/file1.tmp", FALSE, $file_handle, 0, -5) );
+
+delete_files($file_path, 1);
+fclose($file_handle);
+unlink($file_path."/file_put_contents_error.tmp");
+
+echo "\n*** Done ***\n";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+if(file_exists($file_path."/file_put_contents_error.tmp")) {
+ unlink($file_path."/file_put_contents_error.tmp");
+}
+if(file_exists($file_path."/file_put_contents1.tmp")) {
+ unlink($file_path."/file_put_contents1.tmp");
+}
+?>
+--EXPECTF--
+*** Testing error conditions ***
+
+-- Testing with Non-existing file --
+
+Warning: file_get_contents(/no/such/file/or/dir): failed to open stream: No such file or directory in %s on line %d
+
+-- Testing No.of arguments less than expected --
+
+Warning: file_get_contents() expects at least 1 parameter, 0 given in %s on line %d
+
+-- Testing No.of arguments greater than expected --
+
+Warning: file_get_contents() expects at most 5 parameters, 6 given in %s on line %d
+
+-- Testing for invalid negative maxlen values --
+Warning: file_get_contents(): length must be greater than or equal to zero in %s on line %d
+bool(false)
+
+*** Done ***
diff --git a/ext/standard/tests/file/file_get_contents_error001.phpt b/ext/standard/tests/file/file_get_contents_error001.phpt
new file mode 100644
index 0000000..127901a
--- /dev/null
+++ b/ext/standard/tests/file/file_get_contents_error001.phpt
@@ -0,0 +1,19 @@
+--TEST--
+file_get_contents() test using offset parameter out of range
+--CREDITS--
+"Blanche V.N." <valerie_nare@yahoo.fr>
+"Sylvain R." <sracine@phpquebec.org>
+--INI--
+display_errors=false
+--SKIPIF--
+<?php
+ if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
+ if (!function_exists("file_get_contents"))
+ die ("skip file_get_contents function is not found");
+?>
+--FILE--
+<?php
+ var_dump(file_get_contents("http://checkip.dyndns.com",null,null,8000,1));
+?>
+--EXPECT--
+bool(false)
diff --git a/ext/standard/tests/file/file_get_contents_error002.phpt b/ext/standard/tests/file/file_get_contents_error002.phpt
new file mode 100644
index 0000000..47c7b9c
--- /dev/null
+++ b/ext/standard/tests/file/file_get_contents_error002.phpt
@@ -0,0 +1,18 @@
+--TEST--
+file_get_contents() test using negative parameter for length (last parameter)
+--CREDITS--
+"Blanche V.N." <valerie_nare@yahoo.fr>
+"Sylvain R." <sracine@phpquebec.org>
+--INI--
+display_errors=false
+--SKIPIF--
+<?php
+ if (!function_exists("file_get_contents"))
+ die ("skip file_get_contents function is not found");
+?>
+--FILE--
+<?php
+ var_dump(file_get_contents("http://checkip.dyndns.com",null,null,0,-1));
+?>
+--EXPECT--
+bool(false)
diff --git a/ext/standard/tests/file/file_get_contents_file_put_contents_basic.phpt b/ext/standard/tests/file/file_get_contents_file_put_contents_basic.phpt
new file mode 100644
index 0000000..edfad0d
--- /dev/null
+++ b/ext/standard/tests/file/file_get_contents_file_put_contents_basic.phpt
@@ -0,0 +1,50 @@
+--TEST--
+Test file_put_contents() and file_get_contents() functions : basic functionality
+--FILE--
+<?php
+
+/* Prototype: string file_get_contents( string $filename[, bool $use_include_path[,
+ * resource $context[, int $offset[, int $maxlen]]]] )
+ * Description: Reads entire file into a string
+ */
+
+/* Prototype: int file_put_contents( string $filename, mixed $data[, int $flags[, resource $context]] )
+ * Description: Write a string to a file
+ */
+
+$file_path = dirname(__FILE__);
+include($file_path."/file.inc");
+
+echo "*** Testing the basic functionality of file_put_contents() and file_get_contents() functions ***\n";
+
+echo "-- Testing with simple valid data file --\n";
+
+$file_name = "/file_put_contents.tmp";
+fill_buffer($text_buffer, "text", 100);
+file_put_contents( $file_path.$file_name, $text_buffer );
+
+var_dump( file_get_contents($file_path.$file_name) );
+
+echo "\n-- Testing with empty file --\n";
+
+$file_name = "/file_put_contents1.tmp";
+file_put_contents( $file_path.$file_name, "");
+var_dump( file_get_contents( $file_path.$file_name ) );
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/file_put_contents.tmp");
+unlink($file_path."/file_put_contents1.tmp");
+?>
+--EXPECTF--
+*** Testing the basic functionality of file_put_contents() and file_get_contents() functions ***
+-- Testing with simple valid data file --
+string(100) "text text text text text text text text text text text text text text text text text text text text "
+
+-- Testing with empty file --
+string(0) ""
+
+*** Done ***
diff --git a/ext/standard/tests/file/file_get_contents_file_put_contents_error.phpt b/ext/standard/tests/file/file_get_contents_file_put_contents_error.phpt
new file mode 100644
index 0000000..72fe121
--- /dev/null
+++ b/ext/standard/tests/file/file_get_contents_file_put_contents_error.phpt
@@ -0,0 +1,71 @@
+--TEST--
+Test file-get_contents() and file_put_contents() functions : error conditions
+--FILE--
+<?php
+/* Prototype: string file_get_contents( string $filename{, bool $use_include_path[,
+ * resource $context[, int $offset[, int $maxlen]]]] )
+ * Description: Reads entire file into a string
+ */
+
+/* Prototype: int file_put_contents( string $filename, mixed $data[, int $flags[, resource $context]] )
+ * Description: Write a string to a file
+ */
+
+echo "*** Testing error conditions ***\n";
+
+$file_path = dirname(__FILE__);
+
+echo "\n-- Testing with Non-existing file --\n";
+print( file_get_contents("/no/such/file/or/dir") );
+
+echo "\n-- Testing No.of arguments less than expected --\n";
+print( file_get_contents() );
+print( file_put_contents() );
+print( file_put_contents($file_path."/".__FILE__) );
+
+$file_handle = fopen($file_path."/file_put_contents.tmp", "w");
+echo "\n-- Testing No.of arguments greater than expected --\n";
+print( file_put_contents("abc.tmp", 12345, 1, $file_handle, "extra_argument") );
+print( file_get_contents("abc.tmp", false, $file_handle, 1, 2, "extra_argument") );
+
+echo "\n-- Testing for invalid negative maxlen values --";
+file_put_contents($file_path."/file_put_contents1.tmp", "Garbage data in the file");
+var_dump( file_get_contents($file_path."/file_put_contents1.tmp", FALSE, NULL, 0, -5) );
+
+fclose($file_handle);
+
+echo "\n*** Done ***\n";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/file_put_contents.tmp");
+unlink($file_path."/file_put_contents1.tmp");
+
+?>
+--EXPECTF--
+*** Testing error conditions ***
+
+-- Testing with Non-existing file --
+
+Warning: file_get_contents(/no/such/file/or/dir): failed to open stream: No such file or directory in %s on line %d
+
+-- Testing No.of arguments less than expected --
+
+Warning: file_get_contents() expects at least 1 parameter, 0 given in %s on line %d
+
+Warning: file_put_contents() expects at least 2 parameters, 0 given in %s on line %d
+
+Warning: file_put_contents() expects at least 2 parameters, 1 given in %s on line %d
+
+-- Testing No.of arguments greater than expected --
+
+Warning: file_put_contents() expects at most 4 parameters, 5 given in %s on line %d
+
+Warning: file_get_contents() expects at most 5 parameters, 6 given in %s on line %d
+
+-- Testing for invalid negative maxlen values --
+Warning: file_get_contents(): length must be greater than or equal to zero in %s on line %d
+bool(false)
+
+*** Done ***
diff --git a/ext/standard/tests/file/file_get_contents_file_put_contents_variation1.phpt b/ext/standard/tests/file/file_get_contents_file_put_contents_variation1.phpt
new file mode 100644
index 0000000..1bac1c9
--- /dev/null
+++ b/ext/standard/tests/file/file_get_contents_file_put_contents_variation1.phpt
@@ -0,0 +1,116 @@
+--TEST--
+Test file_get_contents() and file_put_contents() functions : usage variations - all arguments
+
+--FILE--
+<?php
+/* Prototype: string file_get_contents( string $filename[, bool $use_include_path[,
+ * resource $context[, int $offset[, int $maxlen]]]] )
+ * Description: Reads entire file into a string
+ */
+
+/* Prototype: int file_put_contents( string $filename, mixed $data[,int $flags[, resource $context]] )
+ * Description: Write a string to a file
+ */
+
+/* Testing variation in all argument values */
+$file_path = dirname(__FILE__);
+include($file_path."/file.inc");
+
+echo "*** Testing with variations in the arguments values ***\n";
+
+$buffer_types = array("text", "numeric", "text_with_new_line", "alphanumeric");
+
+foreach( $buffer_types as $type) {
+ fill_buffer($buffer, $type, 100);
+ file_put_contents( $file_path."/file_put_contents_variation1.tmp", $buffer);
+ var_dump( file_get_contents($file_path."/file_put_contents_variation1.tmp", 0) );
+ var_dump( file_get_contents($file_path."/file_put_contents_variation1.tmp", 1) );
+ var_dump( file_get_contents($file_path."/file_put_contents_variation1.tmp", 0, NULL, 5) );
+ var_dump( file_get_contents($file_path."/file_put_contents_variation1.tmp", 1, NULL, 5) );
+ var_dump( file_get_contents($file_path."/file_put_contents_variation1.tmp", 0, NULL, 5, 20) );
+ var_dump( file_get_contents($file_path."/file_put_contents_variation1.tmp", 1, NULL, 5, 20) );
+
+}
+
+echo "--- Done ---";
+?>
+--CLEAN--
+<?php
+//Deleting the temporary file
+
+$file_path = dirname(__FILE__);
+unlink($file_path."/file_put_contents_variation1.tmp");
+?>
+--EXPECTF--
+*** Testing with variations in the arguments values ***
+string(100) "text text text text text text text text text text text text text text text text text text text text "
+string(100) "text text text text text text text text text text text text text text text text text text text text "
+string(95) "text text text text text text text text text text text text text text text text text text text "
+string(95) "text text text text text text text text text text text text text text text text text text text "
+string(20) "text text text text "
+string(20) "text text text text "
+string(100) "2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222"
+string(100) "2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222"
+string(95) "22222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222"
+string(95) "22222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222"
+string(20) "22222222222222222222"
+string(20) "22222222222222222222"
+string(100) "line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line "
+string(100) "line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line "
+string(95) "line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line "
+string(95) "line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line "
+string(20) "line of text
+line
+li"
+string(20) "line of text
+line
+li"
+string(100) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+string(100) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+string(95) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+string(95) "ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 "
+string(20) "ab12 ab12 ab12 ab12 "
+string(20) "ab12 ab12 ab12 ab12 "
+--- Done ---
diff --git a/ext/standard/tests/file/file_get_contents_file_put_contents_variation2.phpt b/ext/standard/tests/file/file_get_contents_file_put_contents_variation2.phpt
new file mode 100644
index 0000000..fc2281d
--- /dev/null
+++ b/ext/standard/tests/file/file_get_contents_file_put_contents_variation2.phpt
@@ -0,0 +1,57 @@
+--TEST--
+Test file_get_contents() and file_put_contents() functions : usage variations - use_include_path
+
+--FILE--
+<?php
+/* Prototype: string file_get_contents( string $filename[, bool $use_include_path[,
+ * resource $context[, int $offset[, int $maxlen]]]] )
+ * Description: Reads entire file into a string
+ */
+
+/* Prototype: int file_put_contents( string $filename, mixed $data[,int $flags[, resource $context]] )
+ * Description: Write a string to a file
+ */
+
+/* Testing variation using use_include_path argument */
+$file_path = dirname(__FILE__);
+include($file_path."/file.inc");
+
+echo "*** Testing with variation in use_include_path argument ***\n";
+$dir = "file_get_contents_variation2";
+mkdir($file_path."/".$dir);
+$filename = $file_path."/".$dir."/"."file_get_contents_variation2.tmp";
+
+ini_set( 'include_path',$file_path."/".$dir );
+
+$data_array = array( 1, " Data1 in an array", 2, " Data2 in an array" );
+fill_buffer( $buffer, "text", 100);
+file_put_contents( $filename, $buffer );
+fill_buffer( $buffer, "numeric", 100);
+file_put_contents( $filename, $buffer, FILE_APPEND, NULL );
+file_put_contents( $filename, $data_array, FILE_APPEND, NULL );
+var_dump( file_get_contents($filename, 0) );
+var_dump( file_get_contents($filename, 1) );
+var_dump( file_get_contents($filename, 0, NULL, 5) );
+var_dump( file_get_contents($filename, 1, NULL, 5) );
+var_dump( file_get_contents($filename, 0, NULL, 5, 20) );
+var_dump( file_get_contents($filename, 1, NULL, 5, 20) );
+
+echo "--- Done ---";
+?>
+--CLEAN--
+<?php
+//Deleting the temporary files and directory used in the testcase
+
+$file_path = dirname(__FILE__);
+unlink($file_path."/file_get_contents_variation2/file_get_contents_variation2.tmp");
+rmdir($file_path."/file_get_contents_variation2");
+?>
+--EXPECTF--
+*** Testing with variation in use_include_path argument ***
+string(240) "text text text text text text text text text text text text text text text text text text text text 22222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222221 Data1 in an array2 Data2 in an array"
+string(240) "text text text text text text text text text text text text text text text text text text text text 22222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222221 Data1 in an array2 Data2 in an array"
+string(235) "text text text text text text text text text text text text text text text text text text text 22222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222221 Data1 in an array2 Data2 in an array"
+string(235) "text text text text text text text text text text text text text text text text text text text 22222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222221 Data1 in an array2 Data2 in an array"
+string(20) "text text text text "
+string(20) "text text text text "
+--- Done ---
diff --git a/ext/standard/tests/file/file_get_contents_variation1.phpt b/ext/standard/tests/file/file_get_contents_variation1.phpt
new file mode 100644
index 0000000..ddc9261
--- /dev/null
+++ b/ext/standard/tests/file/file_get_contents_variation1.phpt
@@ -0,0 +1,51 @@
+--TEST--
+Test file_get_contents() function : variation - include path testing
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : string file_get_contents(string filename [, bool use_include_path [, resource context [, long offset [, long maxlen]]]])
+ * Description: Read the entire file into a string
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing file_get_contents() : variation ***\n";
+
+require_once('fopen_include_path.inc');
+
+// this doesn't create the include dirs in this directory
+// we change to this to ensure we are not part of the
+// include paths.
+$thisTestDir = "fileGetContentsVar1.dir";
+mkdir($thisTestDir);
+chdir($thisTestDir);
+
+$filename = "afile.txt";
+$secondFile = $dir2."/".$filename;
+
+$newpath = create_include_path();
+set_include_path($newpath);
+runtest();
+teardown_include_path();
+restore_include_path();
+chdir("..");
+rmdir($thisTestDir);
+
+
+function runtest() {
+ global $secondFile, $filename;
+ $h = fopen($secondFile, "w");
+ fwrite($h, "File in include path");
+ fclose($h);
+ $line = file_get_contents($filename, true);
+ echo "$line\n";
+ unlink($secondFile);
+}
+
+?>
+===DONE===
+--EXPECT--
+*** Testing file_get_contents() : variation ***
+File in include path
+===DONE===
diff --git a/ext/standard/tests/file/file_get_contents_variation2.phpt b/ext/standard/tests/file/file_get_contents_variation2.phpt
new file mode 100644
index 0000000..510ec12
--- /dev/null
+++ b/ext/standard/tests/file/file_get_contents_variation2.phpt
@@ -0,0 +1,52 @@
+--TEST--
+Test file_get_contents() function : variation - include path testing
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : string file_get_contents(string filename [, bool use_include_path [, resource context [, long offset [, long maxlen]]]])
+ * Description: Read the entire file into a string
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing file_get_contents() : variation ***\n";
+
+
+require_once('fopen_include_path.inc');
+
+// this doesn't create the include dirs in this directory
+// we change to this to ensure we are not part of the
+// include paths.
+$thisTestDir = "FileGetContentsVar2.dir";
+mkdir($thisTestDir);
+chdir($thisTestDir);
+
+$filename = 'FileGetContentsVar2.tmp';
+$scriptLocFile = dirname(__FILE__)."/".$filename;
+
+$newpath = create_include_path();
+set_include_path($newpath);
+runtest();
+teardown_include_path();
+restore_include_path();
+chdir("..");
+rmdir($thisTestDir);
+
+
+function runtest() {
+ global $scriptLocFile, $filename;
+ $h = fopen($scriptLocFile, "w");
+ fwrite($h, "File in script location");
+ fclose($h);
+ $line = file_get_contents($filename, true);
+ echo "$line\n";
+ unlink($scriptLocFile);
+}
+
+?>
+===DONE===
+--EXPECT--
+*** Testing file_get_contents() : variation ***
+File in script location
+===DONE===
diff --git a/ext/standard/tests/file/file_get_contents_variation3.phpt b/ext/standard/tests/file/file_get_contents_variation3.phpt
new file mode 100644
index 0000000..f485b0e
--- /dev/null
+++ b/ext/standard/tests/file/file_get_contents_variation3.phpt
@@ -0,0 +1,218 @@
+--TEST--
+Test file_get_contents() function : usage variation - different type for use_include_path
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : string file_get_contents(string filename [, bool use_include_path [, resource context [, long offset [, long maxlen]]]])
+ * Description: Read the entire file into a string
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing file_get_contents() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$filename = 'FileGetContentsVar3.tmp';
+$absFile = dirname(__FILE__).'/'.$filename;
+$h = fopen($absFile,"w");
+fwrite($h, "contents read");
+fclose($h);
+
+
+
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+ // int data
+ 'int 0' => 0,
+ 'int 1' => 1,
+ 'int 12345' => 12345,
+ 'int -12345' => -2345,
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float -10.5' => -10.5,
+ 'float 12.3456789000e10' => 12.3456789000e10,
+ 'float -12.3456789000e10' => -12.3456789000e10,
+ 'float .5' => .5,
+
+ // array data
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // string data
+ 'string DQ' => "string",
+ 'string SQ' => 'string',
+ 'mixed case string' => "sTrInG",
+ 'heredoc' => $heredoc,
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for use_include_path
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( file_get_contents($absFile, $value) );
+};
+
+unlink($absFile);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing file_get_contents() : usage variation ***
+
+--int 0--
+string(13) "contents read"
+
+--int 1--
+string(13) "contents read"
+
+--int 12345--
+string(%d) "contents read"
+
+--int -12345--
+string(%d) "contents read"
+
+--float 10.5--
+string(%d) "contents read"
+
+--float -10.5--
+string(%d) "contents read"
+
+--float 12.3456789000e10--
+string(%d) "contents read"
+
+--float -12.3456789000e10--
+string(%d) "contents read"
+
+--float .5--
+string(%d) "contents read"
+
+--empty array--
+Error: 2 - file_get_contents() expects parameter 2 to be boolean, array given, %s(%d)
+NULL
+
+--int indexed array--
+Error: 2 - file_get_contents() expects parameter 2 to be boolean, array given, %s(%d)
+NULL
+
+--associative array--
+Error: 2 - file_get_contents() expects parameter 2 to be boolean, array given, %s(%d)
+NULL
+
+--nested arrays--
+Error: 2 - file_get_contents() expects parameter 2 to be boolean, array given, %s(%d)
+NULL
+
+--uppercase NULL--
+string(%d) "contents read"
+
+--lowercase null--
+string(%d) "contents read"
+
+--lowercase true--
+string(%d) "contents read"
+
+--lowercase false--
+string(%d) "contents read"
+
+--uppercase TRUE--
+string(%d) "contents read"
+
+--uppercase FALSE--
+string(%d) "contents read"
+
+--empty string DQ--
+string(%d) "contents read"
+
+--empty string SQ--
+string(%d) "contents read"
+
+--string DQ--
+string(%d) "contents read"
+
+--string SQ--
+string(%d) "contents read"
+
+--mixed case string--
+string(%d) "contents read"
+
+--heredoc--
+string(%d) "contents read"
+
+--instance of classWithToString--
+Error: 2 - file_get_contents() expects parameter 2 to be boolean, object given, %s(%d)
+NULL
+
+--instance of classWithoutToString--
+Error: 2 - file_get_contents() expects parameter 2 to be boolean, object given, %s(%d)
+NULL
+
+--undefined var--
+string(%d) "contents read"
+
+--unset var--
+string(%d) "contents read"
+===DONE===
diff --git a/ext/standard/tests/file/file_get_contents_variation4.phpt b/ext/standard/tests/file/file_get_contents_variation4.phpt
new file mode 100644
index 0000000..3b494b4
--- /dev/null
+++ b/ext/standard/tests/file/file_get_contents_variation4.phpt
@@ -0,0 +1,251 @@
+--TEST--
+Test file_get_contents() function : usage variation - different types for context.
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : string file_get_contents(string filename [, bool use_include_path [, resource context [, long offset [, long maxlen]]]])
+ * Description: Read the entire file into a string
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing file_get_contents() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$filename = 'FileGetContentsVar4.tmp';
+$absFile = dirname(__FILE__).'/'.$filename;
+$h = fopen($absFile,"w");
+fwrite($h, "contents read");
+fclose($h);
+
+$fileRes = fopen(__FILE__,'r');
+$strContext = stream_context_create();
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+ // int data
+ 'int 0' => 0,
+ 'int 1' => 1,
+ 'int 12345' => 12345,
+ 'int -12345' => -2345,
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float -10.5' => -10.5,
+ 'float 12.3456789000e10' => 12.3456789000e10,
+ 'float -12.3456789000e10' => -12.3456789000e10,
+ 'float .5' => .5,
+
+ // array data
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // string data
+ 'string DQ' => "string",
+ 'string SQ' => 'string',
+ 'mixed case string' => "sTrInG",
+ 'heredoc' => $heredoc,
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+
+ //non context resource
+ 'file resource' => $fileRes,
+
+ //valid stream context
+ 'stream context' => $strContext,
+);
+
+// loop through each element of the array for context
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( file_get_contents($absFile, false, $value) );
+};
+
+unlink($absFile);
+fclose($fileRes);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing file_get_contents() : usage variation ***
+
+--int 0--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, integer given, %s(%d)
+NULL
+
+--int 1--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, integer given, %s(%d)
+NULL
+
+--int 12345--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, integer given, %s(%d)
+NULL
+
+--int -12345--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, integer given, %s(%d)
+NULL
+
+--float 10.5--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, double given, %s(%d)
+NULL
+
+--float -10.5--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, double given, %s(%d)
+NULL
+
+--float 12.3456789000e10--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, double given, %s(%d)
+NULL
+
+--float -12.3456789000e10--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, double given, %s(%d)
+NULL
+
+--float .5--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, double given, %s(%d)
+NULL
+
+--empty array--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, array given, %s(%d)
+NULL
+
+--int indexed array--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, array given, %s(%d)
+NULL
+
+--associative array--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, array given, %s(%d)
+NULL
+
+--nested arrays--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, array given, %s(%d)
+NULL
+
+--uppercase NULL--
+string(%d) "contents read"
+
+--lowercase null--
+string(%d) "contents read"
+
+--lowercase true--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, boolean given, %s(%d)
+NULL
+
+--lowercase false--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, boolean given, %s(%d)
+NULL
+
+--uppercase TRUE--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, boolean given, %s(%d)
+NULL
+
+--uppercase FALSE--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, boolean given, %s(%d)
+NULL
+
+--empty string DQ--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, string given, %s(%d)
+NULL
+
+--empty string SQ--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, string given, %s(%d)
+NULL
+
+--string DQ--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, string given, %s(%d)
+NULL
+
+--string SQ--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, string given, %s(%d)
+NULL
+
+--mixed case string--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, string given, %s(%d)
+NULL
+
+--heredoc--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, string given, %s(%d)
+NULL
+
+--instance of classWithToString--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, object given, %s(%d)
+NULL
+
+--instance of classWithoutToString--
+Error: 2 - file_get_contents() expects parameter 3 to be resource, object given, %s(%d)
+NULL
+
+--undefined var--
+string(%d) "contents read"
+
+--unset var--
+string(%d) "contents read"
+
+--file resource--
+Error: 2 - file_get_contents(): supplied resource is not a valid Stream-Context resource, %s(%d)
+string(%d) "contents read"
+
+--stream context--
+string(%d) "contents read"
+===DONE=== \ No newline at end of file
diff --git a/ext/standard/tests/file/file_get_contents_variation5.phpt b/ext/standard/tests/file/file_get_contents_variation5.phpt
new file mode 100644
index 0000000..ce88d3c
--- /dev/null
+++ b/ext/standard/tests/file/file_get_contents_variation5.phpt
@@ -0,0 +1,222 @@
+--TEST--
+Test file_get_contents() function : usage variation
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : string file_get_contents(string filename [, bool use_include_path [, resource context [, long offset [, long maxlen]]]])
+ * Description: Read the entire file into a string
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing file_get_contents() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$filename = 'FileGetContentsVar5.tmp';
+$absFile = dirname(__FILE__).'/'.$filename;
+$h = fopen($absFile,"w");
+fwrite($h, b"contents read");
+fclose($h);
+
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+ // int data
+ 'int 0' => 0,
+ 'int 1' => 1,
+ 'int 12345' => 12345,
+ 'int -12345' => -2345,
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float -10.5' => -10.5,
+ 'float 12.3456789000e10' => 12.3456789000e10,
+ 'float -12.3456789000e10' => -12.3456789000e10,
+ 'float .5' => .5,
+
+ // array data
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // string data
+ 'string DQ' => "string",
+ 'string SQ' => 'string',
+ 'mixed case string' => "sTrInG",
+ 'heredoc' => $heredoc,
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for offset
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( file_get_contents($absFile, false, null, $value) );
+};
+
+unlink($absFile);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing file_get_contents() : usage variation ***
+
+--int 0--
+string(%d) "contents read"
+
+--int 1--
+string(%d) "ontents read"
+
+--int 12345--
+string(%d) ""
+
+--int -12345--
+string(%d) "contents read"
+
+--float 10.5--
+string(3) "ead"
+
+--float -10.5--
+string(%d) "contents read"
+
+--float 12.3456789000e10--
+string(%d) %s
+
+--float -12.3456789000e10--
+string(%d) %s
+
+--float .5--
+string(%d) "contents read"
+
+--empty array--
+Error: 2 - file_get_contents() expects parameter 4 to be long, array given, %s(%d)
+NULL
+
+--int indexed array--
+Error: 2 - file_get_contents() expects parameter 4 to be long, array given, %s(%d)
+NULL
+
+--associative array--
+Error: 2 - file_get_contents() expects parameter 4 to be long, array given, %s(%d)
+NULL
+
+--nested arrays--
+Error: 2 - file_get_contents() expects parameter 4 to be long, array given, %s(%d)
+NULL
+
+--uppercase NULL--
+string(%d) "contents read"
+
+--lowercase null--
+string(%d) "contents read"
+
+--lowercase true--
+string(12) "ontents read"
+
+--lowercase false--
+string(%d) "contents read"
+
+--uppercase TRUE--
+string(12) "ontents read"
+
+--uppercase FALSE--
+string(%d) "contents read"
+
+--empty string DQ--
+Error: 2 - file_get_contents() expects parameter 4 to be long, %unicode_string_optional% given, %s(%d)
+NULL
+
+--empty string SQ--
+Error: 2 - file_get_contents() expects parameter 4 to be long, %unicode_string_optional% given, %s(%d)
+NULL
+
+--string DQ--
+Error: 2 - file_get_contents() expects parameter 4 to be long, %unicode_string_optional% given, %s(%d)
+NULL
+
+--string SQ--
+Error: 2 - file_get_contents() expects parameter 4 to be long, %unicode_string_optional% given, %s(%d)
+NULL
+
+--mixed case string--
+Error: 2 - file_get_contents() expects parameter 4 to be long, %unicode_string_optional% given, %s(%d)
+NULL
+
+--heredoc--
+Error: 2 - file_get_contents() expects parameter 4 to be long, %unicode_string_optional% given, %s(%d)
+NULL
+
+--instance of classWithToString--
+Error: 2 - file_get_contents() expects parameter 4 to be long, object given, %s(%d)
+NULL
+
+--instance of classWithoutToString--
+Error: 2 - file_get_contents() expects parameter 4 to be long, object given, %s(%d)
+NULL
+
+--undefined var--
+string(%d) "contents read"
+
+--unset var--
+string(%d) "contents read"
+===DONE===
diff --git a/ext/standard/tests/file/file_get_contents_variation6.phpt b/ext/standard/tests/file/file_get_contents_variation6.phpt
new file mode 100644
index 0000000..6795e01
--- /dev/null
+++ b/ext/standard/tests/file/file_get_contents_variation6.phpt
@@ -0,0 +1,215 @@
+--TEST--
+Test file_get_contents() function : usage variation
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : string file_get_contents(string filename [, bool use_include_path [, resource context [, long offset [, long maxlen]]]])
+ * Description: Read the entire file into a string
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing file_get_contents() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$filename = 'FileGetContentsVar5.tmp';
+$absFile = dirname(__FILE__).'/'.$filename;
+$h = fopen($absFile,"w");
+fwrite($h, "contents read");
+fclose($h);
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+ // int data
+ 'int 0' => 0,
+ 'int 1' => 1,
+ 'int 12345' => 12345,
+ 'int -12345' => -2345,
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float -10.5' => -10.5,
+ 'float .5' => .5,
+
+ // array data
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // string data
+ 'string DQ' => "string",
+ 'string SQ' => 'string',
+ 'mixed case string' => "sTrInG",
+ 'heredoc' => $heredoc,
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for maxlen
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( file_get_contents($absFile, false, null, 0, $value) );
+};
+
+unlink($absFile);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing file_get_contents() : usage variation ***
+
+--int 0--
+string(%d) ""
+
+--int 1--
+string(%d) "c"
+
+--int 12345--
+string(%d) "contents read"
+
+--int -12345--
+Error: 2 - file_get_contents(): length must be greater than or equal to zero, %s(%d)
+bool(false)
+
+--float 10.5--
+string(%d) "contents r"
+
+--float -10.5--
+Error: 2 - file_get_contents(): length must be greater than or equal to zero, %s(%d)
+bool(false)
+
+--float .5--
+string(%d) ""
+
+--empty array--
+Error: 2 - file_get_contents() expects parameter 5 to be long, array given, %s(%d)
+NULL
+
+--int indexed array--
+Error: 2 - file_get_contents() expects parameter 5 to be long, array given, %s(%d)
+NULL
+
+--associative array--
+Error: 2 - file_get_contents() expects parameter 5 to be long, array given, %s(%d)
+NULL
+
+--nested arrays--
+Error: 2 - file_get_contents() expects parameter 5 to be long, array given, %s(%d)
+NULL
+
+--uppercase NULL--
+string(%d) ""
+
+--lowercase null--
+string(%d) ""
+
+--lowercase true--
+string(%d) "c"
+
+--lowercase false--
+string(%d) ""
+
+--uppercase TRUE--
+string(%d) "c"
+
+--uppercase FALSE--
+string(%d) ""
+
+--empty string DQ--
+Error: 2 - file_get_contents() expects parameter 5 to be long, string given, %s(%d)
+NULL
+
+--empty string SQ--
+Error: 2 - file_get_contents() expects parameter 5 to be long, string given, %s(%d)
+NULL
+
+--string DQ--
+Error: 2 - file_get_contents() expects parameter 5 to be long, string given, %s(%d)
+NULL
+
+--string SQ--
+Error: 2 - file_get_contents() expects parameter 5 to be long, string given, %s(%d)
+NULL
+
+--mixed case string--
+Error: 2 - file_get_contents() expects parameter 5 to be long, string given, %s(%d)
+NULL
+
+--heredoc--
+Error: 2 - file_get_contents() expects parameter 5 to be long, string given, %s(%d)
+NULL
+
+--instance of classWithToString--
+Error: 2 - file_get_contents() expects parameter 5 to be long, object given, %s(%d)
+NULL
+
+--instance of classWithoutToString--
+Error: 2 - file_get_contents() expects parameter 5 to be long, object given, %s(%d)
+NULL
+
+--undefined var--
+string(%d) ""
+
+--unset var--
+string(%d) ""
+===DONE===
diff --git a/ext/standard/tests/file/file_get_contents_variation7-win32.phpt b/ext/standard/tests/file/file_get_contents_variation7-win32.phpt
new file mode 100644
index 0000000..d350b4b
--- /dev/null
+++ b/ext/standard/tests/file/file_get_contents_variation7-win32.phpt
@@ -0,0 +1,115 @@
+--TEST--
+Test file_get_contents() function : variation - various absolute and relative paths
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+ die("skip Only run on Windows");
+?>
+--FILE--
+<?php
+/* Prototype : string file_get_contents(string filename [, bool use_include_path [, resource context [, long offset [, long maxlen]]]])
+ * Description: Read the entire file into a string
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing file_get_contents() : variation ***\n";
+$mainDir = "fileGetContentsVar7.dir";
+$subDir = "fileGetContentsVar7Sub";
+$absMainDir = dirname(__FILE__)."\\".$mainDir;
+mkdir($absMainDir);
+$absSubDir = $absMainDir."\\".$subDir;
+mkdir($absSubDir);
+
+$old_dir_path = getcwd();
+chdir(dirname(__FILE__));
+$unixifiedDir = '/'.substr(str_replace('\\','/',$absSubDir),3);
+
+$allDirs = array(
+ // absolute paths
+ "$absSubDir\\",
+ "$absSubDir\\..\\".$subDir,
+ "$absSubDir\\\\..\\.\\".$subDir,
+ "$absSubDir\\..\\..\\".$mainDir."\\.\\".$subDir,
+ "$absSubDir\\..\\\\\\".$subDir."\\\\..\\\\..\\".$subDir,
+ "$absSubDir\\BADDIR",
+
+ // relative paths
+ $mainDir."\\".$subDir,
+ $mainDir."\\\\".$subDir,
+ $mainDir."\\\\\\".$subDir,
+ ".\\".$mainDir."\\..\\".$mainDir."\\".$subDir,
+ "BADDIR",
+
+ // unixifed path
+ $unixifiedDir,
+);
+
+$filename = 'FileGetContentsVar7.tmp';
+$absFile = $absSubDir.'/'.$filename;
+$h = fopen($absFile,"w");
+fwrite($h, "contents read");
+fclose($h);
+
+for($i = 0; $i<count($allDirs); $i++) {
+ $j = $i+1;
+ $dir = $allDirs[$i];
+ echo "\n-- Iteration $j --\n";
+ var_dump(file_get_contents($dir."\\".$filename));
+}
+
+unlink($absFile);
+chdir($old_dir_path);
+rmdir($absSubDir);
+rmdir($absMainDir);
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing file_get_contents() : variation ***
+
+-- Iteration 1 --
+string(%d) "contents read"
+
+-- Iteration 2 --
+string(%d) "contents read"
+
+-- Iteration 3 --
+string(%d) "contents read"
+
+-- Iteration 4 --
+string(%d) "contents read"
+
+-- Iteration 5 --
+
+Warning: file_get_contents(%sfileGetContentsVar7.dir\fileGetContentsVar7Sub\..\\\fileGetContentsVar7Sub\\..\\..\fileGetContentsVar7Sub\FileGetContentsVar7.tmp): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+-- Iteration 6 --
+
+Warning: file_get_contents(%sfileGetContentsVar7.dir\fileGetContentsVar7Sub\BADDIR\FileGetContentsVar7.tmp): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+-- Iteration 7 --
+string(%d) "contents read"
+
+-- Iteration 8 --
+string(%d) "contents read"
+
+-- Iteration 9 --
+string(%d) "contents read"
+
+-- Iteration 10 --
+string(%d) "contents read"
+
+-- Iteration 11 --
+
+Warning: file_get_contents(BADDIR\FileGetContentsVar7.tmp): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+-- Iteration 12 --
+string(%d) "contents read"
+
+*** Done *** \ No newline at end of file
diff --git a/ext/standard/tests/file/file_get_contents_variation7.phpt b/ext/standard/tests/file/file_get_contents_variation7.phpt
new file mode 100644
index 0000000..17c55b6
--- /dev/null
+++ b/ext/standard/tests/file/file_get_contents_variation7.phpt
@@ -0,0 +1,104 @@
+--TEST--
+Test file_get_contents() function : variation - various absolute and relative paths
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : string file_get_contents(string filename [, bool use_include_path [, resource context [, long offset [, long maxlen]]]])
+ * Description: Read the entire file into a string
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing file_get_contents() : variation ***\n";
+$mainDir = "fileGetContentsVar7.dir";
+$subDir = "fileGetContentsVar7Sub";
+$absMainDir = dirname(__FILE__)."/".$mainDir;
+mkdir($absMainDir);
+$absSubDir = $absMainDir."/".$subDir;
+mkdir($absSubDir);
+
+$old_dir_path = getcwd();
+chdir(dirname(__FILE__));
+
+$allDirs = array(
+ // absolute paths
+ "$absSubDir/",
+ "$absSubDir/../".$subDir,
+ "$absSubDir//.././".$subDir,
+ "$absSubDir/../../".$mainDir."/./".$subDir,
+ "$absSubDir/..///".$subDir."//..//../".$subDir,
+ "$absSubDir/BADDIR",
+
+ // relative paths
+ $mainDir."/".$subDir,
+ $mainDir."//".$subDir,
+ $mainDir."///".$subDir,
+ "./".$mainDir."/../".$mainDir."/".$subDir,
+ "BADDIR",
+
+);
+
+$filename = 'FileGetContentsVar7.tmp';
+$absFile = $absSubDir.'/'.$filename;
+$h = fopen($absFile,"w");
+fwrite($h, "contents read");
+fclose($h);
+
+for($i = 0; $i<count($allDirs); $i++) {
+ $j = $i+1;
+ $dir = $allDirs[$i];
+ echo "\n-- Iteration $j --\n";
+ var_dump(file_get_contents($dir."/".$filename));
+}
+
+chdir($old_dir_path);
+unlink($absFile);
+rmdir($absSubDir);
+rmdir($absMainDir);
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing file_get_contents() : variation ***
+
+-- Iteration 1 --
+string(%d) "contents read"
+
+-- Iteration 2 --
+string(%d) "contents read"
+
+-- Iteration 3 --
+string(%d) "contents read"
+
+-- Iteration 4 --
+string(%d) "contents read"
+
+-- Iteration 5 --
+
+Warning: file_get_contents(%sfileGetContentsVar7.dir/fileGetContentsVar7Sub/..///fileGetContentsVar7Sub//..//../fileGetContentsVar7Sub/FileGetContentsVar7.tmp): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+-- Iteration 6 --
+
+Warning: file_get_contents(%sfileGetContentsVar7.dir/fileGetContentsVar7Sub/BADDIR/FileGetContentsVar7.tmp): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+-- Iteration 7 --
+string(%d) "contents read"
+
+-- Iteration 8 --
+string(%d) "contents read"
+
+-- Iteration 9 --
+string(%d) "contents read"
+
+-- Iteration 10 --
+string(%d) "contents read"
+
+-- Iteration 11 --
+
+Warning: file_get_contents(BADDIR/FileGetContentsVar7.tmp): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+*** Done ***
diff --git a/ext/standard/tests/file/file_get_contents_variation8-win32.phpt b/ext/standard/tests/file/file_get_contents_variation8-win32.phpt
new file mode 100644
index 0000000..bb62eb4
--- /dev/null
+++ b/ext/standard/tests/file/file_get_contents_variation8-win32.phpt
@@ -0,0 +1,98 @@
+--TEST--
+Test file_get_contents() function : variation - obscure filenames
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die("skip Valid only on Windows");
+}
+?>
+--FILE--
+<?php
+/* Prototype : string file_get_contents(string filename [, bool use_include_path [, resource context [, long offset [, long maxlen]]]])
+ * Description: Read the entire file into a string
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing file_get_contents() : variation ***\n";
+
+/* An array of filenames */
+$names_arr = array(
+ /* Invalid args */
+ "-1" => -1,
+ "TRUE" => TRUE,
+ "FALSE" => FALSE,
+ "NULL" => NULL,
+ "\"\"" => "",
+ "\" \"" => " ",
+ "\\0" => "\0",
+ "array()" => array(),
+
+ /* prefix with path separator of a non existing directory*/
+ "/no/such/file/dir" => "/no/such/file/dir",
+ "php/php"=> "php/php"
+
+);
+
+foreach($names_arr as $key =>$value) {
+ echo "\n-- Filename: $key --\n";
+ var_dump(file_get_contents($value));
+}
+
+?>
+===Done===
+--EXPECTF--
+*** Testing file_get_contents() : variation ***
+
+-- Filename: -1 --
+
+Warning: file_get_contents(-1): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+-- Filename: TRUE --
+
+Warning: file_get_contents(1): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+-- Filename: FALSE --
+
+Warning: file_get_contents(): Filename cannot be empty in %s on line %d
+bool(false)
+
+-- Filename: NULL --
+
+Warning: file_get_contents(): Filename cannot be empty in %sfile_get_contents_variation8-win32.php on line %d
+bool(false)
+
+-- Filename: "" --
+
+Warning: file_get_contents(): Filename cannot be empty in %s on line %d
+bool(false)
+
+-- Filename: " " --
+
+Warning: file_get_contents( ): failed to open stream: Permission denied in %s on line %d
+bool(false)
+
+-- Filename: \0 --
+
+Warning: file_get_contents() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+
+-- Filename: array() --
+
+Warning: file_get_contents() expects parameter 1 to be a valid path, array given in %s on line %d
+NULL
+
+-- Filename: /no/such/file/dir --
+
+Warning: file_get_contents(/no/such/file/dir): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+-- Filename: php/php --
+
+Warning: file_get_contents(php/php): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+===Done===
diff --git a/ext/standard/tests/file/file_get_contents_variation8.phpt b/ext/standard/tests/file/file_get_contents_variation8.phpt
new file mode 100644
index 0000000..5b325b0
--- /dev/null
+++ b/ext/standard/tests/file/file_get_contents_variation8.phpt
@@ -0,0 +1,88 @@
+--TEST--
+Test file_get_contents() function : variation - obscure filenames
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. Not valid for Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype : string file_get_contents(string filename [, bool use_include_path [, resource context [, long offset [, long maxlen]]]])
+ * Description: Read the entire file into a string
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing file_get_contents() : variation ***\n";
+/* An array of filenames */
+$names_arr = array(
+ /* Invalid args */
+ -1,
+ TRUE,
+ FALSE,
+ NULL,
+ "",
+ " ",
+ "\0",
+ array(),
+
+ /* prefix with path separator of a non existing directory*/
+ "/no/such/file/dir",
+ "php/php"
+
+);
+
+for( $i=0; $i<count($names_arr); $i++ ) {
+ echo "-- Iteration $i --\n";
+ var_dump(file_get_contents($names_arr[$i]));
+}
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing file_get_contents() : variation ***
+-- Iteration 0 --
+
+Warning: file_get_contents(-1): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+-- Iteration 1 --
+
+Warning: file_get_contents(1): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+-- Iteration 2 --
+
+Warning: file_get_contents(): Filename cannot be empty in %s on line %d
+bool(false)
+-- Iteration 3 --
+
+Warning: file_get_contents(): Filename cannot be empty in %s on line %d
+bool(false)
+-- Iteration 4 --
+
+Warning: file_get_contents(): Filename cannot be empty in %s on line %d
+bool(false)
+-- Iteration 5 --
+
+Warning: file_get_contents( ): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+-- Iteration 6 --
+
+Warning: file_get_contents() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+-- Iteration 7 --
+
+Warning: file_get_contents() expects parameter 1 to be a valid path, array given in %s on line %d
+NULL
+-- Iteration 8 --
+
+Warning: file_get_contents(/no/such/file/dir): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+-- Iteration 9 --
+
+Warning: file_get_contents(php/php): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+*** Done ***
diff --git a/ext/standard/tests/file/file_get_contents_variation9.phpt b/ext/standard/tests/file/file_get_contents_variation9.phpt
new file mode 100644
index 0000000..99812b5
--- /dev/null
+++ b/ext/standard/tests/file/file_get_contents_variation9.phpt
@@ -0,0 +1,56 @@
+--TEST--
+Test file_get_contents() function : variation - linked files
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+ die("skip Do not run on Windows");
+?>
+--FILE--
+<?php
+/* Prototype : string file_get_contents(string filename [, bool use_include_path [, resource context [, long offset [, long maxlen]]]])
+ * Description: Read the entire file into a string
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing file_get_contents() : variation ***\n";
+$filename = dirname(__FILE__).'/fileGetContentsVar9.tmp';
+$softlink = dirname(__FILE__).'/fileGetContentsVar9.SoftLink';
+$hardlink = dirname(__FILE__).'/fileGetContentsVar9.HardLink';
+$chainlink = dirname(__FILE__).'/fileGetContentsVar9.ChainLink';
+
+// create file
+$h = fopen($filename,"w");
+//Data should be more than the size of a link.
+for ($i = 1; $i <= 10; $i++) {
+ fwrite($h, b"Here is a repeated amount of data");
+}
+fclose($h);
+
+// link files
+link($filename, $hardlink);
+symlink($filename, $softlink);
+symlink($softlink, $chainlink);
+
+// perform tests
+var_dump(file_get_contents($chainlink));
+var_dump(file_get_contents($softlink));
+var_dump(file_get_contents($hardlink));
+
+unlink($chainlink);
+unlink($softlink);
+unlink($hardlink);
+unlink($filename);
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing file_get_contents() : variation ***
+string(330) "Here is a repeated amount of dataHere is a repeated amount of dataHere is a repeated amount of dataHere is a repeated amount of dataHere is a repeated amount of dataHere is a repeated amount of dataHere is a repeated amount of dataHere is a repeated amount of dataHere is a repeated amount of dataHere is a repeated amount of data"
+string(330) "Here is a repeated amount of dataHere is a repeated amount of dataHere is a repeated amount of dataHere is a repeated amount of dataHere is a repeated amount of dataHere is a repeated amount of dataHere is a repeated amount of dataHere is a repeated amount of dataHere is a repeated amount of dataHere is a repeated amount of data"
+string(330) "Here is a repeated amount of dataHere is a repeated amount of dataHere is a repeated amount of dataHere is a repeated amount of dataHere is a repeated amount of dataHere is a repeated amount of dataHere is a repeated amount of dataHere is a repeated amount of dataHere is a repeated amount of dataHere is a repeated amount of data"
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/file_put_contents.phpt b/ext/standard/tests/file/file_put_contents.phpt
new file mode 100644
index 0000000..4566c37
--- /dev/null
+++ b/ext/standard/tests/file/file_put_contents.phpt
@@ -0,0 +1,32 @@
+--TEST--
+file_put_contents() and invalid parameters
+--FILE--
+<?php
+class foo {
+ function __toString() {
+ return __METHOD__;
+ }
+}
+$file = dirname(__FILE__)."/file_put_contents.txt";
+
+$context = stream_context_create();
+
+var_dump(file_put_contents($file, $context));
+var_dump(file_put_contents($file, new stdClass));
+var_dump(file_put_contents($file, new foo));
+$fp = fopen($file, "r");
+var_dump(file_put_contents($file, "string", 0, $fp));
+
+@unlink($file);
+
+echo "Done\n";
+?>
+--EXPECTF--
+Warning: file_put_contents(): supplied resource is not a valid stream resource in %s on line %d
+bool(false)
+bool(false)
+int(15)
+
+Warning: file_put_contents(): supplied resource is not a valid Stream-Context resource in %s on line %d
+int(6)
+Done
diff --git a/ext/standard/tests/file/file_put_contents_variation1.phpt b/ext/standard/tests/file/file_put_contents_variation1.phpt
new file mode 100644
index 0000000..35d1930
--- /dev/null
+++ b/ext/standard/tests/file/file_put_contents_variation1.phpt
@@ -0,0 +1,43 @@
+--TEST--
+Test file_put_contents() function : variation - test append flag
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : int file_put_contents(string file, mixed data [, int flags [, resource context]])
+ * Description: Write/Create a file with contents data and return the number of bytes written
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing file_put_contents() : variation ***\n";
+
+$filename = "FilePutContentsVar1.tmp";
+
+$data = "The first string to write";
+$extra = ", followed by this";
+
+var_dump(file_put_contents($filename, $data));
+var_dump(file_put_contents($filename, $extra, FILE_APPEND));
+echo filesize($filename)."\n";
+readfile($filename);
+echo "\n";
+clearstatcache();
+file_put_contents($filename, $data);
+echo filesize($filename)."\n";
+readfile($filename);
+echo "\n";
+unlink($filename);
+
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing file_put_contents() : variation ***
+int(25)
+int(18)
+43
+The first string to write, followed by this
+25
+The first string to write
+===DONE===
diff --git a/ext/standard/tests/file/file_put_contents_variation2.phpt b/ext/standard/tests/file/file_put_contents_variation2.phpt
new file mode 100644
index 0000000..753e287
--- /dev/null
+++ b/ext/standard/tests/file/file_put_contents_variation2.phpt
@@ -0,0 +1,167 @@
+--TEST--
+Test file_put_contents() function : usage variation - different data types to write
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : int file_put_contents(string file, mixed data [, int flags [, resource context]])
+ * Description: Write/Create a file with contents data and return the number of bytes written
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing file_put_contents() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+
+$filename = __DIR__ . '/fwriteVar5.tmp';
+
+
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+ // int data
+ 'int 0' => 0,
+ 'int 1' => 1,
+ 'int 12345' => 12345,
+ 'int -12345' => -2345,
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float -10.5' => -10.5,
+ 'float 12.3456789000e10' => 12.3456789000e10,
+ 'float -12.3456789000e10' => -12.3456789000e10,
+ 'float .5' => .5,
+
+ // array data
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for str
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ file_put_contents($filename, $value);
+ readfile($filename);
+};
+unlink($filename);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing file_put_contents() : usage variation ***
+
+--int 0--
+0
+--int 1--
+1
+--int 12345--
+12345
+--int -12345--
+-2345
+--float 10.5--
+10.5
+--float -10.5--
+-10.5
+--float 12.3456789000e10--
+123456789000
+--float -12.3456789000e10--
+-123456789000
+--float .5--
+0.5
+--empty array--
+
+--int indexed array--
+123
+--associative array--
+12
+--nested arrays--
+Error: 8 - Array to string conversion, %s(%d)
+Error: 8 - Array to string conversion, %s(%d)
+fooArrayArray
+--uppercase NULL--
+
+--lowercase null--
+
+--lowercase true--
+1
+--lowercase false--
+
+--uppercase TRUE--
+1
+--uppercase FALSE--
+
+--empty string DQ--
+
+--empty string SQ--
+
+--instance of classWithToString--
+Class A object
+--instance of classWithoutToString--
+
+--undefined var--
+
+--unset var--
+===DONE===
diff --git a/ext/standard/tests/file/file_put_contents_variation3.phpt b/ext/standard/tests/file/file_put_contents_variation3.phpt
new file mode 100644
index 0000000..e16f640
--- /dev/null
+++ b/ext/standard/tests/file/file_put_contents_variation3.phpt
@@ -0,0 +1,250 @@
+--TEST--
+Test file_put_contents() function : usage variation - different types for context.
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : int file_put_contents(string file, mixed data [, int flags [, resource context]])
+ * Description: Write/Create a file with contents data and return the number of bytes written
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing file_put_contents() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$filename = 'FilePutContentsVar4.tmp';
+$absFile = dirname(__FILE__).'/'.$filename;
+
+$fileRes = fopen(__FILE__,'r');
+$strContext = stream_context_create();
+
+$data = "data to write";
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+ // int data
+ 'int 0' => 0,
+ 'int 1' => 1,
+ 'int 12345' => 12345,
+ 'int -12345' => -2345,
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float -10.5' => -10.5,
+ 'float 12.3456789000e10' => 12.3456789000e10,
+ 'float -12.3456789000e10' => -12.3456789000e10,
+ 'float .5' => .5,
+
+ // array data
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // string data
+ 'string DQ' => "string",
+ 'string SQ' => 'string',
+ 'mixed case string' => "sTrInG",
+ 'heredoc' => $heredoc,
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+
+ //non context resource
+ 'file resource' => $fileRes,
+
+ //valid stream context
+ 'stream context' => $strContext,
+);
+
+// loop through each element of the array for context
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( file_put_contents($absFile, $data, null, $value) );
+};
+
+unlink($absFile);
+fclose($fileRes);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing file_put_contents() : usage variation ***
+
+--int 0--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, integer given, %s(%d)
+NULL
+
+--int 1--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, integer given, %s(%d)
+NULL
+
+--int 12345--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, integer given, %s(%d)
+NULL
+
+--int -12345--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, integer given, %s(%d)
+NULL
+
+--float 10.5--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, double given, %s(%d)
+NULL
+
+--float -10.5--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, double given, %s(%d)
+NULL
+
+--float 12.3456789000e10--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, double given, %s(%d)
+NULL
+
+--float -12.3456789000e10--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, double given, %s(%d)
+NULL
+
+--float .5--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, double given, %s(%d)
+NULL
+
+--empty array--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, array given, %s(%d)
+NULL
+
+--int indexed array--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, array given, %s(%d)
+NULL
+
+--associative array--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, array given, %s(%d)
+NULL
+
+--nested arrays--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, array given, %s(%d)
+NULL
+
+--uppercase NULL--
+int(13)
+
+--lowercase null--
+int(13)
+
+--lowercase true--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, boolean given, %s(%d)
+NULL
+
+--lowercase false--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, boolean given, %s(%d)
+NULL
+
+--uppercase TRUE--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, boolean given, %s(%d)
+NULL
+
+--uppercase FALSE--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, boolean given, %s(%d)
+NULL
+
+--empty string DQ--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, string given, %s(%d)
+NULL
+
+--empty string SQ--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, string given, %s(%d)
+NULL
+
+--string DQ--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, string given, %s(%d)
+NULL
+
+--string SQ--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, string given, %s(%d)
+NULL
+
+--mixed case string--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, string given, %s(%d)
+NULL
+
+--heredoc--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, string given, %s(%d)
+NULL
+
+--instance of classWithToString--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, object given, %s(%d)
+NULL
+
+--instance of classWithoutToString--
+Error: 2 - file_put_contents() expects parameter 4 to be resource, object given, %s(%d)
+NULL
+
+--undefined var--
+int(13)
+
+--unset var--
+int(13)
+
+--file resource--
+Error: 2 - file_put_contents(): supplied resource is not a valid Stream-Context resource, %s(%d)
+int(13)
+
+--stream context--
+int(13)
+===DONE=== \ No newline at end of file
diff --git a/ext/standard/tests/file/file_put_contents_variation4.phpt b/ext/standard/tests/file/file_put_contents_variation4.phpt
new file mode 100644
index 0000000..d919c4a
--- /dev/null
+++ b/ext/standard/tests/file/file_put_contents_variation4.phpt
@@ -0,0 +1,51 @@
+--TEST--
+Test file_put_contents() function : variation - include path testing
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : int file_put_contents(string file, mixed data [, int flags [, resource context]])
+ * Description: Write/Create a file with contents data and return the number of bytes written
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+
+require_once('fopen_include_path.inc');
+
+$thisTestDir = basename(__FILE__, ".php") . ".dir";
+mkdir($thisTestDir);
+chdir($thisTestDir);
+
+$filename = basename(__FILE__, ".php") . ".tmp";
+
+$newpath = create_include_path();
+set_include_path($newpath);
+runtest();
+
+$newpath = generate_next_path();
+set_include_path($newpath);
+runtest();
+
+teardown_include_path();
+restore_include_path();
+chdir("..");
+rmdir($thisTestDir);
+
+
+function runtest() {
+ global $filename;
+ //correct php53 behaviour is to ingnore the FILE_USE_INCLUDE_PATH unless the file alread exists
+ // in the include path. In this case it doesn't so the file should be written in the current dir.
+ file_put_contents($filename, (binary) "File in include path", FILE_USE_INCLUDE_PATH);
+ $line = file_get_contents($filename);
+ echo "$line\n";
+ unlink($filename);
+}
+
+?>
+===DONE===
+--EXPECT--
+File in include path
+File in include path
+===DONE===
diff --git a/ext/standard/tests/file/file_put_contents_variation5.phpt b/ext/standard/tests/file/file_put_contents_variation5.phpt
new file mode 100644
index 0000000..4ecb521
--- /dev/null
+++ b/ext/standard/tests/file/file_put_contents_variation5.phpt
@@ -0,0 +1,51 @@
+--TEST--
+Test file_put_contents() function : variation - include path testing
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+
+
+$thisTestDir = dirname(__FILE__) . '/' .basename(__FILE__, ".php") . ".directory";
+mkdir($thisTestDir);
+chdir($thisTestDir);
+
+$filename = basename(__FILE__, ".php") . ".tmp";
+$scriptLocFile = dirname(__FILE__)."/".$filename;
+
+$newpath = "rubbish";
+set_include_path($newpath);
+runtest();
+$newpath = "";
+set_include_path($newpath);
+runtest();
+set_include_path(null);
+runtest();
+set_include_path(";; ; ;c:\\rubbish");
+runtest();
+
+chdir(dirname(__FILE__));
+rmdir($thisTestDir);
+
+
+function runtest() {
+ global $scriptLocFile, $filename;
+ file_put_contents($filename, (binary) "File written in working directory", FILE_USE_INCLUDE_PATH);
+ if(file_exists($scriptLocFile)) {
+ echo "Fail - this is PHP52 behaviour\n";
+ unlink($scriptLocFile);
+ }else {
+ $line = file_get_contents($filename);
+ echo "$line\n";
+ unlink($filename);
+ }
+}
+?>
+===DONE===
+--EXPECT--
+File written in working directory
+File written in working directory
+File written in working directory
+File written in working directory
+===DONE===
+
diff --git a/ext/standard/tests/file/file_put_contents_variation6.phpt b/ext/standard/tests/file/file_put_contents_variation6.phpt
new file mode 100644
index 0000000..aaea612
--- /dev/null
+++ b/ext/standard/tests/file/file_put_contents_variation6.phpt
@@ -0,0 +1,56 @@
+--TEST--
+Test file_put_contents() function : variation - include path testing
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : int file_put_contents(string file, mixed data [, int flags [, resource context]])
+ * Description: Write/Create a file with contents data and return the number of bytes written
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing file_put_contents() : variation ***\n";
+
+require_once('fopen_include_path.inc');
+
+$thisTestDir = basename(__FILE__, ".php") . ".dir";
+mkdir($thisTestDir);
+chdir($thisTestDir);
+
+$filename = basename(__FILE__, ".php") . ".tmp";
+
+$newpath = create_include_path();
+set_include_path($newpath);
+runtest();
+
+$newpath = generate_next_path();
+set_include_path($newpath);
+runtest();
+
+teardown_include_path();
+restore_include_path();
+chdir("..");
+rmdir($thisTestDir);
+
+
+function runtest() {
+ global $filename;
+
+ //correct php53 behaviour is to ignore the FILE_USE_INCLUDE_PATH unless the file already exists
+ // in the include path. In this case it doesn't so the file should be written in the current dir.
+
+ file_put_contents($filename, (binary) "File in include path", FILE_USE_INCLUDE_PATH);
+ file_put_contents($filename, (binary) ". This was appended", FILE_USE_INCLUDE_PATH | FILE_APPEND);
+ $line = file_get_contents($filename);
+ echo "$line\n";
+ unlink($filename);
+}
+
+?>
+===DONE===
+--EXPECT--
+*** Testing file_put_contents() : variation ***
+File in include path. This was appended
+File in include path. This was appended
+===DONE===
diff --git a/ext/standard/tests/file/file_put_contents_variation7-win32.phpt b/ext/standard/tests/file/file_put_contents_variation7-win32.phpt
new file mode 100644
index 0000000..d7bfdf9
--- /dev/null
+++ b/ext/standard/tests/file/file_put_contents_variation7-win32.phpt
@@ -0,0 +1,130 @@
+--TEST--
+Test file_put_contents() function : usage variation - various absolute and relative paths
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+ die("skip Only run on Windows");
+?>
+--FILE--
+<?php
+/* Prototype : int file_put_contents(string file, mixed data [, int flags [, resource context]])
+ * Description: Write/Create a file with contents data and return the number of bytes written
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing file_put_contents() : usage variation ***\n";
+
+$mainDir = "filePutContentsVar7.dir";
+$subDir = "filePutContentsVar7Sub";
+$absMainDir = dirname(__FILE__)."/".$mainDir;
+mkdir($absMainDir);
+$absSubDir = $absMainDir."\\".$subDir;
+mkdir($absSubDir);
+
+$old_dir_path = getcwd();
+chdir(dirname(__FILE__));
+$unixifiedDir = '/'.substr(str_replace('\\','/',$absSubDir),3);
+
+
+// Note invalid dirs in p8 result in (The system cannot find the path specified.)
+// rather than No Such File or Directory in php.net
+$allDirs = array(
+ // absolute paths
+ "$absSubDir\\",
+ "$absSubDir\\..\\".$subDir,
+ "$absSubDir\\\\..\\.\\".$subDir,
+ "$absSubDir\\..\\..\\".$mainDir."\\.\\".$subDir,
+ "$absSubDir\\..\\\\\\".$subDir."\\\\..\\\\..\\".$subDir,
+ "$absSubDir\\BADDIR",
+
+ // relative paths
+ $mainDir."\\".$subDir,
+ $mainDir."\\\\".$subDir,
+ $mainDir."\\\\\\".$subDir,
+ ".\\".$mainDir."\\..\\".$mainDir."\\".$subDir,
+ "BADDIR",
+
+ // unixifed path
+ $unixifiedDir,
+);
+
+$filename = 'FileGetContentsVar7.tmp';
+$absFile = $absSubDir.'/'.$filename;
+$data = "This was the written data";
+
+for($i = 0; $i<count($allDirs); $i++) {
+ $j = $i+1;
+ $dir = $allDirs[$i];
+ echo "\n-- Iteration $j --\n";
+ $res = file_put_contents($dir."\\".$filename, ($data + $i));
+ if ($res !== false) {
+ $in = file_get_contents($absFile);
+ if ($in == ($data + $i)) {
+ echo "Data written correctly\n";
+ }
+ else {
+ echo "Data not written correctly or to correct place\n";
+ }
+ unlink($dir."/".$filename);
+ }
+ else {
+ echo "No data written\n";
+ }
+
+}
+
+chdir($old_dir_path);
+rmdir($absSubDir);
+rmdir($absMainDir);
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing file_put_contents() : usage variation ***
+
+-- Iteration 1 --
+Data written correctly
+
+-- Iteration 2 --
+Data written correctly
+
+-- Iteration 3 --
+Data written correctly
+
+-- Iteration 4 --
+Data written correctly
+
+-- Iteration 5 --
+
+Warning: file_put_contents(%sfilePutContentsVar7.dir\filePutContentsVar7Sub\..\\\filePutContentsVar7Sub\\..\\..\filePutContentsVar7Sub\FileGetContentsVar7.tmp): failed to open stream: %s in %s on line %d
+No data written
+
+-- Iteration 6 --
+
+Warning: file_put_contents(%sfilePutContentsVar7.dir\filePutContentsVar7Sub\BADDIR\FileGetContentsVar7.tmp): failed to open stream: %s in %s on line %d
+No data written
+
+-- Iteration 7 --
+Data written correctly
+
+-- Iteration 8 --
+Data written correctly
+
+-- Iteration 9 --
+Data written correctly
+
+-- Iteration 10 --
+Data written correctly
+
+-- Iteration 11 --
+
+Warning: file_put_contents(BADDIR\FileGetContentsVar7.tmp): failed to open stream: %s in %s on line %d
+No data written
+
+-- Iteration 12 --
+Data written correctly
+
+*** Done *** \ No newline at end of file
diff --git a/ext/standard/tests/file/file_put_contents_variation7.phpt b/ext/standard/tests/file/file_put_contents_variation7.phpt
new file mode 100644
index 0000000..5c8e5f3
--- /dev/null
+++ b/ext/standard/tests/file/file_put_contents_variation7.phpt
@@ -0,0 +1,119 @@
+--TEST--
+Test file_put_contents() function : usage variation - various absolute and relative paths
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : int file_put_contents(string file, mixed data [, int flags [, resource context]])
+ * Description: Write/Create a file with contents data and return the number of bytes written
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing file_put_contents() : usage variation ***\n";
+
+$mainDir = "filePutContentsVar7.dir";
+$subDir = "filePutContentsVar7Sub";
+$absMainDir = dirname(__FILE__)."/".$mainDir;
+mkdir($absMainDir);
+$absSubDir = $absMainDir."/".$subDir;
+mkdir($absSubDir);
+
+$old_dir_path = getcwd();
+chdir(dirname(__FILE__));
+
+
+// Note invalid dirs in p8 result in (The system cannot find the path specified.)
+// rather than No Such File or Directory in php.net
+$allDirs = array(
+ // absolute paths
+ "$absSubDir/",
+ "$absSubDir/../".$subDir,
+ "$absSubDir//.././".$subDir,
+ "$absSubDir/../../".$mainDir."/./".$subDir,
+ "$absSubDir/..///".$subDir."//..//../".$subDir,
+ "$absSubDir/BADDIR",
+
+ // relative paths
+ $mainDir."/".$subDir,
+ $mainDir."//".$subDir,
+ $mainDir."///".$subDir,
+ "./".$mainDir."/../".$mainDir."/".$subDir,
+ "BADDIR",
+
+);
+
+$filename = 'FileGetContentsVar7.tmp';
+$absFile = $absSubDir.'/'.$filename;
+$data = "This was the written data";
+
+for($i = 0; $i<count($allDirs); $i++) {
+ $j = $i+1;
+ $dir = $allDirs[$i];
+ echo "\n-- Iteration $j --\n";
+ $res = file_put_contents($dir."/".$filename, ($data + $i));
+ if ($res !== false) {
+ $in = file_get_contents($absFile);
+ if ($in == ($data + $i)) {
+ echo "Data written correctly\n";
+ }
+ else {
+ echo "Data not written correctly or to correct place\n";
+ }
+ unlink($dir."/".$filename);
+ }
+ else {
+ echo "No data written\n";
+ }
+
+}
+
+chdir($old_dir_path);
+rmdir($absSubDir);
+rmdir($absMainDir);
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing file_put_contents() : usage variation ***
+
+-- Iteration 1 --
+Data written correctly
+
+-- Iteration 2 --
+Data written correctly
+
+-- Iteration 3 --
+Data written correctly
+
+-- Iteration 4 --
+Data written correctly
+
+-- Iteration 5 --
+
+Warning: file_put_contents(%sfilePutContentsVar7.dir/filePutContentsVar7Sub/..///filePutContentsVar7Sub//..//../filePutContentsVar7Sub/FileGetContentsVar7.tmp): failed to open stream: %s in %s on line %d
+No data written
+
+-- Iteration 6 --
+
+Warning: file_put_contents(%sfilePutContentsVar7.dir/filePutContentsVar7Sub/BADDIR/FileGetContentsVar7.tmp): failed to open stream: %s in %s on line %d
+No data written
+
+-- Iteration 7 --
+Data written correctly
+
+-- Iteration 8 --
+Data written correctly
+
+-- Iteration 9 --
+Data written correctly
+
+-- Iteration 10 --
+Data written correctly
+
+-- Iteration 11 --
+
+Warning: file_put_contents(BADDIR/FileGetContentsVar7.tmp): failed to open stream: %s in %s on line %d
+No data written
+
+*** Done *** \ No newline at end of file
diff --git a/ext/standard/tests/file/file_put_contents_variation8-win32.phpt b/ext/standard/tests/file/file_put_contents_variation8-win32.phpt
new file mode 100644
index 0000000..92fe7b3
--- /dev/null
+++ b/ext/standard/tests/file/file_put_contents_variation8-win32.phpt
@@ -0,0 +1,98 @@
+--TEST--
+Test file_put_contents() function : usage variation - obscure filenames
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+ die("skip Only run on Windows");
+?>
+--FILE--
+<?php
+/* Prototype : int file_put_contents(string file, mixed data [, int flags [, resource context]])
+ * Description: Write/Create a file with contents data and return the number of bytes written
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing file_put_contents() : usage variation ***\n";
+
+/* An array of filenames */
+$names_arr = array(
+ "-1" => -1,
+ "TRUE" => TRUE,
+ "FALSE" => FALSE,
+ "NULL" => NULL,
+ "\"\"" => "",
+ "\" \"" => " ",
+ "\\0" => "\0",
+ "array()" => array(),
+
+ /* prefix with path separator of a non existing directory*/
+ "/no/such/file/dir" => "/no/such/file/dir",
+ "php/php"=> "php/php"
+
+);
+
+foreach($names_arr as $key =>$value) {
+ echo "\n-- Filename: $key --\n";
+ $res = file_put_contents($value, "Some data");
+ if ($res !== false && $res != null) {
+ echo "$res bytes written to: $value\n";
+ unlink($value);
+ } else {
+ echo "Failed to write data to: $key\n";
+ }
+};
+
+?>
+===Done===
+--EXPECTF--
+*** Testing file_put_contents() : usage variation ***
+
+-- Filename: -1 --
+9 bytes written to: -1
+
+-- Filename: TRUE --
+9 bytes written to: 1
+
+-- Filename: FALSE --
+
+Warning: file_put_contents(): Filename cannot be empty in %s on line %d
+Failed to write data to: FALSE
+
+-- Filename: NULL --
+
+Warning: file_put_contents(): Filename cannot be empty in %s on line %d
+Failed to write data to: NULL
+
+-- Filename: "" --
+
+Warning: file_put_contents(): Filename cannot be empty in %s on line %d
+Failed to write data to: ""
+
+-- Filename: " " --
+
+Warning: file_put_contents( ): failed to open stream: Permission denied in %s on line %d
+Failed to write data to: " "
+
+-- Filename: \0 --
+
+Warning: file_put_contents() expects parameter 1 to be a valid path, string given in %s on line %d
+Failed to write data to: \0
+
+-- Filename: array() --
+
+Warning: file_put_contents() expects parameter 1 to be a valid path, array given in %s on line %d
+Failed to write data to: array()
+
+-- Filename: /no/such/file/dir --
+
+Warning: file_put_contents(/no/such/file/dir): failed to open stream: %s in %s on line %d
+Failed to write data to: /no/such/file/dir
+
+-- Filename: php/php --
+
+Warning: file_put_contents(php/php): failed to open stream: %s in %s on line %d
+Failed to write data to: php/php
+===Done===
diff --git a/ext/standard/tests/file/file_put_contents_variation8.phpt b/ext/standard/tests/file/file_put_contents_variation8.phpt
new file mode 100644
index 0000000..3cd92c5
--- /dev/null
+++ b/ext/standard/tests/file/file_put_contents_variation8.phpt
Binary files differ
diff --git a/ext/standard/tests/file/file_put_contents_variation9.phpt b/ext/standard/tests/file/file_put_contents_variation9.phpt
new file mode 100644
index 0000000..7ad09c4
--- /dev/null
+++ b/ext/standard/tests/file/file_put_contents_variation9.phpt
@@ -0,0 +1,70 @@
+--TEST--
+est file_put_contents() function : usage variation - linked files
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+ die("skip Do not run on Windows");
+?>
+--FILE--
+<?php
+/* Prototype : int file_put_contents(string file, mixed data [, int flags [, resource context]])
+ * Description: Write/Create a file with contents data and return the number of bytes written
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing file_put_contents() : usage variation ***\n";
+
+$filename = dirname(__FILE__).'/fileGetContentsVar9.tmp';
+$softlink = dirname(__FILE__).'/fileGetContentsVar9.SoftLink';
+$hardlink = dirname(__FILE__).'/fileGetContentsVar9.HardLink';
+$chainlink = dirname(__FILE__).'/fileGetContentsVar9.ChainLink';
+
+
+// link files even though it original file doesn't exist yet
+symlink($filename, $softlink);
+symlink($softlink, $chainlink);
+
+
+// perform tests
+run_test($chainlink);
+run_test($softlink);
+
+//can only create a hardlink if the file exists.
+file_put_contents($filename,"");
+link($filename, $hardlink);
+run_test($hardlink);
+
+unlink($chainlink);
+unlink($softlink);
+unlink($hardlink);
+unlink($filename);
+
+
+function run_test($file) {
+ $data = "Here is some data";
+ $extra = ", more data";
+ var_dump(file_put_contents($file, $data));
+ var_dump(file_put_contents($file, $extra, FILE_APPEND));
+ readfile($file);
+ echo "\n";
+}
+
+
+echo "\n*** Done ***\n";
+?>
+--EXPECT--
+*** Testing file_put_contents() : usage variation ***
+int(17)
+int(11)
+Here is some data, more data
+int(17)
+int(11)
+Here is some data, more data
+int(17)
+int(11)
+Here is some data, more data
+
+*** Done ***
diff --git a/ext/standard/tests/file/file_variation.phpt b/ext/standard/tests/file/file_variation.phpt
new file mode 100644
index 0000000..512d5f3
--- /dev/null
+++ b/ext/standard/tests/file/file_variation.phpt
@@ -0,0 +1,160 @@
+--TEST--
+Test file() function : usage variations
+--FILE--
+<?php
+/*
+ * Prototype: array file ( string filename [,int use-include_path [,resource context]] );
+ * Description: Reads entire file into an array
+ Returns the file in an array
+ */
+require(dirname(__FILE__) . '/file.inc');
+
+$data_array = array( "Garbage data", "Gar\nba\nge d\nata", "Gar\n\nbage \n\n data" );
+echo "*** Using various flags values with different data in a file\n";
+$count=1;
+$file_path = dirname(__FILE__);
+foreach( $data_array as $data ) {
+ echo "--Iteration $count --\n";
+ $fh = fopen($file_path."/file_variation.tmp", "w");
+ fwrite($fh, (binary)$data);
+ var_dump( file($file_path."/file_variation.tmp", FILE_IGNORE_NEW_LINES) );
+ var_dump( file($file_path."/file_variation.tmp", FILE_SKIP_EMPTY_LINES) );
+ $count++;
+ fclose($fh);
+}
+
+echo "*** Testing with variation in use_include_path argument ***\n";
+$file_path1 = dirname(__FILE__)."/file_variation";
+mkdir($file_path1);
+ini_set( 'include_path',$file_path.'/file_variation' );
+
+file_put_contents( $file_path1."/file1_variation.tmp", "aaaaaaaaaaaaaaabbbbbbbbbbb111111111222222222" );
+var_dump( file("file1_variation.tmp", FILE_USE_INCLUDE_PATH) );
+var_dump( file($file_path1."/file1_variation.tmp", 1) );
+
+echo "*** Using file function to remove line containing a key string ***\n";
+$file_handle = fopen($file_path."/file2_variation.tmp", "w");
+$key = "SEARCH_KEY";
+fwrite( $file_handle, (binary)"The key string to be searched is SEARCH_KEY\nLine without key string\nThe key string to be searched is SEARCH_KEY" );
+$out_array = file($file_path."/file2_variation.tmp");
+
+echo "File contents in array form Before replacement of the key\n";
+var_dump( $out_array );
+$file_handle2 = fopen($file_path."/file3_variation.tmp", "w");
+// Loop through file content array
+foreach($out_array as $line) {
+ if( !strstr( $line, $key ) )
+ fputs($file_handle2,$line);
+}
+echo "File contents in array form After replacement of the key\n";
+var_dump( file($file_path."/file3_variation.tmp" ));
+fclose($file_handle);
+fclose($file_handle2);
+
+echo "\n--- Done ---";
+?>
+
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/file_variation.tmp");
+unlink($file_path."/file_variation/file1_variation.tmp");
+unlink($file_path."/file2_variation.tmp");
+unlink($file_path."/file3_variation.tmp");
+rmdir($file_path."/file_variation");
+
+?>
+--EXPECTF--
+*** Using various flags values with different data in a file
+--Iteration 1 --
+array(1) {
+ [0]=>
+ string(12) "Garbage data"
+}
+array(1) {
+ [0]=>
+ string(12) "Garbage data"
+}
+--Iteration 2 --
+array(4) {
+ [0]=>
+ string(3) "Gar"
+ [1]=>
+ string(2) "ba"
+ [2]=>
+ string(4) "ge d"
+ [3]=>
+ string(3) "ata"
+}
+array(4) {
+ [0]=>
+ string(4) "Gar
+"
+ [1]=>
+ string(3) "ba
+"
+ [2]=>
+ string(5) "ge d
+"
+ [3]=>
+ string(3) "ata"
+}
+--Iteration 3 --
+array(5) {
+ [0]=>
+ string(3) "Gar"
+ [1]=>
+ string(0) ""
+ [2]=>
+ string(5) "bage "
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(5) " data"
+}
+array(5) {
+ [0]=>
+ string(4) "Gar
+"
+ [1]=>
+ string(1) "
+"
+ [2]=>
+ string(6) "bage
+"
+ [3]=>
+ string(1) "
+"
+ [4]=>
+ string(5) " data"
+}
+*** Testing with variation in use_include_path argument ***
+array(1) {
+ [0]=>
+ string(44) "aaaaaaaaaaaaaaabbbbbbbbbbb111111111222222222"
+}
+array(1) {
+ [0]=>
+ string(44) "aaaaaaaaaaaaaaabbbbbbbbbbb111111111222222222"
+}
+*** Using file function to remove line containing a key string ***
+File contents in array form Before replacement of the key
+array(3) {
+ [0]=>
+ string(44) "The key string to be searched is SEARCH_KEY
+"
+ [1]=>
+ string(24) "Line without key string
+"
+ [2]=>
+ string(43) "The key string to be searched is SEARCH_KEY"
+}
+File contents in array form After replacement of the key
+array(1) {
+ [0]=>
+ string(24) "Line without key string
+"
+}
+
+--- Done ---
+
diff --git a/ext/standard/tests/file/file_variation2.phpt b/ext/standard/tests/file/file_variation2.phpt
new file mode 100644
index 0000000..ab37ea5
--- /dev/null
+++ b/ext/standard/tests/file/file_variation2.phpt
@@ -0,0 +1,210 @@
+--TEST--
+Test file() function : first parameter variation
+--FILE--
+<?php
+/* Prototype : array file(string filename [, int flags[, resource context]])
+ * Description: Read entire file into an array
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing file() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted
+$flags = 0;
+$context = stream_context_create();
+
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+ // int data
+ 'int 0' => 0,
+ 'int 1' => 1,
+ 'int 12345' => 12345,
+ 'int -12345' => -2345,
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float -10.5' => -10.5,
+ 'float 12.3456789000e10' => 12.3456789000e10,
+ 'float -12.3456789000e10' => -12.3456789000e10,
+ 'float .5' => .5,
+
+ // array data
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for filename
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( file($value, $flags, $context) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing file() : usage variation ***
+
+--int 0--
+Error: 2 - file(0): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--int 1--
+Error: 2 - file(1): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--int 12345--
+Error: 2 - file(12345): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--int -12345--
+Error: 2 - file(-2345): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--float 10.5--
+Error: 2 - file(10.5): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--float -10.5--
+Error: 2 - file(-10.5): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--float 12.3456789000e10--
+Error: 2 - file(123456789000): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--float -12.3456789000e10--
+Error: 2 - file(-123456789000): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--float .5--
+Error: 2 - file(0.5): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--empty array--
+Error: 2 - file() expects parameter 1 to be a valid path, array given, %s(%d)
+NULL
+
+--int indexed array--
+Error: 2 - file() expects parameter 1 to be a valid path, array given, %s(%d)
+NULL
+
+--associative array--
+Error: 2 - file() expects parameter 1 to be a valid path, array given, %s(%d)
+NULL
+
+--nested arrays--
+Error: 2 - file() expects parameter 1 to be a valid path, array given, %s(%d)
+NULL
+
+--uppercase NULL--
+Error: 2 - file(): Filename cannot be empty, %s(%d)
+bool(false)
+
+--lowercase null--
+Error: 2 - file(): Filename cannot be empty, %s(%d)
+bool(false)
+
+--lowercase true--
+Error: 2 - file(1): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--lowercase false--
+Error: 2 - file(): Filename cannot be empty, %s(%d)
+bool(false)
+
+--uppercase TRUE--
+Error: 2 - file(1): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--uppercase FALSE--
+Error: 2 - file(): Filename cannot be empty, %s(%d)
+bool(false)
+
+--empty string DQ--
+Error: 2 - file(): Filename cannot be empty, %s(%d)
+bool(false)
+
+--empty string SQ--
+Error: 2 - file(): Filename cannot be empty, %s(%d)
+bool(false)
+
+--instance of classWithToString--
+Error: 2 - file(Class A object): failed to open stream: %s, %s(%d)
+bool(false)
+
+--instance of classWithoutToString--
+Error: 2 - file() expects parameter 1 to be a valid path, object given, %s(%d)
+NULL
+
+--undefined var--
+Error: 2 - file(): Filename cannot be empty, %s(%d)
+bool(false)
+
+--unset var--
+Error: 2 - file(): Filename cannot be empty, %s(%d)
+bool(false)
+===DONE===
diff --git a/ext/standard/tests/file/file_variation3.phpt b/ext/standard/tests/file/file_variation3.phpt
new file mode 100644
index 0000000..1dd8520
--- /dev/null
+++ b/ext/standard/tests/file/file_variation3.phpt
@@ -0,0 +1,294 @@
+--TEST--
+Test file() function : second parameter variation
+--FILE--
+<?php
+/* Prototype : array file(string filename [, int flags[, resource context]])
+ * Description: Read entire file into an array
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing file() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted
+$filename = __FILE__ . ".tmp";
+$fd = fopen($filename, "w+");
+fwrite($fd, "Line 1\nLine 2\nLine 3");
+fclose($fd);
+
+$context = stream_context_create();
+
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float -10.5' => -10.5,
+ 'float 12.3456789000e10' => 12.3456789000e10,
+ 'float -12.3456789000e10' => -12.3456789000e10,
+ 'float .5' => .5,
+
+ // array data
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // string data
+ 'string DQ' => "string",
+ 'string SQ' => 'string',
+ 'mixed case string' => "sTrInG",
+ 'heredoc' => $heredoc,
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for flags
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( file($filename, $value, $context) );
+};
+
+unlink(__FILE__ . ".tmp");
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing file() : usage variation ***
+
+--float 10.5--
+array(3) {
+ [0]=>
+ string(6) "Line 1"
+ [1]=>
+ string(6) "Line 2"
+ [2]=>
+ string(6) "Line 3"
+}
+
+--float -10.5--
+Error: 2 - file(): '-10' flag is not supported, %s(%d)
+bool(false)
+
+--float 12.3456789000e10--
+Error: 2 - file(): '%i' flag is not supported, %s(%d)
+bool(false)
+
+--float -12.3456789000e10--
+Error: 2 - file(): '%i' flag is not supported, %s(%d)
+bool(false)
+
+--float .5--
+array(3) {
+ [0]=>
+ string(7) "Line 1
+"
+ [1]=>
+ string(7) "Line 2
+"
+ [2]=>
+ string(6) "Line 3"
+}
+
+--empty array--
+Error: 2 - file() expects parameter 2 to be long, array given, %s(%d)
+NULL
+
+--int indexed array--
+Error: 2 - file() expects parameter 2 to be long, array given, %s(%d)
+NULL
+
+--associative array--
+Error: 2 - file() expects parameter 2 to be long, array given, %s(%d)
+NULL
+
+--nested arrays--
+Error: 2 - file() expects parameter 2 to be long, array given, %s(%d)
+NULL
+
+--uppercase NULL--
+array(3) {
+ [0]=>
+ string(7) "Line 1
+"
+ [1]=>
+ string(7) "Line 2
+"
+ [2]=>
+ string(6) "Line 3"
+}
+
+--lowercase null--
+array(3) {
+ [0]=>
+ string(7) "Line 1
+"
+ [1]=>
+ string(7) "Line 2
+"
+ [2]=>
+ string(6) "Line 3"
+}
+
+--lowercase true--
+array(3) {
+ [0]=>
+ string(7) "Line 1
+"
+ [1]=>
+ string(7) "Line 2
+"
+ [2]=>
+ string(6) "Line 3"
+}
+
+--lowercase false--
+array(3) {
+ [0]=>
+ string(7) "Line 1
+"
+ [1]=>
+ string(7) "Line 2
+"
+ [2]=>
+ string(6) "Line 3"
+}
+
+--uppercase TRUE--
+array(3) {
+ [0]=>
+ string(7) "Line 1
+"
+ [1]=>
+ string(7) "Line 2
+"
+ [2]=>
+ string(6) "Line 3"
+}
+
+--uppercase FALSE--
+array(3) {
+ [0]=>
+ string(7) "Line 1
+"
+ [1]=>
+ string(7) "Line 2
+"
+ [2]=>
+ string(6) "Line 3"
+}
+
+--empty string DQ--
+Error: 2 - file() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--empty string SQ--
+Error: 2 - file() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--string DQ--
+Error: 2 - file() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--string SQ--
+Error: 2 - file() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--mixed case string--
+Error: 2 - file() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--heredoc--
+Error: 2 - file() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--instance of classWithToString--
+Error: 2 - file() expects parameter 2 to be long, object given, %s(%d)
+NULL
+
+--instance of classWithoutToString--
+Error: 2 - file() expects parameter 2 to be long, object given, %s(%d)
+NULL
+
+--undefined var--
+array(3) {
+ [0]=>
+ string(7) "Line 1
+"
+ [1]=>
+ string(7) "Line 2
+"
+ [2]=>
+ string(6) "Line 3"
+}
+
+--unset var--
+array(3) {
+ [0]=>
+ string(7) "Line 1
+"
+ [1]=>
+ string(7) "Line 2
+"
+ [2]=>
+ string(6) "Line 3"
+}
+===DONE===
diff --git a/ext/standard/tests/file/file_variation4.phpt b/ext/standard/tests/file/file_variation4.phpt
new file mode 100644
index 0000000..5010368
--- /dev/null
+++ b/ext/standard/tests/file/file_variation4.phpt
@@ -0,0 +1,291 @@
+--TEST--
+Test file() function : third parameter variation
+--FILE--
+<?php
+/* Prototype : array file(string filename [, int flags[, resource context]])
+ * Description: Read entire file into an array
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing file() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted
+$filename = __FILE__ . ".tmp";
+$fd = fopen($filename, "w+");
+fwrite($fd, "Line 1\nLine 2\nLine 3");
+fclose($fd);
+
+$flags = 0;
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+// create a file stream resource
+$tmp_filename = __FILE__ . ".tmp2";
+$file_stream_resource = fopen($tmp_filename, "w+");
+
+//array of values to iterate over
+$inputs = array(
+
+ // int data
+ 'int 0' => 0,
+ 'int 1' => 1,
+ 'int 12345' => 12345,
+ 'int -12345' => -2345,
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float -10.5' => -10.5,
+ 'float 12.3456789000e10' => 12.3456789000e10,
+ 'float -12.3456789000e10' => -12.3456789000e10,
+ 'float .5' => .5,
+
+ // array data
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // string data
+ 'string DQ' => "string",
+ 'string SQ' => 'string',
+ 'mixed case string' => "sTrInG",
+ 'heredoc' => $heredoc,
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+
+ // file stream resource
+ 'file stream resource' => $file_stream_resource,
+);
+
+// loop through each element of the array for context
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( file($filename, $flags, $value) );
+};
+
+fclose($file_stream_resource);
+unlink($tmp_filename);
+unlink($filename);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing file() : usage variation ***
+
+--int 0--
+Error: 2 - file() expects parameter 3 to be resource, integer given, %s(%d)
+NULL
+
+--int 1--
+Error: 2 - file() expects parameter 3 to be resource, integer given, %s(%d)
+NULL
+
+--int 12345--
+Error: 2 - file() expects parameter 3 to be resource, integer given, %s(%d)
+NULL
+
+--int -12345--
+Error: 2 - file() expects parameter 3 to be resource, integer given, %s(%d)
+NULL
+
+--float 10.5--
+Error: 2 - file() expects parameter 3 to be resource, double given, %s(%d)
+NULL
+
+--float -10.5--
+Error: 2 - file() expects parameter 3 to be resource, double given, %s(%d)
+NULL
+
+--float 12.3456789000e10--
+Error: 2 - file() expects parameter 3 to be resource, double given, %s(%d)
+NULL
+
+--float -12.3456789000e10--
+Error: 2 - file() expects parameter 3 to be resource, double given, %s(%d)
+NULL
+
+--float .5--
+Error: 2 - file() expects parameter 3 to be resource, double given, %s(%d)
+NULL
+
+--empty array--
+Error: 2 - file() expects parameter 3 to be resource, array given, %s(%d)
+NULL
+
+--int indexed array--
+Error: 2 - file() expects parameter 3 to be resource, array given, %s(%d)
+NULL
+
+--associative array--
+Error: 2 - file() expects parameter 3 to be resource, array given, %s(%d)
+NULL
+
+--nested arrays--
+Error: 2 - file() expects parameter 3 to be resource, array given, %s(%d)
+NULL
+
+--uppercase NULL--
+array(3) {
+ [0]=>
+ string(7) "Line 1
+"
+ [1]=>
+ string(7) "Line 2
+"
+ [2]=>
+ string(6) "Line 3"
+}
+
+--lowercase null--
+array(3) {
+ [0]=>
+ string(7) "Line 1
+"
+ [1]=>
+ string(7) "Line 2
+"
+ [2]=>
+ string(6) "Line 3"
+}
+
+--lowercase true--
+Error: 2 - file() expects parameter 3 to be resource, boolean given, %s(%d)
+NULL
+
+--lowercase false--
+Error: 2 - file() expects parameter 3 to be resource, boolean given, %s(%d)
+NULL
+
+--uppercase TRUE--
+Error: 2 - file() expects parameter 3 to be resource, boolean given, %s(%d)
+NULL
+
+--uppercase FALSE--
+Error: 2 - file() expects parameter 3 to be resource, boolean given, %s(%d)
+NULL
+
+--empty string DQ--
+Error: 2 - file() expects parameter 3 to be resource, string given, %s(%d)
+NULL
+
+--empty string SQ--
+Error: 2 - file() expects parameter 3 to be resource, string given, %s(%d)
+NULL
+
+--string DQ--
+Error: 2 - file() expects parameter 3 to be resource, string given, %s(%d)
+NULL
+
+--string SQ--
+Error: 2 - file() expects parameter 3 to be resource, string given, %s(%d)
+NULL
+
+--mixed case string--
+Error: 2 - file() expects parameter 3 to be resource, string given, %s(%d)
+NULL
+
+--heredoc--
+Error: 2 - file() expects parameter 3 to be resource, string given, %s(%d)
+NULL
+
+--instance of classWithToString--
+Error: 2 - file() expects parameter 3 to be resource, object given, %s(%d)
+NULL
+
+--instance of classWithoutToString--
+Error: 2 - file() expects parameter 3 to be resource, object given, %s(%d)
+NULL
+
+--undefined var--
+array(3) {
+ [0]=>
+ string(7) "Line 1
+"
+ [1]=>
+ string(7) "Line 2
+"
+ [2]=>
+ string(6) "Line 3"
+}
+
+--unset var--
+array(3) {
+ [0]=>
+ string(7) "Line 1
+"
+ [1]=>
+ string(7) "Line 2
+"
+ [2]=>
+ string(6) "Line 3"
+}
+
+--file stream resource--
+Error: 2 - file(): supplied resource is not a valid Stream-Context resource, %s(%d)
+array(3) {
+ [0]=>
+ string(7) "Line 1
+"
+ [1]=>
+ string(7) "Line 2
+"
+ [2]=>
+ string(6) "Line 3"
+}
+===DONE===
diff --git a/ext/standard/tests/file/file_variation5-win32.phpt b/ext/standard/tests/file/file_variation5-win32.phpt
new file mode 100644
index 0000000..d6390db
--- /dev/null
+++ b/ext/standard/tests/file/file_variation5-win32.phpt
@@ -0,0 +1,74 @@
+--TEST--
+file() with various paths
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip windows only test');
+}
+?>
+--FILE--
+<?php
+
+$script_directory = dirname(__FILE__);
+chdir($script_directory);
+$test_dirname = basename(__FILE__, ".php") . "testdir";
+mkdir($test_dirname);
+
+$filepath = __FILE__ . ".tmp";
+$filename = basename($filepath);
+$fd = fopen($filepath, "w+");
+fwrite($fd, "Line 1\nLine 2\nLine 3");
+fclose($fd);
+
+echo "file() on a path containing .. and .\n";
+var_dump(file("./$test_dirname/../$filename"));
+
+echo "\nfile() on a path containing .. with invalid directories\n";
+var_dump(file("./$test_dirname/bad_dir/../../$filename"));
+
+echo "\nfile() on a relative path from a different working directory\n";
+chdir($test_dirname);
+var_dump(file("../$filename"));
+chdir($script_directory);
+
+chdir($script_directory);
+rmdir($test_dirname);
+unlink($filepath);
+
+?>
+--EXPECT--
+file() on a path containing .. and .
+array(3) {
+ [0]=>
+ string(7) "Line 1
+"
+ [1]=>
+ string(7) "Line 2
+"
+ [2]=>
+ string(6) "Line 3"
+}
+
+file() on a path containing .. with invalid directories
+array(3) {
+ [0]=>
+ string(7) "Line 1
+"
+ [1]=>
+ string(7) "Line 2
+"
+ [2]=>
+ string(6) "Line 3"
+}
+
+file() on a relative path from a different working directory
+array(3) {
+ [0]=>
+ string(7) "Line 1
+"
+ [1]=>
+ string(7) "Line 2
+"
+ [2]=>
+ string(6) "Line 3"
+}
diff --git a/ext/standard/tests/file/file_variation5.phpt b/ext/standard/tests/file/file_variation5.phpt
new file mode 100644
index 0000000..1f15491
--- /dev/null
+++ b/ext/standard/tests/file/file_variation5.phpt
@@ -0,0 +1,94 @@
+--TEST--
+file() with various paths
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip non-windows only test');
+}
+?>
+--FILE--
+<?php
+
+$script_directory = dirname(__FILE__);
+chdir($script_directory);
+$test_dirname = basename(__FILE__, ".php") . "testdir";
+mkdir($test_dirname);
+
+$filepath = __FILE__ . ".tmp";
+$filename = basename($filepath);
+$fd = fopen($filepath, "w+");
+fwrite($fd, "Line 1\nLine 2\nLine 3");
+fclose($fd);
+
+echo "file() on a path containing .. and .\n";
+var_dump(file("./$test_dirname/../$filename"));
+
+echo "\nfile() on a path containing .. with invalid directories\n";
+var_dump(file("./$test_dirname/bad_dir/../../$filename"));
+
+echo "\nfile() on a linked file\n";
+$linkname = "somelink";
+var_dump(symlink($filepath, $linkname));
+var_dump(file($linkname));
+var_dump(unlink($linkname));
+
+echo "\nfile() on a relative path from a different working directory\n";
+chdir($test_dirname);
+var_dump(file("../$filename"));
+chdir($script_directory);
+
+chdir($script_directory);
+rmdir($test_dirname);
+unlink($filepath);
+
+?>
+--EXPECT--
+file() on a path containing .. and .
+array(3) {
+ [0]=>
+ string(7) "Line 1
+"
+ [1]=>
+ string(7) "Line 2
+"
+ [2]=>
+ string(6) "Line 3"
+}
+
+file() on a path containing .. with invalid directories
+array(3) {
+ [0]=>
+ string(7) "Line 1
+"
+ [1]=>
+ string(7) "Line 2
+"
+ [2]=>
+ string(6) "Line 3"
+}
+
+file() on a linked file
+bool(true)
+array(3) {
+ [0]=>
+ string(7) "Line 1
+"
+ [1]=>
+ string(7) "Line 2
+"
+ [2]=>
+ string(6) "Line 3"
+}
+bool(true)
+
+file() on a relative path from a different working directory
+array(3) {
+ [0]=>
+ string(7) "Line 1
+"
+ [1]=>
+ string(7) "Line 2
+"
+ [2]=>
+ string(6) "Line 3"
+}
diff --git a/ext/standard/tests/file/file_variation6.phpt b/ext/standard/tests/file/file_variation6.phpt
new file mode 100644
index 0000000..7e34f28
--- /dev/null
+++ b/ext/standard/tests/file/file_variation6.phpt
@@ -0,0 +1,261 @@
+--TEST--
+file() with a range of integer flag values
+--FILE--
+<?php
+
+$filepath = __FILE__ . ".tmp";
+$fd = fopen($filepath, "w+");
+fwrite($fd, "Line 1\nLine 2\nLine 3");
+fclose($fd);
+
+for ($flags = 0; $flags <= 32; $flags++) {
+ var_dump(file($filepath, $flags));
+}
+
+unlink($filepath);
+
+?>
+--EXPECTF--
+array(3) {
+ [0]=>
+ string(7) "Line 1
+"
+ [1]=>
+ string(7) "Line 2
+"
+ [2]=>
+ string(6) "Line 3"
+}
+array(3) {
+ [0]=>
+ string(7) "Line 1
+"
+ [1]=>
+ string(7) "Line 2
+"
+ [2]=>
+ string(6) "Line 3"
+}
+array(3) {
+ [0]=>
+ string(6) "Line 1"
+ [1]=>
+ string(6) "Line 2"
+ [2]=>
+ string(6) "Line 3"
+}
+array(3) {
+ [0]=>
+ string(6) "Line 1"
+ [1]=>
+ string(6) "Line 2"
+ [2]=>
+ string(6) "Line 3"
+}
+array(3) {
+ [0]=>
+ string(7) "Line 1
+"
+ [1]=>
+ string(7) "Line 2
+"
+ [2]=>
+ string(6) "Line 3"
+}
+array(3) {
+ [0]=>
+ string(7) "Line 1
+"
+ [1]=>
+ string(7) "Line 2
+"
+ [2]=>
+ string(6) "Line 3"
+}
+array(3) {
+ [0]=>
+ string(6) "Line 1"
+ [1]=>
+ string(6) "Line 2"
+ [2]=>
+ string(6) "Line 3"
+}
+array(3) {
+ [0]=>
+ string(6) "Line 1"
+ [1]=>
+ string(6) "Line 2"
+ [2]=>
+ string(6) "Line 3"
+}
+array(3) {
+ [0]=>
+ string(7) "Line 1
+"
+ [1]=>
+ string(7) "Line 2
+"
+ [2]=>
+ string(6) "Line 3"
+}
+array(3) {
+ [0]=>
+ string(7) "Line 1
+"
+ [1]=>
+ string(7) "Line 2
+"
+ [2]=>
+ string(6) "Line 3"
+}
+array(3) {
+ [0]=>
+ string(6) "Line 1"
+ [1]=>
+ string(6) "Line 2"
+ [2]=>
+ string(6) "Line 3"
+}
+array(3) {
+ [0]=>
+ string(6) "Line 1"
+ [1]=>
+ string(6) "Line 2"
+ [2]=>
+ string(6) "Line 3"
+}
+array(3) {
+ [0]=>
+ string(7) "Line 1
+"
+ [1]=>
+ string(7) "Line 2
+"
+ [2]=>
+ string(6) "Line 3"
+}
+array(3) {
+ [0]=>
+ string(7) "Line 1
+"
+ [1]=>
+ string(7) "Line 2
+"
+ [2]=>
+ string(6) "Line 3"
+}
+array(3) {
+ [0]=>
+ string(6) "Line 1"
+ [1]=>
+ string(6) "Line 2"
+ [2]=>
+ string(6) "Line 3"
+}
+array(3) {
+ [0]=>
+ string(6) "Line 1"
+ [1]=>
+ string(6) "Line 2"
+ [2]=>
+ string(6) "Line 3"
+}
+array(3) {
+ [0]=>
+ string(7) "Line 1
+"
+ [1]=>
+ string(7) "Line 2
+"
+ [2]=>
+ string(6) "Line 3"
+}
+array(3) {
+ [0]=>
+ string(7) "Line 1
+"
+ [1]=>
+ string(7) "Line 2
+"
+ [2]=>
+ string(6) "Line 3"
+}
+array(3) {
+ [0]=>
+ string(6) "Line 1"
+ [1]=>
+ string(6) "Line 2"
+ [2]=>
+ string(6) "Line 3"
+}
+array(3) {
+ [0]=>
+ string(6) "Line 1"
+ [1]=>
+ string(6) "Line 2"
+ [2]=>
+ string(6) "Line 3"
+}
+array(3) {
+ [0]=>
+ string(7) "Line 1
+"
+ [1]=>
+ string(7) "Line 2
+"
+ [2]=>
+ string(6) "Line 3"
+}
+array(3) {
+ [0]=>
+ string(7) "Line 1
+"
+ [1]=>
+ string(7) "Line 2
+"
+ [2]=>
+ string(6) "Line 3"
+}
+array(3) {
+ [0]=>
+ string(6) "Line 1"
+ [1]=>
+ string(6) "Line 2"
+ [2]=>
+ string(6) "Line 3"
+}
+array(3) {
+ [0]=>
+ string(6) "Line 1"
+ [1]=>
+ string(6) "Line 2"
+ [2]=>
+ string(6) "Line 3"
+}
+
+Warning: file(): '24' flag is not supported in %s on line %d
+bool(false)
+
+Warning: file(): '25' flag is not supported in %s on line %d
+bool(false)
+
+Warning: file(): '26' flag is not supported in %s on line %d
+bool(false)
+
+Warning: file(): '27' flag is not supported in %s on line %d
+bool(false)
+
+Warning: file(): '28' flag is not supported in %s on line %d
+bool(false)
+
+Warning: file(): '29' flag is not supported in %s on line %d
+bool(false)
+
+Warning: file(): '30' flag is not supported in %s on line %d
+bool(false)
+
+Warning: file(): '31' flag is not supported in %s on line %d
+bool(false)
+
+Warning: file(): '32' flag is not supported in %s on line %d
+bool(false)
diff --git a/ext/standard/tests/file/file_variation7.phpt b/ext/standard/tests/file/file_variation7.phpt
new file mode 100644
index 0000000..3cd9d7f
--- /dev/null
+++ b/ext/standard/tests/file/file_variation7.phpt
@@ -0,0 +1,87 @@
+--TEST--
+file() on a file with blank lines
+--FILE--
+<?php
+
+$filepath = __FILE__ . ".tmp";
+$fd = fopen($filepath, "w+");
+fwrite($fd, "Line 1\n\n \n \n\Line 3");
+fclose($fd);
+
+echo "file():\n";
+var_dump(file($filepath));
+
+echo "\nfile() with FILE_IGNORE_NEW_LINES:\n";
+var_dump(file($filepath, FILE_IGNORE_NEW_LINES));
+
+echo "\nfile() with FILE_SKIP_EMPTY_LINES:\n";
+var_dump(file($filepath, FILE_SKIP_EMPTY_LINES));
+
+echo "\nfile() with FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES:\n";
+var_dump(file($filepath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES));
+
+unlink($filepath);
+
+?>
+--EXPECT--
+file():
+array(5) {
+ [0]=>
+ string(7) "Line 1
+"
+ [1]=>
+ string(1) "
+"
+ [2]=>
+ string(2) "
+"
+ [3]=>
+ string(3) "
+"
+ [4]=>
+ string(7) "\Line 3"
+}
+
+file() with FILE_IGNORE_NEW_LINES:
+array(5) {
+ [0]=>
+ string(6) "Line 1"
+ [1]=>
+ string(0) ""
+ [2]=>
+ string(1) " "
+ [3]=>
+ string(2) " "
+ [4]=>
+ string(7) "\Line 3"
+}
+
+file() with FILE_SKIP_EMPTY_LINES:
+array(5) {
+ [0]=>
+ string(7) "Line 1
+"
+ [1]=>
+ string(1) "
+"
+ [2]=>
+ string(2) "
+"
+ [3]=>
+ string(3) "
+"
+ [4]=>
+ string(7) "\Line 3"
+}
+
+file() with FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES:
+array(4) {
+ [0]=>
+ string(6) "Line 1"
+ [1]=>
+ string(1) " "
+ [2]=>
+ string(2) " "
+ [3]=>
+ string(7) "\Line 3"
+}
diff --git a/ext/standard/tests/file/file_variation8-win32.phpt b/ext/standard/tests/file/file_variation8-win32.phpt
new file mode 100644
index 0000000..ca3be36
--- /dev/null
+++ b/ext/standard/tests/file/file_variation8-win32.phpt
@@ -0,0 +1,142 @@
+--TEST--
+Test file() function : variation - various absolute and relative paths
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+ die("skip Only run on Windows");
+?>
+--FILE--
+<?php
+/* Prototype : array file(string filename [, int flags[, resource context]])
+ * Description: Read entire file into an array
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing file() : variation ***\n";
+$mainDir = "fileVar8.dir";
+$subDir = "fileVar8Sub";
+$absMainDir = dirname(__FILE__)."\\".$mainDir;
+mkdir($absMainDir);
+$absSubDir = $absMainDir."\\".$subDir;
+mkdir($absSubDir);
+
+$old_dir_path = getcwd();
+chdir(dirname(__FILE__));
+$unixifiedDir = '/'.substr(str_replace('\\','/',$absSubDir),3);
+
+$allDirs = array(
+ // absolute paths
+ "$absSubDir\\",
+ "$absSubDir\\..\\".$subDir,
+ "$absSubDir\\\\..\\.\\".$subDir,
+ "$absSubDir\\..\\..\\".$mainDir."\\.\\".$subDir,
+ "$absSubDir\\..\\\\\\".$subDir."\\\\..\\\\..\\".$subDir,
+ "$absSubDir\\BADDIR",
+
+ // relative paths
+ $mainDir."\\".$subDir,
+ $mainDir."\\\\".$subDir,
+ $mainDir."\\\\\\".$subDir,
+ ".\\".$mainDir."\\..\\".$mainDir."\\".$subDir,
+ "BADDIR",
+
+ // unixifed path
+ $unixifiedDir,
+);
+
+$filename = 'FileGetContentsVar7.tmp';
+$absFile = $absSubDir.'/'.$filename;
+$h = fopen($absFile,"w");
+fwrite($h, "contents read");
+fclose($h);
+
+for($i = 0; $i<count($allDirs); $i++) {
+ $j = $i+1;
+ $dir = $allDirs[$i];
+ echo "\n-- Iteration $j --\n";
+ var_dump(file($dir."\\".$filename));
+}
+
+unlink($absFile);
+chdir($old_dir_path);
+rmdir($absSubDir);
+rmdir($absMainDir);
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing file() : variation ***
+
+-- Iteration 1 --
+array(1) {
+ [0]=>
+ string(13) "contents read"
+}
+
+-- Iteration 2 --
+array(1) {
+ [0]=>
+ string(13) "contents read"
+}
+
+-- Iteration 3 --
+array(1) {
+ [0]=>
+ string(13) "contents read"
+}
+
+-- Iteration 4 --
+array(1) {
+ [0]=>
+ string(13) "contents read"
+}
+
+-- Iteration 5 --
+
+Warning: file(%sfileVar8.dir\fileVar8Sub\..\\\fileVar8Sub\\..\\..\fileVar8Sub\FileGetContentsVar7.tmp): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+-- Iteration 6 --
+
+Warning: file(%sfileVar8.dir\fileVar8Sub\BADDIR\FileGetContentsVar7.tmp): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+-- Iteration 7 --
+array(1) {
+ [0]=>
+ string(13) "contents read"
+}
+
+-- Iteration 8 --
+array(1) {
+ [0]=>
+ string(13) "contents read"
+}
+
+-- Iteration 9 --
+array(1) {
+ [0]=>
+ string(13) "contents read"
+}
+
+-- Iteration 10 --
+array(1) {
+ [0]=>
+ string(13) "contents read"
+}
+
+-- Iteration 11 --
+
+Warning: file(BADDIR\FileGetContentsVar7.tmp): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+-- Iteration 12 --
+array(1) {
+ [0]=>
+ string(13) "contents read"
+}
+
+*** Done *** \ No newline at end of file
diff --git a/ext/standard/tests/file/file_variation8.phpt b/ext/standard/tests/file/file_variation8.phpt
new file mode 100644
index 0000000..be18fcb
--- /dev/null
+++ b/ext/standard/tests/file/file_variation8.phpt
@@ -0,0 +1,128 @@
+--TEST--
+Test file function : variation - various absolute and relative paths
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : array file(string filename [, int flags[, resource context]])
+ * Description: Read entire file into an array
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing file() : variation ***\n";
+$mainDir = "fileVar8.dir";
+$subDir = "fileVar8Sub";
+$absMainDir = dirname(__FILE__)."/".$mainDir;
+mkdir($absMainDir);
+$absSubDir = $absMainDir."/".$subDir;
+mkdir($absSubDir);
+
+$old_dir_path = getcwd();
+chdir(dirname(__FILE__));
+
+$allDirs = array(
+ // absolute paths
+ "$absSubDir/",
+ "$absSubDir/../".$subDir,
+ "$absSubDir//.././".$subDir,
+ "$absSubDir/../../".$mainDir."/./".$subDir,
+ "$absSubDir/..///".$subDir."//..//../".$subDir,
+ "$absSubDir/BADDIR",
+
+ // relative paths
+ $mainDir."/".$subDir,
+ $mainDir."//".$subDir,
+ $mainDir."///".$subDir,
+ "./".$mainDir."/../".$mainDir."/".$subDir,
+ "BADDIR",
+
+);
+
+$filename = 'FileGetContentsVar7.tmp';
+$absFile = $absSubDir.'/'.$filename;
+$h = fopen($absFile,"w");
+fwrite($h, "contents read");
+fclose($h);
+
+for($i = 0; $i<count($allDirs); $i++) {
+ $j = $i+1;
+ $dir = $allDirs[$i];
+ echo "\n-- Iteration $j --\n";
+ var_dump(file($dir."/".$filename));
+}
+
+unlink($absFile);
+chdir($old_dir_path);
+rmdir($absSubDir);
+rmdir($absMainDir);
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing file() : variation ***
+
+-- Iteration 1 --
+array(1) {
+ [0]=>
+ string(13) "contents read"
+}
+
+-- Iteration 2 --
+array(1) {
+ [0]=>
+ string(13) "contents read"
+}
+
+-- Iteration 3 --
+array(1) {
+ [0]=>
+ string(13) "contents read"
+}
+
+-- Iteration 4 --
+array(1) {
+ [0]=>
+ string(13) "contents read"
+}
+
+-- Iteration 5 --
+
+Warning: file(%sfileVar8.dir/fileVar8Sub/..///fileVar8Sub//..//../fileVar8Sub/FileGetContentsVar7.tmp): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+-- Iteration 6 --
+
+Warning: file(%sfileVar8.dir/fileVar8Sub/BADDIR/FileGetContentsVar7.tmp): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+-- Iteration 7 --
+array(1) {
+ [0]=>
+ string(13) "contents read"
+}
+
+-- Iteration 8 --
+array(1) {
+ [0]=>
+ string(13) "contents read"
+}
+
+-- Iteration 9 --
+array(1) {
+ [0]=>
+ string(13) "contents read"
+}
+
+-- Iteration 10 --
+array(1) {
+ [0]=>
+ string(13) "contents read"
+}
+
+-- Iteration 11 --
+
+Warning: file(BADDIR/FileGetContentsVar7.tmp): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+*** Done *** \ No newline at end of file
diff --git a/ext/standard/tests/file/file_variation9.phpt b/ext/standard/tests/file/file_variation9.phpt
new file mode 100644
index 0000000..9ddd1e6
--- /dev/null
+++ b/ext/standard/tests/file/file_variation9.phpt
@@ -0,0 +1,89 @@
+--TEST--
+Test file function : variation - test various endings of a file
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : array file(string filename [, int flags[, resource context]])
+ * Description: Read entire file into an array
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing file() : variation ***\n";
+$testfile = dirname(__FILE__)."/fileVar9.txt";
+
+$contents = array(
+ "File ends on a single character\na",
+ "File ends on a new line\n",
+ "File ends on multiple newlines\n\n\n\n",
+ "File has\n\nmultiple lines and newlines\n\n",
+ "File has\r\nmultiple crlfs\n\r\n"
+ );
+
+@unlink($testfile);
+foreach ($contents as $content) {
+ $h = fopen($testfile, "w");
+ fwrite($h, $content);
+ fclose($h);
+ var_dump(file($testfile));
+ unlink($testfile);
+}
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing file() : variation ***
+array(2) {
+ [0]=>
+ string(32) "File ends on a single character
+"
+ [1]=>
+ string(1) "a"
+}
+array(1) {
+ [0]=>
+ string(24) "File ends on a new line
+"
+}
+array(4) {
+ [0]=>
+ string(31) "File ends on multiple newlines
+"
+ [1]=>
+ string(1) "
+"
+ [2]=>
+ string(1) "
+"
+ [3]=>
+ string(1) "
+"
+}
+array(4) {
+ [0]=>
+ string(9) "File has
+"
+ [1]=>
+ string(1) "
+"
+ [2]=>
+ string(28) "multiple lines and newlines
+"
+ [3]=>
+ string(1) "
+"
+}
+array(3) {
+ [0]=>
+ string(10) "File has
+"
+ [1]=>
+ string(15) "multiple crlfs
+"
+ [2]=>
+ string(2) "
+"
+}
+
+*** Done *** \ No newline at end of file
diff --git a/ext/standard/tests/file/filegroup_basic.phpt b/ext/standard/tests/file/filegroup_basic.phpt
new file mode 100644
index 0000000..36333b2
--- /dev/null
+++ b/ext/standard/tests/file/filegroup_basic.phpt
@@ -0,0 +1,69 @@
+--TEST--
+Test filegroup() function: basic functionality
+--SKIPIF--
+<?php
+if( substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip Not valid for Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: int filegroup ( string $filename )
+ * Description: Returns the group ID of the file, or FALSE in case of an error.
+ */
+
+echo "*** Testing filegroup(): basic functionality ***\n";
+
+echo "-- Testing with the file or directory created by owner --\n";
+
+$file_path = dirname(__FILE__);
+var_dump( filegroup(__FILE__) );
+var_dump( filegroup(".") );
+var_dump( filegroup("./..") );
+
+/* Newly created files and dirs */
+$file_name = $file_path."/filegroup_basic.tmp";
+$file_handle = fopen($file_name, "w");
+
+$string = "Hello, world\n1234\n123Hello";
+fwrite($file_handle, $string);
+var_dump( filegroup($file_name) );
+fclose($file_handle);
+
+$dir_name = $file_path."/filegroup_basic";
+mkdir($dir_name);
+var_dump( filegroup($dir_name) );
+
+echo "\n-- Testing with the standard file or directory --\n";
+var_dump( filegroup("/etc/passwd") );
+var_dump( filegroup("/etc") );
+var_dump( filegroup("/") );
+
+echo "\n*** Done ***\n";
+?>
+
+--CLEAN--
+<?php
+
+$file_path = dirname(__FILE__);
+$file_name = $file_path."/filegroup_basic.tmp";
+$dir_name = $file_path."/filegroup_basic";
+unlink($file_name);
+rmdir($dir_name);
+?>
+
+--EXPECTF--
+*** Testing filegroup(): basic functionality ***
+-- Testing with the file or directory created by owner --
+int(%d)
+int(%d)
+int(%d)
+int(%d)
+int(%d)
+
+-- Testing with the standard file or directory --
+int(%d)
+int(%d)
+int(%d)
+
+*** Done ***
diff --git a/ext/standard/tests/file/filegroup_error.phpt b/ext/standard/tests/file/filegroup_error.phpt
new file mode 100644
index 0000000..3d96ffd
--- /dev/null
+++ b/ext/standard/tests/file/filegroup_error.phpt
@@ -0,0 +1,44 @@
+--TEST--
+Test filegroup() function: error conditions
+--FILE--
+<?php
+/* Prototype: int filegroup ( string $filename )
+ * Description: Returns the group ID of the file, or FALSE in case of an error.
+ */
+
+echo "*** Testing filegroup(): error conditions ***\n";
+
+/* Non-existing file or dir */
+var_dump( filegroup("/no/such/file/dir") );
+
+/* Invalid arguments */
+var_dump( filegroup("string") );
+var_dump( filegroup(100) );
+
+/* Invalid no.of arguments */
+var_dump( filegroup() ); // args < expected
+var_dump( filegroup("/no/such/file", "root") ); // args > expected
+
+echo "\n*** Done ***\n";
+?>
+
+--EXPECTF--
+*** Testing filegroup(): error conditions ***
+
+Warning: filegroup(): stat failed for /no/such/file/dir in %s on line %d
+bool(false)
+
+Warning: filegroup(): stat failed for string in %s on line %d
+bool(false)
+
+Warning: filegroup(): stat failed for 100 in %s on line %d
+bool(false)
+
+Warning: filegroup() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: filegroup() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/filegroup_variation1.phpt b/ext/standard/tests/file/filegroup_variation1.phpt
new file mode 100644
index 0000000..ee76477
--- /dev/null
+++ b/ext/standard/tests/file/filegroup_variation1.phpt
@@ -0,0 +1,47 @@
+--TEST--
+Test filegroup() function: usage variations - links
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip Do not run on Windows');
+}
+--FILE--
+<?php
+/* Prototype: int filegroup ( string $filename )
+ * Description: Returns the group ID of the file, or FALSE in case of an error.
+ */
+
+/* Creating soft and hard links to a file and applying filegroup() on links */
+
+$file_path = dirname(__FILE__);
+fclose( fopen($file_path."/filegroup_variation1.tmp", "w") );
+
+echo "*** Testing filegroup() with links ***\n";
+/* With symlink */
+symlink($file_path."/filegroup_variation1.tmp", $file_path."/filegroup_variation1_symlink.tmp");
+var_dump( filegroup($file_path."/filegroup_variation1_symlink.tmp") ); //expected true
+clearstatcache();
+
+/* With hardlink */
+link($file_path."/filegroup_variation1.tmp", $file_path."/filegroup_variation1_link.tmp");
+var_dump( filegroup($file_path."/filegroup_variation1_link.tmp") ); // expected: true
+clearstatcache();
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/filegroup_variation1_symlink.tmp");
+unlink($file_path."/filegroup_variation1_link.tmp");
+unlink($file_path."/filegroup_variation1.tmp");
+?>
+
+--EXPECTF--
+*** Testing filegroup() with links ***
+int(%d)
+int(%d)
+
+*** Done ***
diff --git a/ext/standard/tests/file/filegroup_variation2.phpt b/ext/standard/tests/file/filegroup_variation2.phpt
new file mode 100644
index 0000000..afac40c
--- /dev/null
+++ b/ext/standard/tests/file/filegroup_variation2.phpt
@@ -0,0 +1,71 @@
+--TEST--
+Test filegroup() function: usage variations - invalid filenames
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype: int filegroup ( string $filename )
+ * Description: Returns the group ID of the file, or FALSE in case of an error.
+ */
+
+/* Testing filegroup() with invalid arguments -int, float, bool, NULL, resource */
+
+$file_path = dirname(__FILE__);
+$file_handle = fopen($file_path."/filegroup_variation2.tmp", "w");
+
+echo "*** Testing Invalid file types ***\n";
+$filenames = array(
+ /* Invalid filenames */
+ -2.34555,
+ " ",
+ "",
+ TRUE,
+ FALSE,
+ NULL,
+ $file_handle,
+
+ /* scalars */
+ 1234,
+ 0
+);
+
+/* loop through to test each element the above array */
+foreach( $filenames as $filename ) {
+ var_dump( filegroup($filename) );
+ clearstatcache();
+}
+fclose($file_handle);
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/filegroup_variation2.tmp");
+?>
+--EXPECTF--
+*** Testing Invalid file types ***
+
+Warning: filegroup(): stat failed for -2.34555 in %s on line %d
+bool(false)
+
+Warning: filegroup(): stat failed for in %s on line %d
+bool(false)
+bool(false)
+
+Warning: filegroup(): stat failed for 1 in %s on line %d
+bool(false)
+bool(false)
+bool(false)
+
+Warning: filegroup() expects parameter 1 to be a valid path, resource given in %s on line %d
+NULL
+
+Warning: filegroup(): stat failed for 1234 in %s on line %d
+bool(false)
+
+Warning: filegroup(): stat failed for 0 in %s on line %d
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/filegroup_variation3.phpt b/ext/standard/tests/file/filegroup_variation3.phpt
new file mode 100644
index 0000000..b275944
--- /dev/null
+++ b/ext/standard/tests/file/filegroup_variation3.phpt
@@ -0,0 +1,85 @@
+--TEST--
+Test filegroup() function: usage variations - diff. path notations
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype: int filegroup ( string $filename )
+ * Description: Returns the group ID of the file, or FALSE in case of an error.
+ */
+
+/* Passing file names with different notations, using slashes, wild-card chars */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Testing filegroup() with different notations of file names ***\n";
+$dir_name = $file_path."/filegroup_variation3";
+mkdir($dir_name);
+$file_handle = fopen($dir_name."/filegroup_variation3.tmp", "w");
+fclose($file_handle);
+
+$files_arr = array(
+ "/filegroup_variation3/filegroup_variation3.tmp",
+
+ /* Testing a file trailing slash */
+ "/filegroup_variation3/filegroup_variation3.tmp/",
+
+ /* Testing file with double slashes */
+ "/filegroup_variation3//filegroup_variation3.tmp",
+ "//filegroup_variation3//filegroup_variation3.tmp",
+ "/filegroup_variation3/*.tmp",
+ "filegroup_variation3/filegroup*.tmp",
+
+ /* Testing Binary safe */
+ "/filegroup_variation3/filegroup_variation3.tmp".chr(0),
+ "/filegroup_variation3/filegroup_variation3.tmp\0"
+);
+
+$count = 1;
+/* loop through to test each element in the above array */
+foreach($files_arr as $file) {
+ echo "- Iteration $count -\n";
+ var_dump( filegroup( $file_path."/".$file ) );
+ clearstatcache();
+ $count++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$dir_name = $file_path."/filegroup_variation3";
+unlink($dir_name."/filegroup_variation3.tmp");
+rmdir($dir_name);
+?>
+--EXPECTF--
+*** Testing filegroup() with different notations of file names ***
+- Iteration 1 -
+int(%d)
+- Iteration 2 -
+
+Warning: filegroup(): stat failed for %s//filegroup_variation3/filegroup_variation3.tmp/ in %s on line %d
+bool(false)
+- Iteration 3 -
+int(%d)
+- Iteration 4 -
+int(%d)
+- Iteration 5 -
+
+Warning: filegroup(): stat failed for %s//filegroup_variation3/*.tmp in %s on line %d
+bool(false)
+- Iteration 6 -
+
+Warning: filegroup(): stat failed for %s/filegroup_variation3/filegroup*.tmp in %s on line %d
+bool(false)
+- Iteration 7 -
+
+Warning: filegroup() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+- Iteration 8 -
+
+Warning: filegroup() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+
+*** Done ***
diff --git a/ext/standard/tests/file/fileinode_basic.phpt b/ext/standard/tests/file/fileinode_basic.phpt
new file mode 100644
index 0000000..98e5cf0
--- /dev/null
+++ b/ext/standard/tests/file/fileinode_basic.phpt
@@ -0,0 +1,36 @@
+--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
index 0000000..d716c4a
--- /dev/null
+++ b/ext/standard/tests/file/fileinode_error.phpt
@@ -0,0 +1,44 @@
+--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 10
+bool(false)
+
+Warning: fileinode(): stat failed for string in %s on line 13
+bool(false)
+
+Warning: fileinode(): stat failed for 100 in %s on line 14
+bool(false)
+
+Warning: fileinode() expects exactly 1 parameter, 0 given in %s on line 17
+NULL
+
+Warning: fileinode() expects exactly 1 parameter, 2 given in %s on line 20
+NULL
+
+*** Done ***
diff --git a/ext/standard/tests/file/fileinode_variation.phpt b/ext/standard/tests/file/fileinode_variation.phpt
new file mode 100644
index 0000000..1fac953
--- /dev/null
+++ b/ext/standard/tests/file/fileinode_variation.phpt
@@ -0,0 +1,112 @@
+--TEST--
+Test fileinode() function: Variations
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip no link()/symlink() on Windows');
+}
+?>
+--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 files, links and directories ***\n";
+$file_path = dirname(__FILE__);
+$file1 = $file_path."/fileinode1_variation.tmp";
+$file2 = $file_path."/fileinode2_variation.tmp";
+$link1 = $file_path."/fileinode1_variation_link.tmp";
+$link2 = $file_path."/fileinode2_variation_link.tmp";
+
+
+echo "-- Testing with files --\n";
+//creating the files
+fclose( fopen( $file1, "w" ) );
+fclose( fopen( $file2, "w" ) );
+
+print( fileinode( $file1) )."\n";
+print( fileinode( $file2) )."\n";
+clearstatcache();
+
+echo "-- Testing with links: hard link --\n";
+link( $file1, $link1); // Creating an hard link
+print( fileinode( $file1) )."\n";
+clearstatcache();
+print( fileinode( $link1) )."\n";
+clearstatcache();
+
+echo "-- Testing with links: soft link --\n";
+symlink( $file2, $link2); // Creating a soft link
+print( fileinode( $file2) )."\n";
+clearstatcache();
+print( fileinode( $link2) )."\n";
+
+unlink( $link1 );
+unlink( $link2 );
+
+echo "-- Testing after copying a file --\n";
+copy( $file1, $file_path."/fileinode1_variation_new.tmp");
+print( fileinode( $file1) )."\n";
+clearstatcache();
+print( fileinode( $file_path."/fileinode1_variation_new.tmp") )."\n";
+
+unlink( $file_path."/fileinode1_variation_new.tmp");
+unlink( $file1);
+unlink( $file2);
+
+
+echo "-- Testing after renaming the file --\n";
+fclose( 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") )."\n";
+clearstatcache();
+
+echo "-- Testing with binary input --\n";
+print( fileinode(b"$file_path/dir") )."\n";
+clearstatcache();
+print( fileinode(b"$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
+-- Testing with binary input --
+%d
+%d
+*** Done ***
diff --git a/ext/standard/tests/file/fileinode_variation1.phpt b/ext/standard/tests/file/fileinode_variation1.phpt
new file mode 100644
index 0000000..d251cc3
--- /dev/null
+++ b/ext/standard/tests/file/fileinode_variation1.phpt
@@ -0,0 +1,48 @@
+--TEST--
+Test fileinode() function: usage variations - links
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip Do not run on Windows');
+}
+--FILE--
+<?php
+/*
+Prototype: int fileinode ( string $filename );
+Description: Returns the inode number of the file, or FALSE in case of an error.
+*/
+
+/* Creating soft and hard links to a file and applying fileinode() on links */
+
+$file_path = dirname(__FILE__);
+fclose( fopen($file_path."/fileinode_variation1.tmp", "w") );
+
+echo "*** Testing fileinode() with links ***\n";
+/* With symlink */
+symlink($file_path."/fileinode_variation1.tmp", $file_path."/fileinode_variation1_symlink.tmp");
+var_dump( fileinode($file_path."/fileinode_variation1_symlink.tmp") ); //expected true
+clearstatcache();
+
+/* With hardlink */
+link($file_path."/fileinode_variation1.tmp", $file_path."/fileinode_variation1_link.tmp");
+var_dump( fileinode($file_path."/fileinode_variation1_link.tmp") ); // expected: true
+clearstatcache();
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/fileinode_variation1_symlink.tmp");
+unlink($file_path."/fileinode_variation1_link.tmp");
+unlink($file_path."/fileinode_variation1.tmp");
+?>
+
+--EXPECTF--
+*** Testing fileinode() with links ***
+int(%d)
+int(%d)
+
+*** Done ***
diff --git a/ext/standard/tests/file/fileinode_variation2.phpt b/ext/standard/tests/file/fileinode_variation2.phpt
new file mode 100644
index 0000000..e8e7af6
--- /dev/null
+++ b/ext/standard/tests/file/fileinode_variation2.phpt
@@ -0,0 +1,72 @@
+--TEST--
+Test fileinode() function: usage variations - invalid filenames
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/*
+Prototype: int fileinode ( string $filename );
+Description: Returns the inode number of the file, or FALSE in case of an error.
+*/
+
+/* Testing fileinode() with invalid arguments -int, float, bool, NULL, resource */
+
+$file_path = dirname(__FILE__);
+$file_handle = fopen($file_path."/fileinode_variation2.tmp", "w");
+
+echo "*** Testing Invalid file types ***\n";
+$filenames = array(
+ /* Invalid filenames */
+ -2.34555,
+ " ",
+ "",
+ TRUE,
+ FALSE,
+ NULL,
+ $file_handle,
+
+ /* scalars */
+ 1234,
+ 0
+);
+
+/* loop through to test each element the above array */
+foreach( $filenames as $filename ) {
+ var_dump( fileinode($filename) );
+ clearstatcache();
+}
+fclose($file_handle);
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/fileinode_variation2.tmp");
+?>
+--EXPECTF--
+*** Testing Invalid file types ***
+
+Warning: fileinode(): stat failed for -2.34555 in %s on line %d
+bool(false)
+
+Warning: fileinode(): stat failed for in %s on line %d
+bool(false)
+bool(false)
+
+Warning: fileinode(): stat failed for 1 in %s on line %d
+bool(false)
+bool(false)
+bool(false)
+
+Warning: fileinode() expects parameter 1 to be a valid path, resource given in %s on line %d
+NULL
+
+Warning: fileinode(): stat failed for 1234 in %s on line %d
+bool(false)
+
+Warning: fileinode(): stat failed for 0 in %s on line %d
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fileinode_variation3.phpt b/ext/standard/tests/file/fileinode_variation3.phpt
new file mode 100644
index 0000000..ca84864
--- /dev/null
+++ b/ext/standard/tests/file/fileinode_variation3.phpt
@@ -0,0 +1,86 @@
+--TEST--
+Test fileinode() function: usage variations - diff. path notations
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/*
+Prototype: int fileinode ( string $filename );
+Description: Returns the inode number of the file, or FALSE in case of an error.
+*/
+
+/* Passing file names with different notations, using slashes, wild-card chars */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Testing fileinode() with different notations of file names ***\n";
+$dir_name = $file_path."/fileinode_variation3";
+mkdir($dir_name);
+$file_handle = fopen($dir_name."/fileinode_variation3.tmp", "w");
+fclose($file_handle);
+
+$files_arr = array(
+ "/fileinode_variation3/fileinode_variation3.tmp",
+
+ /* Testing a file trailing slash */
+ "/fileinode_variation3/fileinode_variation3.tmp/",
+
+ /* Testing file with double slashes */
+ "/fileinode_variation3//fileinode_variation3.tmp",
+ "//fileinode_variation3//fileinode_variation3.tmp",
+ "/fileinode_variation3/*.tmp",
+ "fileinode_variation3/fileinode*.tmp",
+
+ /* Testing Binary safe */
+ "/fileinode_variation3/fileinode_variation3.tmp".chr(0),
+ "/fileinode_variation3/fileinode_variation3.tmp\0"
+);
+
+$count = 1;
+/* loop through to test each element in the above array */
+foreach($files_arr as $file) {
+ echo "- Iteration $count -\n";
+ var_dump( fileinode( $file_path."/".$file ) );
+ clearstatcache();
+ $count++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$dir_name = $file_path."/fileinode_variation3";
+unlink($dir_name."/fileinode_variation3.tmp");
+rmdir($dir_name);
+?>
+--EXPECTF--
+*** Testing fileinode() with different notations of file names ***
+- Iteration 1 -
+int(%i)
+- Iteration 2 -
+
+Warning: fileinode(): stat failed for %s//fileinode_variation3/fileinode_variation3.tmp/ in %s on line %d
+bool(false)
+- Iteration 3 -
+int(%i)
+- Iteration 4 -
+int(%i)
+- Iteration 5 -
+
+Warning: fileinode(): stat failed for %s//fileinode_variation3/*.tmp in %s on line %d
+bool(false)
+- Iteration 6 -
+
+Warning: fileinode(): stat failed for %s/fileinode_variation3/fileinode*.tmp in %s on line %d
+bool(false)
+- Iteration 7 -
+
+Warning: fileinode() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+- Iteration 8 -
+
+Warning: fileinode() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+
+*** Done ***
diff --git a/ext/standard/tests/file/fileowner_basic.phpt b/ext/standard/tests/file/fileowner_basic.phpt
new file mode 100644
index 0000000..5b5ff9a
--- /dev/null
+++ b/ext/standard/tests/file/fileowner_basic.phpt
@@ -0,0 +1,51 @@
+--TEST--
+Test fileowner() function: basic functionality
+--FILE--
+<?php
+/* Prototype: int fileowner ( string $filename )
+ * Description: Returns the user ID of the owner of the file, or
+ * FALSE in case of an error.
+ */
+
+echo "*** Testing fileowner(): basic functionality ***\n";
+
+echo "-- Testing with the file or directory created by owner --\n";
+var_dump( fileowner(__FILE__) );
+var_dump( fileowner(".") );
+var_dump( fileowner("./..") );
+
+/* Newly created files and dirs */
+$file_path = dirname(__FILE__);
+$file_name = $file_path."/fileowner_basic.tmp";
+$file_handle = fopen($file_name, "w");
+$string = "Hello, world\n1234\n123Hello";
+fwrite($file_handle, $string);
+var_dump( fileowner($file_name) );
+fclose($file_handle);
+
+$dir_name = $file_path."/fileowner_basic";
+mkdir($dir_name);
+var_dump( fileowner($dir_name) );
+
+echo "*** Done ***\n";
+?>
+
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$file_name = $file_path."/fileowner_basic.tmp";
+$dir_name = $file_path."/fileowner_basic";
+unlink($file_name);
+rmdir($dir_name);
+?>
+
+--EXPECTF--
+*** Testing fileowner(): basic functionality ***
+-- Testing with the file or directory created by owner --
+int(%d)
+int(%d)
+int(%d)
+int(%d)
+int(%d)
+*** Done ***
+
diff --git a/ext/standard/tests/file/fileowner_error.phpt b/ext/standard/tests/file/fileowner_error.phpt
new file mode 100644
index 0000000..efffb36
--- /dev/null
+++ b/ext/standard/tests/file/fileowner_error.phpt
@@ -0,0 +1,44 @@
+--TEST--
+Test of fileowner() function: error conditions
+--FILE--
+<?php
+/* Prototype: int fileowner ( string $filename )
+ * Description: Returns the user ID of the owner of the file, or
+ * FALSE in case of an error.
+ */
+
+echo "*** Testing fileowner(): error conditions ***\n";
+/* Non-existing file or dir */
+var_dump( fileowner("/no/such/file/dir") );
+
+/* Invalid arguments */
+var_dump( fileowner("string") );
+var_dump( fileowner(100) );
+
+/* Invalid no.of arguments */
+var_dump( fileowner() ); // args < expected
+var_dump( fileowner("/no/such/file", "root") ); // args > expected
+
+echo "\n*** Done ***\n";
+?>
+
+--EXPECTF--
+*** Testing fileowner(): error conditions ***
+
+Warning: fileowner(): stat failed for /no/such/file/dir in %s on line %d
+bool(false)
+
+Warning: fileowner(): stat failed for string in %s on line %d
+bool(false)
+
+Warning: fileowner(): stat failed for 100 in %s on line %d
+bool(false)
+
+Warning: fileowner() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: fileowner() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fileowner_variation1.phpt b/ext/standard/tests/file/fileowner_variation1.phpt
new file mode 100644
index 0000000..b70ac36
--- /dev/null
+++ b/ext/standard/tests/file/fileowner_variation1.phpt
@@ -0,0 +1,48 @@
+--TEST--
+Test fileowner() function: usage variations - links
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip Do not run on Windows');
+}
+--FILE--
+<?php
+/* Prototype: int fileowner ( string $filename )
+ * Description: Returns the user ID of the owner of the file, or
+ * FALSE in case of an error.
+ */
+
+/* Creating soft and hard links to a file and applying fileowner() on links */
+
+$file_path = dirname(__FILE__);
+fclose( fopen($file_path."/fileowner_variation1.tmp", "w") );
+
+echo "*** Testing fileowner() with links ***\n";
+/* With symlink */
+symlink($file_path."/fileowner_variation1.tmp", $file_path."/fileowner_variation1_symlink.tmp");
+var_dump( fileowner($file_path."/fileowner_variation1_symlink.tmp") ); //expected true
+clearstatcache();
+
+/* With hardlink */
+link($file_path."/fileowner_variation1.tmp", $file_path."/fileowner_variation1_link.tmp");
+var_dump( fileowner($file_path."/fileowner_variation1_link.tmp") ); // expected: true
+clearstatcache();
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/fileowner_variation1_symlink.tmp");
+unlink($file_path."/fileowner_variation1_link.tmp");
+unlink($file_path."/fileowner_variation1.tmp");
+?>
+
+--EXPECTF--
+*** Testing fileowner() with links ***
+int(%d)
+int(%d)
+
+*** Done ***
diff --git a/ext/standard/tests/file/fileowner_variation2.phpt b/ext/standard/tests/file/fileowner_variation2.phpt
new file mode 100644
index 0000000..feff767
--- /dev/null
+++ b/ext/standard/tests/file/fileowner_variation2.phpt
@@ -0,0 +1,72 @@
+--TEST--
+Test fileowner() function: usage variations - invalid filenames
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype: int fileowner ( string $filename )
+ * Description: Returns the user ID of the owner of the file, or
+ * FALSE in case of an error.
+ */
+
+/* Testing fileowner() with invalid arguments -int, float, bool, NULL, resource */
+
+$file_path = dirname(__FILE__);
+$file_handle = fopen($file_path."/fileowner_variation2.tmp", "w");
+
+echo "*** Testing Invalid file types ***\n";
+$filenames = array(
+ /* Invalid filenames */
+ -2.34555,
+ " ",
+ "",
+ TRUE,
+ FALSE,
+ NULL,
+ $file_handle,
+
+ /* scalars */
+ 1234,
+ 0
+);
+
+/* loop through to test each element the above array */
+foreach( $filenames as $filename ) {
+ var_dump( fileowner($filename) );
+ clearstatcache();
+}
+fclose($file_handle);
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/fileowner_variation2.tmp");
+?>
+--EXPECTF--
+*** Testing Invalid file types ***
+
+Warning: fileowner(): stat failed for -2.34555 in %s on line %d
+bool(false)
+
+Warning: fileowner(): stat failed for in %s on line %d
+bool(false)
+bool(false)
+
+Warning: fileowner(): stat failed for 1 in %s on line %d
+bool(false)
+bool(false)
+bool(false)
+
+Warning: fileowner() expects parameter 1 to be a valid path, resource given in %s on line %d
+NULL
+
+Warning: fileowner(): stat failed for 1234 in %s on line %d
+bool(false)
+
+Warning: fileowner(): stat failed for 0 in %s on line %d
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fileowner_variation3.phpt b/ext/standard/tests/file/fileowner_variation3.phpt
new file mode 100644
index 0000000..6f91c31
--- /dev/null
+++ b/ext/standard/tests/file/fileowner_variation3.phpt
@@ -0,0 +1,86 @@
+--TEST--
+Test fileowner() function: usage variations - diff. path notations
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype: int fileowner ( string $filename )
+ * Description: Returns the user ID of the owner of the file, or
+ * FALSE in case of an error.
+ */
+
+/* Passing file names with different notations, using slashes, wild-card chars */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Testing fileowner() with different notations of file names ***\n";
+$dir_name = $file_path."/fileowner_variation3";
+mkdir($dir_name);
+$file_handle = fopen($dir_name."/fileowner_variation3.tmp", "w");
+fclose($file_handle);
+
+$files_arr = array(
+ "/fileowner_variation3/fileowner_variation3.tmp",
+
+ /* Testing a file trailing slash */
+ "/fileowner_variation3/fileowner_variation3.tmp/",
+
+ /* Testing file with double slashes */
+ "/fileowner_variation3//fileowner_variation3.tmp",
+ "//fileowner_variation3//fileowner_variation3.tmp",
+ "/fileowner_variation3/*.tmp",
+ "fileowner_variation3/fileowner*.tmp",
+
+ /* Testing Binary safe */
+ "/fileowner_variation3/fileowner_variation3.tmp".chr(0),
+ "/fileowner_variation3/fileowner_variation3.tmp\0"
+);
+
+$count = 1;
+/* loop through to test each element in the above array */
+foreach($files_arr as $file) {
+ echo "- Iteration $count -\n";
+ var_dump( fileowner( $file_path."/".$file ) );
+ clearstatcache();
+ $count++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$dir_name = $file_path."/fileowner_variation3";
+unlink($dir_name."/fileowner_variation3.tmp");
+rmdir($dir_name);
+?>
+--EXPECTF--
+*** Testing fileowner() with different notations of file names ***
+- Iteration 1 -
+int(%d)
+- Iteration 2 -
+
+Warning: fileowner(): stat failed for %s//fileowner_variation3/fileowner_variation3.tmp/ in %s on line %d
+bool(false)
+- Iteration 3 -
+int(%d)
+- Iteration 4 -
+int(%d)
+- Iteration 5 -
+
+Warning: fileowner(): stat failed for %s//fileowner_variation3/*.tmp in %s on line %d
+bool(false)
+- Iteration 6 -
+
+Warning: fileowner(): stat failed for %s/fileowner_variation3/fileowner*.tmp in %s on line %d
+bool(false)
+- Iteration 7 -
+
+Warning: fileowner() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+- Iteration 8 -
+
+Warning: fileowner() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+
+*** Done ***
diff --git a/ext/standard/tests/file/fileperms_variation1.phpt b/ext/standard/tests/file/fileperms_variation1.phpt
new file mode 100644
index 0000000..e90cf87
--- /dev/null
+++ b/ext/standard/tests/file/fileperms_variation1.phpt
@@ -0,0 +1,47 @@
+--TEST--
+Test fileperms() function: usage variations - links
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip Do not run on Windows');
+}
+--FILE--
+<?php
+/* Prototype: int fileperms ( string $filename )
+ * Description: Returns the group ID of the file, or FALSE in case of an error.
+ */
+
+/* Creating soft and hard links to a file and applying fileperms() on links */
+
+$file_path = dirname(__FILE__);
+fclose( fopen($file_path."/fileperms_variation1.tmp", "w") );
+
+echo "*** Testing fileperms() with links ***\n";
+/* With symlink */
+symlink($file_path."/fileperms_variation1.tmp", $file_path."/fileperms_variation1_symlink.tmp");
+var_dump( fileperms($file_path."/fileperms_variation1_symlink.tmp") ); //expected true
+clearstatcache();
+
+/* With hardlink */
+link($file_path."/fileperms_variation1.tmp", $file_path."/fileperms_variation1_link.tmp");
+var_dump( fileperms($file_path."/fileperms_variation1_link.tmp") ); // expected: true
+clearstatcache();
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/fileperms_variation1_symlink.tmp");
+unlink($file_path."/fileperms_variation1_link.tmp");
+unlink($file_path."/fileperms_variation1.tmp");
+?>
+
+--EXPECTF--
+*** Testing fileperms() with links ***
+int(%d)
+int(%d)
+
+*** Done ***
diff --git a/ext/standard/tests/file/fileperms_variation2.phpt b/ext/standard/tests/file/fileperms_variation2.phpt
new file mode 100644
index 0000000..47c0c65
--- /dev/null
+++ b/ext/standard/tests/file/fileperms_variation2.phpt
@@ -0,0 +1,71 @@
+--TEST--
+Test fileperms() function: usage variations - invalid filenames
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype: int fileperms ( string $filename )
+ * Description: Returns the group ID of the file, or FALSE in case of an error.
+ */
+
+/* Testing fileperms() with invalid arguments -int, float, bool, NULL, resource */
+
+$file_path = dirname(__FILE__);
+$file_handle = fopen($file_path."/fileperms_variation2.tmp", "w");
+
+echo "*** Testing Invalid file types ***\n";
+$filenames = array(
+ /* Invalid filenames */
+ -2.34555,
+ " ",
+ "",
+ TRUE,
+ FALSE,
+ NULL,
+ $file_handle,
+
+ /* scalars */
+ 1234,
+ 0
+);
+
+/* loop through to test each element the above array */
+foreach( $filenames as $filename ) {
+ var_dump( fileperms($filename) );
+ clearstatcache();
+}
+fclose($file_handle);
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/fileperms_variation2.tmp");
+?>
+--EXPECTF--
+*** Testing Invalid file types ***
+
+Warning: fileperms(): stat failed for -2.34555 in %s on line %d
+bool(false)
+
+Warning: fileperms(): stat failed for in %s on line %d
+bool(false)
+bool(false)
+
+Warning: fileperms(): stat failed for 1 in %s on line %d
+bool(false)
+bool(false)
+bool(false)
+
+Warning: fileperms() expects parameter 1 to be a valid path, resource given in %s on line %d
+NULL
+
+Warning: fileperms(): stat failed for 1234 in %s on line %d
+bool(false)
+
+Warning: fileperms(): stat failed for 0 in %s on line %d
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fileperms_variation3.phpt b/ext/standard/tests/file/fileperms_variation3.phpt
new file mode 100644
index 0000000..575fe11
--- /dev/null
+++ b/ext/standard/tests/file/fileperms_variation3.phpt
@@ -0,0 +1,85 @@
+--TEST--
+Test fileperms() function: usage variations - diff. path notations
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype: int fileperms ( string $filename )
+ * Description: Returns the group ID of the file, or FALSE in case of an error.
+ */
+
+/* Passing file names with different notations, using slashes, wild-card chars */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Testing fileperms() with different notations of file names ***\n";
+$dir_name = $file_path."/fileperms_variation3";
+mkdir($dir_name);
+$file_handle = fopen($dir_name."/fileperms_variation3.tmp", "w");
+fclose($file_handle);
+
+$files_arr = array(
+ "/fileperms_variation3/fileperms_variation3.tmp",
+
+ /* Testing a file trailing slash */
+ "/fileperms_variation3/fileperms_variation3.tmp/",
+
+ /* Testing file with double slashes */
+ "/fileperms_variation3//fileperms_variation3.tmp",
+ "//fileperms_variation3//fileperms_variation3.tmp",
+ "/fileperms_variation3/*.tmp",
+ "fileperms_variation3/fileperms*.tmp",
+
+ /* Testing Binary safe */
+ "/fileperms_variation3/fileperms_variation3.tmp".chr(0),
+ "/fileperms_variation3/fileperms_variation3.tmp\0"
+);
+
+$count = 1;
+/* loop through to test each element in the above array */
+foreach($files_arr as $file) {
+ echo "- Iteration $count -\n";
+ var_dump( fileperms( $file_path."/".$file ) );
+ clearstatcache();
+ $count++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$dir_name = $file_path."/fileperms_variation3";
+unlink($dir_name."/fileperms_variation3.tmp");
+rmdir($dir_name);
+?>
+--EXPECTF--
+*** Testing fileperms() with different notations of file names ***
+- Iteration 1 -
+int(%d)
+- Iteration 2 -
+
+Warning: fileperms(): stat failed for %s//fileperms_variation3/fileperms_variation3.tmp/ in %s on line %d
+bool(false)
+- Iteration 3 -
+int(%d)
+- Iteration 4 -
+int(%d)
+- Iteration 5 -
+
+Warning: fileperms(): stat failed for %s//fileperms_variation3/*.tmp in %s on line %d
+bool(false)
+- Iteration 6 -
+
+Warning: fileperms(): stat failed for %s/fileperms_variation3/fileperms*.tmp in %s on line %d
+bool(false)
+- Iteration 7 -
+
+Warning: fileperms() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+- Iteration 8 -
+
+Warning: fileperms() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+
+*** Done ***
diff --git a/ext/standard/tests/file/filesize_basic.phpt b/ext/standard/tests/file/filesize_basic.phpt
new file mode 100644
index 0000000..58041b9
--- /dev/null
+++ b/ext/standard/tests/file/filesize_basic.phpt
@@ -0,0 +1,39 @@
+--TEST--
+Test filesize() function: basic functionaity
+--FILE--
+<?php
+/*
+ * Prototype: int filesize ( string $filename );
+ * Description: Returns the size of the file in bytes, or FALSE
+ * (and generates an error of level E_WARNING) in case of an error.
+ */
+
+
+echo "*** Testing size of files and directories with filesize() ***\n";
+
+$file_path = dirname(__FILE__);
+
+var_dump( filesize(__FILE__) );
+var_dump( filesize(".") );
+
+/* Empty file */
+$file_name = $file_path."/filesize_basic.tmp";
+$file_handle = fopen($file_name, "w");
+fclose($file_handle);
+var_dump( filesize($file_name) );
+
+echo "*** Done ***\n";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$file_name = $file_path."/filesize_basic.tmp";
+unlink($file_name);
+?>
+--EXPECTF--
+*** Testing size of files and directories with filesize() ***
+int(%d)
+int(%d)
+int(0)
+*** Done ***
+
diff --git a/ext/standard/tests/file/filesize_error.phpt b/ext/standard/tests/file/filesize_error.phpt
new file mode 100644
index 0000000..6d8cfa8
--- /dev/null
+++ b/ext/standard/tests/file/filesize_error.phpt
@@ -0,0 +1,41 @@
+--TEST--
+Test filesize() function: error conditions
+--FILE--
+<?php
+/*
+ * Prototype : int filesize ( string $filename );
+ * Description : Returns the size of the file in bytes, or FALSE
+ * (and generates an error of level E_WARNING) in case of an error.
+ */
+
+echo "*** Testing filesize(): error conditions ***";
+
+/* Non-existing file or dir */
+var_dump( filesize("/no/such/file") );
+var_dump( filesize("/no/such/dir") );
+
+/* No.of arguments less than expected */
+var_dump( filesize() );
+
+/* No.of arguments greater than expected */
+var_dump( filesize(__FILE__, 2000) );
+echo "\n";
+
+echo "*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing filesize(): error conditions ***
+Warning: filesize(): stat failed for /no/such/file in %s on line %d
+bool(false)
+
+Warning: filesize(): stat failed for /no/such/dir in %s on line %d
+bool(false)
+
+Warning: filesize() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: filesize() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/filesize_variation1-win32.phpt b/ext/standard/tests/file/filesize_variation1-win32.phpt
new file mode 100644
index 0000000..e9ff053
--- /dev/null
+++ b/ext/standard/tests/file/filesize_variation1-win32.phpt
@@ -0,0 +1,45 @@
+--TEST--
+Test filesize() function: usage variations - size of files
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip only valid for Windows');
+}
+--FILE--
+<?php
+/*
+ Prototype : int filesize ( string $filename );
+ Description : Returns the size of the file in bytes, or FALSE
+ (and generates an error of level E_WARNING) in case of an error.
+*/
+
+$file_path = dirname(__FILE__);
+require($file_path."/file.inc");
+
+echo "*** Testing filesize(): usage variations ***\n";
+
+echo "*** Checking filesize() with different size of files ***\n";
+for($size = 1; $size <10000; $size = $size+1000)
+{
+ create_files($file_path, 1, "numeric", 0755, $size, "w", "filesize_variation");
+ var_dump( filesize( $file_path."/filesize_variation1.tmp") );
+ clearstatcache();
+ delete_files($file_path, 1, "filesize_variation");
+}
+
+echo "*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing filesize(): usage variations ***
+*** Checking filesize() with different size of files ***
+int(1024)
+int(1025024)
+int(2049024)
+int(3073024)
+int(4097024)
+int(5121024)
+int(6145024)
+int(7169024)
+int(8193024)
+int(9217024)
+*** Done ***
diff --git a/ext/standard/tests/file/filesize_variation1.phpt b/ext/standard/tests/file/filesize_variation1.phpt
new file mode 100644
index 0000000..0a490cd
--- /dev/null
+++ b/ext/standard/tests/file/filesize_variation1.phpt
@@ -0,0 +1,45 @@
+--TEST--
+Test filesize() function: usage variations - size of files
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip Not valid on Windows');
+}
+--FILE--
+<?php
+/*
+ Prototype : int filesize ( string $filename );
+ Description : Returns the size of the file in bytes, or FALSE
+ (and generates an error of level E_WARNING) in case of an error.
+*/
+
+$file_path = dirname(__FILE__);
+require($file_path."/file.inc");
+
+echo "*** Testing filesize(): usage variations ***\n";
+
+echo "*** Checking filesize() with different size of files ***\n";
+for($size = 1; $size <10000; $size = $size+1000)
+{
+ create_files($file_path, 1, "numeric", 0755, $size, "w", "filesize_variation");
+ var_dump( filesize( $file_path."/filesize_variation1.tmp") );
+ clearstatcache();
+ delete_files($file_path, 1, "filesize_variation");
+}
+
+echo "Done\n";
+
+--EXPECTF--
+*** Testing filesize(): usage variations ***
+*** Checking filesize() with different size of files ***
+int(%d)
+int(%d)
+int(%d)
+int(%d)
+int(%d)
+int(%d)
+int(%d)
+int(%d)
+int(%d)
+int(%d)
+Done
diff --git a/ext/standard/tests/file/filesize_variation2-win32.phpt b/ext/standard/tests/file/filesize_variation2-win32.phpt
new file mode 100644
index 0000000..544e3aa
--- /dev/null
+++ b/ext/standard/tests/file/filesize_variation2-win32.phpt
@@ -0,0 +1,83 @@
+--TEST--
+Test filesize() function: usage variations - size of dir/subdir
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip only valid for Windows');
+}
+--FILE--
+<?php
+/*
+ Prototype : int filesize ( string $filename );
+ Description : Returns the size of the file in bytes, or FALSE
+ (and generates an error of level E_WARNING) in case of an error.
+*/
+
+$file_path = dirname(__FILE__);
+require($file_path."/file.inc");
+
+echo "*** Testing filesize(): usage variations ***\n";
+
+echo "\n*** Testing size of a dir, sub-dir and file with filesize() ***\n";
+echo "-- Creating a base dir, and checking its size --\n";
+mkdir( $file_path."/filesize_variation2");
+var_dump( filesize( $file_path."/filesize_variation2"));
+clearstatcache();
+
+echo "-- Creating a file inside base dir, and checking dir & file size --\n";
+create_files($file_path."/filesize_variation2", 1, "numeric", 0755, 1, "w", "filesize_variation", 2);
+var_dump( filesize( $file_path."/filesize_variation2"));
+clearstatcache();
+var_dump( filesize( $file_path."/filesize_variation2/filesize_variation2.tmp"));
+clearstatcache();
+delete_files($file_path."/filesize_variation2", 1, "filesize_variation", 2);
+
+echo "-- Creating an empty sub-dir in base-dir, and checking size of base and sub dir --\n";
+mkdir( $file_path."/filesize_variation2/filesize_variation2_sub");
+var_dump( filesize( $file_path."/filesize_variation2")); // size of base dir
+clearstatcache();
+var_dump( filesize( $file_path."/filesize_variation2/filesize_variation2_sub")); // size of subdir
+clearstatcache();
+
+echo "-- Creating a file inside sub-dir, and checking size of base, subdir and file created --\n";
+// create only the file, as base and subdir is already created
+$filename = $file_path."/filesize_variation2/filesize_variation2_sub/filesize_variation2.tmp";
+$file_handle = fopen($filename, "w");
+fwrite($file_handle, str_repeat("Hello,World ", 1000) ); // create file of size 12000 bytes
+fclose($file_handle);
+// size of base dir
+var_dump( filesize( $file_path."/filesize_variation2"));
+clearstatcache();
+// size of subdir
+var_dump( filesize( $file_path."/filesize_variation2/filesize_variation2_sub"));
+clearstatcache();
+// size of file inside subdir
+var_dump( filesize( $file_path."/filesize_variation2/filesize_variation2_sub/filesize_variation2.tmp"));
+clearstatcache();
+
+echo "*** Done ***\n";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/filesize_variation2/filesize_variation2_sub/filesize_variation2.tmp");
+rmdir($file_path."/filesize_variation2/filesize_variation2_sub");
+rmdir($file_path."/filesize_variation2");
+?>
+--EXPECTF--
+*** Testing filesize(): usage variations ***
+
+*** Testing size of a dir, sub-dir and file with filesize() ***
+-- Creating a base dir, and checking its size --
+int(0)
+-- Creating a file inside base dir, and checking dir & file size --
+int(0)
+int(1024)
+-- Creating an empty sub-dir in base-dir, and checking size of base and sub dir --
+int(0)
+int(0)
+-- Creating a file inside sub-dir, and checking size of base, subdir and file created --
+int(0)
+int(0)
+int(12000)
+*** Done ***
diff --git a/ext/standard/tests/file/filesize_variation2.phpt b/ext/standard/tests/file/filesize_variation2.phpt
new file mode 100644
index 0000000..8a7594e
--- /dev/null
+++ b/ext/standard/tests/file/filesize_variation2.phpt
@@ -0,0 +1,83 @@
+--TEST--
+Test filesize() function: usage variations - size of dir/subdir
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip only valid for Linux');
+}
+--FILE--
+<?php
+/*
+ Prototype : int filesize ( string $filename );
+ Description : Returns the size of the file in bytes, or FALSE
+ (and generates an error of level E_WARNING) in case of an error.
+*/
+
+$file_path = dirname(__FILE__);
+require($file_path."/file.inc");
+
+echo "*** Testing filesize(): usage variations ***\n";
+
+echo "\n*** Testing size of a dir, sub-dir and file with filesize() ***\n";
+echo "-- Creating a base dir, and checking its size --\n";
+mkdir( $file_path."/filesize_variation2");
+var_dump( filesize( $file_path."/filesize_variation2"));
+clearstatcache();
+
+echo "-- Creating a file inside base dir, and checking dir & file size --\n";
+create_files($file_path."/filesize_variation2", 1, "numeric", 0755, 1, "w", "filesize_variation");
+var_dump( filesize( $file_path."/filesize_variation2"));
+clearstatcache();
+var_dump( filesize( $file_path."/filesize_variation2/filesize_variation1.tmp"));
+clearstatcache();
+delete_files($file_path."/filesize_variation2", 1, "filesize_variation");
+
+echo "-- Creating an empty sub-dir in base-dir, and checking size of base and sub dir --\n";
+mkdir( $file_path."/filesize_variation2/filesize_variation2_sub");
+var_dump( filesize( $file_path."/filesize_variation2")); // size of base dir
+clearstatcache();
+var_dump( filesize( $file_path."/filesize_variation2/filesize_variation2_sub")); // size of subdir
+clearstatcache();
+
+echo "-- Creating a file inside sub-dir, and checking size of base, subdir and file created --\n";
+// create only the file, as base and subdir is already created
+$filename = $file_path."/filesize_variation2/filesize_variation2_sub/filesize_variation2.tmp";
+$file_handle = fopen($filename, "w");
+fwrite($file_handle, str_repeat("Hello,World ", 1000) ); // create file of size 12000 bytes
+fclose($file_handle);
+// size of base dir
+var_dump( filesize( $file_path."/filesize_variation2"));
+clearstatcache();
+// size of subdir
+var_dump( filesize( $file_path."/filesize_variation2/filesize_variation2_sub"));
+clearstatcache();
+// size of file inside subdir
+var_dump( filesize( $file_path."/filesize_variation2/filesize_variation2_sub/filesize_variation2.tmp"));
+clearstatcache();
+
+echo "*** Done ***\n";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/filesize_variation2/filesize_variation2_sub/filesize_variation2.tmp");
+rmdir($file_path."/filesize_variation2/filesize_variation2_sub");
+rmdir($file_path."/filesize_variation2");
+?>
+--EXPECTF--
+*** Testing filesize(): usage variations ***
+
+*** Testing size of a dir, sub-dir and file with filesize() ***
+-- Creating a base dir, and checking its size --
+int(%d)
+-- Creating a file inside base dir, and checking dir & file size --
+int(%d)
+int(1024)
+-- Creating an empty sub-dir in base-dir, and checking size of base and sub dir --
+int(%d)
+int(%d)
+-- Creating a file inside sub-dir, and checking size of base, subdir and file created --
+int(%d)
+int(%d)
+int(12000)
+*** Done ***
diff --git a/ext/standard/tests/file/filesize_variation3-win32.phpt b/ext/standard/tests/file/filesize_variation3-win32.phpt
new file mode 100644
index 0000000..f466959
--- /dev/null
+++ b/ext/standard/tests/file/filesize_variation3-win32.phpt
@@ -0,0 +1,70 @@
+--TEST--
+Test filesize() function: usage variations - file size after truncate
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip only valid for Windows');
+}
+--FILE--
+<?php
+/*
+ Prototype : int filesize ( string $filename );
+ Description : Returns the size of the file in bytes, or FALSE
+ (and generates an error of level E_WARNING) in case of an error.
+*/
+
+$file_path = dirname(__FILE__);
+
+echo "*** Testing filesize(): usage variations ***\n";
+$filename = $file_path."/filesize_variation3.tmp";
+$file_handle = fopen($filename, "w");
+fwrite($file_handle, (binary)str_repeat("Hello,World ", 1000) ); // create file of size 12000 bytes
+fclose($file_handle);
+
+echo "-- Testing filesize() after truncating the file to a new length --\n";
+// truncate the file created earlier in subdir, the size of the file is 12000bytes
+// truncate the same file, in the loop , each time with the decrement in size by 1200 bytes,
+// until -1200bytes size
+for($size = filesize($filename); $size>=-1200; $size-=1200) {
+ $file_handle = fopen($filename, "r+");
+ var_dump( ftruncate($file_handle, $size) );
+ fclose($file_handle);
+ var_dump( filesize($filename) );
+ clearstatcache();
+}
+
+echo "*** Done ***\n";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/filesize_variation3.tmp");
+?>
+--EXPECTF--
+*** Testing filesize(): usage variations ***
+-- Testing filesize() after truncating the file to a new length --
+bool(true)
+int(12000)
+bool(true)
+int(10800)
+bool(true)
+int(9600)
+bool(true)
+int(8400)
+bool(true)
+int(7200)
+bool(true)
+int(6000)
+bool(true)
+int(4800)
+bool(true)
+int(3600)
+bool(true)
+int(2400)
+bool(true)
+int(1200)
+bool(true)
+int(0)
+bool(false)
+int(0)
+*** Done ***
diff --git a/ext/standard/tests/file/filesize_variation3.phpt b/ext/standard/tests/file/filesize_variation3.phpt
new file mode 100644
index 0000000..3ae06fa
--- /dev/null
+++ b/ext/standard/tests/file/filesize_variation3.phpt
@@ -0,0 +1,70 @@
+--TEST--
+Test filesize() function: usage variations - file size after truncate
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip only valid for Linux');
+}
+--FILE--
+<?php
+/*
+ Prototype : int filesize ( string $filename );
+ Description : Returns the size of the file in bytes, or FALSE
+ (and generates an error of level E_WARNING) in case of an error.
+*/
+
+$file_path = dirname(__FILE__);
+
+echo "*** Testing filesize(): usage variations ***\n";
+$filename = $file_path."/filesize_variation3.tmp";
+$file_handle = fopen($filename, "w");
+fwrite($file_handle, str_repeat("Hello,World ", 1000) ); // create file of size 12000 bytes
+fclose($file_handle);
+
+echo "-- Testing filesize() after truncating the file to a new length --\n";
+// truncate the file created earlier in subdir, the size of the file is 12000bytes
+// truncate the same file, in the loop , each time with the decrement in size by 1200 bytes,
+// until -1200bytes size
+for($size = filesize($filename); $size>=-1200; $size-=1200) {
+ $file_handle = fopen($filename, "r+");
+ var_dump( ftruncate($file_handle, $size) );
+ fclose($file_handle);
+ var_dump( filesize($filename) );
+ clearstatcache();
+}
+
+echo "*** Done ***\n";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/filesize_variation3.tmp");
+?>
+--EXPECTF--
+*** Testing filesize(): usage variations ***
+-- Testing filesize() after truncating the file to a new length --
+bool(true)
+int(12000)
+bool(true)
+int(10800)
+bool(true)
+int(9600)
+bool(true)
+int(8400)
+bool(true)
+int(7200)
+bool(true)
+int(6000)
+bool(true)
+int(4800)
+bool(true)
+int(3600)
+bool(true)
+int(2400)
+bool(true)
+int(1200)
+bool(true)
+int(0)
+bool(false)
+int(0)
+*** Done ***
diff --git a/ext/standard/tests/file/filesize_variation4-win32.phpt b/ext/standard/tests/file/filesize_variation4-win32.phpt
new file mode 100644
index 0000000..5f20f42
--- /dev/null
+++ b/ext/standard/tests/file/filesize_variation4-win32.phpt
@@ -0,0 +1,109 @@
+--TEST--
+Test filesize() function: usage variations - file mode & holes in file
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip only valid for Windows');
+}
+--FILE--
+<?php
+/*
+ Prototype : int filesize ( string $filename );
+ Description : Returns the size of the file in bytes, or FALSE
+ (and generates an error of level E_WARNING) in case of an error.
+*/
+
+$file_path = dirname(__FILE__);
+require($file_path."/file.inc");
+
+echo "*** Testing filesize(): usage variations ***\n";
+echo "\n*** Testing filesize() with data written using different file modes and by creating holes in file ***\n";
+
+$filename = $file_path."/filesize_variation4.tmp";
+$string = "Test 2 test the filesize() fn, with data containing all the types like !@@##$%^&*():<>?|~+!;',.\][{}(special) chars, 12345(numeric) chars, and \n(newline char), \t(tab), \0, \r and so on........\0";
+echo "-- opening the file in 'w' mode and get the size --\n";
+$file_handle = fopen($filename, "w");
+var_dump( strlen($string) ); //strlen of the string
+fwrite($file_handle, $string);
+fclose($file_handle);
+var_dump( filesize($filename) ); //size of the file = strlen of string
+clearstatcache();
+
+echo "-- opening the file in 'wt' mode and get the size --\n";
+$file_handle = fopen($filename, "wt");
+var_dump( strlen($string) ); //strlen of the string = 191 bytes
+fwrite($file_handle, $string);
+fclose($file_handle);
+var_dump( filesize($filename) ); //size of the file = 192 bytes != strlen of string
+clearstatcache();
+
+echo "-- opening the file in 'a' mode, adding data and checking the file --\n";
+$file_handle = fopen($filename, "a");
+fwrite($file_handle, "Hello, world");
+fclose($file_handle);
+var_dump( filesize($filename) ); //204 bytes
+clearstatcache();
+
+echo "-- opening the file in 'at' mode, adding data and checking the file --\n";
+$file_handle = fopen($filename, "at");
+fwrite($file_handle, "Hello, world\n");
+fclose($file_handle);
+var_dump( filesize($filename) ); //218 bytes
+clearstatcache();
+
+echo "-- creating a hole and checking the size --\n";
+$file_handle = fopen($filename, "a");
+var_dump( ftruncate($file_handle, 220) ); //creating 4 bytes of hole
+fclose($file_handle);
+var_dump( filesize($filename) ); //220 bytes
+clearstatcache();
+
+echo "-- writing data after hole and checking the size --\n";
+$file_handle = fopen($filename, "a");
+fwrite($file_handle, "Hello\0"); //wrting 6 bytes of data
+fclose($file_handle);
+var_dump( filesize($filename) ); //226 bytes
+clearstatcache();
+
+echo "-- opening the existing file in write mode --\n";
+fclose( fopen($filename, "w") );
+var_dump( filesize($filename) ); //0 bytes
+clearstatcache();
+
+echo "-- with empty file --\n";
+$filename = dirname(__FILE__)."/filesize_variation4_empty.tmp";
+fclose( fopen($filename, "w") );
+var_dump( filesize($filename) ); //0 bytes
+
+echo "*** Done ***\n";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/filesize_variation4.tmp");
+unlink($file_path."/filesize_variation4_empty.tmp");
+?>
+--EXPECTF--
+*** Testing filesize(): usage variations ***
+
+*** Testing filesize() with data written using different file modes and by creating holes in file ***
+-- opening the file in 'w' mode and get the size --
+int(191)
+int(191)
+-- opening the file in 'wt' mode and get the size --
+int(191)
+int(192)
+-- opening the file in 'a' mode, adding data and checking the file --
+int(204)
+-- opening the file in 'at' mode, adding data and checking the file --
+int(218)
+-- creating a hole and checking the size --
+bool(true)
+int(220)
+-- writing data after hole and checking the size --
+int(226)
+-- opening the existing file in write mode --
+int(0)
+-- with empty file --
+int(0)
+*** Done ***
diff --git a/ext/standard/tests/file/filesize_variation4.phpt b/ext/standard/tests/file/filesize_variation4.phpt
new file mode 100644
index 0000000..29f85fc
--- /dev/null
+++ b/ext/standard/tests/file/filesize_variation4.phpt
@@ -0,0 +1,111 @@
+--TEST--
+Test filesize() function: usage variations - file mode & holes in file
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip only valid for Linux');
+}
+--FILE--
+<?php
+/*
+ Prototype : int filesize ( string $filename );
+ Description : Returns the size of the file in bytes, or FALSE
+ (and generates an error of level E_WARNING) in case of an error.
+*/
+
+/* Testing filesize() with data written using different file modes and by creating holes in file */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Testing filesize(): usage variations ***\n";
+echo "\n*** Testing filesize() with data written using different file modes and by creating holes in file ***\n";
+
+$filename = $file_path."/filesize_variation4.tmp";
+$string = "Test 2 test the filesize() fn, with data containing all the types like !@@##$%^&*():<>?|~+!;',.\][{}(special) cha
+rs, 12345(numeric) chars, and \n(newline char), \t(tab), \0, \r and so on........\0";
+echo "-- opening the file in 'w' mode and get the size --\n";
+$file_handle = fopen($filename, "w");
+var_dump( strlen($string) ); //strlen of the string
+fwrite($file_handle, $string);
+fclose($file_handle);
+var_dump( filesize($filename) ); //size of the file = strlen of string
+clearstatcache();
+
+echo "-- opening the file in 'wt' mode and get the size --\n";
+$file_handle = fopen($filename, "wt");
+var_dump( strlen($string) ); //strlen of the string = 191 bytes
+fwrite($file_handle, $string);
+fclose($file_handle);
+var_dump( filesize($filename) ); //size of the file = strlen of string = 191 bytes
+clearstatcache();
+
+echo "-- opening the file in 'a' mode, adding data and checking the file --\n";
+$file_handle = fopen($filename, "a");
+fwrite($file_handle, "Hello, world");
+fclose($file_handle);
+var_dump( filesize($filename) ); //203 bytes
+clearstatcache();
+
+echo "-- opening the file in 'at' mode, adding data and checking the file --\n";
+$file_handle = fopen($filename, "at");
+fwrite($file_handle, "Hello, world\n");
+fclose($file_handle);
+var_dump( filesize($filename) ); //216 bytes
+clearstatcache();
+
+echo "-- creating a hole and checking the size --\n";
+$file_handle = fopen($filename, "a");
+var_dump( ftruncate($file_handle, 220) ); //creating 4 bytes of hole
+fclose($file_handle);
+var_dump( filesize($filename) ); //220 bytes
+clearstatcache();
+
+echo "-- writing data after hole and checking the size --\n";
+$file_handle = fopen($filename, "a");
+fwrite($file_handle, "Hello\0"); //wrting 6 bytes of data
+fclose($file_handle);
+var_dump( filesize($filename) ); //226 bytes
+clearstatcache();
+
+echo "-- opening the existing file in write mode --\n";
+fclose( fopen($filename, "w") );
+var_dump( filesize($filename) ); //0 bytes
+clearstatcache();
+
+echo "-- with empty file --\n";
+$filename = dirname(__FILE__)."/filesize_variation4_empty.tmp";
+fclose( fopen($filename, "w") );
+var_dump( filesize($filename) ); //0 bytes
+
+echo "*** Done ***\n";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/filesize_variation4.tmp");
+unlink($file_path."/filesize_variation4_empty.tmp");
+?>
+--EXPECTF--
+*** Testing filesize(): usage variations ***
+
+*** Testing filesize() with data written using different file modes and by creating holes in file ***
+-- opening the file in 'w' mode and get the size --
+int(192)
+int(192)
+-- opening the file in 'wt' mode and get the size --
+int(192)
+int(192)
+-- opening the file in 'a' mode, adding data and checking the file --
+int(204)
+-- opening the file in 'at' mode, adding data and checking the file --
+int(217)
+-- creating a hole and checking the size --
+bool(true)
+int(220)
+-- writing data after hole and checking the size --
+int(226)
+-- opening the existing file in write mode --
+int(0)
+-- with empty file --
+int(0)
+*** Done ***
diff --git a/ext/standard/tests/file/filesize_variation5.phpt b/ext/standard/tests/file/filesize_variation5.phpt
new file mode 100644
index 0000000..638f8ba
--- /dev/null
+++ b/ext/standard/tests/file/filesize_variation5.phpt
@@ -0,0 +1,34 @@
+--TEST--
+Test filesize() function: usage variations - size of files
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/*
+ * Prototype : int filesize ( string $filename );
+ * Description : Returns the size of the file in bytes, or FALSE
+ * (and generates an error of level E_WARNING) in case of an error.
+ */
+
+echo "*** Testing filesize(): usage variations ***\n";
+
+/* null, false, "", " " */
+var_dump( filesize(NULL) );
+var_dump( filesize(false) );
+var_dump( filesize('') );
+var_dump( filesize(' ') );
+var_dump( filesize('|') );
+echo "*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing filesize(): usage variations ***
+bool(false)
+bool(false)
+bool(false)
+
+Warning: filesize(): stat failed for in %s on line %d
+bool(false)
+
+Warning: filesize(): stat failed for | in %s on line %d
+bool(false)
+*** Done ***
diff --git a/ext/standard/tests/file/filestat.phpt b/ext/standard/tests/file/filestat.phpt
new file mode 100644
index 0000000..d02f9f2
--- /dev/null
+++ b/ext/standard/tests/file/filestat.phpt
@@ -0,0 +1,63 @@
+--TEST--
+various file stat func tests
+--FILE--
+<?php
+
+var_dump(fileinode("."));
+var_dump(fileowner("."));
+var_dump(filegroup("."));
+var_dump(fileatime("."));
+var_dump(filectime("."));
+
+var_dump(fileinode("./.."));
+var_dump(fileowner("./.."));
+var_dump(filegroup("./.."));
+var_dump(fileatime("./.."));
+var_dump(filectime("./.."));
+
+var_dump(fileinode(__FILE__));
+var_dump(fileowner(__FILE__));
+var_dump(filegroup(__FILE__));
+var_dump(fileatime(__FILE__));
+var_dump(filectime(__FILE__));
+
+var_dump(fileinode("/no/such/file/or/dir"));
+var_dump(fileowner("/no/such/file/or/dir"));
+var_dump(filegroup("/no/such/file/or/dir"));
+var_dump(fileatime("/no/such/file/or/dir"));
+var_dump(filectime("/no/such/file/or/dir"));
+
+echo "Done\n";
+?>
+--EXPECTF--
+int(%d)
+int(%d)
+int(%d)
+int(%d)
+int(%d)
+int(%d)
+int(%d)
+int(%d)
+int(%d)
+int(%d)
+int(%d)
+int(%d)
+int(%d)
+int(%d)
+int(%d)
+
+Warning: fileinode(): stat failed for /no/such/file/or/dir in %s on line %d
+bool(false)
+
+Warning: fileowner(): stat failed for /no/such/file/or/dir in %s on line %d
+bool(false)
+
+Warning: filegroup(): stat failed for /no/such/file/or/dir in %s on line %d
+bool(false)
+
+Warning: fileatime(): stat failed for /no/such/file/or/dir in %s on line %d
+bool(false)
+
+Warning: filectime(): stat failed for /no/such/file/or/dir in %s on line %d
+bool(false)
+Done
diff --git a/ext/standard/tests/file/filetype_basic.phpt b/ext/standard/tests/file/filetype_basic.phpt
new file mode 100644
index 0000000..4a6d3b2
--- /dev/null
+++ b/ext/standard/tests/file/filetype_basic.phpt
@@ -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
index 0000000..b965272
--- /dev/null
+++ b/ext/standard/tests/file/filetype_error.phpt
@@ -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 "*** 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: filetype() expects exactly 1 parameter, 0 given in %s on line %d
+
+Warning: filetype() expects exactly 1 parameter, 2 given 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
index 0000000..3308cee
--- /dev/null
+++ b/ext/standard/tests/file/filetype_variation.phpt
@@ -0,0 +1,78 @@
+--TEST--
+Test filetype() function: Variations
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip no link()/symlink() on Windows');
+}
+if (!function_exists("posix_mkfifo")) {
+ die("skip no posix_mkfifo()");
+}
+?>
+--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 various types ***\n";
+$file_path = dirname(__FILE__);
+$file1 = $file_path."/filetype1_variation.tmp";
+$file2 = $file_path."/filetype2_variation.tmp";
+$file3 = $file_path."/filetype3_variation.tmp";
+$link1 = $file_path."/filetype1_variation_link.tmp";
+$link2 = $file_path."/filetype2_variation_link.tmp";
+
+fclose( fopen($file1, "w") );
+fclose( fopen($file2, "w") );
+
+echo "-- Checking with files --\n";
+print( filetype($file1) )."\n";
+print( filetype($file2) )."\n";
+clearstatcache();
+
+echo "-- Checking with links: hardlink --\n";
+link( $file1, $link1);
+print( filetype($link1 ) )."\n";
+
+echo "-- Checking with links: symlink --\n";
+symlink( $file2, $link2);
+print( filetype($link2) )."\n";
+
+unlink($link1);
+unlink($link2);
+unlink($file1);
+unlink($file2);
+
+echo "-- Checking with directory --\n";
+mkdir("$file_path/filetype_variation");
+print( filetype("$file_path/filetype_variation") )."\n";
+rmdir( "$file_path/filetype_variation" );
+
+echo "-- Checking with fifo --\n";
+posix_mkfifo( $file3, 0755);
+print( filetype( $file3) )."\n";
+unlink($file3);
+
+/* 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/filetype_variation2.phpt b/ext/standard/tests/file/filetype_variation2.phpt
new file mode 100644
index 0000000..d538e32
--- /dev/null
+++ b/ext/standard/tests/file/filetype_variation2.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Test filetype() function: Check character type
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip no /dev on Windows');
+}
+if (!file_exists("/dev/console")) {
+ die('skip /dev/console not available');
+}
+?>
+--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 "-- Checking for char --\n";
+print( filetype("/dev/console") )."\n";
+?>
+===DONE===
+--EXPECTF--
+-- Checking for char --
+char
+===DONE===
diff --git a/ext/standard/tests/file/filetype_variation3.phpt b/ext/standard/tests/file/filetype_variation3.phpt
new file mode 100644
index 0000000..9a1a68f
--- /dev/null
+++ b/ext/standard/tests/file/filetype_variation3.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Test filetype() function: Check block device
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip no /dev on Windows');
+}
+if (!file_exists("/dev/ram0")) {
+ die('skip /dev/ram0 not available');
+}
+?>
+--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 "-- Checking for block --\n";
+print( filetype("/dev/ram0") )."\n";
+?>
+===DONE===
+--EXPECTF--
+-- Checking for block --
+block
+===DONE===
diff --git a/ext/standard/tests/file/flock.phpt b/ext/standard/tests/file/flock.phpt
new file mode 100644
index 0000000..efc059c
--- /dev/null
+++ b/ext/standard/tests/file/flock.phpt
@@ -0,0 +1,64 @@
+--TEST--
+flock() tests
+--FILE--
+<?php
+
+$file = dirname(__FILE__)."/flock.dat";
+
+var_dump(flock());
+var_dump(flock("", "", $var));
+
+$fp = fopen($file, "w");
+fclose($fp);
+
+var_dump(flock($fp, LOCK_SH|LOCK_NB));
+
+$fp = fopen($file, "w");
+
+var_dump(flock($fp, LOCK_SH|LOCK_NB));
+var_dump(flock($fp, LOCK_UN));
+var_dump(flock($fp, LOCK_EX));
+var_dump(flock($fp, LOCK_UN));
+
+$would = array(1,2,3);
+var_dump(flock($fp, LOCK_SH|LOCK_NB, $would));
+var_dump($would);
+var_dump(flock($fp, LOCK_UN, $would));
+var_dump($would);
+var_dump(flock($fp, LOCK_EX, $would));
+var_dump($would);
+var_dump(flock($fp, LOCK_UN, $would));
+var_dump($would);
+
+var_dump(flock($fp, -1));
+var_dump(flock($fp, 0));
+
+@unlink($file);
+echo "Done\n";
+?>
+--EXPECTF--
+Warning: flock() expects at least 2 parameters, 0 given in %s on line %d
+NULL
+
+Warning: flock() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+
+Warning: flock(): %d is not a valid stream resource in %s on line %d
+bool(false)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+int(0)
+bool(true)
+int(0)
+bool(true)
+int(0)
+bool(true)
+int(0)
+bool(true)
+
+Warning: flock(): Illegal operation argument in %s on line %d
+bool(false)
+Done
diff --git a/ext/standard/tests/file/flock_basic.phpt b/ext/standard/tests/file/flock_basic.phpt
new file mode 100644
index 0000000..d218cee
--- /dev/null
+++ b/ext/standard/tests/file/flock_basic.phpt
@@ -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
index 0000000..fe61e2a
--- /dev/null
+++ b/ext/standard/tests/file/flock_error.phpt
@@ -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(): %d 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
index 0000000..af67ab4
--- /dev/null
+++ b/ext/standard/tests/file/flock_variation.phpt
@@ -0,0 +1,371 @@
+--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",
+ "",
+ /* binary input */
+ b"string",
+ b"",
+ "\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)
+-- Inner iteration 12 in 0 --
+bool(true)
+-- Inner iteration 13 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)
+-- Inner iteration 12 in 1 --
+bool(true)
+-- Inner iteration 13 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)
+-- Inner iteration 12 in 2 --
+bool(true)
+-- Inner iteration 13 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)
+-- Inner iteration 12 in 3 --
+bool(true)
+-- Inner iteration 13 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)
+-- Inner iteration 12 in 4 --
+bool(true)
+-- Inner iteration 13 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)
+-- Inner iteration 12 in 5 --
+bool(true)
+-- Inner iteration 13 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)
+-- Inner iteration 12 in 6 --
+bool(true)
+-- Inner iteration 13 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)
+-- Inner iteration 12 in 7 --
+bool(true)
+-- Inner iteration 13 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)
+-- Inner iteration 12 in 8 --
+bool(true)
+-- Inner iteration 13 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)
+-- Inner iteration 12 in 9 --
+bool(true)
+-- Inner iteration 13 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
index 0000000..1896051
--- /dev/null
+++ b/ext/standard/tests/file/fnmatch_basic.phpt
@@ -0,0 +1,49 @@
+--TEST--
+Test fnmatch() function: Basic functionality
+--SKIPIF--
+<?php
+if (!function_exists('fnmatch'))
+ die("skip fnmatch() function is not available");
+?>
+--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";
+?>
+--EXPECT--
+*** 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
index 0000000..5277874
--- /dev/null
+++ b/ext/standard/tests/file/fnmatch_error.phpt
@@ -0,0 +1,57 @@
+--TEST--
+Test fnmatch() function: Error conditions
+--SKIPIF--
+<?php
+if (!function_exists('fnmatch'))
+ die("skip fnmatch() function is not available");
+?>
+--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 a valid path, array given in %s on line %d
+NULL
+
+Warning: fnmatch() expects parameter 1 to be a valid path, resource given in %s on line %d
+NULL
+
+Warning: fnmatch() expects parameter 1 to be a valid path, object given in %s on line %d
+NULL
+
+Warning: fnmatch() expects at least 2 parameters, 1 given in %s on line %d%d
+NULL
+
+Warning: fnmatch() expects at least 2 parameters, 1 given in %s on line %d%d
+NULL
+
+Warning: fnmatch() expects at most 3 parameters, 4 given in %s on line %d%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
index 0000000..6d28528
--- /dev/null
+++ b/ext/standard/tests/file/fnmatch_variation.phpt
@@ -0,0 +1,505 @@
+--TEST--
+Test fnmatch() function: Variations
+--SKIPIF--
+<?php
+if (!function_exists('fnmatch'))
+ die("skip fnmatch() function is not available");
+?>
+--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";
+
+/* avoid using \, it breaks the pattern */
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ $file_name = str_replace('\\','/', $file_name);
+}
+
+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,
+
+/* binary inputs */
+32 => b"match*",
+33 => b"*.tmp",
+34 => b"mat*",
+35 => b"mat*tmp",
+36 => b"m*t",
+);
+
+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",
+
+ /* binary input */
+ b"string"
+);
+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 --
+
+Warning: fnmatch() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+-- Iteration 24 --
+
+Warning: fnmatch() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+-- 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)
+-- Iteration 32 --
+bool(false)
+-- Iteration 33 --
+bool(true)
+-- Iteration 34 --
+bool(false)
+-- Iteration 35 --
+bool(false)
+-- Iteration 36 --
+bool(false)
+
+*** 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)
+
+Warning: fnmatch() expects parameter 2 to be a valid path, string given in %s on line %d
+NULL
+bool(true)
+
+Warning: fnmatch() expects parameter 2 to be a valid path, string given in %s on line %d
+NULL
+bool(false)
+bool(true)
+-- Iteration 1 --
+
+Warning: fnmatch() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+
+Warning: fnmatch() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+
+Warning: fnmatch() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+
+Warning: fnmatch() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+
+Warning: fnmatch() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+
+Warning: fnmatch() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+-- Iteration 2 --
+bool(true)
+
+Warning: fnmatch() expects parameter 2 to be a valid path, string given in %s on line %d
+NULL
+bool(true)
+
+Warning: fnmatch() expects parameter 2 to be a valid path, string given in %s on line %d
+NULL
+bool(false)
+bool(true)
+-- Iteration 3 --
+
+Warning: fnmatch() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+
+Warning: fnmatch() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+
+Warning: fnmatch() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+
+Warning: fnmatch() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+
+Warning: fnmatch() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+
+Warning: fnmatch() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+-- Iteration 4 --
+bool(false)
+
+Warning: fnmatch() expects parameter 2 to be a valid path, string given in %s on line %d
+NULL
+bool(false)
+
+Warning: fnmatch() expects parameter 2 to be a valid path, string given in %s on line %d
+NULL
+bool(true)
+bool(false)
+-- Iteration 5 --
+bool(true)
+
+Warning: fnmatch() expects parameter 2 to be a valid path, string given in %s on line %d
+NULL
+bool(true)
+
+Warning: fnmatch() expects parameter 2 to be a valid path, string given in %s on line %d
+NULL
+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)
+
+Warning: fnmatch() expects parameter 2 to be a valid path, string given in %s on line %d
+NULL
+bool(false)
+bool(false)
+-- Iteration 1 --
+bool(true)
+bool(true)
+bool(true)
+
+Warning: fnmatch() expects parameter 2 to be a valid path, string given in %s on line %d
+NULL
+bool(false)
+bool(false)
+-- Iteration 2 --
+bool(true)
+bool(true)
+bool(true)
+
+Warning: fnmatch() expects parameter 2 to be a valid path, string given in %s on line %d
+NULL
+bool(false)
+bool(false)
+-- Iteration 3 --
+
+Warning: fnmatch() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+
+Warning: fnmatch() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+
+Warning: fnmatch() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+
+Warning: fnmatch() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+
+Warning: fnmatch() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+
+Warning: fnmatch() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+-- Iteration 4 --
+bool(false)
+bool(false)
+bool(false)
+
+Warning: fnmatch() expects parameter 2 to be a valid path, string given in %s on line %d
+NULL
+bool(true)
+bool(false)
+-- Iteration 5 --
+bool(false)
+bool(false)
+bool(false)
+
+Warning: fnmatch() expects parameter 2 to be a valid path, string given in %s on line %d
+NULL
+bool(false)
+bool(true)
+
+*** Done ***
diff --git a/ext/standard/tests/file/fopen_include_path.inc b/ext/standard/tests/file/fopen_include_path.inc
new file mode 100644
index 0000000..7d6723a
--- /dev/null
+++ b/ext/standard/tests/file/fopen_include_path.inc
@@ -0,0 +1,92 @@
+<?php
+$pwd = getcwd();
+$f = basename(__FILE__);
+$dir1 = $pwd."/".$f.".dir1";
+$dir2 = $pwd."/".$f.".dir2";
+$dir3 = $pwd."/".$f.".dir3";
+//invalid directory
+$dir4 = $pwd."/".$f.".dir4";
+$newdirs = array($dir1, $dir2, $dir3);
+
+$reldirs = array("dir1", "dir2", "dir3");
+
+function generate_next_rel_path() {
+ global $reldirs;
+ //create the include directory structure
+ $pathSep = ":";
+ $newIncludePath = "";
+ if(substr(PHP_OS, 0, 3) == 'WIN' ) {
+ $pathSep = ";";
+ }
+ foreach($reldirs as $newdir) {
+ $newIncludePath .= $newdir.$pathSep;
+ }
+ return "dir4".$pathSep . $newIncludePath;
+}
+
+function generate_next_path() {
+ global $newdirs, $dir4;
+ //create the include directory structure
+ $pathSep = ":";
+ $newIncludePath = "";
+ if(substr(PHP_OS, 0, 3) == 'WIN' ) {
+ $pathSep = ";";
+ }
+ foreach($newdirs as $newdir) {
+ $newIncludePath .= $newdir.$pathSep;
+ }
+ return $dir4.$pathSep . $newIncludePath;
+}
+
+
+function create_include_path() {
+
+ global $newdirs;
+ //create the include directory structure
+ $pathSep = ":";
+ $newIncludePath = "";
+ if(substr(PHP_OS, 0, 3) == 'WIN' ) {
+ $pathSep = ";";
+ }
+ foreach($newdirs as $newdir) {
+ mkdir($newdir);
+ $newIncludePath .= $newdir.$pathSep;
+ }
+ return $newIncludePath;
+}
+
+function relative_include_path() {
+
+ global $reldirs;
+ //create the include directory structure
+ $pathSep = ":";
+ $newIncludePath = "";
+ if(substr(PHP_OS, 0, 3) == 'WIN' ) {
+ $pathSep = ";";
+ }
+ foreach($reldirs as $newdir) {
+ mkdir($newdir);
+ $newIncludePath .= $newdir.$pathSep;
+ }
+ return $newIncludePath;
+}
+
+
+function teardown_include_path() {
+
+ global $newdirs;
+ // remove the directory structure
+ foreach($newdirs as $newdir) {
+ rmdir($newdir);
+ }
+}
+
+function teardown_relative_path() {
+
+ global $reldirs;
+ // remove the directory structure
+ foreach($reldirs as $newdir) {
+ rmdir($newdir);
+ }
+}
+?> \ No newline at end of file
diff --git a/ext/standard/tests/file/fopen_variation1.phpt b/ext/standard/tests/file/fopen_variation1.phpt
new file mode 100644
index 0000000..53f635b
--- /dev/null
+++ b/ext/standard/tests/file/fopen_variation1.phpt
@@ -0,0 +1,14 @@
+--TEST--
+fopen() with relative path on a file in the script directory
+--FILE--
+<?php
+
+$file = basename(__FILE__);
+
+$fd = fopen($file, "r", true);
+var_dump($fd);
+fclose($fd);
+
+?>
+--EXPECTF--
+resource(%d) of type (stream)
diff --git a/ext/standard/tests/file/fopen_variation10-win32.phpt b/ext/standard/tests/file/fopen_variation10-win32.phpt
new file mode 100644
index 0000000..c949f86
--- /dev/null
+++ b/ext/standard/tests/file/fopen_variation10-win32.phpt
@@ -0,0 +1,149 @@
+--TEST--
+Test fopen() function : variation: interesting paths, no use include path
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+ die("skip Run only on Windows");
+
+if (!is_writable('c:\\fopen_variation10.tmp')) {
+ die('skip. C:\\ not writable.');
+}
+
+?>
+--FILE--
+<?php
+/* Prototype : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
+ * Description: Open a file or a URL and return a file pointer
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing fopen() : variation ***\n";
+
+// fopen with interesting windows paths.
+$testdir = dirname(__FILE__).'/fopen10.tmpDir';
+$rootdir = 'fopen10.tmpdirTwo';
+mkdir($testdir);
+mkdir('c:\\'.$rootdir);
+
+$unixifiedDir = '/'.substr(str_replace('\\','/',$testdir),3);
+
+$paths = array('c:\\',
+ 'c:',
+ 'c',
+ '\\',
+ '/',
+ 'c:'.$rootdir,
+ 'c:adir',
+ 'c:\\/',
+ 'c:\\'.$rootdir.'\\/',
+ 'c:\\'.$rootdir.'\\',
+ 'c:\\'.$rootdir.'/',
+ $unixifiedDir,
+ '/sortout');
+
+$file = "fopen_variation10.tmp";
+$firstfile = 'c:\\'.$rootdir.'\\'.$file;
+$secondfile = $testdir.'\\'.$file;
+$thirdfile = 'c:\\'.$file;
+
+$h = fopen($firstfile, 'w');
+fwrite($h, "file in $rootdir");
+fclose($h);
+
+$h = fopen($secondfile, 'w');
+fwrite($h, "file in fopen10.tmpDir");
+fclose($h);
+
+$h = fopen($thirdfile, 'w');
+fwrite($h, "file in root");
+fclose($h);
+
+foreach($paths as $path) {
+ echo "\n--$path--\n";
+ $toFind = $path.'\\'.$file;
+ $h = fopen($toFind, 'r');
+ if ($h === false) {
+ echo "file not opened for read\n";
+ }
+ else {
+ fpassthru($h);
+ echo "\n";
+ }
+ fclose($h);
+};
+
+unlink($firstfile);
+unlink($secondfile);
+unlink($thirdfile);
+rmdir($testdir);
+rmdir('c:\\'.$rootdir);
+
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing fopen() : variation ***
+
+--c:\--
+file in root
+
+--c:--
+file in root
+
+--c--
+
+Warning: fopen(c\fopen_variation10.tmp): failed to open stream: No such file or directory in %s on line %d
+file not opened for read
+
+Warning: fclose() expects parameter 1 to be resource, boolean given in %s on line %d
+
+--\--
+
+Warning: fopen(\\fopen_variation10.tmp): failed to open stream: Invalid argument in %s on line %d
+file not opened for read
+
+Warning: fclose() expects parameter 1 to be resource, boolean given in %s on line %d
+
+--/--
+
+Warning: fopen(/\fopen_variation10.tmp): failed to open stream: Invalid argument in %s on line %d
+file not opened for read
+
+Warning: fclose() expects parameter 1 to be resource, boolean given in %s on line %d
+
+--c:fopen10.tmpdirTwo--
+file in fopen10.tmpdirTwo
+
+--c:adir--
+
+Warning: fopen(c:adir\fopen_variation10.tmp): failed to open stream: No such file or directory in %s on line %d
+file not opened for read
+
+Warning: fclose() expects parameter 1 to be resource, boolean given in %s on line %d
+
+--c:\/--
+file in root
+
+--c:\fopen10.tmpdirTwo\/--
+file in fopen10.tmpdirTwo
+
+--c:\fopen10.tmpdirTwo\--
+file in fopen10.tmpdirTwo
+
+--c:\fopen10.tmpdirTwo/--
+file in fopen10.tmpdirTwo
+
+--%s/fopen10.tmpDir--
+file in fopen10.tmpDir
+
+--/sortout--
+
+Warning: fopen(/sortout\fopen_variation10.tmp): failed to open stream: No such file or directory in %s on line %d
+file not opened for read
+
+Warning: fclose() expects parameter 1 to be resource, boolean given in %s on line %d
+===DONE===
+
diff --git a/ext/standard/tests/file/fopen_variation11-win32.phpt b/ext/standard/tests/file/fopen_variation11-win32.phpt
new file mode 100644
index 0000000..61a2f60
--- /dev/null
+++ b/ext/standard/tests/file/fopen_variation11-win32.phpt
@@ -0,0 +1,147 @@
+--TEST--
+Test fopen() function : variation: interesting paths, use include path = true
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+ die("skip Run only on Windows");
+if (!is_writable('c:\\fopen_variation10.tmp')) {
+ die('skip. C:\\ not writable.');
+}
+
+?>
+--FILE--
+<?php
+/* Prototype : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
+ * Description: Open a file or a URL and return a file pointer
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing fopen() : variation ***\n";
+
+// fopen with interesting windows paths.
+$testdir = dirname(__FILE__).'/fopen11.tmpDir';
+$rootdir = 'fopen11.tmpdirTwo';
+mkdir($testdir);
+mkdir('c:\\'.$rootdir);
+
+$unixifiedDir = '/'.substr(str_replace('\\','/',$testdir),3);
+
+$paths = array('c:\\',
+ 'c:',
+ 'c',
+ '\\',
+ '/',
+ 'c:'.$rootdir,
+ 'c:adir',
+ 'c:\\/',
+ 'c:\\'.$rootdir.'\\/',
+ 'c:\\'.$rootdir.'\\',
+ 'c:\\'.$rootdir.'/',
+ $unixifiedDir,
+ '/sortout');
+
+$file = "fopen_variation11.tmp";
+$firstfile = 'c:\\'.$rootdir.'\\'.$file;
+$secondfile = $testdir.'\\'.$file;
+$thirdfile = 'c:\\'.$file;
+
+$h = fopen($firstfile, 'w');
+fwrite($h, "file in $rootdir");
+fclose($h);
+
+$h = fopen($secondfile, 'w');
+fwrite($h, "file in fopen11.tmpDir");
+fclose($h);
+
+$h = fopen($thirdfile, 'w');
+fwrite($h, "file in root");
+fclose($h);
+
+foreach($paths as $path) {
+ echo "\n--$path--\n";
+ $toFind = $path.'\\'.$file;
+ $h = fopen($toFind, 'r', true);
+ if ($h === false) {
+ echo "file not opened for read\n";
+ }
+ else {
+ fpassthru($h);
+ echo "\n";
+ }
+ fclose($h);
+};
+
+unlink($firstfile);
+unlink($secondfile);
+unlink($thirdfile);
+rmdir($testdir);
+rmdir('c:\\'.$rootdir);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing fopen() : variation ***
+
+--c:\--
+file in root
+
+--c:--
+file in root
+
+--c--
+
+Warning: fopen(c\fopen_variation11.tmp): failed to open stream: No such file or directory in %s on line %d
+file not opened for read
+
+Warning: fclose() expects parameter 1 to be resource, boolean given in %s on line %d
+
+--\--
+
+Warning: fopen(\\FOPEN_VARIATION11.TMP): failed to open stream: Invalid argument in %s on line %d
+file not opened for read
+
+Warning: fclose() expects parameter 1 to be resource, boolean given in %s on line %d
+
+--/--
+
+Warning: fopen(\\FOPEN_VARIATION11.TMP): failed to open stream: Invalid argument in %s on line %d
+file not opened for read
+
+Warning: fclose() expects parameter 1 to be resource, boolean given in %s on line %d
+
+--c:fopen11.tmpdirTwo--
+file in fopen11.tmpdirTwo
+
+--c:adir--
+
+Warning: fopen(c:adir\fopen_variation11.tmp): failed to open stream: No such file or directory in %s on line %d
+file not opened for read
+
+Warning: fclose() expects parameter 1 to be resource, boolean given in %s on line %d
+
+--c:\/--
+file in root
+
+--c:\fopen11.tmpdirTwo\/--
+file in fopen11.tmpdirTwo
+
+--c:\fopen11.tmpdirTwo\--
+file in fopen11.tmpdirTwo
+
+--c:\fopen11.tmpdirTwo/--
+file in fopen11.tmpdirTwo
+
+--%s/fopen11.tmpDir--
+file in fopen11.tmpDir
+
+--/sortout--
+
+Warning: fopen(/sortout\fopen_variation11.tmp): failed to open stream: No such file or directory in %s on line %d
+file not opened for read
+
+Warning: fclose() expects parameter 1 to be resource, boolean given in %s on line %d
+===DONE===
+
diff --git a/ext/standard/tests/file/fopen_variation12.phpt b/ext/standard/tests/file/fopen_variation12.phpt
new file mode 100644
index 0000000..9df4490
--- /dev/null
+++ b/ext/standard/tests/file/fopen_variation12.phpt
@@ -0,0 +1,52 @@
+--TEST--
+Test fopen() function : variation: use include path (path is bad) create a file (relative)
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
+ * Description: Open a file or a URL and return a file pointer
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+set_include_path("rubbish");
+testme();
+restore_include_path();
+
+
+function testme() {
+ $tmpfile = basename(__FILE__, ".php") . ".tmp";
+ $h = fopen($tmpfile, "w", true);
+ fwrite($h, (binary) "This is the test file");
+ fclose($h);
+
+
+ $h = @fopen($tmpfile, "r");
+ if ($h === false) {
+ echo "Not created in working dir\n";
+ }
+ else {
+ echo "created in working dir\n";
+ fclose($h);
+ unlink($tmpfile);
+ }
+
+
+ $scriptDirFile = dirname(__FILE__).'/'.$tmpfile;
+ $h = @fopen($scriptDirFile, "r");
+ if ($h === false) {
+ echo "Not created in script dir\n";
+ }
+ else {
+ echo "created in script dir\n";
+ fclose($h);
+ unlink($scriptDirFile);
+ }
+}
+?>
+===DONE===
+--EXPECT--
+created in working dir
+Not created in script dir
+===DONE===
diff --git a/ext/standard/tests/file/fopen_variation13.phpt b/ext/standard/tests/file/fopen_variation13.phpt
new file mode 100644
index 0000000..d540d70
--- /dev/null
+++ b/ext/standard/tests/file/fopen_variation13.phpt
@@ -0,0 +1,56 @@
+--TEST--
+Test fopen() function : variation: use include path create a file (absolute)
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
+ * Description: Open a file or a URL and return a file pointer
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+require_once('fopen_include_path.inc');
+
+echo "*** Testing fopen() : variation ***\n";
+$newpath = create_include_path();
+set_include_path($newpath);
+runtest();
+$newpath = generate_next_path();
+set_include_path($newpath);
+runtest();
+
+teardown_include_path();
+restore_include_path();
+
+
+function runtest() {
+ $tempDir = 'fopen_variation13.dir.tmp';
+ $tmpfile = 'fopen_variation13.tmp';
+ $absFile = getcwd().'/'.$tempDir.'/'.$tmpfile;
+
+ mkdir($tempDir);
+ $h = fopen($absFile, "w", true);
+ fwrite($h, "This is the test file");
+ fclose($h);
+
+
+ $h = fopen($absFile, "r");
+ if ($h === false) {
+ echo "Not created absolute location\n";
+ }
+ else {
+ echo "Created in correct location\n";
+ fclose($h);
+ }
+ unlink($absFile);
+ rmdir($tempDir);
+
+}
+?>
+===DONE===
+--EXPECT--
+*** Testing fopen() : variation ***
+Created in correct location
+Created in correct location
+===DONE===
diff --git a/ext/standard/tests/file/fopen_variation14-win32.phpt b/ext/standard/tests/file/fopen_variation14-win32.phpt
new file mode 100644
index 0000000..554d8c6
--- /dev/null
+++ b/ext/standard/tests/file/fopen_variation14-win32.phpt
@@ -0,0 +1,189 @@
+--TEST--
+Test fopen() function : variation: file uri, no use include path
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+ die("skip Run only on Windows");
+?>
+--FILE--
+<?php
+/* Prototype : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
+ * Description: Open a file or a URL and return a file pointer
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing fopen() : variation ***\n";
+
+// fopen with interesting windows paths.
+$testDir = 'fopen14.tmpDir';
+$absTestDir = getcwd().'/'.$testDir;
+$file = "fopen_variation14.tmp";
+$unixifiedDir = '/'.substr(str_replace('\\','/',$absTestDir),3);
+$absFile = $absTestDir.'/'.$file;
+
+mkdir($testDir);
+
+$files = array("file://$testDir\\$file",
+ "file://$testDir/$file",
+ "file://./$testDir/$file",
+ "file://.\\$testDir\\$file",
+ "file://$absTestDir/$file",
+ "file://$absTestDir\\$file",
+ "file://$unixifiedDir/$file"
+);
+
+runtest($files);
+
+chdir($testDir);
+$files = array("file://../$testDir/$file",
+ "file://..\\$testDir\\$file",
+ "file://$absTestDir/$file",
+ "file://$absTestDir\\$file",
+ "file://$unixifiedDir/$file"
+);
+runtest($files);
+chdir("..");
+rmdir($testDir);
+
+function runtest($fileURIs) {
+ global $absFile;
+ $iteration = 0;
+ foreach($fileURIs as $fileURI) {
+ echo "--- READ: $fileURI ---\n";
+
+ $readData = "read:$iteration";
+ $writeData = "write:$iteration";
+
+ // create the file and test read
+ $h = fopen($absFile, 'w');
+ fwrite($h, $readData);
+ fclose($h);
+
+ $h = fopen($fileURI, 'r');
+ if ($h !== false) {
+ if (fread($h, 4096) != $readData) {
+ echo "contents not correct\n";
+ }
+ else {
+ echo "test passed\n";
+ }
+ fclose($h);
+ }
+ unlink($absFile);
+
+ echo "--- WRITE: $fileURI ---\n";
+ // create the file to test write
+ $h = fopen($fileURI, 'w');
+ if ($h !== false) {
+ fwrite($h, $writeData);
+ fclose($h);
+
+ $h = fopen($absFile, 'r');
+ if ($h !== false) {
+ if (fread($h, 4096) != $writeData) {
+ echo "contents not correct\n";
+ }
+ else {
+ echo "test passed\n";
+ }
+ fclose($h);
+ }
+ unlink($absFile);
+ }
+ }
+}
+
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing fopen() : variation ***
+--- READ: file://fopen14.tmpDir\fopen_variation14.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://fopen14.tmpDir\fopen_variation14.tmp in %s on line %d
+
+Warning: fopen(file://fopen14.tmpDir\fopen_variation14.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- WRITE: file://fopen14.tmpDir\fopen_variation14.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://fopen14.tmpDir\fopen_variation14.tmp in %s on line %d
+
+Warning: fopen(file://fopen14.tmpDir\fopen_variation14.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- READ: file://fopen14.tmpDir/fopen_variation14.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://fopen14.tmpDir/fopen_variation14.tmp in %s on line %d
+
+Warning: fopen(file://fopen14.tmpDir/fopen_variation14.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- WRITE: file://fopen14.tmpDir/fopen_variation14.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://fopen14.tmpDir/fopen_variation14.tmp in %s on line %d
+
+Warning: fopen(file://fopen14.tmpDir/fopen_variation14.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- READ: file://./fopen14.tmpDir/fopen_variation14.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://./fopen14.tmpDir/fopen_variation14.tmp in %s on line %d
+
+Warning: fopen(file://./fopen14.tmpDir/fopen_variation14.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- WRITE: file://./fopen14.tmpDir/fopen_variation14.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://./fopen14.tmpDir/fopen_variation14.tmp in %s on line %d
+
+Warning: fopen(file://./fopen14.tmpDir/fopen_variation14.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- READ: file://.\fopen14.tmpDir\fopen_variation14.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://.\fopen14.tmpDir\fopen_variation14.tmp in %s on line %d
+
+Warning: fopen(file://.\fopen14.tmpDir\fopen_variation14.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- WRITE: file://.\fopen14.tmpDir\fopen_variation14.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://.\fopen14.tmpDir\fopen_variation14.tmp in %s on line %d
+
+Warning: fopen(file://.\fopen14.tmpDir\fopen_variation14.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- READ: file://%s/fopen14.tmpDir/fopen_variation14.tmp ---
+test passed
+--- WRITE: file://%s/fopen14.tmpDir/fopen_variation14.tmp ---
+test passed
+--- READ: file://%s/fopen14.tmpDir\fopen_variation14.tmp ---
+test passed
+--- WRITE: file://%s/fopen14.tmpDir\fopen_variation14.tmp ---
+test passed
+--- READ: file:///%s/fopen14.tmpDir/fopen_variation14.tmp ---
+test passed
+--- WRITE: file:///%s/fopen14.tmpDir/fopen_variation14.tmp ---
+test passed
+--- READ: file://../fopen14.tmpDir/fopen_variation14.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://../fopen14.tmpDir/fopen_variation14.tmp in %s on line %d
+
+Warning: fopen(file://../fopen14.tmpDir/fopen_variation14.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- WRITE: file://../fopen14.tmpDir/fopen_variation14.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://../fopen14.tmpDir/fopen_variation14.tmp in %s on line %d
+
+Warning: fopen(file://../fopen14.tmpDir/fopen_variation14.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- READ: file://..\fopen14.tmpDir\fopen_variation14.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://..\fopen14.tmpDir\fopen_variation14.tmp in %s on line %d
+
+Warning: fopen(file://..\fopen14.tmpDir\fopen_variation14.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- WRITE: file://..\fopen14.tmpDir\fopen_variation14.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://..\fopen14.tmpDir\fopen_variation14.tmp in %s on line %d
+
+Warning: fopen(file://..\fopen14.tmpDir\fopen_variation14.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- READ: file://%s/fopen14.tmpDir/fopen_variation14.tmp ---
+test passed
+--- WRITE: file://%s/fopen14.tmpDir/fopen_variation14.tmp ---
+test passed
+--- READ: file://%s/fopen14.tmpDir\fopen_variation14.tmp ---
+test passed
+--- WRITE: file://%s/fopen14.tmpDir\fopen_variation14.tmp ---
+test passed
+--- READ: file:///%s/fopen14.tmpDir/fopen_variation14.tmp ---
+test passed
+--- WRITE: file:///%s/fopen14.tmpDir/fopen_variation14.tmp ---
+test passed
+===DONE===
+
diff --git a/ext/standard/tests/file/fopen_variation14.phpt b/ext/standard/tests/file/fopen_variation14.phpt
new file mode 100644
index 0000000..aa4e05b
--- /dev/null
+++ b/ext/standard/tests/file/fopen_variation14.phpt
@@ -0,0 +1,134 @@
+--TEST--
+Test fopen() function : variation: file uri, no use include path
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+ die("skip not for Windows");
+?>
+--FILE--
+<?php
+/* Prototype : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
+ * Description: Open a file or a URL and return a file pointer
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing fopen() : variation ***\n";
+
+// fopen with interesting windows paths.
+$testDir = 'fopen14.tmpDir';
+$absTestDir = getcwd().'/'.$testDir;
+$file = "fopen_variation14.tmp";
+$absFile = $absTestDir.'/'.$file;
+
+mkdir($testDir);
+
+$files = array("file://$testDir/$file",
+ "file://./$testDir/$file",
+ "file://$absTestDir/$file"
+);
+
+runtest($files);
+
+chdir($testDir);
+$files = array("file://../$testDir/$file",
+ "file://$absTestDir/$file",
+);
+runtest($files);
+chdir("..");
+rmdir($testDir);
+
+function runtest($fileURIs) {
+ global $absFile;
+ $iteration = 0;
+ foreach($fileURIs as $fileURI) {
+ echo "--- READ: $fileURI ---\n";
+
+ $readData = "read:$iteration";
+ $writeData = "write:$iteration";
+
+ // create the file and test read
+ $h = fopen($absFile, 'w');
+ fwrite($h, $readData);
+ fclose($h);
+
+ $h = fopen($fileURI, 'r');
+ if ($h !== false) {
+ if (fread($h, 4096) != $readData) {
+ echo "contents not correct\n";
+ }
+ else {
+ echo "test passed\n";
+ }
+ fclose($h);
+ }
+ unlink($absFile);
+
+ echo "--- WRITE: $fileURI ---\n";
+ // create the file to test write
+ $h = fopen($fileURI, 'w');
+ if ($h !== false) {
+ fwrite($h, $writeData);
+ fclose($h);
+
+ $h = fopen($absFile, 'r');
+ if ($h !== false) {
+ if (fread($h, 4096) != $writeData) {
+ echo "contents not correct\n";
+ }
+ else {
+ echo "test passed\n";
+ }
+ fclose($h);
+ }
+ unlink($absFile);
+ }
+ }
+}
+
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing fopen() : variation ***
+--- READ: file://fopen14.tmpDir/fopen_variation14.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://fopen14.tmpDir/fopen_variation14.tmp in %s on line %d
+
+Warning: fopen(file://fopen14.tmpDir/fopen_variation14.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- WRITE: file://fopen14.tmpDir/fopen_variation14.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://fopen14.tmpDir/fopen_variation14.tmp in %s on line %d
+
+Warning: fopen(file://fopen14.tmpDir/fopen_variation14.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- READ: file://./fopen14.tmpDir/fopen_variation14.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://./fopen14.tmpDir/fopen_variation14.tmp in %s on line %d
+
+Warning: fopen(file://./fopen14.tmpDir/fopen_variation14.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- WRITE: file://./fopen14.tmpDir/fopen_variation14.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://./fopen14.tmpDir/fopen_variation14.tmp in %s on line %d
+
+Warning: fopen(file://./fopen14.tmpDir/fopen_variation14.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- READ: file:///%s/fopen14.tmpDir/fopen_variation14.tmp ---
+test passed
+--- WRITE: file:///%s/fopen14.tmpDir/fopen_variation14.tmp ---
+test passed
+--- READ: file://../fopen14.tmpDir/fopen_variation14.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://../fopen14.tmpDir/fopen_variation14.tmp in %s on line %d
+
+Warning: fopen(file://../fopen14.tmpDir/fopen_variation14.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- WRITE: file://../fopen14.tmpDir/fopen_variation14.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://../fopen14.tmpDir/fopen_variation14.tmp in %s on line %d
+
+Warning: fopen(file://../fopen14.tmpDir/fopen_variation14.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- READ: file:///%s/fopen14.tmpDir/fopen_variation14.tmp ---
+test passed
+--- WRITE: file:///%s/fopen14.tmpDir/fopen_variation14.tmp ---
+test passed
+===DONE=== \ No newline at end of file
diff --git a/ext/standard/tests/file/fopen_variation15-win32.phpt b/ext/standard/tests/file/fopen_variation15-win32.phpt
new file mode 100644
index 0000000..8599306
--- /dev/null
+++ b/ext/standard/tests/file/fopen_variation15-win32.phpt
@@ -0,0 +1,193 @@
+--TEST--
+Test fopen() function : variation: file uri, use include path = true
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+ die("skip Run only on Windows");
+?>
+--FILE--
+<?php
+/* Prototype : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
+ * Description: Open a file or a URL and return a file pointer
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing fopen() : variation ***\n";
+
+// fopen with interesting windows paths.
+$includePathDir = getcwd().'/fopen15.includeDir';
+$testDir = 'fopen15.tmpDir';
+$absTestDir = getcwd().'/'.$testDir;
+$file = "fopen_variation15.tmp";
+$unixifiedDir = '/'.substr(str_replace('\\','/',$absTestDir),3);
+$absFile = $absTestDir.'/'.$file;
+
+mkdir($testDir);
+mkdir($includePathDir);
+set_include_path($includePathDir);
+
+$files = array("file://$testDir\\$file",
+ "file://$testDir/$file",
+ "file://./$testDir/$file",
+ "file://.\\$testDir\\$file",
+ "file://$absTestDir/$file",
+ "file://$absTestDir\\$file",
+ "file://$unixifiedDir/$file"
+);
+
+runtest($files);
+
+chdir($testDir);
+$files = array("file://../$testDir/$file",
+ "file://..\\$testDir\\$file",
+ "file://$absTestDir/$file",
+ "file://$absTestDir\\$file",
+ "file://$unixifiedDir/$file"
+);
+runtest($files);
+chdir("..");
+rmdir($testDir);
+rmdir($includePathDir);
+
+function runtest($fileURIs) {
+ global $absFile;
+ $iteration = 0;
+ foreach($fileURIs as $fileURI) {
+ echo "--- READ: $fileURI ---\n";
+
+ $readData = "read:$iteration";
+ $writeData = "write:$iteration";
+
+ // create the file and test read
+ $h = fopen($absFile, 'w');
+ fwrite($h, $readData);
+ fclose($h);
+
+ $h = fopen($fileURI, 'r', true);
+ if ($h !== false) {
+ if (fread($h, 4096) != $readData) {
+ echo "contents not correct\n";
+ }
+ else {
+ echo "test passed\n";
+ }
+ fclose($h);
+ }
+ unlink($absFile);
+
+ echo "--- WRITE: $fileURI ---\n";
+ // create the file to test write
+ $h = fopen($fileURI, 'w', true);
+ if ($h !== false) {
+ fwrite($h, $writeData);
+ fclose($h);
+
+ $h = fopen($absFile, 'r');
+ if ($h !== false) {
+ if (fread($h, 4096) != $writeData) {
+ echo "contents not correct\n";
+ }
+ else {
+ echo "test passed\n";
+ }
+ fclose($h);
+ }
+ unlink($absFile);
+ }
+ }
+}
+
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing fopen() : variation ***
+--- READ: file://fopen15.tmpDir\fopen_variation15.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://fopen15.tmpDir\fopen_variation15.tmp in %s on line %d
+
+Warning: fopen(file://fopen15.tmpDir\fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- WRITE: file://fopen15.tmpDir\fopen_variation15.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://fopen15.tmpDir\fopen_variation15.tmp in %s on line %d
+
+Warning: fopen(file://fopen15.tmpDir\fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- READ: file://fopen15.tmpDir/fopen_variation15.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://fopen15.tmpDir/fopen_variation15.tmp in %s on line %d
+
+Warning: fopen(file://fopen15.tmpDir/fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- WRITE: file://fopen15.tmpDir/fopen_variation15.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://fopen15.tmpDir/fopen_variation15.tmp in %s on line %d
+
+Warning: fopen(file://fopen15.tmpDir/fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- READ: file://./fopen15.tmpDir/fopen_variation15.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://./fopen15.tmpDir/fopen_variation15.tmp in %s on line %d
+
+Warning: fopen(file://./fopen15.tmpDir/fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- WRITE: file://./fopen15.tmpDir/fopen_variation15.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://./fopen15.tmpDir/fopen_variation15.tmp in %s on line %d
+
+Warning: fopen(file://./fopen15.tmpDir/fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- READ: file://.\fopen15.tmpDir\fopen_variation15.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://.\fopen15.tmpDir\fopen_variation15.tmp in %s on line %d
+
+Warning: fopen(file://.\fopen15.tmpDir\fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- WRITE: file://.\fopen15.tmpDir\fopen_variation15.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://.\fopen15.tmpDir\fopen_variation15.tmp in %s on line %d
+
+Warning: fopen(file://.\fopen15.tmpDir\fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- READ: file://%s/fopen15.tmpDir/fopen_variation15.tmp ---
+test passed
+--- WRITE: file://%s/fopen15.tmpDir/fopen_variation15.tmp ---
+test passed
+--- READ: file://%s/fopen15.tmpDir\fopen_variation15.tmp ---
+test passed
+--- WRITE: file://%s/fopen15.tmpDir\fopen_variation15.tmp ---
+test passed
+--- READ: file:///%s/fopen15.tmpDir/fopen_variation15.tmp ---
+test passed
+--- WRITE: file:///%s/fopen15.tmpDir/fopen_variation15.tmp ---
+test passed
+--- READ: file://../fopen15.tmpDir/fopen_variation15.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://../fopen15.tmpDir/fopen_variation15.tmp in %s on line %d
+
+Warning: fopen(file://../fopen15.tmpDir/fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- WRITE: file://../fopen15.tmpDir/fopen_variation15.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://../fopen15.tmpDir/fopen_variation15.tmp in %s on line %d
+
+Warning: fopen(file://../fopen15.tmpDir/fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- READ: file://..\fopen15.tmpDir\fopen_variation15.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://..\fopen15.tmpDir\fopen_variation15.tmp in %s on line %d
+
+Warning: fopen(file://..\fopen15.tmpDir\fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- WRITE: file://..\fopen15.tmpDir\fopen_variation15.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://..\fopen15.tmpDir\fopen_variation15.tmp in %s on line %d
+
+Warning: fopen(file://..\fopen15.tmpDir\fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- READ: file://%s/fopen15.tmpDir/fopen_variation15.tmp ---
+test passed
+--- WRITE: file://%s/fopen15.tmpDir/fopen_variation15.tmp ---
+test passed
+--- READ: file://%s/fopen15.tmpDir\fopen_variation15.tmp ---
+test passed
+--- WRITE: file://%s/fopen15.tmpDir\fopen_variation15.tmp ---
+test passed
+--- READ: file:///%s/fopen15.tmpDir/fopen_variation15.tmp ---
+test passed
+--- WRITE: file:///%s/fopen15.tmpDir/fopen_variation15.tmp ---
+test passed
+===DONE===
+
diff --git a/ext/standard/tests/file/fopen_variation15.phpt b/ext/standard/tests/file/fopen_variation15.phpt
new file mode 100644
index 0000000..24b01fb
--- /dev/null
+++ b/ext/standard/tests/file/fopen_variation15.phpt
@@ -0,0 +1,138 @@
+--TEST--
+Test fopen() function : variation: file uri, use include path = true
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+ die("skip Not for Windows");
+?>
+--FILE--
+<?php
+/* Prototype : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
+ * Description: Open a file or a URL and return a file pointer
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing fopen() : variation ***\n";
+
+// fopen with interesting windows paths.
+$includePathDir = getcwd().'/fopen15.includeDir';
+$testDir = 'fopen15.tmpDir';
+$absTestDir = getcwd().'/'.$testDir;
+$file = "fopen_variation15.tmp";
+$absFile = $absTestDir.'/'.$file;
+
+mkdir($testDir);
+mkdir($includePathDir);
+set_include_path($includePathDir);
+
+$files = array("file://$testDir/$file",
+ "file://./$testDir/$file",
+ "file://$absTestDir/$file"
+);
+
+runtest($files);
+
+chdir($testDir);
+$files = array("file://../$testDir/$file",
+ "file://$absTestDir/$file"
+);
+runtest($files);
+chdir("..");
+rmdir($testDir);
+rmdir($includePathDir);
+
+function runtest($fileURIs) {
+ global $absFile;
+ $iteration = 0;
+ foreach($fileURIs as $fileURI) {
+ echo "--- READ: $fileURI ---\n";
+
+ $readData = "read:$iteration";
+ $writeData = "write:$iteration";
+
+ // create the file and test read
+ $h = fopen($absFile, 'w');
+ fwrite($h, $readData);
+ fclose($h);
+
+ $h = fopen($fileURI, 'r', true);
+ if ($h !== false) {
+ if (fread($h, 4096) != $readData) {
+ echo "contents not correct\n";
+ }
+ else {
+ echo "test passed\n";
+ }
+ fclose($h);
+ }
+ unlink($absFile);
+
+ echo "--- WRITE: $fileURI ---\n";
+ // create the file to test write
+ $h = fopen($fileURI, 'w', true);
+ if ($h !== false) {
+ fwrite($h, $writeData);
+ fclose($h);
+
+ $h = fopen($absFile, 'r');
+ if ($h !== false) {
+ if (fread($h, 4096) != $writeData) {
+ echo "contents not correct\n";
+ }
+ else {
+ echo "test passed\n";
+ }
+ fclose($h);
+ }
+ unlink($absFile);
+ }
+ }
+}
+
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing fopen() : variation ***
+--- READ: file://fopen15.tmpDir/fopen_variation15.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://fopen15.tmpDir/fopen_variation15.tmp in %s on line %d
+
+Warning: fopen(file://fopen15.tmpDir/fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- WRITE: file://fopen15.tmpDir/fopen_variation15.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://fopen15.tmpDir/fopen_variation15.tmp in %s on line %d
+
+Warning: fopen(file://fopen15.tmpDir/fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- READ: file://./fopen15.tmpDir/fopen_variation15.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://./fopen15.tmpDir/fopen_variation15.tmp in %s on line %d
+
+Warning: fopen(file://./fopen15.tmpDir/fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- WRITE: file://./fopen15.tmpDir/fopen_variation15.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://./fopen15.tmpDir/fopen_variation15.tmp in %s on line %d
+
+Warning: fopen(file://./fopen15.tmpDir/fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- READ: file:///%s/fopen15.tmpDir/fopen_variation15.tmp ---
+test passed
+--- WRITE: file:///%s/fopen15.tmpDir/fopen_variation15.tmp ---
+test passed
+--- READ: file://../fopen15.tmpDir/fopen_variation15.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://../fopen15.tmpDir/fopen_variation15.tmp in %s on line %d
+
+Warning: fopen(file://../fopen15.tmpDir/fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- WRITE: file://../fopen15.tmpDir/fopen_variation15.tmp ---
+
+Warning: fopen(): remote host file access not supported, file://../fopen15.tmpDir/fopen_variation15.tmp in %s on line %d
+
+Warning: fopen(file://../fopen15.tmpDir/fopen_variation15.tmp): failed to open stream: no suitable wrapper could be found in %s on line %d
+--- READ: file:///%s/fopen15.tmpDir/fopen_variation15.tmp ---
+test passed
+--- WRITE: file:///%s/fopen15.tmpDir/fopen_variation15.tmp ---
+test passed
+===DONE=== \ No newline at end of file
diff --git a/ext/standard/tests/file/fopen_variation16.phpt b/ext/standard/tests/file/fopen_variation16.phpt
new file mode 100644
index 0000000..3f220aa
--- /dev/null
+++ b/ext/standard/tests/file/fopen_variation16.phpt
@@ -0,0 +1,75 @@
+--TEST--
+Test fopen() function : variation: use include path create and read a file (relative)
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
+ * Description: Open a file or a URL and return a file pointer
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+require_once('fopen_include_path.inc');
+
+$thisTestDir = "fopenVariation16.dir";
+mkdir($thisTestDir);
+chdir($thisTestDir);
+
+$newpath = create_include_path();
+set_include_path($newpath);
+runtest();
+
+$newpath = generate_next_path();
+set_include_path($newpath);
+runtest();
+
+teardown_include_path();
+restore_include_path();
+chdir("..");
+rmdir($thisTestDir);
+
+function runtest() {
+ global $dir1;
+
+ $extraDir = "extraDir";
+
+ mkdir($dir1.'/'.$extraDir);
+ mkdir($extraDir);
+
+ $tmpfile = $extraDir.'/fopen_variation16.tmp';
+
+ $h = fopen($tmpfile, "w+", true);
+ fwrite($h, (binary) "This is the test file");
+ fclose($h);
+
+ $h = @fopen($dir1.'/'.$tmpfile, "r");
+ if ($h === false) {
+ echo "Not created in dir1\n";
+ }
+ else {
+ echo "created in dir1\n";
+ fclose($h);
+ }
+
+ $h = fopen($tmpfile, "r", true);
+ if ($h === false) {
+ echo "could not find file for reading\n";
+ }
+ else {
+ echo "found file - not in dir1\n";
+ fclose($h);
+ }
+
+ unlink($tmpfile);
+ rmdir($dir1.'/'.$extraDir);
+ rmdir($extraDir);
+}
+?>
+===DONE===
+--EXPECT--
+Not created in dir1
+found file - not in dir1
+Not created in dir1
+found file - not in dir1
+===DONE===
diff --git a/ext/standard/tests/file/fopen_variation17.phpt b/ext/standard/tests/file/fopen_variation17.phpt
new file mode 100644
index 0000000..bc75c11
--- /dev/null
+++ b/ext/standard/tests/file/fopen_variation17.phpt
@@ -0,0 +1,74 @@
+--TEST--
+Test fopen() function : variation: use include path create and read a file (relative)
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
+ * Description: Open a file or a URL and return a file pointer
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+require_once('fopen_include_path.inc');
+
+$thisTestDir = basename(__FILE__, ".php") . ".dir";
+mkdir($thisTestDir);
+chdir($thisTestDir);
+
+$newpath = create_include_path();
+set_include_path($newpath);
+runtest();
+
+$newpath = generate_next_path();
+set_include_path($newpath);
+runtest();
+
+teardown_include_path();
+restore_include_path();
+chdir("..");
+rmdir($thisTestDir);
+
+function runtest() {
+ global $dir1;
+
+ $extraDir = "extraDir";
+
+ mkdir($dir1.'/'.$extraDir);
+ mkdir($extraDir);
+
+ $tmpfile = $extraDir . '/' . basename(__FILE__, ".php") . ".tmp";
+ $h = fopen($tmpfile, "w+", true);
+ fwrite($h, (binary) "This is the test file");
+ fclose($h);
+
+ $h = @fopen($dir1.'/'.$tmpfile, "r");
+ if ($h === false) {
+ echo "Not created in dir1\n";
+ }
+ else {
+ echo "created in dir1\n";
+ fclose($h);
+ }
+
+ $h = fopen($tmpfile, "r", true);
+ if ($h === false) {
+ echo "could not find file for reading\n";
+ }
+ else {
+ echo "found file for reading\n";
+ fclose($h);
+ }
+
+ unlink($tmpfile);
+ rmdir($dir1.'/'.$extraDir);
+ rmdir($extraDir);
+}
+?>
+===DONE===
+--EXPECT--
+Not created in dir1
+found file for reading
+Not created in dir1
+found file for reading
+===DONE===
diff --git a/ext/standard/tests/file/fopen_variation19.phpt b/ext/standard/tests/file/fopen_variation19.phpt
new file mode 100644
index 0000000..031ba45
--- /dev/null
+++ b/ext/standard/tests/file/fopen_variation19.phpt
@@ -0,0 +1,110 @@
+--TEST--
+Test fopen() function : variation: test opening linked files
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+ die("skip Not for Windows");
+?>
+--FILE--
+<?php
+/* Prototype : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
+ * Description: Open a file or a URL and return a file pointer
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+$tmpDir = 'fopenVar19.Dir';
+$realFilename = __FILE__.'.real';
+$sortFilename = __FILE__.'.soft';
+$hardFilename = __FILE__.'.hard';
+$linkOfLink = __FILE__.'.soft2';
+
+echo "*** Testing fopen() : variation ***\n";
+// start the test
+mkdir($tmpDir);
+chdir($tmpDir);
+
+$h = fopen($realFilename, "w");
+fwrite($h, "Hello World");
+fclose($h);
+
+symlink($realFilename, $sortFilename);
+symlink($sortFilename, $linkOfLink);
+link($realFilename, $hardFilename);
+
+
+
+echo "*** testing reading of links ***\n";
+echo "soft link:";
+readFile2($sortFilename);
+echo "hard link:";
+readFile2($hardFilename);
+echo "link of link:";
+readFile2($linkOfLink);
+
+echo "*** test appending to links ***\n";
+echo "soft link:";
+appendFile($sortFilename);
+echo "hard link:";
+appendFile($hardFilename);
+echo "link of link:";
+appendFile($linkOfLink);
+
+echo "*** test overwriting links ***\n";
+echo "soft link:";
+writeFile($sortFilename);
+echo "hard link:";
+writeFile($hardFilename);
+echo "link of link:";
+writeFile($linkOfLink);
+
+unlink($linkOfLink);
+unlink($sortFilename);
+unlink($hardFilename);
+unlink($realFilename);
+chdir("..");
+rmdir($tmpDir);
+
+function readFile2($file) {
+ $h = fopen($file, 'r');
+ fpassthru($h);
+ fclose($h);
+ echo "\n";
+}
+
+function appendFile($file) {
+ $h = fopen($file, 'a+');
+ fwrite($h, ' again!');
+ fseek($h, 0);
+ fpassthru($h);
+ fclose($h);
+ echo "\n";
+}
+
+function writeFile($file) {
+ $h = fopen($file, 'w');
+ fwrite($h, 'Goodbye World');
+ fclose($h);
+ readFile2($file);
+}
+
+
+?>
+===DONE===
+--EXPECT--
+*** Testing fopen() : variation ***
+*** testing reading of links ***
+soft link:Hello World
+hard link:Hello World
+link of link:Hello World
+*** test appending to links ***
+soft link:Hello World again!
+hard link:Hello World again! again!
+link of link:Hello World again! again! again!
+*** test overwriting links ***
+soft link:Goodbye World
+hard link:Goodbye World
+link of link:Goodbye World
+===DONE===
diff --git a/ext/standard/tests/file/fopen_variation3.phpt b/ext/standard/tests/file/fopen_variation3.phpt
new file mode 100644
index 0000000..3467a3a
--- /dev/null
+++ b/ext/standard/tests/file/fopen_variation3.phpt
@@ -0,0 +1,218 @@
+--TEST--
+Test fopen() function : usage variation different datatypes for use_include_path
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
+ * Description: Open a file or a URL and return a file pointer
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing fopen() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$filename = __FILE__;
+$mode = 'r';
+
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+ // int data
+ 'int 0' => 0,
+ 'int 1' => 1,
+ 'int 12345' => 12345,
+ 'int -12345' => -2345,
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float -10.5' => -10.5,
+ 'float 12.3456789000e10' => 12.3456789000e10,
+ 'float -12.3456789000e10' => -12.3456789000e10,
+ 'float .5' => .5,
+
+ // array data
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // string data
+ 'string DQ' => "string",
+ 'string SQ' => 'string',
+ 'mixed case string' => "sTrInG",
+ 'heredoc' => $heredoc,
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for use_include_path
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ $h = fopen($filename, $mode, $value);
+ if ($h !== false) {
+ echo "ok\n";
+ fclose($h);
+ }
+ else {
+ var_dump($h);
+ }
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing fopen() : usage variation ***
+
+--int 0--
+ok
+
+--int 1--
+ok
+
+--int 12345--
+ok
+
+--int -12345--
+ok
+
+--float 10.5--
+ok
+
+--float -10.5--
+ok
+
+--float 12.3456789000e10--
+ok
+
+--float -12.3456789000e10--
+ok
+
+--float .5--
+ok
+
+--empty array--
+Error: 2 - fopen() expects parameter 3 to be boolean, array given, %s(%d)
+bool(false)
+
+--int indexed array--
+Error: 2 - fopen() expects parameter 3 to be boolean, array given, %s(%d)
+bool(false)
+
+--associative array--
+Error: 2 - fopen() expects parameter 3 to be boolean, array given, %s(%d)
+bool(false)
+
+--nested arrays--
+Error: 2 - fopen() expects parameter 3 to be boolean, array given, %s(%d)
+bool(false)
+
+--uppercase NULL--
+ok
+
+--lowercase null--
+ok
+
+--lowercase true--
+ok
+
+--lowercase false--
+ok
+
+--uppercase TRUE--
+ok
+
+--uppercase FALSE--
+ok
+
+--empty string DQ--
+ok
+
+--empty string SQ--
+ok
+
+--string DQ--
+ok
+
+--string SQ--
+ok
+
+--mixed case string--
+ok
+
+--heredoc--
+ok
+
+--instance of classWithToString--
+Error: 2 - fopen() expects parameter 3 to be boolean, object given, %s(%d)
+bool(false)
+
+--instance of classWithoutToString--
+Error: 2 - fopen() expects parameter 3 to be boolean, object given, %s(%d)
+bool(false)
+
+--undefined var--
+ok
+
+--unset var--
+ok
+===DONE===
diff --git a/ext/standard/tests/file/fopen_variation4.phpt b/ext/standard/tests/file/fopen_variation4.phpt
new file mode 100644
index 0000000..61d850c
--- /dev/null
+++ b/ext/standard/tests/file/fopen_variation4.phpt
@@ -0,0 +1,251 @@
+--TEST--
+Test fopen() function : usage variation different datatypes for stream context
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
+ * Description: Open a file or a URL and return a file pointer
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing fopen() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$filename = __FILE__;
+$mode = 'r';
+$use_include_path = false;
+$fileresource = fopen($filename, $mode);
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+ // int data
+ 'int 0' => 0,
+ 'int 1' => 1,
+ 'int 12345' => 12345,
+ 'int -12345' => -2345,
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float -10.5' => -10.5,
+ 'float 12.3456789000e10' => 12.3456789000e10,
+ 'float -12.3456789000e10' => -12.3456789000e10,
+ 'float .5' => .5,
+
+ // array data
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // string data
+ 'string DQ' => "string",
+ 'string SQ' => 'string',
+ 'mixed case string' => "sTrInG",
+ 'heredoc' => $heredoc,
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+
+ //file resource
+ 'file resource' => $fileresource
+);
+
+// loop through each element of the array for context
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ $h = fopen($filename, $mode, false, $value);
+ if ($h !== false) {
+ echo "ok\n";
+ fclose($h);
+ }
+ else {
+ var_dump($h);
+ }
+};
+
+fclose($fileresource);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing fopen() : usage variation ***
+
+--int 0--
+Error: 2 - fopen() expects parameter 4 to be resource, integer given, %s(%d)
+bool(false)
+
+--int 1--
+Error: 2 - fopen() expects parameter 4 to be resource, integer given, %s(%d)
+bool(false)
+
+--int 12345--
+Error: 2 - fopen() expects parameter 4 to be resource, integer given, %s(%d)
+bool(false)
+
+--int -12345--
+Error: 2 - fopen() expects parameter 4 to be resource, integer given, %s(%d)
+bool(false)
+
+--float 10.5--
+Error: 2 - fopen() expects parameter 4 to be resource, double given, %s(%d)
+bool(false)
+
+--float -10.5--
+Error: 2 - fopen() expects parameter 4 to be resource, double given, %s(%d)
+bool(false)
+
+--float 12.3456789000e10--
+Error: 2 - fopen() expects parameter 4 to be resource, double given, %s(%d)
+bool(false)
+
+--float -12.3456789000e10--
+Error: 2 - fopen() expects parameter 4 to be resource, double given, %s(%d)
+bool(false)
+
+--float .5--
+Error: 2 - fopen() expects parameter 4 to be resource, double given, %s(%d)
+bool(false)
+
+--empty array--
+Error: 2 - fopen() expects parameter 4 to be resource, array given, %s(%d)
+bool(false)
+
+--int indexed array--
+Error: 2 - fopen() expects parameter 4 to be resource, array given, %s(%d)
+bool(false)
+
+--associative array--
+Error: 2 - fopen() expects parameter 4 to be resource, array given, %s(%d)
+bool(false)
+
+--nested arrays--
+Error: 2 - fopen() expects parameter 4 to be resource, array given, %s(%d)
+bool(false)
+
+--uppercase NULL--
+Error: 2 - fopen() expects parameter 4 to be resource, null given, %s(%d)
+bool(false)
+
+--lowercase null--
+Error: 2 - fopen() expects parameter 4 to be resource, null given, %s(%d)
+bool(false)
+
+--lowercase true--
+Error: 2 - fopen() expects parameter 4 to be resource, boolean given, %s(%d)
+bool(false)
+
+--lowercase false--
+Error: 2 - fopen() expects parameter 4 to be resource, boolean given, %s(%d)
+bool(false)
+
+--uppercase TRUE--
+Error: 2 - fopen() expects parameter 4 to be resource, boolean given, %s(%d)
+bool(false)
+
+--uppercase FALSE--
+Error: 2 - fopen() expects parameter 4 to be resource, boolean given, %s(%d)
+bool(false)
+
+--empty string DQ--
+Error: 2 - fopen() expects parameter 4 to be resource, string given, %s(%d)
+bool(false)
+
+--empty string SQ--
+Error: 2 - fopen() expects parameter 4 to be resource, string given, %s(%d)
+bool(false)
+
+--string DQ--
+Error: 2 - fopen() expects parameter 4 to be resource, string given, %s(%d)
+bool(false)
+
+--string SQ--
+Error: 2 - fopen() expects parameter 4 to be resource, string given, %s(%d)
+bool(false)
+
+--mixed case string--
+Error: 2 - fopen() expects parameter 4 to be resource, string given, %s(%d)
+bool(false)
+
+--heredoc--
+Error: 2 - fopen() expects parameter 4 to be resource, string given, %s(%d)
+bool(false)
+
+--instance of classWithToString--
+Error: 2 - fopen() expects parameter 4 to be resource, object given, %s(%d)
+bool(false)
+
+--instance of classWithoutToString--
+Error: 2 - fopen() expects parameter 4 to be resource, object given, %s(%d)
+bool(false)
+
+--undefined var--
+Error: 2 - fopen() expects parameter 4 to be resource, null given, %s(%d)
+bool(false)
+
+--unset var--
+Error: 2 - fopen() expects parameter 4 to be resource, null given, %s(%d)
+bool(false)
+
+--file resource--
+Error: 2 - fopen(): supplied resource is not a valid Stream-Context resource, %s(%d)
+ok
+===DONE===
diff --git a/ext/standard/tests/file/fopen_variation5.phpt b/ext/standard/tests/file/fopen_variation5.phpt
new file mode 100644
index 0000000..975560f
--- /dev/null
+++ b/ext/standard/tests/file/fopen_variation5.phpt
@@ -0,0 +1,151 @@
+--TEST--
+Test fopen() function : variation: use include path and stream context (absolute directories in path)
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
+ * Description: Open a file or a URL and return a file pointer
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+
+
+//create the include directory structure
+$thisTestDir = basename(__FILE__, ".php") . ".dir";
+mkdir($thisTestDir);
+chdir($thisTestDir);
+
+$workingDir = "workdir";
+$filename = basename(__FILE__, ".php") . ".tmp";
+$scriptDir = dirname(__FILE__);
+$baseDir = getcwd();
+$secondFile = $baseDir."/dir2/".$filename;
+$firstFile = "../dir1/".$filename;
+$scriptFile = $scriptDir.'/'.$filename;
+
+$newdirs = array("dir1", "dir2", "dir3");
+$pathSep = ":";
+$newIncludePath = "";
+if(substr(PHP_OS, 0, 3) == 'WIN' ) {
+ $pathSep = ";";
+}
+foreach($newdirs as $newdir) {
+ mkdir($newdir);
+ $newIncludePath .= $baseDir.'/'.$newdir.$pathSep;
+}
+mkdir($workingDir);
+chdir($workingDir);
+
+//define the files to go into these directories, create one in dir2
+echo "\n--- testing include path ---\n";
+set_include_path($newIncludePath);
+$modes = array("r", "r+", "rt");
+foreach($modes as $mode) {
+ test_fopen($mode);
+}
+restore_include_path();
+
+// remove the directory structure
+chdir($baseDir);
+rmdir($workingDir);
+foreach($newdirs as $newdir) {
+ rmdir($newdir);
+}
+
+chdir("..");
+rmdir($thisTestDir);
+
+
+function test_fopen($mode) {
+ global $scriptFile, $secondFile, $firstFile, $filename;
+
+ // create a file in the middle directory
+ $h = fopen($secondFile, "w");
+ fwrite($h, (binary) "in dir2");
+ fclose($h);
+
+ echo "\n** testing with mode=$mode **\n";
+ // should read dir2 file
+ $h = fopen($filename, $mode, true);
+ fpassthru($h);
+ fclose($h);
+ echo "\n";
+
+ //create a file in dir1
+ $h = fopen($firstFile, "w");
+ fwrite($h, (binary) "in dir1");
+ fclose($h);
+
+ //should now read dir1 file
+ $h = fopen($filename, $mode, true);
+ fpassthru($h);
+ fclose($h);
+ echo "\n";
+
+ // create a file in working directory
+ $h = fopen($filename, "w");
+ fwrite($h, (binary) "in working dir");
+ fclose($h);
+
+ //should still read dir1 file
+ $h = fopen($filename, $mode, true);
+ fpassthru($h);
+ fclose($h);
+ echo "\n";
+
+ unlink($firstFile);
+ unlink($secondFile);
+
+ //should read the file in working dir
+ $h = fopen($filename, $mode, true);
+ fpassthru($h);
+ fclose($h);
+ echo "\n";
+
+ // create a file in the script directory
+ $h = fopen($scriptFile, "w");
+ fwrite($h, (binary) "in script dir");
+ fclose($h);
+
+ //should read the file in script dir
+ $h = fopen($filename, $mode, true);
+ fpassthru($h);
+ fclose($h);
+ echo "\n";
+
+ //cleanup
+ unlink($filename);
+ unlink($scriptFile);
+
+}
+
+?>
+===DONE===
+--EXPECTF--
+
+--- testing include path ---
+
+** testing with mode=r **
+in dir2
+in dir1
+in dir1
+in working dir
+in script dir
+
+** testing with mode=r+ **
+in dir2
+in dir1
+in dir1
+in working dir
+in script dir
+
+** testing with mode=rt **
+in dir2
+in dir1
+in dir1
+in working dir
+in script dir
+===DONE===
+
diff --git a/ext/standard/tests/file/fopen_variation6.phpt b/ext/standard/tests/file/fopen_variation6.phpt
new file mode 100644
index 0000000..3a99212
--- /dev/null
+++ b/ext/standard/tests/file/fopen_variation6.phpt
@@ -0,0 +1,44 @@
+--TEST--
+Test fopen() function : variation: use include path and stream context relative/absolute file
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
+ * Description: Open a file or a URL and return a file pointer
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing fopen() : variation ***\n";
+$absfile = __FILE__.'.tmp';
+$relfile = "fopen_variation6.tmp";
+
+$h = fopen($absfile, "w");
+fwrite($h, "This is an absolute file");
+fclose($h);
+
+$h = fopen($relfile, "w");
+fwrite($h, "This is a relative file");
+fclose($h);
+
+$ctx = stream_context_create();
+$h = fopen($absfile, "r", true, $ctx);
+fpassthru($h);
+fclose($h);
+echo "\n";
+
+$h = fopen($relfile, "r", true, $ctx);
+fpassthru($h);
+fclose($h);
+echo "\n";
+
+unlink($absfile);
+unlink($relfile);
+?>
+===DONE===
+--EXPECTF--
+*** Testing fopen() : variation ***
+This is an absolute file
+This is a relative file
+===DONE===
diff --git a/ext/standard/tests/file/fopen_variation7.phpt b/ext/standard/tests/file/fopen_variation7.phpt
new file mode 100644
index 0000000..13f075c
--- /dev/null
+++ b/ext/standard/tests/file/fopen_variation7.phpt
@@ -0,0 +1,66 @@
+--TEST--
+Test fopen() function : variation: use include path create a file (relative)
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
+ * Description: Open a file or a URL and return a file pointer
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+require_once('fopen_include_path.inc');
+
+$thisTestDir = basename(__FILE__, ".php") . ".dir";
+mkdir($thisTestDir);
+chdir($thisTestDir);
+
+$newpath = create_include_path();
+set_include_path($newpath);
+runtest();
+$newpath = generate_next_path();
+set_include_path($newpath);
+runtest();
+
+teardown_include_path();
+restore_include_path();
+chdir("..");
+rmdir($thisTestDir);
+
+function runtest() {
+ global $dir1;
+ $tmpfile = basename(__FILE__, ".php") . ".tmp";
+ $h = fopen($tmpfile, "w", true);
+ fwrite($h, (binary)"This is the test file");
+ fclose($h);
+
+
+ $h = @fopen($tmpfile, "r");
+ if ($h === false) {
+ echo "Not created in working dir\n";
+ }
+ else {
+ echo "created in working dir\n";
+ fclose($h);
+ unlink($tmpfile);
+ }
+
+ $h = @fopen($dir1.'/'.$tmpfile, "r");
+ if ($h === false) {
+ echo "Not created in dir1\n";
+ }
+ else {
+ echo "created in dir1\n";
+ fclose($h);
+ unlink($dir1.'/'.$tmpfile);
+ }
+}
+?>
+===DONE===
+--EXPECT--
+created in working dir
+Not created in dir1
+created in working dir
+Not created in dir1
+===DONE===
diff --git a/ext/standard/tests/file/fopen_variation8.phpt b/ext/standard/tests/file/fopen_variation8.phpt
new file mode 100644
index 0000000..dd95014
--- /dev/null
+++ b/ext/standard/tests/file/fopen_variation8.phpt
@@ -0,0 +1,150 @@
+--TEST--
+Test fopen() function : variation: use include path and stream context (relative directories in path)
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
+ * Description: Open a file or a URL and return a file pointer
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+
+
+$thisTestDir = basename(__FILE__, ".php") . ".dir";
+mkdir($thisTestDir);
+chdir($thisTestDir);
+
+//create the include directory structure
+$workingDir = "workdir";
+$filename = basename(__FILE__, ".php") . ".tmp";
+$scriptDir = dirname(__FILE__);
+$baseDir = getcwd();
+$secondFile = $baseDir."/dir2/".$filename;
+$firstFile = "../dir1/".$filename;
+$scriptFile = $scriptDir.'/'.$filename;
+
+$newdirs = array("dir1", "dir2", "dir3");
+$pathSep = ":";
+$newIncludePath = "";
+if(substr(PHP_OS, 0, 3) == 'WIN' ) {
+ $pathSep = ";";
+}
+foreach($newdirs as $newdir) {
+ mkdir($newdir);
+ $newIncludePath .= '../'.$newdir.$pathSep;
+}
+mkdir($workingDir);
+chdir($workingDir);
+
+//define the files to go into these directories, create one in dir2
+echo "\n--- testing include path ---\n";
+set_include_path($newIncludePath);
+$modes = array("r", "r+", "rt");
+foreach($modes as $mode) {
+ test_fopen($mode);
+}
+restore_include_path();
+
+// remove the directory structure
+chdir($baseDir);
+rmdir($workingDir);
+foreach($newdirs as $newdir) {
+ rmdir($newdir);
+}
+
+chdir("..");
+rmdir($thisTestDir);
+
+function test_fopen($mode) {
+ global $scriptFile, $secondFile, $firstFile, $filename;
+
+ // create a file in the middle directory
+ $h = fopen($secondFile, "w");
+ fwrite($h, (binary) "in dir2");
+ fclose($h);
+
+ echo "\n** testing with mode=$mode **\n";
+ // should read dir2 file
+ $h = fopen($filename, $mode, true);
+ fpassthru($h);
+ fclose($h);
+ echo "\n";
+
+ //create a file in dir1
+ $h = fopen($firstFile, "w");
+ fwrite($h, (binary) "in dir1");
+ fclose($h);
+
+ //should now read dir1 file
+ $h = fopen($filename, $mode, true);
+ fpassthru($h);
+ fclose($h);
+ echo "\n";
+
+ // create a file in working directory
+ $h = fopen($filename, "w");
+ fwrite($h, (binary) "in working dir");
+ fclose($h);
+
+ //should read the dir1 file
+ $h = fopen($filename, $mode, true);
+ fpassthru($h);
+ fclose($h);
+ echo "\n";
+
+ unlink($firstFile);
+ unlink($secondFile);
+
+ //should read the working dir file
+ $h = fopen($filename, $mode, true);
+ fpassthru($h);
+ fclose($h);
+ echo "\n";
+
+ // create a file in the script directory
+ $h = fopen($scriptFile, "w");
+ fwrite($h, (binary) "in script dir");
+ fclose($h);
+
+ //should read the file in script dir
+ $h = fopen($filename, $mode, true);
+ fpassthru($h);
+ fclose($h);
+ echo "\n";
+
+ //cleanup
+ unlink($filename);
+ unlink($scriptFile);
+
+}
+
+?>
+===DONE===
+--EXPECTF--
+
+--- testing include path ---
+
+** testing with mode=r **
+in dir2
+in dir1
+in dir1
+in working dir
+in script dir
+
+** testing with mode=r+ **
+in dir2
+in dir1
+in dir1
+in working dir
+in script dir
+
+** testing with mode=rt **
+in dir2
+in dir1
+in dir1
+in working dir
+in script dir
+===DONE===
+
diff --git a/ext/standard/tests/file/fopen_variation9.phpt b/ext/standard/tests/file/fopen_variation9.phpt
new file mode 100644
index 0000000..4b0a727
--- /dev/null
+++ b/ext/standard/tests/file/fopen_variation9.phpt
@@ -0,0 +1,66 @@
+--TEST--
+Test fopen() function : variation: use include path and stream context create a file, relative path
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
+ * Description: Open a file or a URL and return a file pointer
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+require_once('fopen_include_path.inc');
+
+$thisTestDir = basename(__FILE__, ".php") . ".dir";
+mkdir($thisTestDir);
+chdir($thisTestDir);
+
+$newpath = relative_include_path();
+set_include_path($newpath);
+runtest();
+
+$newpath = generate_next_rel_path();
+set_include_path($newpath);
+runtest();
+
+teardown_relative_path();
+restore_include_path();
+chdir("..");
+rmdir($thisTestDir);
+
+function runtest() {
+ $tmpfile = basename(__FILE__, ".php") . ".tmp";
+ $h = fopen($tmpfile, "w", true);
+ fwrite($h, (binary) "This is the test file");
+ fclose($h);
+
+
+ $h = @fopen($tmpfile, "r");
+ if ($h === false) {
+ echo "Not created in working dir\n";
+ }
+ else {
+ echo "created in working dir\n";
+ fclose($h);
+ unlink($tmpfile);
+ }
+
+ $h = @fopen('dir1/'.$tmpfile, "r");
+ if ($h === false) {
+ echo "Not created in dir1\n";
+ }
+ else {
+ echo "created in dir1\n";
+ fclose($h);
+ unlink('dir1/'.$tmpfile);
+ }
+}
+?>
+===DONE===
+--EXPECT--
+created in working dir
+Not created in dir1
+created in working dir
+Not created in dir1
+===DONE===
diff --git a/ext/standard/tests/file/fopencookie.phpt b/ext/standard/tests/file/fopencookie.phpt
new file mode 100644
index 0000000..cd6bed8
--- /dev/null
+++ b/ext/standard/tests/file/fopencookie.phpt
@@ -0,0 +1,88 @@
+--TEST--
+fopencookie detected and working (or cast mechanism works)
+--FILE--
+<?php
+# vim600:syn=php:
+
+/* This test verifies that the casting mechanism is working correctly.
+ * On systems with fopencookie, a FILE* is created around the user
+ * stream and that is passed back to the ZE to include.
+ * On systems without fopencookie, the stream is fed into a temporary
+ * file, and that temporary file is passed back to the ZE.
+ * The important thing here is really fopencookie; the glibc people
+ * changed the binary interface, so if haven't detected it correctly,
+ * you can expect this test to segfault.
+ *
+ * FIXME: the test really needs something to fseek(3) on the FILE*
+ * used internally for this test to be really effective.
+ */
+
+class userstream {
+ public $position = 0;
+ public $data = "If you can read this, it worked";
+
+ function stream_open($path, $mode, $options, &$opened_path)
+ {
+ return true;
+ }
+
+ function stream_read($count)
+ {
+ $ret = substr($this->data, $this->position, $count);
+ $this->position += strlen($ret);
+ return $ret;
+ }
+
+ function stream_tell()
+ {
+ return $this->position;
+ }
+
+ function stream_eof()
+ {
+ return $this->position >= strlen($this->data);
+ }
+
+ function stream_seek($offset, $whence)
+ {
+ switch($whence) {
+ case SEEK_SET:
+ if ($offset < strlen($this->data) && $offset >= 0) {
+ $this->position = $offset;
+ return true;
+ } else {
+ return false;
+ }
+ break;
+ case SEEK_CUR:
+ if ($offset >= 0) {
+ $this->position += $offset;
+ return true;
+ } else {
+ return false;
+ }
+ break;
+ case SEEK_END:
+ if (strlen($this->data) + $offset >= 0) {
+ $this->position = strlen($this->data) + $offset;
+ return true;
+ } else {
+ return false;
+ }
+ break;
+ default:
+ return false;
+ }
+ }
+ function stream_stat() {
+ return array('size' => strlen($this->data));
+ }
+}
+
+stream_wrapper_register("cookietest", "userstream");
+
+include("cookietest://foo");
+
+?>
+--EXPECT--
+If you can read this, it worked
diff --git a/ext/standard/tests/file/fpassthru_basic.phpt b/ext/standard/tests/file/fpassthru_basic.phpt
new file mode 100644
index 0000000..8924b27
--- /dev/null
+++ b/ext/standard/tests/file/fpassthru_basic.phpt
@@ -0,0 +1,128 @@
+--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";
+if(substr(PHP_OS, 0, 3) == "WIN") {
+ $string = str_replace("\r",'', $string);
+}
+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 ***
diff --git a/ext/standard/tests/file/fpassthru_error.phpt b/ext/standard/tests/file/fpassthru_error.phpt
new file mode 100644
index 0000000..958397b
--- /dev/null
+++ b/ext/standard/tests/file/fpassthru_error.phpt
@@ -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() expects parameter 1 to be resource, string given in %s on line %d
+
+Warning: fpassthru() expects parameter 1 to be resource, boolean given in %s on line %d
+bool(false)
+
+Warning: fpassthru() expects exactly 1 parameter, 0 given in %s on line %d
+bool(false)
+
+Warning: fpassthru() expects exactly 1 parameter, 2 given in %s on line %d
+bool(false)
+
+*** Done ***
diff --git a/ext/standard/tests/file/fpassthru_variation.phpt b/ext/standard/tests/file/fpassthru_variation.phpt
new file mode 100644
index 0000000..56a039e
--- /dev/null
+++ b/ext/standard/tests/file/fpassthru_variation.phpt
@@ -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/file/fpassthru_variation1.phpt b/ext/standard/tests/file/fpassthru_variation1.phpt
new file mode 100644
index 0000000..f6868e3
--- /dev/null
+++ b/ext/standard/tests/file/fpassthru_variation1.phpt
@@ -0,0 +1,224 @@
+--TEST--
+Test fpassthru() function : usage variations - different parameter types
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : proto int fpassthru(resource fp)
+ * Description: Output all remaining data from a file pointer
+ * Source code: ext/standard/file.c
+ * Alias to functions: gzpassthru
+ */
+
+echo "*** Testing fpassthru() : usage variations ***\n";
+error_reporting(E_ALL & ~E_NOTICE);
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+class testClass {
+ public function __toString() {
+ return "testClass";
+ }
+}
+
+//array of values to iterate over
+$values = array(
+
+ // int data
+ 0,
+ 1,
+ 12345,
+ -2345,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // string data
+ "string",
+ 'string',
+
+ // object data
+ new testClass(),
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for fp
+
+foreach($values as $value) {
+ echo @"\nArg value $value \n";
+ var_dump( fpassthru($value) );
+};
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing fpassthru() : usage variations ***
+
+Arg value 0
+
+Warning: fpassthru() expects parameter 1 to be resource, integer given in %s on line %d
+bool(false)
+
+Arg value 1
+
+Warning: fpassthru() expects parameter 1 to be resource, integer given in %s on line %d
+bool(false)
+
+Arg value 12345
+
+Warning: fpassthru() expects parameter 1 to be resource, integer given in %s on line %d
+bool(false)
+
+Arg value -2345
+
+Warning: fpassthru() expects parameter 1 to be resource, integer given in %s on line %d
+bool(false)
+
+Arg value 10.5
+
+Warning: fpassthru() expects parameter 1 to be resource, double given in %s on line %d
+bool(false)
+
+Arg value -10.5
+
+Warning: fpassthru() expects parameter 1 to be resource, double given in %s on line %d
+bool(false)
+
+Arg value 101234567000
+
+Warning: fpassthru() expects parameter 1 to be resource, double given in %s on line %d
+bool(false)
+
+Arg value 1.07654321E-9
+
+Warning: fpassthru() expects parameter 1 to be resource, double given in %s on line %d
+bool(false)
+
+Arg value 0.5
+
+Warning: fpassthru() expects parameter 1 to be resource, double given in %s on line %d
+bool(false)
+
+Arg value Array
+
+Warning: fpassthru() expects parameter 1 to be resource, array given in %s on line %d
+bool(false)
+
+Arg value Array
+
+Warning: fpassthru() expects parameter 1 to be resource, array given in %s on line %d
+bool(false)
+
+Arg value Array
+
+Warning: fpassthru() expects parameter 1 to be resource, array given in %s on line %d
+bool(false)
+
+Arg value Array
+
+Warning: fpassthru() expects parameter 1 to be resource, array given in %s on line %d
+bool(false)
+
+Arg value Array
+
+Warning: fpassthru() expects parameter 1 to be resource, array given in %s on line %d
+bool(false)
+
+Arg value
+
+Warning: fpassthru() expects parameter 1 to be resource, null given in %s on line %d
+bool(false)
+
+Arg value
+
+Warning: fpassthru() expects parameter 1 to be resource, null given in %s on line %d
+bool(false)
+
+Arg value 1
+
+Warning: fpassthru() expects parameter 1 to be resource, boolean given in %s on line %d
+bool(false)
+
+Arg value
+
+Warning: fpassthru() expects parameter 1 to be resource, boolean given in %s on line %d
+bool(false)
+
+Arg value 1
+
+Warning: fpassthru() expects parameter 1 to be resource, boolean given in %s on line %d
+bool(false)
+
+Arg value
+
+Warning: fpassthru() expects parameter 1 to be resource, boolean given in %s on line %d
+bool(false)
+
+Arg value
+
+Warning: fpassthru() expects parameter 1 to be resource, string given in %s on line %d
+bool(false)
+
+Arg value
+
+Warning: fpassthru() expects parameter 1 to be resource, string given in %s on line %d
+bool(false)
+
+Arg value string
+
+Warning: fpassthru() expects parameter 1 to be resource, string given in %s on line %d
+bool(false)
+
+Arg value string
+
+Warning: fpassthru() expects parameter 1 to be resource, string given in %s on line %d
+bool(false)
+
+Arg value testClass
+
+Warning: fpassthru() expects parameter 1 to be resource, object given in %s on line %d
+bool(false)
+
+Arg value
+
+Warning: fpassthru() expects parameter 1 to be resource, null given in %s on line %d
+bool(false)
+
+Arg value
+
+Warning: fpassthru() expects parameter 1 to be resource, null given in %s on line %d
+bool(false)
+Done
+
diff --git a/ext/standard/tests/file/fputcsv.phpt b/ext/standard/tests/file/fputcsv.phpt
new file mode 100644
index 0000000..63c4150
--- /dev/null
+++ b/ext/standard/tests/file/fputcsv.phpt
@@ -0,0 +1,105 @@
+--TEST--
+various fputcsv() functionality tests
+--FILE--
+<?php
+
+$list = array (
+ 0 => 'aaa,bbb',
+ 1 => 'aaa,"bbb"',
+ 2 => '"aaa","bbb"',
+ 3 => 'aaa,bbb',
+ 4 => '"aaa",bbb',
+ 5 => '"aaa", "bbb"',
+ 6 => ',',
+ 7 => 'aaa,',
+ 8 => ',"aaa"',
+ 9 => '"",""',
+ 10 => '"""""",',
+ 11 => '""""",aaa',
+ 12 => 'aaa,bbb ',
+ 13 => 'aaa,"bbb "',
+ 14 => 'aaa"aaa","bbb"bbb',
+ 15 => 'aaa"aaa""",bbb',
+ 16 => 'aaa,"\\"bbb,ccc',
+ 17 => 'aaa"\\"a","bbb"',
+ 18 => '"\\"","aaa"',
+ 19 => '"\\""",aaa',
+);
+
+$file = dirname(__FILE__) . 'fgetcsv.csv';
+@unlink($file);
+
+$fp = fopen($file, "w");
+foreach ($list as $v) {
+ fputcsv($fp, explode(',', $v));
+}
+fclose($fp);
+
+$res = file($file);
+foreach($res as &$val)
+{
+ $val = substr($val, 0, -1);
+}
+echo '$list = ';var_export($res);echo ";\n";
+
+$fp = fopen($file, "r");
+$res = array();
+while($l=fgetcsv($fp))
+{
+ $res[] = join(',',$l);
+}
+fclose($fp);
+
+echo '$list = ';var_export($res);echo ";\n";
+
+@unlink($file);
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+$list = array (
+ 0 => 'aaa,bbb',
+ 1 => 'aaa,"""bbb"""',
+ 2 => '"""aaa""","""bbb"""',
+ 3 => 'aaa,bbb',
+ 4 => '"""aaa""",bbb',
+ 5 => '"""aaa"""," ""bbb"""',
+ 6 => ',',
+ 7 => 'aaa,',
+ 8 => ',"""aaa"""',
+ 9 => '"""""",""""""',
+ 10 => '"""""""""""""",',
+ 11 => '"""""""""""",aaa',
+ 12 => 'aaa,"bbb "',
+ 13 => 'aaa,"""bbb """',
+ 14 => '"aaa""aaa""","""bbb""bbb"',
+ 15 => '"aaa""aaa""""""",bbb',
+ 16 => 'aaa,"""\\"bbb",ccc',
+ 17 => '"aaa""\\"a""","""bbb"""',
+ 18 => '"""\\"""","""aaa"""',
+ 19 => '"""\\"""""",aaa',
+);
+$list = array (
+ 0 => 'aaa,bbb',
+ 1 => 'aaa,"bbb"',
+ 2 => '"aaa","bbb"',
+ 3 => 'aaa,bbb',
+ 4 => '"aaa",bbb',
+ 5 => '"aaa", "bbb"',
+ 6 => ',',
+ 7 => 'aaa,',
+ 8 => ',"aaa"',
+ 9 => '"",""',
+ 10 => '"""""",',
+ 11 => '""""",aaa',
+ 12 => 'aaa,bbb ',
+ 13 => 'aaa,"bbb "',
+ 14 => 'aaa"aaa","bbb"bbb',
+ 15 => 'aaa"aaa""",bbb',
+ 16 => 'aaa,"\\"bbb,ccc',
+ 17 => 'aaa"\\"a","bbb"',
+ 18 => '"\\"","aaa"',
+ 19 => '"\\""",aaa',
+);
+===DONE===
diff --git a/ext/standard/tests/file/fputcsv_002.phpt b/ext/standard/tests/file/fputcsv_002.phpt
new file mode 100644
index 0000000..544ad30
--- /dev/null
+++ b/ext/standard/tests/file/fputcsv_002.phpt
@@ -0,0 +1,43 @@
+--TEST--
+fputcsv(): Checking data after calling the function
+--FILE--
+<?php
+
+$file = dirname(__FILE__) .'/fgetcsv-test.csv';
+
+$data = array(1, 2, 'foo', 'haha', array(4, 5, 6), 1.3, null);
+
+$fp = fopen($file, 'w');
+
+fputcsv($fp, $data);
+
+var_dump($data);
+
+@unlink($file);
+
+?>
+--EXPECTF--
+Notice: Array to string conversion in %s on line %d
+array(7) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ string(3) "foo"
+ [3]=>
+ string(4) "haha"
+ [4]=>
+ array(3) {
+ [0]=>
+ int(4)
+ [1]=>
+ int(5)
+ [2]=>
+ int(6)
+ }
+ [5]=>
+ float(1.3)
+ [6]=>
+ NULL
+}
diff --git a/ext/standard/tests/file/fputcsv_error.phpt b/ext/standard/tests/file/fputcsv_error.phpt
new file mode 100644
index 0000000..9403cf4
--- /dev/null
+++ b/ext/standard/tests/file/fputcsv_error.phpt
@@ -0,0 +1,97 @@
+--TEST--
+Test fputcsv() function : error conditions
+--FILE--
+<?php
+/*
+ Prototype: int fputcsv ( resource $handle [, array $fields [, string $delimiter [, string $enclosure]]] );
+ Description:fputcsv() formats a line (passed as a fields array) as CSV and write it to the specified file
+ handle. Returns the length of the written string, or FALSE on failure.
+*/
+
+echo "*** Testing error conditions ***\n";
+// zero argument
+echo "-- Testing fputcsv() with zero argument --\n";
+var_dump( fputcsv() );
+
+// more than expected no. of args
+echo "-- Testing fputcsv() with more than expected number of arguments --\n";
+$fp = fopen(__FILE__, "r");
+$fields = array("fld1", "fld2");
+$delim = ";";
+$enclosure ="\"";
+var_dump( fputcsv($fp, $fields, $delim, $enclosure, $fp) );
+fclose($fp);
+
+// test invalid arguments : non-resources
+echo "-- Testing fputcsv() with invalid arguments --\n";
+$invalid_args = array (
+ "string",
+ 10,
+ 10.5,
+ true,
+ array(1,2,3),
+ new stdclass,
+);
+/* loop to test fputcsv() with different invalid type of args */
+for($loop_counter = 1; $loop_counter <= count($invalid_args); $loop_counter++) {
+ echo "-- Iteration $loop_counter --\n";
+ var_dump( fputcsv($invalid_args[$loop_counter - 1]) ); // with default args
+ var_dump( fputcsv($invalid_args[$loop_counter - 1], $fields, $delim, $enclosure) ); // all args specified
+}
+
+echo "Done\n";
+--EXPECTF--
+*** Testing error conditions ***
+-- Testing fputcsv() with zero argument --
+
+Warning: fputcsv() expects at least 2 parameters, 0 given in %s on line %d
+NULL
+-- Testing fputcsv() with more than expected number of arguments --
+
+Warning: fputcsv() expects at most 4 parameters, 5 given in %s on line %d
+NULL
+-- Testing fputcsv() with invalid arguments --
+-- Iteration 1 --
+
+Warning: fputcsv() expects at least 2 parameters, 1 given in %s on line %d
+NULL
+
+Warning: fputcsv() expects parameter 1 to be resource, string given in %s on line %d
+NULL
+-- Iteration 2 --
+
+Warning: fputcsv() expects at least 2 parameters, 1 given in %s on line %d
+NULL
+
+Warning: fputcsv() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
+-- Iteration 3 --
+
+Warning: fputcsv() expects at least 2 parameters, 1 given in %s on line %d
+NULL
+
+Warning: fputcsv() expects parameter 1 to be resource, double given in %s on line %d
+NULL
+-- Iteration 4 --
+
+Warning: fputcsv() expects at least 2 parameters, 1 given in %s on line %d
+NULL
+
+Warning: fputcsv() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
+-- Iteration 5 --
+
+Warning: fputcsv() expects at least 2 parameters, 1 given in %s on line %d
+NULL
+
+Warning: fputcsv() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+-- Iteration 6 --
+
+Warning: fputcsv() expects at least 2 parameters, 1 given in %s on line %d
+NULL
+
+Warning: fputcsv() expects parameter 1 to be resource, object given in %s on line %d
+NULL
+Done
+
diff --git a/ext/standard/tests/file/fputcsv_variation1.phpt b/ext/standard/tests/file/fputcsv_variation1.phpt
new file mode 100644
index 0000000..68df33c
--- /dev/null
+++ b/ext/standard/tests/file/fputcsv_variation1.phpt
@@ -0,0 +1,834 @@
+--TEST--
+Test fputcsv() : usage variations - with all parameters specified
+--FILE--
+<?php
+/*
+ Prototype: array fputcsv ( resource $handle , array $fields [, string $delimiter [, string $enclosure]]] );
+ Description: Format line as CSV and write to the file pointer
+*/
+
+/* Testing fputcsv() to write to a file when all its parameters are provided */
+
+echo "*** Testing fputcsv() : with all parameters specified ***\n";
+
+/* the array is with three elements in it. Each element should be read as
+ 1st element is delimiter, 2nd element is enclosure
+ and 3rd element is csv fields
+*/
+$csv_lists = array (
+ array(',', '"', array('water','fruit') ),
+ array(',', '"', array('"water","fruit') ),
+ array(',', '"', array('"water","fruit"') ),
+ array(' ', '^', array('^water^ ^fruit^')),
+ array(':', '&', array('&water&:&fruit&')),
+ array('=', '=', array('=water===fruit=')),
+ array('-', '-', array('-water--fruit-air')),
+ array('-', '-', array('-water---fruit---air-')),
+ array(':', '&', array('&""""&:&"&:,:":&,&:,,,,'))
+
+);
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fputcsv_variation1.tmp";
+
+$file_modes = array ("r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+
+ echo "\n-- file opened in $file_modes[$mode_counter] --\n";
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $file_handle = fopen($filename, "w");
+ } else {
+ $file_handle = fopen($filename, $file_modes[$mode_counter] );
+ }
+ if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+ }
+ $delimiter = $csv_list[0];
+ $enclosure = $csv_list[1];
+ $csv_field = $csv_list[2];
+
+
+ var_dump( fputcsv($file_handle, $csv_field, $delimiter, $enclosure) );
+ // check the file pointer position and eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+ //close the file
+ fclose($file_handle);
+
+ // print the file contents
+ var_dump( file_get_contents($filename) );
+
+ //delete file
+ unlink($filename);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fputcsv() : with all parameters specified ***
+
+-- file opened in r+ --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in r+b --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in r+t --
+int(12)
+int(12)
+bool(false)
+string(%d) "water,fruit
+"
+
+-- file opened in a+ --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in a+b --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in a+t --
+int(12)
+int(12)
+bool(false)
+string(%d) "water,fruit
+"
+
+-- file opened in w+ --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in w+b --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in w+t --
+int(12)
+int(12)
+bool(false)
+string(%d) "water,fruit
+"
+
+-- file opened in x+ --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in x+b --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in x+t --
+int(12)
+int(12)
+bool(false)
+string(%d) "water,fruit
+"
+
+-- file opened in r+ --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in r+b --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in r+t --
+int(20)
+int(20)
+bool(false)
+string(%d) """"water"",""fruit"
+"
+
+-- file opened in a+ --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in a+b --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in a+t --
+int(20)
+int(20)
+bool(false)
+string(%d) """"water"",""fruit"
+"
+
+-- file opened in w+ --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in w+b --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in w+t --
+int(20)
+int(20)
+bool(false)
+string(%d) """"water"",""fruit"
+"
+
+-- file opened in x+ --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in x+b --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in x+t --
+int(20)
+int(20)
+bool(false)
+string(%d) """"water"",""fruit"
+"
+
+-- file opened in r+ --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in r+b --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in r+t --
+int(22)
+int(22)
+bool(false)
+string(%d) """"water"",""fruit"""
+"
+
+-- file opened in a+ --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in a+b --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in a+t --
+int(22)
+int(22)
+bool(false)
+string(%d) """"water"",""fruit"""
+"
+
+-- file opened in w+ --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in w+b --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in w+t --
+int(22)
+int(22)
+bool(false)
+string(%d) """"water"",""fruit"""
+"
+
+-- file opened in x+ --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in x+b --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in x+t --
+int(22)
+int(22)
+bool(false)
+string(%d) """"water"",""fruit"""
+"
+
+-- file opened in r+ --
+int(22)
+int(22)
+bool(false)
+string(22) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in r+b --
+int(22)
+int(22)
+bool(false)
+string(22) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in r+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in a+ --
+int(22)
+int(22)
+bool(false)
+string(22) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in a+b --
+int(22)
+int(22)
+bool(false)
+string(22) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in a+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in w+ --
+int(22)
+int(22)
+bool(false)
+string(22) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in w+b --
+int(22)
+int(22)
+bool(false)
+string(22) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in w+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in x+ --
+int(22)
+int(22)
+bool(false)
+string(22) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in x+b --
+int(22)
+int(22)
+bool(false)
+string(22) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in x+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in r+ --
+int(22)
+int(22)
+bool(false)
+string(22) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in r+b --
+int(22)
+int(22)
+bool(false)
+string(22) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in r+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in a+ --
+int(22)
+int(22)
+bool(false)
+string(22) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in a+b --
+int(22)
+int(22)
+bool(false)
+string(22) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in a+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in w+ --
+int(22)
+int(22)
+bool(false)
+string(22) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in w+b --
+int(22)
+int(22)
+bool(false)
+string(22) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in w+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in x+ --
+int(22)
+int(22)
+bool(false)
+string(22) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in x+b --
+int(22)
+int(22)
+bool(false)
+string(22) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in x+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in r+ --
+int(23)
+int(23)
+bool(false)
+string(23) "===water======fruit===
+"
+
+-- file opened in r+b --
+int(23)
+int(23)
+bool(false)
+string(23) "===water======fruit===
+"
+
+-- file opened in r+t --
+int(23)
+int(23)
+bool(false)
+string(%d) "===water======fruit===
+"
+
+-- file opened in a+ --
+int(23)
+int(23)
+bool(false)
+string(23) "===water======fruit===
+"
+
+-- file opened in a+b --
+int(23)
+int(23)
+bool(false)
+string(23) "===water======fruit===
+"
+
+-- file opened in a+t --
+int(23)
+int(23)
+bool(false)
+string(%d) "===water======fruit===
+"
+
+-- file opened in w+ --
+int(23)
+int(23)
+bool(false)
+string(23) "===water======fruit===
+"
+
+-- file opened in w+b --
+int(23)
+int(23)
+bool(false)
+string(23) "===water======fruit===
+"
+
+-- file opened in w+t --
+int(23)
+int(23)
+bool(false)
+string(%d) "===water======fruit===
+"
+
+-- file opened in x+ --
+int(23)
+int(23)
+bool(false)
+string(23) "===water======fruit===
+"
+
+-- file opened in x+b --
+int(23)
+int(23)
+bool(false)
+string(23) "===water======fruit===
+"
+
+-- file opened in x+t --
+int(23)
+int(23)
+bool(false)
+string(%d) "===water======fruit===
+"
+
+-- file opened in r+ --
+int(24)
+int(24)
+bool(false)
+string(24) "---water----fruit--air-
+"
+
+-- file opened in r+b --
+int(24)
+int(24)
+bool(false)
+string(24) "---water----fruit--air-
+"
+
+-- file opened in r+t --
+int(24)
+int(24)
+bool(false)
+string(%d) "---water----fruit--air-
+"
+
+-- file opened in a+ --
+int(24)
+int(24)
+bool(false)
+string(24) "---water----fruit--air-
+"
+
+-- file opened in a+b --
+int(24)
+int(24)
+bool(false)
+string(24) "---water----fruit--air-
+"
+
+-- file opened in a+t --
+int(24)
+int(24)
+bool(false)
+string(%d) "---water----fruit--air-
+"
+
+-- file opened in w+ --
+int(24)
+int(24)
+bool(false)
+string(24) "---water----fruit--air-
+"
+
+-- file opened in w+b --
+int(24)
+int(24)
+bool(false)
+string(24) "---water----fruit--air-
+"
+
+-- file opened in w+t --
+int(24)
+int(24)
+bool(false)
+string(%d) "---water----fruit--air-
+"
+
+-- file opened in x+ --
+int(24)
+int(24)
+bool(false)
+string(24) "---water----fruit--air-
+"
+
+-- file opened in x+b --
+int(24)
+int(24)
+bool(false)
+string(24) "---water----fruit--air-
+"
+
+-- file opened in x+t --
+int(24)
+int(24)
+bool(false)
+string(%d) "---water----fruit--air-
+"
+
+-- file opened in r+ --
+int(32)
+int(32)
+bool(false)
+string(32) "---water------fruit------air---
+"
+
+-- file opened in r+b --
+int(32)
+int(32)
+bool(false)
+string(32) "---water------fruit------air---
+"
+
+-- file opened in r+t --
+int(32)
+int(32)
+bool(false)
+string(%d) "---water------fruit------air---
+"
+
+-- file opened in a+ --
+int(32)
+int(32)
+bool(false)
+string(32) "---water------fruit------air---
+"
+
+-- file opened in a+b --
+int(32)
+int(32)
+bool(false)
+string(32) "---water------fruit------air---
+"
+
+-- file opened in a+t --
+int(32)
+int(32)
+bool(false)
+string(%d) "---water------fruit------air---
+"
+
+-- file opened in w+ --
+int(32)
+int(32)
+bool(false)
+string(32) "---water------fruit------air---
+"
+
+-- file opened in w+b --
+int(32)
+int(32)
+bool(false)
+string(32) "---water------fruit------air---
+"
+
+-- file opened in w+t --
+int(32)
+int(32)
+bool(false)
+string(%d) "---water------fruit------air---
+"
+
+-- file opened in x+ --
+int(32)
+int(32)
+bool(false)
+string(32) "---water------fruit------air---
+"
+
+-- file opened in x+b --
+int(32)
+int(32)
+bool(false)
+string(32) "---water------fruit------air---
+"
+
+-- file opened in x+t --
+int(32)
+int(32)
+bool(false)
+string(%d) "---water------fruit------air---
+"
+
+-- file opened in r+ --
+int(32)
+int(32)
+bool(false)
+string(32) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+
+-- file opened in r+b --
+int(32)
+int(32)
+bool(false)
+string(32) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+
+-- file opened in r+t --
+int(32)
+int(32)
+bool(false)
+string(%d) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+
+-- file opened in a+ --
+int(32)
+int(32)
+bool(false)
+string(32) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+
+-- file opened in a+b --
+int(32)
+int(32)
+bool(false)
+string(32) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+
+-- file opened in a+t --
+int(32)
+int(32)
+bool(false)
+string(%d) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+
+-- file opened in w+ --
+int(32)
+int(32)
+bool(false)
+string(32) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+
+-- file opened in w+b --
+int(32)
+int(32)
+bool(false)
+string(32) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+
+-- file opened in w+t --
+int(32)
+int(32)
+bool(false)
+string(%d) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+
+-- file opened in x+ --
+int(32)
+int(32)
+bool(false)
+string(32) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+
+-- file opened in x+b --
+int(32)
+int(32)
+bool(false)
+string(32) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+
+-- file opened in x+t --
+int(32)
+int(32)
+bool(false)
+string(%d) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+Done
+
diff --git a/ext/standard/tests/file/fputcsv_variation10.phpt b/ext/standard/tests/file/fputcsv_variation10.phpt
new file mode 100644
index 0000000..21d845f
--- /dev/null
+++ b/ext/standard/tests/file/fputcsv_variation10.phpt
@@ -0,0 +1,336 @@
+--TEST--
+Test fputcsv() : usage variations - with line without any csv fields
+--FILE--
+<?php
+/*
+ Prototype: array fputcsv ( resource $handle , array $fields [, string $delimiter [, string $enclosure]]] );
+ Description: Format line as CSV and write to the file pointer
+*/
+
+
+/* Testing fputcsv() to write to a file when the field has no CSV format */
+
+echo "*** Testing fputcsv() : with no CSV format in the field ***\n";
+
+/* the array is with three elements in it. Each element should be read as
+ 1st element is delimiter, 2nd element is enclosure
+ and 3rd element is csv fields
+*/
+
+$fields = array( array('water_fruit\n'),
+ array("water_fruit\n"),
+ array("")
+ );
+
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fputcsv_variation10.tmp";
+
+$file_modes = array ("r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+foreach ($fields as $field) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+
+ echo "\n-- file opened in $file_modes[$mode_counter] --\n";
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $file_handle = fopen($filename, "w");
+ } else {
+ $file_handle = fopen($filename, $file_modes[$mode_counter] );
+ }
+ if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+ }
+ $csv_field = $field;
+
+ // write to a file in csv format
+ var_dump( fputcsv($file_handle, $csv_field) );
+
+ // check the file pointer position and eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+ //close the file
+ fclose($file_handle);
+
+ // print the file contents
+ var_dump( file_get_contents($filename) );
+
+ //delete file
+ unlink($filename);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fputcsv() : with no CSV format in the field ***
+
+-- file opened in r+ --
+int(16)
+int(16)
+bool(false)
+string(16) ""water_fruit\n"
+"
+
+-- file opened in r+b --
+int(16)
+int(16)
+bool(false)
+string(16) ""water_fruit\n"
+"
+
+-- file opened in r+t --
+int(16)
+int(16)
+bool(false)
+string(%d) ""water_fruit\n"
+"
+
+-- file opened in a+ --
+int(16)
+int(16)
+bool(false)
+string(16) ""water_fruit\n"
+"
+
+-- file opened in a+b --
+int(16)
+int(16)
+bool(false)
+string(16) ""water_fruit\n"
+"
+
+-- file opened in a+t --
+int(16)
+int(16)
+bool(false)
+string(%d) ""water_fruit\n"
+"
+
+-- file opened in w+ --
+int(16)
+int(16)
+bool(false)
+string(16) ""water_fruit\n"
+"
+
+-- file opened in w+b --
+int(16)
+int(16)
+bool(false)
+string(16) ""water_fruit\n"
+"
+
+-- file opened in w+t --
+int(16)
+int(16)
+bool(false)
+string(%d) ""water_fruit\n"
+"
+
+-- file opened in x+ --
+int(16)
+int(16)
+bool(false)
+string(16) ""water_fruit\n"
+"
+
+-- file opened in x+b --
+int(16)
+int(16)
+bool(false)
+string(16) ""water_fruit\n"
+"
+
+-- file opened in x+t --
+int(16)
+int(16)
+bool(false)
+string(%d) ""water_fruit\n"
+"
+
+-- file opened in r+ --
+int(15)
+int(15)
+bool(false)
+string(15) ""water_fruit
+"
+"
+
+-- file opened in r+b --
+int(15)
+int(15)
+bool(false)
+string(15) ""water_fruit
+"
+"
+
+-- file opened in r+t --
+int(15)
+int(15)
+bool(false)
+string(%d) ""water_fruit
+"
+"
+
+-- file opened in a+ --
+int(15)
+int(15)
+bool(false)
+string(15) ""water_fruit
+"
+"
+
+-- file opened in a+b --
+int(15)
+int(15)
+bool(false)
+string(15) ""water_fruit
+"
+"
+
+-- file opened in a+t --
+int(15)
+int(15)
+bool(false)
+string(%d) ""water_fruit
+"
+"
+
+-- file opened in w+ --
+int(15)
+int(15)
+bool(false)
+string(15) ""water_fruit
+"
+"
+
+-- file opened in w+b --
+int(15)
+int(15)
+bool(false)
+string(15) ""water_fruit
+"
+"
+
+-- file opened in w+t --
+int(15)
+int(15)
+bool(false)
+string(%d) ""water_fruit
+"
+"
+
+-- file opened in x+ --
+int(15)
+int(15)
+bool(false)
+string(15) ""water_fruit
+"
+"
+
+-- file opened in x+b --
+int(15)
+int(15)
+bool(false)
+string(15) ""water_fruit
+"
+"
+
+-- file opened in x+t --
+int(15)
+int(15)
+bool(false)
+string(%d) ""water_fruit
+"
+"
+
+-- file opened in r+ --
+int(1)
+int(1)
+bool(false)
+string(1) "
+"
+
+-- file opened in r+b --
+int(1)
+int(1)
+bool(false)
+string(1) "
+"
+
+-- file opened in r+t --
+int(1)
+int(1)
+bool(false)
+string(%d) "
+"
+
+-- file opened in a+ --
+int(1)
+int(1)
+bool(false)
+string(1) "
+"
+
+-- file opened in a+b --
+int(1)
+int(1)
+bool(false)
+string(1) "
+"
+
+-- file opened in a+t --
+int(1)
+int(1)
+bool(false)
+string(%d) "
+"
+
+-- file opened in w+ --
+int(1)
+int(1)
+bool(false)
+string(1) "
+"
+
+-- file opened in w+b --
+int(1)
+int(1)
+bool(false)
+string(1) "
+"
+
+-- file opened in w+t --
+int(1)
+int(1)
+bool(false)
+string(%d) "
+"
+
+-- file opened in x+ --
+int(1)
+int(1)
+bool(false)
+string(1) "
+"
+
+-- file opened in x+b --
+int(1)
+int(1)
+bool(false)
+string(1) "
+"
+
+-- file opened in x+t --
+int(1)
+int(1)
+bool(false)
+string(%d) "
+"
+Done
+
diff --git a/ext/standard/tests/file/fputcsv_variation11.phpt b/ext/standard/tests/file/fputcsv_variation11.phpt
new file mode 100644
index 0000000..770b89b
--- /dev/null
+++ b/ext/standard/tests/file/fputcsv_variation11.phpt
@@ -0,0 +1,834 @@
+--TEST--
+Test fputcsv() : usage variations - with default enclosure value
+--FILE--
+<?php
+/*
+ Prototype: array fputcsv ( resource $handle , array $fields [, string $delimiter [, string $enclosure]]] );
+ Description: Format line as CSV and write to the file pointer
+*/
+
+/* Testing fputcsv() to write to a file when default enclosure value is provided */
+
+echo "*** Testing fputcsv() : with default enclosure value ***\n";
+
+/* the array is with three elements in it. Each element should be read as
+ 1st element is delimiter, 2nd element is enclosure
+ and 3rd element is csv fields
+*/
+$csv_lists = array (
+ array(',', '"', array('water,fruit') ),
+ array(',', '"', array('"water","fruit') ),
+ array(',', '"', array('"water","fruit"') ),
+ array(' ', '^', array('^water^ ^fruit^')),
+ array(':', '&', array('&water&:&fruit&')),
+ array('=', '=', array('=water===fruit=')),
+ array('-', '-', array('-water--fruit-air')),
+ array('-', '-', array('-water---fruit---air-')),
+ array(':', '&', array('&""""&:&"&:,:":&,&:,,,,'))
+
+);
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fputcsv_variation11.tmp";
+
+$file_modes = array ("r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+
+ echo "\n-- file opened in $file_modes[$mode_counter] --\n";
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $file_handle = fopen($filename, "w");
+ } else {
+ $file_handle = fopen($filename, $file_modes[$mode_counter] );
+ }
+ if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+ }
+ $delimiter = $csv_list[0];
+ $enclosure = $csv_list[1];
+ $csv_field = $csv_list[2];
+
+ // write to a file in csv format
+ var_dump( fputcsv($file_handle, $csv_field, $delimiter) );
+ // check the file pointer position and eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+ //close the file
+ fclose($file_handle);
+
+ // print the file contents
+ var_dump( file_get_contents($filename) );
+
+ //delete file
+ unlink($filename);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fputcsv() : with default enclosure value ***
+
+-- file opened in r+ --
+int(14)
+int(14)
+bool(false)
+string(14) ""water,fruit"
+"
+
+-- file opened in r+b --
+int(14)
+int(14)
+bool(false)
+string(14) ""water,fruit"
+"
+
+-- file opened in r+t --
+int(14)
+int(14)
+bool(false)
+string(%d) ""water,fruit"
+"
+
+-- file opened in a+ --
+int(14)
+int(14)
+bool(false)
+string(14) ""water,fruit"
+"
+
+-- file opened in a+b --
+int(14)
+int(14)
+bool(false)
+string(14) ""water,fruit"
+"
+
+-- file opened in a+t --
+int(14)
+int(14)
+bool(false)
+string(%d) ""water,fruit"
+"
+
+-- file opened in w+ --
+int(14)
+int(14)
+bool(false)
+string(14) ""water,fruit"
+"
+
+-- file opened in w+b --
+int(14)
+int(14)
+bool(false)
+string(14) ""water,fruit"
+"
+
+-- file opened in w+t --
+int(14)
+int(14)
+bool(false)
+string(%d) ""water,fruit"
+"
+
+-- file opened in x+ --
+int(14)
+int(14)
+bool(false)
+string(14) ""water,fruit"
+"
+
+-- file opened in x+b --
+int(14)
+int(14)
+bool(false)
+string(14) ""water,fruit"
+"
+
+-- file opened in x+t --
+int(14)
+int(14)
+bool(false)
+string(%d) ""water,fruit"
+"
+
+-- file opened in r+ --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in r+b --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in r+t --
+int(20)
+int(20)
+bool(false)
+string(%d) """"water"",""fruit"
+"
+
+-- file opened in a+ --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in a+b --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in a+t --
+int(20)
+int(20)
+bool(false)
+string(%d) """"water"",""fruit"
+"
+
+-- file opened in w+ --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in w+b --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in w+t --
+int(20)
+int(20)
+bool(false)
+string(%d) """"water"",""fruit"
+"
+
+-- file opened in x+ --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in x+b --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in x+t --
+int(20)
+int(20)
+bool(false)
+string(%d) """"water"",""fruit"
+"
+
+-- file opened in r+ --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in r+b --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in r+t --
+int(22)
+int(22)
+bool(false)
+string(%d) """"water"",""fruit"""
+"
+
+-- file opened in a+ --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in a+b --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in a+t --
+int(22)
+int(22)
+bool(false)
+string(%d) """"water"",""fruit"""
+"
+
+-- file opened in w+ --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in w+b --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in w+t --
+int(22)
+int(22)
+bool(false)
+string(%d) """"water"",""fruit"""
+"
+
+-- file opened in x+ --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in x+b --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in x+t --
+int(22)
+int(22)
+bool(false)
+string(%d) """"water"",""fruit"""
+"
+
+-- file opened in r+ --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in r+b --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in r+t --
+int(18)
+int(18)
+bool(false)
+string(%d) ""^water^ ^fruit^"
+"
+
+-- file opened in a+ --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in a+b --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in a+t --
+int(18)
+int(18)
+bool(false)
+string(%d) ""^water^ ^fruit^"
+"
+
+-- file opened in w+ --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in w+b --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in w+t --
+int(18)
+int(18)
+bool(false)
+string(%d) ""^water^ ^fruit^"
+"
+
+-- file opened in x+ --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in x+b --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in x+t --
+int(18)
+int(18)
+bool(false)
+string(%d) ""^water^ ^fruit^"
+"
+
+-- file opened in r+ --
+int(18)
+int(18)
+bool(false)
+string(18) ""&water&:&fruit&"
+"
+
+-- file opened in r+b --
+int(18)
+int(18)
+bool(false)
+string(18) ""&water&:&fruit&"
+"
+
+-- file opened in r+t --
+int(18)
+int(18)
+bool(false)
+string(%d) ""&water&:&fruit&"
+"
+
+-- file opened in a+ --
+int(18)
+int(18)
+bool(false)
+string(18) ""&water&:&fruit&"
+"
+
+-- file opened in a+b --
+int(18)
+int(18)
+bool(false)
+string(18) ""&water&:&fruit&"
+"
+
+-- file opened in a+t --
+int(18)
+int(18)
+bool(false)
+string(%d) ""&water&:&fruit&"
+"
+
+-- file opened in w+ --
+int(18)
+int(18)
+bool(false)
+string(18) ""&water&:&fruit&"
+"
+
+-- file opened in w+b --
+int(18)
+int(18)
+bool(false)
+string(18) ""&water&:&fruit&"
+"
+
+-- file opened in w+t --
+int(18)
+int(18)
+bool(false)
+string(%d) ""&water&:&fruit&"
+"
+
+-- file opened in x+ --
+int(18)
+int(18)
+bool(false)
+string(18) ""&water&:&fruit&"
+"
+
+-- file opened in x+b --
+int(18)
+int(18)
+bool(false)
+string(18) ""&water&:&fruit&"
+"
+
+-- file opened in x+t --
+int(18)
+int(18)
+bool(false)
+string(%d) ""&water&:&fruit&"
+"
+
+-- file opened in r+ --
+int(18)
+int(18)
+bool(false)
+string(18) ""=water===fruit="
+"
+
+-- file opened in r+b --
+int(18)
+int(18)
+bool(false)
+string(18) ""=water===fruit="
+"
+
+-- file opened in r+t --
+int(18)
+int(18)
+bool(false)
+string(%d) ""=water===fruit="
+"
+
+-- file opened in a+ --
+int(18)
+int(18)
+bool(false)
+string(18) ""=water===fruit="
+"
+
+-- file opened in a+b --
+int(18)
+int(18)
+bool(false)
+string(18) ""=water===fruit="
+"
+
+-- file opened in a+t --
+int(18)
+int(18)
+bool(false)
+string(%d) ""=water===fruit="
+"
+
+-- file opened in w+ --
+int(18)
+int(18)
+bool(false)
+string(18) ""=water===fruit="
+"
+
+-- file opened in w+b --
+int(18)
+int(18)
+bool(false)
+string(18) ""=water===fruit="
+"
+
+-- file opened in w+t --
+int(18)
+int(18)
+bool(false)
+string(%d) ""=water===fruit="
+"
+
+-- file opened in x+ --
+int(18)
+int(18)
+bool(false)
+string(18) ""=water===fruit="
+"
+
+-- file opened in x+b --
+int(18)
+int(18)
+bool(false)
+string(18) ""=water===fruit="
+"
+
+-- file opened in x+t --
+int(18)
+int(18)
+bool(false)
+string(%d) ""=water===fruit="
+"
+
+-- file opened in r+ --
+int(20)
+int(20)
+bool(false)
+string(20) ""-water--fruit-air"
+"
+
+-- file opened in r+b --
+int(20)
+int(20)
+bool(false)
+string(20) ""-water--fruit-air"
+"
+
+-- file opened in r+t --
+int(20)
+int(20)
+bool(false)
+string(%d) ""-water--fruit-air"
+"
+
+-- file opened in a+ --
+int(20)
+int(20)
+bool(false)
+string(20) ""-water--fruit-air"
+"
+
+-- file opened in a+b --
+int(20)
+int(20)
+bool(false)
+string(20) ""-water--fruit-air"
+"
+
+-- file opened in a+t --
+int(20)
+int(20)
+bool(false)
+string(%d) ""-water--fruit-air"
+"
+
+-- file opened in w+ --
+int(20)
+int(20)
+bool(false)
+string(20) ""-water--fruit-air"
+"
+
+-- file opened in w+b --
+int(20)
+int(20)
+bool(false)
+string(20) ""-water--fruit-air"
+"
+
+-- file opened in w+t --
+int(20)
+int(20)
+bool(false)
+string(%d) ""-water--fruit-air"
+"
+
+-- file opened in x+ --
+int(20)
+int(20)
+bool(false)
+string(20) ""-water--fruit-air"
+"
+
+-- file opened in x+b --
+int(20)
+int(20)
+bool(false)
+string(20) ""-water--fruit-air"
+"
+
+-- file opened in x+t --
+int(20)
+int(20)
+bool(false)
+string(%d) ""-water--fruit-air"
+"
+
+-- file opened in r+ --
+int(24)
+int(24)
+bool(false)
+string(24) ""-water---fruit---air-"
+"
+
+-- file opened in r+b --
+int(24)
+int(24)
+bool(false)
+string(24) ""-water---fruit---air-"
+"
+
+-- file opened in r+t --
+int(24)
+int(24)
+bool(false)
+string(%d) ""-water---fruit---air-"
+"
+
+-- file opened in a+ --
+int(24)
+int(24)
+bool(false)
+string(24) ""-water---fruit---air-"
+"
+
+-- file opened in a+b --
+int(24)
+int(24)
+bool(false)
+string(24) ""-water---fruit---air-"
+"
+
+-- file opened in a+t --
+int(24)
+int(24)
+bool(false)
+string(%d) ""-water---fruit---air-"
+"
+
+-- file opened in w+ --
+int(24)
+int(24)
+bool(false)
+string(24) ""-water---fruit---air-"
+"
+
+-- file opened in w+b --
+int(24)
+int(24)
+bool(false)
+string(24) ""-water---fruit---air-"
+"
+
+-- file opened in w+t --
+int(24)
+int(24)
+bool(false)
+string(%d) ""-water---fruit---air-"
+"
+
+-- file opened in x+ --
+int(24)
+int(24)
+bool(false)
+string(24) ""-water---fruit---air-"
+"
+
+-- file opened in x+b --
+int(24)
+int(24)
+bool(false)
+string(24) ""-water---fruit---air-"
+"
+
+-- file opened in x+t --
+int(24)
+int(24)
+bool(false)
+string(%d) ""-water---fruit---air-"
+"
+
+-- file opened in r+ --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in r+b --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in r+t --
+int(32)
+int(32)
+bool(false)
+string(%d) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in a+ --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in a+b --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in a+t --
+int(32)
+int(32)
+bool(false)
+string(%d) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in w+ --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in w+b --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in w+t --
+int(32)
+int(32)
+bool(false)
+string(%d) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in x+ --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in x+b --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in x+t --
+int(32)
+int(32)
+bool(false)
+string(%d) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+Done
+
diff --git a/ext/standard/tests/file/fputcsv_variation12.phpt b/ext/standard/tests/file/fputcsv_variation12.phpt
new file mode 100644
index 0000000..24fe5c4
--- /dev/null
+++ b/ext/standard/tests/file/fputcsv_variation12.phpt
@@ -0,0 +1,835 @@
+--TEST--
+Test fputcsv() : usage variations - with default enclosure and different delimiter
+--FILE--
+<?php
+/*
+ Prototype: array fputcsv ( resource $handle , array $fields [, string $delimiter [, string $enclosure]]] );
+ Description: Format line as CSV and write to the file pointer
+*/
+
+/* Testing fputcsv() to write to a file when default enclosure value and delimiter value
+ other than that in the field is provided */
+
+echo "*** Testing fputcsv() : with default enclosure and different delimiter value ***\n";
+
+/* the array is with three elements in it. Each element should be read as
+ 1st element is delimiter, 2nd element is enclosure
+ and 3rd element is csv fields
+*/
+$csv_lists = array (
+ array(',', '"', array('water,fruit') ),
+ array(',', '"', array('"water","fruit') ),
+ array(',', '"', array('"water","fruit"') ),
+ array(' ', '^', array('^water^ ^fruit^')),
+ array(':', '&', array('&water&:&fruit&')),
+ array('=', '=', array('=water===fruit=')),
+ array('-', '-', array('-water--fruit-air')),
+ array('-', '-', array('-water---fruit---air-')),
+ array(':', '&', array('&""""&:&"&:,:":&,&:,,,,'))
+
+);
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fputcsv_variation12.tmp";
+
+$file_modes = array ("r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+
+ echo "\n-- file opened in $file_modes[$mode_counter] --\n";
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $file_handle = fopen($filename, "w");
+ } else {
+ $file_handle = fopen($filename, $file_modes[$mode_counter] );
+ }
+ if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+ }
+ $delimiter = $csv_list[0];
+ $enclosure = $csv_list[1];
+ $csv_field = $csv_list[2];
+
+ // write to a file in csv format
+ var_dump( fputcsv($file_handle, $csv_field, '+') );
+ // check the file pointer position and eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+ //close the file
+ fclose($file_handle);
+
+ // print the file contents
+ var_dump( file_get_contents($filename) );
+
+ //delete file
+ unlink($filename);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fputcsv() : with default enclosure and different delimiter value ***
+
+-- file opened in r+ --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in r+b --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in r+t --
+int(12)
+int(12)
+bool(false)
+string(%d) "water,fruit
+"
+
+-- file opened in a+ --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in a+b --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in a+t --
+int(12)
+int(12)
+bool(false)
+string(%d) "water,fruit
+"
+
+-- file opened in w+ --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in w+b --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in w+t --
+int(12)
+int(12)
+bool(false)
+string(%d) "water,fruit
+"
+
+-- file opened in x+ --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in x+b --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in x+t --
+int(12)
+int(12)
+bool(false)
+string(%d) "water,fruit
+"
+
+-- file opened in r+ --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in r+b --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in r+t --
+int(20)
+int(20)
+bool(false)
+string(%d) """"water"",""fruit"
+"
+
+-- file opened in a+ --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in a+b --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in a+t --
+int(20)
+int(20)
+bool(false)
+string(%d) """"water"",""fruit"
+"
+
+-- file opened in w+ --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in w+b --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in w+t --
+int(20)
+int(20)
+bool(false)
+string(%d) """"water"",""fruit"
+"
+
+-- file opened in x+ --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in x+b --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in x+t --
+int(20)
+int(20)
+bool(false)
+string(%d) """"water"",""fruit"
+"
+
+-- file opened in r+ --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in r+b --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in r+t --
+int(22)
+int(22)
+bool(false)
+string(%d) """"water"",""fruit"""
+"
+
+-- file opened in a+ --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in a+b --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in a+t --
+int(22)
+int(22)
+bool(false)
+string(%d) """"water"",""fruit"""
+"
+
+-- file opened in w+ --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in w+b --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in w+t --
+int(22)
+int(22)
+bool(false)
+string(%d) """"water"",""fruit"""
+"
+
+-- file opened in x+ --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in x+b --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in x+t --
+int(22)
+int(22)
+bool(false)
+string(%d) """"water"",""fruit"""
+"
+
+-- file opened in r+ --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in r+b --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in r+t --
+int(18)
+int(18)
+bool(false)
+string(%d) ""^water^ ^fruit^"
+"
+
+-- file opened in a+ --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in a+b --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in a+t --
+int(18)
+int(18)
+bool(false)
+string(%d) ""^water^ ^fruit^"
+"
+
+-- file opened in w+ --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in w+b --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in w+t --
+int(18)
+int(18)
+bool(false)
+string(%d) ""^water^ ^fruit^"
+"
+
+-- file opened in x+ --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in x+b --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in x+t --
+int(18)
+int(18)
+bool(false)
+string(%d) ""^water^ ^fruit^"
+"
+
+-- file opened in r+ --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in r+b --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in r+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "&water&:&fruit&
+"
+
+-- file opened in a+ --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in a+b --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in a+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "&water&:&fruit&
+"
+
+-- file opened in w+ --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in w+b --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in w+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "&water&:&fruit&
+"
+
+-- file opened in x+ --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in x+b --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in x+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "&water&:&fruit&
+"
+
+-- file opened in r+ --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in r+b --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in r+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "=water===fruit=
+"
+
+-- file opened in a+ --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in a+b --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in a+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "=water===fruit=
+"
+
+-- file opened in w+ --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in w+b --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in w+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "=water===fruit=
+"
+
+-- file opened in x+ --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in x+b --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in x+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "=water===fruit=
+"
+
+-- file opened in r+ --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in r+b --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in r+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "-water--fruit-air
+"
+
+-- file opened in a+ --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in a+b --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in a+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "-water--fruit-air
+"
+
+-- file opened in w+ --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in w+b --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in w+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "-water--fruit-air
+"
+
+-- file opened in x+ --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in x+b --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in x+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "-water--fruit-air
+"
+
+-- file opened in r+ --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in r+b --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in r+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "-water---fruit---air-
+"
+
+-- file opened in a+ --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in a+b --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in a+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "-water---fruit---air-
+"
+
+-- file opened in w+ --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in w+b --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in w+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "-water---fruit---air-
+"
+
+-- file opened in x+ --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in x+b --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in x+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "-water---fruit---air-
+"
+
+-- file opened in r+ --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in r+b --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in r+t --
+int(32)
+int(32)
+bool(false)
+string(%d) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in a+ --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in a+b --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in a+t --
+int(32)
+int(32)
+bool(false)
+string(%d) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in w+ --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in w+b --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in w+t --
+int(32)
+int(32)
+bool(false)
+string(%d) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in x+ --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in x+b --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in x+t --
+int(32)
+int(32)
+bool(false)
+string(%d) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+Done
+
diff --git a/ext/standard/tests/file/fputcsv_variation13.phpt b/ext/standard/tests/file/fputcsv_variation13.phpt
new file mode 100644
index 0000000..a8a350b
--- /dev/null
+++ b/ext/standard/tests/file/fputcsv_variation13.phpt
@@ -0,0 +1,1051 @@
+--TEST--
+Test fputcsv() : usage variations - with default enclosure & delimiter of two chars
+--FILE--
+<?php
+/*
+ Prototype: array fputcsv ( resource $handle , array $fields [, string $delimiter [, string $enclosure]]] );
+ Description: Format line as CSV and write to the file pointer
+*/
+
+/* Testing fputcsv() to write to a file when default enclosure value and delimiter
+ of two chars is provided */
+
+echo "*** Testing fputcsv() : with default enclosure & delimiter of two chars ***\n";
+
+/* the array is with three elements in it. Each element should be read as
+ 1st element is delimiter, 2nd element is enclosure
+ and 3rd element is csv fields
+*/
+$csv_lists = array (
+ array(',', '"', array('water,fruit') ),
+ array(',', '"', array('"water","fruit') ),
+ array(',', '"', array('"water","fruit"') ),
+ array(' ', '^', array('^water^ ^fruit^')),
+ array(':', '&', array('&water&:&fruit&')),
+ array('=', '=', array('=water===fruit=')),
+ array('-', '-', array('-water--fruit-air')),
+ array('-', '-', array('-water---fruit---air-')),
+ array(':', '&', array('&""""&:&"&:,:":&,&:,,,,'))
+
+);
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fputcsv_variation13.tmp";
+
+$file_modes = array ("r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+
+ echo "\n-- file opened in $file_modes[$mode_counter] --\n";
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $file_handle = fopen($filename, "w");
+ } else {
+ $file_handle = fopen($filename, $file_modes[$mode_counter] );
+ }
+ if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+ }
+ $delimiter = $csv_list[0];
+ $enclosure = $csv_list[1];
+ $csv_field = $csv_list[2];
+
+ // write to a file in csv format
+ var_dump( fputcsv($file_handle, $csv_field, '++') );
+ // check the file pointer position and eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+ //close the file
+ fclose($file_handle);
+
+ // print the file contents
+ var_dump( file_get_contents($filename) );
+
+ //delete file
+ unlink($filename);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fputcsv() : with default enclosure & delimiter of two chars ***
+
+-- file opened in r+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in r+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in r+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(12)
+int(12)
+bool(false)
+string(%d) "water,fruit
+"
+
+-- file opened in a+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in a+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in a+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(12)
+int(12)
+bool(false)
+string(%d) "water,fruit
+"
+
+-- file opened in w+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in w+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in w+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(12)
+int(12)
+bool(false)
+string(%d) "water,fruit
+"
+
+-- file opened in x+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in x+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in x+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(12)
+int(12)
+bool(false)
+string(%d) "water,fruit
+"
+
+-- file opened in r+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in r+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in r+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(20)
+int(20)
+bool(false)
+string(%d) """"water"",""fruit"
+"
+
+-- file opened in a+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in a+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in a+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(20)
+int(20)
+bool(false)
+string(%d) """"water"",""fruit"
+"
+
+-- file opened in w+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in w+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in w+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(20)
+int(20)
+bool(false)
+string(%d) """"water"",""fruit"
+"
+
+-- file opened in x+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in x+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in x+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(20)
+int(20)
+bool(false)
+string(%d) """"water"",""fruit"
+"
+
+-- file opened in r+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in r+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in r+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(22)
+int(22)
+bool(false)
+string(%d) """"water"",""fruit"""
+"
+
+-- file opened in a+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in a+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in a+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(22)
+int(22)
+bool(false)
+string(%d) """"water"",""fruit"""
+"
+
+-- file opened in w+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in w+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in w+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(22)
+int(22)
+bool(false)
+string(%d) """"water"",""fruit"""
+"
+
+-- file opened in x+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in x+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in x+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(22)
+int(22)
+bool(false)
+string(%d) """"water"",""fruit"""
+"
+
+-- file opened in r+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in r+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in r+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(%d) ""^water^ ^fruit^"
+"
+
+-- file opened in a+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in a+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in a+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(%d) ""^water^ ^fruit^"
+"
+
+-- file opened in w+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in w+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in w+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(%d) ""^water^ ^fruit^"
+"
+
+-- file opened in x+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in x+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in x+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(%d) ""^water^ ^fruit^"
+"
+
+-- file opened in r+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in r+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in r+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(%d) "&water&:&fruit&
+"
+
+-- file opened in a+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in a+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in a+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(%d) "&water&:&fruit&
+"
+
+-- file opened in w+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in w+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in w+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(%d) "&water&:&fruit&
+"
+
+-- file opened in x+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in x+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in x+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(%d) "&water&:&fruit&
+"
+
+-- file opened in r+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in r+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in r+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(%d) "=water===fruit=
+"
+
+-- file opened in a+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in a+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in a+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(%d) "=water===fruit=
+"
+
+-- file opened in w+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in w+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in w+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(%d) "=water===fruit=
+"
+
+-- file opened in x+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in x+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in x+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(%d) "=water===fruit=
+"
+
+-- file opened in r+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in r+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in r+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(%d) "-water--fruit-air
+"
+
+-- file opened in a+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in a+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in a+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(%d) "-water--fruit-air
+"
+
+-- file opened in w+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in w+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in w+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(%d) "-water--fruit-air
+"
+
+-- file opened in x+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in x+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in x+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(%d) "-water--fruit-air
+"
+
+-- file opened in r+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in r+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in r+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(22)
+int(22)
+bool(false)
+string(%d) "-water---fruit---air-
+"
+
+-- file opened in a+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in a+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in a+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(22)
+int(22)
+bool(false)
+string(%d) "-water---fruit---air-
+"
+
+-- file opened in w+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in w+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in w+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(22)
+int(22)
+bool(false)
+string(%d) "-water---fruit---air-
+"
+
+-- file opened in x+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in x+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in x+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(22)
+int(22)
+bool(false)
+string(%d) "-water---fruit---air-
+"
+
+-- file opened in r+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in r+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in r+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(32)
+int(32)
+bool(false)
+string(%d) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in a+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in a+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in a+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(32)
+int(32)
+bool(false)
+string(%d) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in w+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in w+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in w+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(32)
+int(32)
+bool(false)
+string(%d) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in x+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in x+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in x+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+int(32)
+int(32)
+bool(false)
+string(%d) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+Done
+
diff --git a/ext/standard/tests/file/fputcsv_variation14.phpt b/ext/standard/tests/file/fputcsv_variation14.phpt
new file mode 100644
index 0000000..36a4975
--- /dev/null
+++ b/ext/standard/tests/file/fputcsv_variation14.phpt
@@ -0,0 +1,357 @@
+--TEST--
+Test fputcsv() : usage variations - with enclosure & delimiter of two chars(read only modes)
+--FILE--
+<?php
+/*
+ Prototype: array fputcsv ( resource $handle , array $fields [, string $delimiter [, string $enclosure]]] );
+ Description: Format line as CSV and write to the file pointer
+*/
+
+/* Testing fputcsv() to write to a file when default enclosure value and delimiter
+ of two chars is provided and file is opened in read only mode */
+
+echo "*** Testing fputcsv() : with enclosure & delimiter of two chars and file opened in read mode ***\n";
+
+/* the array is with three elements in it. Each element should be read as
+ 1st element is delimiter, 2nd element is enclosure
+ and 3rd element is csv fields
+*/
+$csv_lists = array (
+ array(',', '"', array('water,fruit') ),
+ array(',', '"', array('"water","fruit') ),
+ array(',', '"', array('"water","fruit"') ),
+ array(' ', '^', array('^water^ ^fruit^')),
+ array(':', '&', array('&water&:&fruit&')),
+ array('=', '=', array('=water===fruit=')),
+ array('-', '-', array('-water--fruit-air')),
+ array('-', '-', array('-water---fruit---air-')),
+ array(':', '&', array('&""""&:&"&:,:":&,&:,,,,'))
+
+);
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fputcsv_variation14.tmp";
+
+$file_modes = array ("r", "rb", "rt");
+
+// create the file
+$file_handle = fopen($filename, "w" );
+if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+}
+fclose($file_handle);
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ // create the file
+ $file_handle = fopen($filename, "w" );
+ if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+ }
+ fclose($file_handle);
+
+ echo "\n-- file opened in $file_modes[$mode_counter] --\n";
+ // add the content with has csv fields
+ $file_handle = fopen($filename, $file_modes[$mode_counter] );
+ if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+ }
+ $delimiter = $csv_list[0];
+ $enclosure = $csv_list[1];
+ $csv_field = $csv_list[2];
+
+ // write to a file in csv format
+ var_dump( fputcsv($file_handle, $csv_field, '++', '%%') );
+ // check the file pointer position and eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+ //close the file
+ fclose($file_handle);
+
+ // print the file contents
+ var_dump( file_get_contents($filename) );
+
+ //delete file
+ unlink($filename);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fputcsv() : with enclosure & delimiter of two chars and file opened in read mode ***
+
+-- file opened in r --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(0)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in rb --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(0)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in rt --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(0)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(0)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in rb --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(0)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in rt --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(0)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(0)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in rb --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(0)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in rt --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(0)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(0)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in rb --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(0)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in rt --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(0)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(0)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in rb --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(0)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in rt --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(0)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(0)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in rb --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(0)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in rt --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(0)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(0)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in rb --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(0)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in rt --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(0)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(0)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in rb --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(0)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in rt --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(0)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(0)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in rb --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(0)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in rt --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(0)
+int(0)
+bool(false)
+string(0) ""
+Done
+
diff --git a/ext/standard/tests/file/fputcsv_variation2.phpt b/ext/standard/tests/file/fputcsv_variation2.phpt
new file mode 100644
index 0000000..3ec4e91
--- /dev/null
+++ b/ext/standard/tests/file/fputcsv_variation2.phpt
@@ -0,0 +1,942 @@
+--TEST--
+Test fputcsv() : usage variations - with delimiter as NULL
+--FILE--
+<?php
+/*
+ Prototype: array fputcsv ( resource $handle , array $fields [, string $delimiter [, string $enclosure]]] );
+ Description: Format line as CSV and write to the file pointer
+*/
+
+/* Testing fputcsv() to write to a file when delimiter is NULL */
+
+echo "*** Testing fputcsv() : with delimiter as NULL ***\n";
+
+/* the array is with three elements in it. Each element should be read as
+ 1st element is delimiter, 2nd element is enclosure
+ and 3rd element is csv fields
+*/
+$csv_lists = array (
+ array(',', '"', array('water','fruit') ),
+ array(',', '"', array('"water","fruit') ),
+ array(',', '"', array('"water","fruit"') ),
+ array(' ', '^', array('^water^ ^fruit^')),
+ array(':', '&', array('&water&:&fruit&')),
+ array('=', '=', array('=water===fruit=')),
+ array('-', '-', array('-water--fruit-air')),
+ array('-', '-', array('-water---fruit---air-')),
+ array(':', '&', array('&""""&:&"&:,:":&,&:,,,,'))
+
+);
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fputcsv_variation2.tmp";
+
+$file_modes = array ("r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+
+ echo "\n-- file opened in $file_modes[$mode_counter] --\n";
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $file_handle = fopen($filename, "w");
+ } else {
+ $file_handle = fopen($filename, $file_modes[$mode_counter] );
+ }
+ if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+ }
+ $delimiter = $csv_list[0];
+ $enclosure = $csv_list[1];
+ $csv_field = $csv_list[2];
+
+ // write to a file in csv format
+ var_dump( fputcsv($file_handle, $csv_field, NULL, $enclosure) );
+ // check the file pointer position and eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+ //close the file
+ fclose($file_handle);
+
+ // print the file contents
+ var_dump( file_get_contents($filename) );
+
+ //delete file
+ unlink($filename);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fputcsv() : with delimiter as NULL ***
+
+-- file opened in r+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+Done
+
diff --git a/ext/standard/tests/file/fputcsv_variation3.phpt b/ext/standard/tests/file/fputcsv_variation3.phpt
new file mode 100644
index 0000000..14a2503
--- /dev/null
+++ b/ext/standard/tests/file/fputcsv_variation3.phpt
@@ -0,0 +1,942 @@
+--TEST--
+Test fputcsv() : usage variations - with enclosure as NULL
+--FILE--
+<?php
+/*
+ Prototype: array fputcsv ( resource $handle , array $fields [, string $delimiter [, string $enclosure]]] );
+ Description: Format line as CSV and write to the file pointer
+*/
+
+/* Testing fputcsv() to write to a file when enclosure is NULL */
+
+echo "*** Testing fputcsv() : with enclosure as NULL ***\n";
+
+/* the array is with three elements in it. Each element should be read as
+ 1st element is delimiter, 2nd element is enclosure
+ and 3rd element is csv fields
+*/
+$csv_lists = array (
+ array(',', '"', array('water','fruit') ),
+ array(',', '"', array('"water","fruit') ),
+ array(',', '"', array('"water","fruit"') ),
+ array(' ', '^', array('^water^ ^fruit^')),
+ array(':', '&', array('&water&:&fruit&')),
+ array('=', '=', array('=water===fruit=')),
+ array('-', '-', array('-water--fruit-air')),
+ array('-', '-', array('-water---fruit---air-')),
+ array(':', '&', array('&""""&:&"&:,:":&,&:,,,,'))
+
+);
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fputcsv_variation3.tmp";
+
+$file_modes = array ("r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+
+ echo "\n-- file opened in $file_modes[$mode_counter] --\n";
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $file_handle = fopen($filename, "w");
+ } else {
+ $file_handle = fopen($filename, $file_modes[$mode_counter] );
+ }
+ if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+ }
+ $delimiter = $csv_list[0];
+ $enclosure = $csv_list[1];
+ $csv_field = $csv_list[2];
+
+ // write to a file in csv format
+ var_dump( fputcsv($file_handle, $csv_field, $delimiter, NULL) );
+ // check the file pointer position and eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+ //close the file
+ fclose($file_handle);
+
+ // print the file contents
+ var_dump( file_get_contents($filename) );
+
+ //delete file
+ unlink($filename);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fputcsv() : with enclosure as NULL ***
+
+-- file opened in r+ --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+b --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+t --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+ --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+b --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+t --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+ --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+b --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+t --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+ --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+b --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+t --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+ --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+b --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+t --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+ --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+b --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+t --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+ --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+b --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+t --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+ --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+b --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+t --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+ --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+b --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+t --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+ --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+b --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+t --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+ --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+b --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+t --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+ --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+b --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+t --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+ --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+b --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+t --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+ --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+b --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+t --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+ --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+b --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+t --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+ --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+b --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+t --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+ --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+b --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+t --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+ --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+b --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+t --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+ --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+b --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+t --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+ --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+b --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+t --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+ --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+b --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+t --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+ --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+b --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+t --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+ --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+b --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+t --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+ --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+b --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+t --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+ --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+b --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+t --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+ --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+b --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+t --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+ --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+b --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+t --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+ --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+b --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+t --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+ --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+b --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+t --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+ --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+b --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+t --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+ --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+b --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+t --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+ --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+b --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+t --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+ --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+b --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+t --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+ --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+b --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+t --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+ --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+b --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+t --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+ --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+b --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+t --
+
+Warning: fputcsv(): enclosure must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+Done
+
diff --git a/ext/standard/tests/file/fputcsv_variation4.phpt b/ext/standard/tests/file/fputcsv_variation4.phpt
new file mode 100644
index 0000000..bc374ad
--- /dev/null
+++ b/ext/standard/tests/file/fputcsv_variation4.phpt
@@ -0,0 +1,942 @@
+--TEST--
+Test fputcsv() : usage variations - with delimiter and enclosure as NULL
+--FILE--
+<?php
+/*
+ Prototype: array fputcsv ( resource $handle , array $fields [, string $delimiter [, string $enclosure]]] );
+ Description: Format line as CSV and write to the file pointer
+*/
+
+/* Testing fputcsv() to write to a file when delimiter and enclosure is NULL */
+
+echo "*** Testing fputcsv() : with delimiter and enclosure as NULL ***\n";
+
+/* the array is with three elements in it. Each element should be read as
+ 1st element is delimiter, 2nd element is enclosure
+ and 3rd element is csv fields
+*/
+$csv_lists = array (
+ array(',', '"', array('water','fruit') ),
+ array(',', '"', array('"water","fruit') ),
+ array(',', '"', array('"water","fruit"') ),
+ array(' ', '^', array('^water^ ^fruit^')),
+ array(':', '&', array('&water&:&fruit&')),
+ array('=', '=', array('=water===fruit=')),
+ array('-', '-', array('-water--fruit-air')),
+ array('-', '-', array('-water---fruit---air-')),
+ array(':', '&', array('&""""&:&"&:,:":&,&:,,,,'))
+
+);
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fputcsv_variation4.tmp";
+
+$file_modes = array ("r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+
+ echo "\n-- file opened in $file_modes[$mode_counter] --\n";
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $file_handle = fopen($filename, "w");
+ } else {
+ $file_handle = fopen($filename, $file_modes[$mode_counter] );
+ }
+ if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+ }
+ $delimiter = $csv_list[0];
+ $enclosure = $csv_list[1];
+ $csv_field = $csv_list[2];
+
+ // write to a file in csv format
+ var_dump( fputcsv($file_handle, $csv_field, NULL, NULL) );
+ // check the file pointer position and eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+ //close the file
+ fclose($file_handle);
+
+ // print the file contents
+ var_dump( file_get_contents($filename) );
+
+ //delete file
+ unlink($filename);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fputcsv() : with delimiter and enclosure as NULL ***
+
+-- file opened in r+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in r+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in a+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in w+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+ --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+b --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+
+-- file opened in x+t --
+
+Warning: fputcsv(): delimiter must be a character in %s on line %d
+bool(false)
+int(0)
+bool(false)
+string(0) ""
+Done
+
diff --git a/ext/standard/tests/file/fputcsv_variation5.phpt b/ext/standard/tests/file/fputcsv_variation5.phpt
new file mode 100644
index 0000000..9d78854
--- /dev/null
+++ b/ext/standard/tests/file/fputcsv_variation5.phpt
@@ -0,0 +1,834 @@
+--TEST--
+Test fputcsv() : usage variations - with default arguments value
+--FILE--
+<?php
+/*
+ Prototype: array fputcsv ( resource $handle , array $fields [, string $delimiter [, string $enclosure]]] );
+ Description: Format line as CSV and write to the file pointer
+*/
+
+/* Testing fputcsv() to write to a file when default arguments values are considered */
+
+echo "*** Testing fputcsv() : with default arguments value ***\n";
+
+/* the array is with three elements in it. Each element should be read as
+ 1st element is delimiter, 2nd element is enclosure
+ and 3rd element is csv fields
+*/
+$csv_lists = array (
+ array(',', '"', array('water','fruit') ),
+ array(',', '"', array('"water","fruit') ),
+ array(',', '"', array('"water","fruit"') ),
+ array(' ', '^', array('^water^ ^fruit^')),
+ array(':', '&', array('&water&:&fruit&')),
+ array('=', '=', array('=water===fruit=')),
+ array('-', '-', array('-water--fruit-air')),
+ array('-', '-', array('-water---fruit---air-')),
+ array(':', '&', array('&""""&:&"&:,:":&,&:,,,,'))
+
+);
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fputcsv_variation5.tmp";
+
+$file_modes = array ("r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+
+ echo "\n-- file opened in $file_modes[$mode_counter] --\n";
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $file_handle = fopen($filename, "w");
+ } else {
+ $file_handle = fopen($filename, $file_modes[$mode_counter] );
+ }
+ if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+ }
+ $delimiter = $csv_list[0];
+ $enclosure = $csv_list[1];
+ $csv_field = $csv_list[2];
+
+ // write to a file in csv format
+ var_dump( fputcsv($file_handle, $csv_field) );
+ // check the file pointer position and eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+ //close the file
+ fclose($file_handle);
+
+ // print the file contents
+ var_dump( file_get_contents($filename) );
+
+ //delete file
+ unlink($filename);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fputcsv() : with default arguments value ***
+
+-- file opened in r+ --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in r+b --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in r+t --
+int(12)
+int(12)
+bool(false)
+string(%d) "water,fruit
+"
+
+-- file opened in a+ --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in a+b --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in a+t --
+int(12)
+int(12)
+bool(false)
+string(%d) "water,fruit
+"
+
+-- file opened in w+ --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in w+b --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in w+t --
+int(12)
+int(12)
+bool(false)
+string(%d) "water,fruit
+"
+
+-- file opened in x+ --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in x+b --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in x+t --
+int(12)
+int(12)
+bool(false)
+string(%d) "water,fruit
+"
+
+-- file opened in r+ --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in r+b --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in r+t --
+int(20)
+int(20)
+bool(false)
+string(%d) """"water"",""fruit"
+"
+
+-- file opened in a+ --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in a+b --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in a+t --
+int(20)
+int(20)
+bool(false)
+string(%d) """"water"",""fruit"
+"
+
+-- file opened in w+ --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in w+b --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in w+t --
+int(20)
+int(20)
+bool(false)
+string(%d) """"water"",""fruit"
+"
+
+-- file opened in x+ --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in x+b --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in x+t --
+int(20)
+int(20)
+bool(false)
+string(%d) """"water"",""fruit"
+"
+
+-- file opened in r+ --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in r+b --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in r+t --
+int(22)
+int(22)
+bool(false)
+string(%d) """"water"",""fruit"""
+"
+
+-- file opened in a+ --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in a+b --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in a+t --
+int(22)
+int(22)
+bool(false)
+string(%d) """"water"",""fruit"""
+"
+
+-- file opened in w+ --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in w+b --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in w+t --
+int(22)
+int(22)
+bool(false)
+string(%d) """"water"",""fruit"""
+"
+
+-- file opened in x+ --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in x+b --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in x+t --
+int(22)
+int(22)
+bool(false)
+string(%d) """"water"",""fruit"""
+"
+
+-- file opened in r+ --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in r+b --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in r+t --
+int(18)
+int(18)
+bool(false)
+string(%d) ""^water^ ^fruit^"
+"
+
+-- file opened in a+ --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in a+b --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in a+t --
+int(18)
+int(18)
+bool(false)
+string(%d) ""^water^ ^fruit^"
+"
+
+-- file opened in w+ --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in w+b --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in w+t --
+int(18)
+int(18)
+bool(false)
+string(%d) ""^water^ ^fruit^"
+"
+
+-- file opened in x+ --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in x+b --
+int(18)
+int(18)
+bool(false)
+string(18) ""^water^ ^fruit^"
+"
+
+-- file opened in x+t --
+int(18)
+int(18)
+bool(false)
+string(%d) ""^water^ ^fruit^"
+"
+
+-- file opened in r+ --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in r+b --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in r+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "&water&:&fruit&
+"
+
+-- file opened in a+ --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in a+b --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in a+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "&water&:&fruit&
+"
+
+-- file opened in w+ --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in w+b --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in w+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "&water&:&fruit&
+"
+
+-- file opened in x+ --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in x+b --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in x+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "&water&:&fruit&
+"
+
+-- file opened in r+ --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in r+b --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in r+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "=water===fruit=
+"
+
+-- file opened in a+ --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in a+b --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in a+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "=water===fruit=
+"
+
+-- file opened in w+ --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in w+b --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in w+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "=water===fruit=
+"
+
+-- file opened in x+ --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in x+b --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in x+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "=water===fruit=
+"
+
+-- file opened in r+ --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in r+b --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in r+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "-water--fruit-air
+"
+
+-- file opened in a+ --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in a+b --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in a+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "-water--fruit-air
+"
+
+-- file opened in w+ --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in w+b --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in w+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "-water--fruit-air
+"
+
+-- file opened in x+ --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in x+b --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in x+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "-water--fruit-air
+"
+
+-- file opened in r+ --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in r+b --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in r+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "-water---fruit---air-
+"
+
+-- file opened in a+ --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in a+b --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in a+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "-water---fruit---air-
+"
+
+-- file opened in w+ --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in w+b --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in w+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "-water---fruit---air-
+"
+
+-- file opened in x+ --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in x+b --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in x+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "-water---fruit---air-
+"
+
+-- file opened in r+ --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in r+b --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in r+t --
+int(32)
+int(32)
+bool(false)
+string(%d) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in a+ --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in a+b --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in a+t --
+int(32)
+int(32)
+bool(false)
+string(%d) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in w+ --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in w+b --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in w+t --
+int(32)
+int(32)
+bool(false)
+string(%d) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in x+ --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in x+b --
+int(32)
+int(32)
+bool(false)
+string(32) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+
+-- file opened in x+t --
+int(32)
+int(32)
+bool(false)
+string(%d) ""&""""""""&:&""&:,:"":&,&:,,,,"
+"
+Done
+
diff --git a/ext/standard/tests/file/fputcsv_variation6.phpt b/ext/standard/tests/file/fputcsv_variation6.phpt
new file mode 100644
index 0000000..f30ce24
--- /dev/null
+++ b/ext/standard/tests/file/fputcsv_variation6.phpt
@@ -0,0 +1,837 @@
+--TEST--
+Test fputcsv() : usage variations - with different delimiter and enclosure
+--FILE--
+<?php
+/*
+ Prototype: array fputcsv ( resource $handle , array $fields [, string $delimiter [, string $enclosure]]] );
+ Description: Format line as CSV and write to the file pointer
+*/
+
+/*
+ Testing fputcsv() to write to a file when delimiter are different from those
+ present in the field to be written to the file
+ */
+
+echo "*** Testing fputcsv() : with different delimiter and enclosure ***\n";
+
+/* the array is with three elements in it. Each element should be read as
+ 1st element is delimiter, 2nd element is enclosure
+ and 3rd element is csv fields
+*/
+$csv_lists = array (
+ array(',', '"', array('water,fruit') ),
+ array(',', '"', array('"water","fruit') ),
+ array(',', '"', array('"water","fruit"') ),
+ array(' ', '^', array('^water^ ^fruit^')),
+ array(':', '&', array('&water&:&fruit&')),
+ array('=', '=', array('=water===fruit=')),
+ array('-', '-', array('-water--fruit-air')),
+ array('-', '-', array('-water---fruit---air-')),
+ array(':', '&', array('&""""&:&"&:,:":&,&:,,,,'))
+
+);
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fputcsv_variation6.tmp";
+
+$file_modes = array ("r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+
+ echo "\n-- file opened in $file_modes[$mode_counter] --\n";
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $file_handle = fopen($filename, "w");
+ } else {
+ $file_handle = fopen($filename, $file_modes[$mode_counter] );
+ }
+ if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+ }
+ $delimiter = $csv_list[0];
+ $enclosure = $csv_list[1];
+ $csv_field = $csv_list[2];
+
+ // write to a file in csv format
+ var_dump( fputcsv($file_handle, $csv_field, '+', '%') );
+ // check the file pointer position and eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+ //close the file
+ fclose($file_handle);
+
+ // print the file contents
+ var_dump( file_get_contents($filename) );
+
+ //delete file
+ unlink($filename);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fputcsv() : with different delimiter and enclosure ***
+
+-- file opened in r+ --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in r+b --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in r+t --
+int(12)
+int(12)
+bool(false)
+string(%d) "water,fruit
+"
+
+-- file opened in a+ --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in a+b --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in a+t --
+int(12)
+int(12)
+bool(false)
+string(%d) "water,fruit
+"
+
+-- file opened in w+ --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in w+b --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in w+t --
+int(12)
+int(12)
+bool(false)
+string(%d) "water,fruit
+"
+
+-- file opened in x+ --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in x+b --
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in x+t --
+int(12)
+int(12)
+bool(false)
+string(%d) "water,fruit
+"
+
+-- file opened in r+ --
+int(15)
+int(15)
+bool(false)
+string(15) ""water","fruit
+"
+
+-- file opened in r+b --
+int(15)
+int(15)
+bool(false)
+string(15) ""water","fruit
+"
+
+-- file opened in r+t --
+int(15)
+int(15)
+bool(false)
+string(%d) ""water","fruit
+"
+
+-- file opened in a+ --
+int(15)
+int(15)
+bool(false)
+string(15) ""water","fruit
+"
+
+-- file opened in a+b --
+int(15)
+int(15)
+bool(false)
+string(15) ""water","fruit
+"
+
+-- file opened in a+t --
+int(15)
+int(15)
+bool(false)
+string(%d) ""water","fruit
+"
+
+-- file opened in w+ --
+int(15)
+int(15)
+bool(false)
+string(15) ""water","fruit
+"
+
+-- file opened in w+b --
+int(15)
+int(15)
+bool(false)
+string(15) ""water","fruit
+"
+
+-- file opened in w+t --
+int(15)
+int(15)
+bool(false)
+string(%d) ""water","fruit
+"
+
+-- file opened in x+ --
+int(15)
+int(15)
+bool(false)
+string(15) ""water","fruit
+"
+
+-- file opened in x+b --
+int(15)
+int(15)
+bool(false)
+string(15) ""water","fruit
+"
+
+-- file opened in x+t --
+int(15)
+int(15)
+bool(false)
+string(%d) ""water","fruit
+"
+
+-- file opened in r+ --
+int(16)
+int(16)
+bool(false)
+string(16) ""water","fruit"
+"
+
+-- file opened in r+b --
+int(16)
+int(16)
+bool(false)
+string(16) ""water","fruit"
+"
+
+-- file opened in r+t --
+int(16)
+int(16)
+bool(false)
+string(%d) ""water","fruit"
+"
+
+-- file opened in a+ --
+int(16)
+int(16)
+bool(false)
+string(16) ""water","fruit"
+"
+
+-- file opened in a+b --
+int(16)
+int(16)
+bool(false)
+string(16) ""water","fruit"
+"
+
+-- file opened in a+t --
+int(16)
+int(16)
+bool(false)
+string(%d) ""water","fruit"
+"
+
+-- file opened in w+ --
+int(16)
+int(16)
+bool(false)
+string(16) ""water","fruit"
+"
+
+-- file opened in w+b --
+int(16)
+int(16)
+bool(false)
+string(16) ""water","fruit"
+"
+
+-- file opened in w+t --
+int(16)
+int(16)
+bool(false)
+string(%d) ""water","fruit"
+"
+
+-- file opened in x+ --
+int(16)
+int(16)
+bool(false)
+string(16) ""water","fruit"
+"
+
+-- file opened in x+b --
+int(16)
+int(16)
+bool(false)
+string(16) ""water","fruit"
+"
+
+-- file opened in x+t --
+int(16)
+int(16)
+bool(false)
+string(%d) ""water","fruit"
+"
+
+-- file opened in r+ --
+int(18)
+int(18)
+bool(false)
+string(18) "%^water^ ^fruit^%
+"
+
+-- file opened in r+b --
+int(18)
+int(18)
+bool(false)
+string(18) "%^water^ ^fruit^%
+"
+
+-- file opened in r+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "%^water^ ^fruit^%
+"
+
+-- file opened in a+ --
+int(18)
+int(18)
+bool(false)
+string(18) "%^water^ ^fruit^%
+"
+
+-- file opened in a+b --
+int(18)
+int(18)
+bool(false)
+string(18) "%^water^ ^fruit^%
+"
+
+-- file opened in a+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "%^water^ ^fruit^%
+"
+
+-- file opened in w+ --
+int(18)
+int(18)
+bool(false)
+string(18) "%^water^ ^fruit^%
+"
+
+-- file opened in w+b --
+int(18)
+int(18)
+bool(false)
+string(18) "%^water^ ^fruit^%
+"
+
+-- file opened in w+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "%^water^ ^fruit^%
+"
+
+-- file opened in x+ --
+int(18)
+int(18)
+bool(false)
+string(18) "%^water^ ^fruit^%
+"
+
+-- file opened in x+b --
+int(18)
+int(18)
+bool(false)
+string(18) "%^water^ ^fruit^%
+"
+
+-- file opened in x+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "%^water^ ^fruit^%
+"
+
+-- file opened in r+ --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in r+b --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in r+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "&water&:&fruit&
+"
+
+-- file opened in a+ --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in a+b --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in a+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "&water&:&fruit&
+"
+
+-- file opened in w+ --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in w+b --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in w+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "&water&:&fruit&
+"
+
+-- file opened in x+ --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in x+b --
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in x+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "&water&:&fruit&
+"
+
+-- file opened in r+ --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in r+b --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in r+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "=water===fruit=
+"
+
+-- file opened in a+ --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in a+b --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in a+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "=water===fruit=
+"
+
+-- file opened in w+ --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in w+b --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in w+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "=water===fruit=
+"
+
+-- file opened in x+ --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in x+b --
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in x+t --
+int(16)
+int(16)
+bool(false)
+string(%d) "=water===fruit=
+"
+
+-- file opened in r+ --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in r+b --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in r+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "-water--fruit-air
+"
+
+-- file opened in a+ --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in a+b --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in a+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "-water--fruit-air
+"
+
+-- file opened in w+ --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in w+b --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in w+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "-water--fruit-air
+"
+
+-- file opened in x+ --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in x+b --
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in x+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "-water--fruit-air
+"
+
+-- file opened in r+ --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in r+b --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in r+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "-water---fruit---air-
+"
+
+-- file opened in a+ --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in a+b --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in a+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "-water---fruit---air-
+"
+
+-- file opened in w+ --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in w+b --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in w+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "-water---fruit---air-
+"
+
+-- file opened in x+ --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in x+b --
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in x+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "-water---fruit---air-
+"
+
+-- file opened in r+ --
+int(24)
+int(24)
+bool(false)
+string(24) "&""""&:&"&:,:":&,&:,,,,
+"
+
+-- file opened in r+b --
+int(24)
+int(24)
+bool(false)
+string(24) "&""""&:&"&:,:":&,&:,,,,
+"
+
+-- file opened in r+t --
+int(24)
+int(24)
+bool(false)
+string(%d) "&""""&:&"&:,:":&,&:,,,,
+"
+
+-- file opened in a+ --
+int(24)
+int(24)
+bool(false)
+string(24) "&""""&:&"&:,:":&,&:,,,,
+"
+
+-- file opened in a+b --
+int(24)
+int(24)
+bool(false)
+string(24) "&""""&:&"&:,:":&,&:,,,,
+"
+
+-- file opened in a+t --
+int(24)
+int(24)
+bool(false)
+string(%d) "&""""&:&"&:,:":&,&:,,,,
+"
+
+-- file opened in w+ --
+int(24)
+int(24)
+bool(false)
+string(24) "&""""&:&"&:,:":&,&:,,,,
+"
+
+-- file opened in w+b --
+int(24)
+int(24)
+bool(false)
+string(24) "&""""&:&"&:,:":&,&:,,,,
+"
+
+-- file opened in w+t --
+int(24)
+int(24)
+bool(false)
+string(%d) "&""""&:&"&:,:":&,&:,,,,
+"
+
+-- file opened in x+ --
+int(24)
+int(24)
+bool(false)
+string(24) "&""""&:&"&:,:":&,&:,,,,
+"
+
+-- file opened in x+b --
+int(24)
+int(24)
+bool(false)
+string(24) "&""""&:&"&:,:":&,&:,,,,
+"
+
+-- file opened in x+t --
+int(24)
+int(24)
+bool(false)
+string(%d) "&""""&:&"&:,:":&,&:,,,,
+"
+Done
+
diff --git a/ext/standard/tests/file/fputcsv_variation7.phpt b/ext/standard/tests/file/fputcsv_variation7.phpt
new file mode 100644
index 0000000..8329251
--- /dev/null
+++ b/ext/standard/tests/file/fputcsv_variation7.phpt
@@ -0,0 +1,837 @@
+--TEST--
+Test fputcsv() : usage variations - with different delimiter and same enclosure
+--FILE--
+<?php
+/*
+ Prototype: array fputcsv ( resource $handle , array $fields [, string $delimiter [, string $enclosure]]] );
+ Description: Format line as CSV and write to the file pointer
+*/
+
+/*
+ Testing fputcsv() to write to a file when enclosure is same but delimiter is different from those
+ present in the field to be written to the file
+ */
+
+echo "*** Testing fputcsv() : with different delimiter and same enclosure ***\n";
+
+/* the array is with three elements in it. Each element should be read as
+ 1st element is delimiter, 2nd element is enclosure
+ and 3rd element is csv fields
+*/
+$csv_lists = array (
+ array(',', '"', array('water','fruit') ),
+ array(',', '"', array('"water","fruit') ),
+ array(',', '"', array('"water","fruit"') ),
+ array(' ', '^', array('^water^ ^fruit^')),
+ array(':', '&', array('&water&:&fruit&')),
+ array('=', '=', array('=water===fruit=')),
+ array('-', '-', array('-water--fruit-air')),
+ array('-', '-', array('-water---fruit---air-')),
+ array(':', '&', array('&""""&:&"&:,:":&,&:,,,,'))
+
+);
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fputcsv_variation7.tmp";
+
+$file_modes = array ("r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+
+ echo "\n-- file opened in $file_modes[$mode_counter] --\n";
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $file_handle = fopen($filename, "w");
+ } else {
+ $file_handle = fopen($filename, $file_modes[$mode_counter] );
+ }
+ if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+ }
+ $delimiter = $csv_list[0];
+ $enclosure = $csv_list[1];
+ $csv_field = $csv_list[2];
+
+ // write to a file in csv format
+ var_dump( fputcsv($file_handle, $csv_field, '+', $enclosure) );
+ // check the file pointer position and eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+ //close the file
+ fclose($file_handle);
+
+ // print the file contents
+ var_dump( file_get_contents($filename) );
+
+ //delete file
+ unlink($filename);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fputcsv() : with different delimiter and same enclosure ***
+
+-- file opened in r+ --
+int(12)
+int(12)
+bool(false)
+string(12) "water+fruit
+"
+
+-- file opened in r+b --
+int(12)
+int(12)
+bool(false)
+string(12) "water+fruit
+"
+
+-- file opened in r+t --
+int(12)
+int(12)
+bool(false)
+string(%d) "water+fruit
+"
+
+-- file opened in a+ --
+int(12)
+int(12)
+bool(false)
+string(12) "water+fruit
+"
+
+-- file opened in a+b --
+int(12)
+int(12)
+bool(false)
+string(12) "water+fruit
+"
+
+-- file opened in a+t --
+int(12)
+int(12)
+bool(false)
+string(%d) "water+fruit
+"
+
+-- file opened in w+ --
+int(12)
+int(12)
+bool(false)
+string(12) "water+fruit
+"
+
+-- file opened in w+b --
+int(12)
+int(12)
+bool(false)
+string(12) "water+fruit
+"
+
+-- file opened in w+t --
+int(12)
+int(12)
+bool(false)
+string(%d) "water+fruit
+"
+
+-- file opened in x+ --
+int(12)
+int(12)
+bool(false)
+string(12) "water+fruit
+"
+
+-- file opened in x+b --
+int(12)
+int(12)
+bool(false)
+string(12) "water+fruit
+"
+
+-- file opened in x+t --
+int(12)
+int(12)
+bool(false)
+string(%d) "water+fruit
+"
+
+-- file opened in r+ --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in r+b --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in r+t --
+int(20)
+int(20)
+bool(false)
+string(%d) """"water"",""fruit"
+"
+
+-- file opened in a+ --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in a+b --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in a+t --
+int(20)
+int(20)
+bool(false)
+string(%d) """"water"",""fruit"
+"
+
+-- file opened in w+ --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in w+b --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in w+t --
+int(20)
+int(20)
+bool(false)
+string(%d) """"water"",""fruit"
+"
+
+-- file opened in x+ --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in x+b --
+int(20)
+int(20)
+bool(false)
+string(20) """"water"",""fruit"
+"
+
+-- file opened in x+t --
+int(20)
+int(20)
+bool(false)
+string(%d) """"water"",""fruit"
+"
+
+-- file opened in r+ --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in r+b --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in r+t --
+int(22)
+int(22)
+bool(false)
+string(%d) """"water"",""fruit"""
+"
+
+-- file opened in a+ --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in a+b --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in a+t --
+int(22)
+int(22)
+bool(false)
+string(%d) """"water"",""fruit"""
+"
+
+-- file opened in w+ --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in w+b --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in w+t --
+int(22)
+int(22)
+bool(false)
+string(%d) """"water"",""fruit"""
+"
+
+-- file opened in x+ --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in x+b --
+int(22)
+int(22)
+bool(false)
+string(22) """"water"",""fruit"""
+"
+
+-- file opened in x+t --
+int(22)
+int(22)
+bool(false)
+string(%d) """"water"",""fruit"""
+"
+
+-- file opened in r+ --
+int(22)
+int(22)
+bool(false)
+string(22) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in r+b --
+int(22)
+int(22)
+bool(false)
+string(22) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in r+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in a+ --
+int(22)
+int(22)
+bool(false)
+string(22) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in a+b --
+int(22)
+int(22)
+bool(false)
+string(22) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in a+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in w+ --
+int(22)
+int(22)
+bool(false)
+string(22) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in w+b --
+int(22)
+int(22)
+bool(false)
+string(22) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in w+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in x+ --
+int(22)
+int(22)
+bool(false)
+string(22) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in x+b --
+int(22)
+int(22)
+bool(false)
+string(22) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in x+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "^^^water^^ ^^fruit^^^
+"
+
+-- file opened in r+ --
+int(22)
+int(22)
+bool(false)
+string(22) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in r+b --
+int(22)
+int(22)
+bool(false)
+string(22) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in r+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in a+ --
+int(22)
+int(22)
+bool(false)
+string(22) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in a+b --
+int(22)
+int(22)
+bool(false)
+string(22) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in a+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in w+ --
+int(22)
+int(22)
+bool(false)
+string(22) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in w+b --
+int(22)
+int(22)
+bool(false)
+string(22) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in w+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in x+ --
+int(22)
+int(22)
+bool(false)
+string(22) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in x+b --
+int(22)
+int(22)
+bool(false)
+string(22) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in x+t --
+int(22)
+int(22)
+bool(false)
+string(%d) "&&&water&&:&&fruit&&&
+"
+
+-- file opened in r+ --
+int(23)
+int(23)
+bool(false)
+string(23) "===water======fruit===
+"
+
+-- file opened in r+b --
+int(23)
+int(23)
+bool(false)
+string(23) "===water======fruit===
+"
+
+-- file opened in r+t --
+int(23)
+int(23)
+bool(false)
+string(%d) "===water======fruit===
+"
+
+-- file opened in a+ --
+int(23)
+int(23)
+bool(false)
+string(23) "===water======fruit===
+"
+
+-- file opened in a+b --
+int(23)
+int(23)
+bool(false)
+string(23) "===water======fruit===
+"
+
+-- file opened in a+t --
+int(23)
+int(23)
+bool(false)
+string(%d) "===water======fruit===
+"
+
+-- file opened in w+ --
+int(23)
+int(23)
+bool(false)
+string(23) "===water======fruit===
+"
+
+-- file opened in w+b --
+int(23)
+int(23)
+bool(false)
+string(23) "===water======fruit===
+"
+
+-- file opened in w+t --
+int(23)
+int(23)
+bool(false)
+string(%d) "===water======fruit===
+"
+
+-- file opened in x+ --
+int(23)
+int(23)
+bool(false)
+string(23) "===water======fruit===
+"
+
+-- file opened in x+b --
+int(23)
+int(23)
+bool(false)
+string(23) "===water======fruit===
+"
+
+-- file opened in x+t --
+int(23)
+int(23)
+bool(false)
+string(%d) "===water======fruit===
+"
+
+-- file opened in r+ --
+int(24)
+int(24)
+bool(false)
+string(24) "---water----fruit--air-
+"
+
+-- file opened in r+b --
+int(24)
+int(24)
+bool(false)
+string(24) "---water----fruit--air-
+"
+
+-- file opened in r+t --
+int(24)
+int(24)
+bool(false)
+string(%d) "---water----fruit--air-
+"
+
+-- file opened in a+ --
+int(24)
+int(24)
+bool(false)
+string(24) "---water----fruit--air-
+"
+
+-- file opened in a+b --
+int(24)
+int(24)
+bool(false)
+string(24) "---water----fruit--air-
+"
+
+-- file opened in a+t --
+int(24)
+int(24)
+bool(false)
+string(%d) "---water----fruit--air-
+"
+
+-- file opened in w+ --
+int(24)
+int(24)
+bool(false)
+string(24) "---water----fruit--air-
+"
+
+-- file opened in w+b --
+int(24)
+int(24)
+bool(false)
+string(24) "---water----fruit--air-
+"
+
+-- file opened in w+t --
+int(24)
+int(24)
+bool(false)
+string(%d) "---water----fruit--air-
+"
+
+-- file opened in x+ --
+int(24)
+int(24)
+bool(false)
+string(24) "---water----fruit--air-
+"
+
+-- file opened in x+b --
+int(24)
+int(24)
+bool(false)
+string(24) "---water----fruit--air-
+"
+
+-- file opened in x+t --
+int(24)
+int(24)
+bool(false)
+string(%d) "---water----fruit--air-
+"
+
+-- file opened in r+ --
+int(32)
+int(32)
+bool(false)
+string(32) "---water------fruit------air---
+"
+
+-- file opened in r+b --
+int(32)
+int(32)
+bool(false)
+string(32) "---water------fruit------air---
+"
+
+-- file opened in r+t --
+int(32)
+int(32)
+bool(false)
+string(%d) "---water------fruit------air---
+"
+
+-- file opened in a+ --
+int(32)
+int(32)
+bool(false)
+string(32) "---water------fruit------air---
+"
+
+-- file opened in a+b --
+int(32)
+int(32)
+bool(false)
+string(32) "---water------fruit------air---
+"
+
+-- file opened in a+t --
+int(32)
+int(32)
+bool(false)
+string(%d) "---water------fruit------air---
+"
+
+-- file opened in w+ --
+int(32)
+int(32)
+bool(false)
+string(32) "---water------fruit------air---
+"
+
+-- file opened in w+b --
+int(32)
+int(32)
+bool(false)
+string(32) "---water------fruit------air---
+"
+
+-- file opened in w+t --
+int(32)
+int(32)
+bool(false)
+string(%d) "---water------fruit------air---
+"
+
+-- file opened in x+ --
+int(32)
+int(32)
+bool(false)
+string(32) "---water------fruit------air---
+"
+
+-- file opened in x+b --
+int(32)
+int(32)
+bool(false)
+string(32) "---water------fruit------air---
+"
+
+-- file opened in x+t --
+int(32)
+int(32)
+bool(false)
+string(%d) "---water------fruit------air---
+"
+
+-- file opened in r+ --
+int(32)
+int(32)
+bool(false)
+string(32) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+
+-- file opened in r+b --
+int(32)
+int(32)
+bool(false)
+string(32) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+
+-- file opened in r+t --
+int(32)
+int(32)
+bool(false)
+string(%d) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+
+-- file opened in a+ --
+int(32)
+int(32)
+bool(false)
+string(32) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+
+-- file opened in a+b --
+int(32)
+int(32)
+bool(false)
+string(32) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+
+-- file opened in a+t --
+int(32)
+int(32)
+bool(false)
+string(%d) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+
+-- file opened in w+ --
+int(32)
+int(32)
+bool(false)
+string(32) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+
+-- file opened in w+b --
+int(32)
+int(32)
+bool(false)
+string(32) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+
+-- file opened in w+t --
+int(32)
+int(32)
+bool(false)
+string(%d) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+
+-- file opened in x+ --
+int(32)
+int(32)
+bool(false)
+string(32) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+
+-- file opened in x+b --
+int(32)
+int(32)
+bool(false)
+string(32) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+
+-- file opened in x+t --
+int(32)
+int(32)
+bool(false)
+string(%d) "&&&""""&&:&&"&&:,:":&&,&&:,,,,&
+"
+Done
+
diff --git a/ext/standard/tests/file/fputcsv_variation8.phpt b/ext/standard/tests/file/fputcsv_variation8.phpt
new file mode 100644
index 0000000..096f379
--- /dev/null
+++ b/ext/standard/tests/file/fputcsv_variation8.phpt
@@ -0,0 +1,837 @@
+--TEST--
+Test fputcsv() : usage variations - with same delimiter and different enclosure
+--FILE--
+<?php
+/*
+ Prototype: array fputcsv ( resource $handle , array $fields [, string $delimiter [, string $enclosure]]] );
+ Description: Format line as CSV and write to the file pointer
+*/
+
+/*
+ Testing fputcsv() to write to a file when delimiter is same but enclosure is different from those
+ present in the field to be written to the file
+ */
+
+echo "*** Testing fputcsv() : with same delimiter and different enclosure ***\n";
+
+/* the array is with three elements in it. Each element should be read as
+ 1st element is delimiter, 2nd element is enclosure
+ and 3rd element is csv fields
+*/
+$csv_lists = array (
+ array(',', '"', array('water,fruit') ),
+ array(',', '"', array('"water","fruit') ),
+ array(',', '"', array('"water","fruit"') ),
+ array(' ', '^', array('^water^ ^fruit^')),
+ array(':', '&', array('&water&:&fruit&')),
+ array('=', '=', array('=water===fruit=')),
+ array('-', '-', array('-water--fruit-air')),
+ array('-', '-', array('-water---fruit---air-')),
+ array(':', '&', array('&""""&:&"&:,:":&,&:,,,,'))
+
+);
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fputcsv_variation8.tmp";
+
+$file_modes = array ("r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+
+ echo "\n-- file opened in $file_modes[$mode_counter] --\n";
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $file_handle = fopen($filename, "w");
+ } else {
+ $file_handle = fopen($filename, $file_modes[$mode_counter] );
+ }
+ if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+ }
+ $delimiter = $csv_list[0];
+ $enclosure = $csv_list[1];
+ $csv_field = $csv_list[2];
+
+ // write to a file in csv format
+ var_dump( fputcsv($file_handle, $csv_field, $delimiter, '+') );
+ // check the file pointer position and eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+ //close the file
+ fclose($file_handle);
+
+ // print the file contents
+ var_dump( file_get_contents($filename) );
+
+ //delete file
+ unlink($filename);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fputcsv() : with same delimiter and different enclosure ***
+
+-- file opened in r+ --
+int(14)
+int(14)
+bool(false)
+string(14) "+water,fruit+
+"
+
+-- file opened in r+b --
+int(14)
+int(14)
+bool(false)
+string(14) "+water,fruit+
+"
+
+-- file opened in r+t --
+int(14)
+int(14)
+bool(false)
+string(%d) "+water,fruit+
+"
+
+-- file opened in a+ --
+int(14)
+int(14)
+bool(false)
+string(14) "+water,fruit+
+"
+
+-- file opened in a+b --
+int(14)
+int(14)
+bool(false)
+string(14) "+water,fruit+
+"
+
+-- file opened in a+t --
+int(14)
+int(14)
+bool(false)
+string(%d) "+water,fruit+
+"
+
+-- file opened in w+ --
+int(14)
+int(14)
+bool(false)
+string(14) "+water,fruit+
+"
+
+-- file opened in w+b --
+int(14)
+int(14)
+bool(false)
+string(14) "+water,fruit+
+"
+
+-- file opened in w+t --
+int(14)
+int(14)
+bool(false)
+string(%d) "+water,fruit+
+"
+
+-- file opened in x+ --
+int(14)
+int(14)
+bool(false)
+string(14) "+water,fruit+
+"
+
+-- file opened in x+b --
+int(14)
+int(14)
+bool(false)
+string(14) "+water,fruit+
+"
+
+-- file opened in x+t --
+int(14)
+int(14)
+bool(false)
+string(%d) "+water,fruit+
+"
+
+-- file opened in r+ --
+int(17)
+int(17)
+bool(false)
+string(17) "+"water","fruit+
+"
+
+-- file opened in r+b --
+int(17)
+int(17)
+bool(false)
+string(17) "+"water","fruit+
+"
+
+-- file opened in r+t --
+int(17)
+int(17)
+bool(false)
+string(%d) "+"water","fruit+
+"
+
+-- file opened in a+ --
+int(17)
+int(17)
+bool(false)
+string(17) "+"water","fruit+
+"
+
+-- file opened in a+b --
+int(17)
+int(17)
+bool(false)
+string(17) "+"water","fruit+
+"
+
+-- file opened in a+t --
+int(17)
+int(17)
+bool(false)
+string(%d) "+"water","fruit+
+"
+
+-- file opened in w+ --
+int(17)
+int(17)
+bool(false)
+string(17) "+"water","fruit+
+"
+
+-- file opened in w+b --
+int(17)
+int(17)
+bool(false)
+string(17) "+"water","fruit+
+"
+
+-- file opened in w+t --
+int(17)
+int(17)
+bool(false)
+string(%d) "+"water","fruit+
+"
+
+-- file opened in x+ --
+int(17)
+int(17)
+bool(false)
+string(17) "+"water","fruit+
+"
+
+-- file opened in x+b --
+int(17)
+int(17)
+bool(false)
+string(17) "+"water","fruit+
+"
+
+-- file opened in x+t --
+int(17)
+int(17)
+bool(false)
+string(%d) "+"water","fruit+
+"
+
+-- file opened in r+ --
+int(18)
+int(18)
+bool(false)
+string(18) "+"water","fruit"+
+"
+
+-- file opened in r+b --
+int(18)
+int(18)
+bool(false)
+string(18) "+"water","fruit"+
+"
+
+-- file opened in r+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "+"water","fruit"+
+"
+
+-- file opened in a+ --
+int(18)
+int(18)
+bool(false)
+string(18) "+"water","fruit"+
+"
+
+-- file opened in a+b --
+int(18)
+int(18)
+bool(false)
+string(18) "+"water","fruit"+
+"
+
+-- file opened in a+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "+"water","fruit"+
+"
+
+-- file opened in w+ --
+int(18)
+int(18)
+bool(false)
+string(18) "+"water","fruit"+
+"
+
+-- file opened in w+b --
+int(18)
+int(18)
+bool(false)
+string(18) "+"water","fruit"+
+"
+
+-- file opened in w+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "+"water","fruit"+
+"
+
+-- file opened in x+ --
+int(18)
+int(18)
+bool(false)
+string(18) "+"water","fruit"+
+"
+
+-- file opened in x+b --
+int(18)
+int(18)
+bool(false)
+string(18) "+"water","fruit"+
+"
+
+-- file opened in x+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "+"water","fruit"+
+"
+
+-- file opened in r+ --
+int(18)
+int(18)
+bool(false)
+string(18) "+^water^ ^fruit^+
+"
+
+-- file opened in r+b --
+int(18)
+int(18)
+bool(false)
+string(18) "+^water^ ^fruit^+
+"
+
+-- file opened in r+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "+^water^ ^fruit^+
+"
+
+-- file opened in a+ --
+int(18)
+int(18)
+bool(false)
+string(18) "+^water^ ^fruit^+
+"
+
+-- file opened in a+b --
+int(18)
+int(18)
+bool(false)
+string(18) "+^water^ ^fruit^+
+"
+
+-- file opened in a+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "+^water^ ^fruit^+
+"
+
+-- file opened in w+ --
+int(18)
+int(18)
+bool(false)
+string(18) "+^water^ ^fruit^+
+"
+
+-- file opened in w+b --
+int(18)
+int(18)
+bool(false)
+string(18) "+^water^ ^fruit^+
+"
+
+-- file opened in w+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "+^water^ ^fruit^+
+"
+
+-- file opened in x+ --
+int(18)
+int(18)
+bool(false)
+string(18) "+^water^ ^fruit^+
+"
+
+-- file opened in x+b --
+int(18)
+int(18)
+bool(false)
+string(18) "+^water^ ^fruit^+
+"
+
+-- file opened in x+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "+^water^ ^fruit^+
+"
+
+-- file opened in r+ --
+int(18)
+int(18)
+bool(false)
+string(18) "+&water&:&fruit&+
+"
+
+-- file opened in r+b --
+int(18)
+int(18)
+bool(false)
+string(18) "+&water&:&fruit&+
+"
+
+-- file opened in r+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "+&water&:&fruit&+
+"
+
+-- file opened in a+ --
+int(18)
+int(18)
+bool(false)
+string(18) "+&water&:&fruit&+
+"
+
+-- file opened in a+b --
+int(18)
+int(18)
+bool(false)
+string(18) "+&water&:&fruit&+
+"
+
+-- file opened in a+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "+&water&:&fruit&+
+"
+
+-- file opened in w+ --
+int(18)
+int(18)
+bool(false)
+string(18) "+&water&:&fruit&+
+"
+
+-- file opened in w+b --
+int(18)
+int(18)
+bool(false)
+string(18) "+&water&:&fruit&+
+"
+
+-- file opened in w+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "+&water&:&fruit&+
+"
+
+-- file opened in x+ --
+int(18)
+int(18)
+bool(false)
+string(18) "+&water&:&fruit&+
+"
+
+-- file opened in x+b --
+int(18)
+int(18)
+bool(false)
+string(18) "+&water&:&fruit&+
+"
+
+-- file opened in x+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "+&water&:&fruit&+
+"
+
+-- file opened in r+ --
+int(18)
+int(18)
+bool(false)
+string(18) "+=water===fruit=+
+"
+
+-- file opened in r+b --
+int(18)
+int(18)
+bool(false)
+string(18) "+=water===fruit=+
+"
+
+-- file opened in r+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "+=water===fruit=+
+"
+
+-- file opened in a+ --
+int(18)
+int(18)
+bool(false)
+string(18) "+=water===fruit=+
+"
+
+-- file opened in a+b --
+int(18)
+int(18)
+bool(false)
+string(18) "+=water===fruit=+
+"
+
+-- file opened in a+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "+=water===fruit=+
+"
+
+-- file opened in w+ --
+int(18)
+int(18)
+bool(false)
+string(18) "+=water===fruit=+
+"
+
+-- file opened in w+b --
+int(18)
+int(18)
+bool(false)
+string(18) "+=water===fruit=+
+"
+
+-- file opened in w+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "+=water===fruit=+
+"
+
+-- file opened in x+ --
+int(18)
+int(18)
+bool(false)
+string(18) "+=water===fruit=+
+"
+
+-- file opened in x+b --
+int(18)
+int(18)
+bool(false)
+string(18) "+=water===fruit=+
+"
+
+-- file opened in x+t --
+int(18)
+int(18)
+bool(false)
+string(%d) "+=water===fruit=+
+"
+
+-- file opened in r+ --
+int(20)
+int(20)
+bool(false)
+string(20) "+-water--fruit-air+
+"
+
+-- file opened in r+b --
+int(20)
+int(20)
+bool(false)
+string(20) "+-water--fruit-air+
+"
+
+-- file opened in r+t --
+int(20)
+int(20)
+bool(false)
+string(%d) "+-water--fruit-air+
+"
+
+-- file opened in a+ --
+int(20)
+int(20)
+bool(false)
+string(20) "+-water--fruit-air+
+"
+
+-- file opened in a+b --
+int(20)
+int(20)
+bool(false)
+string(20) "+-water--fruit-air+
+"
+
+-- file opened in a+t --
+int(20)
+int(20)
+bool(false)
+string(%d) "+-water--fruit-air+
+"
+
+-- file opened in w+ --
+int(20)
+int(20)
+bool(false)
+string(20) "+-water--fruit-air+
+"
+
+-- file opened in w+b --
+int(20)
+int(20)
+bool(false)
+string(20) "+-water--fruit-air+
+"
+
+-- file opened in w+t --
+int(20)
+int(20)
+bool(false)
+string(%d) "+-water--fruit-air+
+"
+
+-- file opened in x+ --
+int(20)
+int(20)
+bool(false)
+string(20) "+-water--fruit-air+
+"
+
+-- file opened in x+b --
+int(20)
+int(20)
+bool(false)
+string(20) "+-water--fruit-air+
+"
+
+-- file opened in x+t --
+int(20)
+int(20)
+bool(false)
+string(%d) "+-water--fruit-air+
+"
+
+-- file opened in r+ --
+int(24)
+int(24)
+bool(false)
+string(24) "+-water---fruit---air-+
+"
+
+-- file opened in r+b --
+int(24)
+int(24)
+bool(false)
+string(24) "+-water---fruit---air-+
+"
+
+-- file opened in r+t --
+int(24)
+int(24)
+bool(false)
+string(%d) "+-water---fruit---air-+
+"
+
+-- file opened in a+ --
+int(24)
+int(24)
+bool(false)
+string(24) "+-water---fruit---air-+
+"
+
+-- file opened in a+b --
+int(24)
+int(24)
+bool(false)
+string(24) "+-water---fruit---air-+
+"
+
+-- file opened in a+t --
+int(24)
+int(24)
+bool(false)
+string(%d) "+-water---fruit---air-+
+"
+
+-- file opened in w+ --
+int(24)
+int(24)
+bool(false)
+string(24) "+-water---fruit---air-+
+"
+
+-- file opened in w+b --
+int(24)
+int(24)
+bool(false)
+string(24) "+-water---fruit---air-+
+"
+
+-- file opened in w+t --
+int(24)
+int(24)
+bool(false)
+string(%d) "+-water---fruit---air-+
+"
+
+-- file opened in x+ --
+int(24)
+int(24)
+bool(false)
+string(24) "+-water---fruit---air-+
+"
+
+-- file opened in x+b --
+int(24)
+int(24)
+bool(false)
+string(24) "+-water---fruit---air-+
+"
+
+-- file opened in x+t --
+int(24)
+int(24)
+bool(false)
+string(%d) "+-water---fruit---air-+
+"
+
+-- file opened in r+ --
+int(26)
+int(26)
+bool(false)
+string(26) "+&""""&:&"&:,:":&,&:,,,,+
+"
+
+-- file opened in r+b --
+int(26)
+int(26)
+bool(false)
+string(26) "+&""""&:&"&:,:":&,&:,,,,+
+"
+
+-- file opened in r+t --
+int(26)
+int(26)
+bool(false)
+string(%d) "+&""""&:&"&:,:":&,&:,,,,+
+"
+
+-- file opened in a+ --
+int(26)
+int(26)
+bool(false)
+string(26) "+&""""&:&"&:,:":&,&:,,,,+
+"
+
+-- file opened in a+b --
+int(26)
+int(26)
+bool(false)
+string(26) "+&""""&:&"&:,:":&,&:,,,,+
+"
+
+-- file opened in a+t --
+int(26)
+int(26)
+bool(false)
+string(%d) "+&""""&:&"&:,:":&,&:,,,,+
+"
+
+-- file opened in w+ --
+int(26)
+int(26)
+bool(false)
+string(26) "+&""""&:&"&:,:":&,&:,,,,+
+"
+
+-- file opened in w+b --
+int(26)
+int(26)
+bool(false)
+string(26) "+&""""&:&"&:,:":&,&:,,,,+
+"
+
+-- file opened in w+t --
+int(26)
+int(26)
+bool(false)
+string(%d) "+&""""&:&"&:,:":&,&:,,,,+
+"
+
+-- file opened in x+ --
+int(26)
+int(26)
+bool(false)
+string(26) "+&""""&:&"&:,:":&,&:,,,,+
+"
+
+-- file opened in x+b --
+int(26)
+int(26)
+bool(false)
+string(26) "+&""""&:&"&:,:":&,&:,,,,+
+"
+
+-- file opened in x+t --
+int(26)
+int(26)
+bool(false)
+string(%d) "+&""""&:&"&:,:":&,&:,,,,+
+"
+Done
+
diff --git a/ext/standard/tests/file/fputcsv_variation9.phpt b/ext/standard/tests/file/fputcsv_variation9.phpt
new file mode 100644
index 0000000..386d7bd
--- /dev/null
+++ b/ext/standard/tests/file/fputcsv_variation9.phpt
@@ -0,0 +1,1268 @@
+--TEST--
+Test fputcsv() : usage variations - two chars as enclosure & delimiter
+--FILE--
+<?php
+/*
+ Prototype: array fputcsv ( resource $handle , array $fields [, string $delimiter [, string $enclosure]]] );
+ Description: Format line as CSV and write to the file pointer
+*/
+
+
+/* Testing fputcsv() to write to a file when delimiter and enclosure are of two chars each */
+
+echo "*** Testing fputcsv() : with two chars as enclosure & delimiter ***\n";
+
+/* the array is with three elements in it. Each element should be read as
+ 1st element is delimiter, 2nd element is enclosure
+ and 3rd element is csv fields
+*/
+$csv_lists = array (
+ array(',', '"', array('water,fruit') ),
+ array(',', '"', array('"water","fruit') ),
+ array(',', '"', array('"water","fruit"') ),
+ array(' ', '^', array('^water^ ^fruit^')),
+ array(':', '&', array('&water&:&fruit&')),
+ array('=', '=', array('=water===fruit=')),
+ array('-', '-', array('-water--fruit-air')),
+ array('-', '-', array('-water---fruit---air-')),
+ array(':', '&', array('&""""&:&"&:,:":&,&:,,,,'))
+
+);
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fputcsv_variation9.tmp";
+
+$file_modes = array ("r+", "r+b", "r+t",
+ "a+", "a+b", "a+t",
+ "w+", "w+b", "w+t",
+ "x+", "x+b", "x+t");
+
+$loop_counter = 1;
+foreach ($csv_lists as $csv_list) {
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+
+ echo "\n-- file opened in $file_modes[$mode_counter] --\n";
+ // create the file and add the content with has csv fields
+ if ( strstr($file_modes[$mode_counter], "r") ) {
+ $file_handle = fopen($filename, "w");
+ } else {
+ $file_handle = fopen($filename, $file_modes[$mode_counter] );
+ }
+ if ( !$file_handle ) {
+ echo "Error: failed to create file $filename!\n";
+ exit();
+ }
+ $delimiter = $csv_list[0];
+ $enclosure = $csv_list[1];
+ $csv_field = $csv_list[2];
+
+ // write to a file in csv format
+ var_dump( fputcsv($file_handle, $csv_field, '++', '%%'
+) );
+ // check the file pointer position and eof
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+ //close the file
+ fclose($file_handle);
+
+ // print the file contents
+ var_dump( file_get_contents($filename) );
+
+ //delete file
+ unlink($filename);
+ } //end of mode loop
+} // end of foreach
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fputcsv() : with two chars as enclosure & delimiter ***
+
+-- file opened in r+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in r+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in r+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(12)
+int(12)
+bool(false)
+string(%d) "water,fruit
+"
+
+-- file opened in a+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in a+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in a+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(12)
+int(12)
+bool(false)
+string(%d) "water,fruit
+"
+
+-- file opened in w+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in w+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in w+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(12)
+int(12)
+bool(false)
+string(%d) "water,fruit
+"
+
+-- file opened in x+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in x+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(12)
+int(12)
+bool(false)
+string(12) "water,fruit
+"
+
+-- file opened in x+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(12)
+int(12)
+bool(false)
+string(%d) "water,fruit
+"
+
+-- file opened in r+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(15)
+int(15)
+bool(false)
+string(15) ""water","fruit
+"
+
+-- file opened in r+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(15)
+int(15)
+bool(false)
+string(15) ""water","fruit
+"
+
+-- file opened in r+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(15)
+int(15)
+bool(false)
+string(%d) ""water","fruit
+"
+
+-- file opened in a+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(15)
+int(15)
+bool(false)
+string(15) ""water","fruit
+"
+
+-- file opened in a+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(15)
+int(15)
+bool(false)
+string(15) ""water","fruit
+"
+
+-- file opened in a+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(15)
+int(15)
+bool(false)
+string(%d) ""water","fruit
+"
+
+-- file opened in w+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(15)
+int(15)
+bool(false)
+string(15) ""water","fruit
+"
+
+-- file opened in w+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(15)
+int(15)
+bool(false)
+string(15) ""water","fruit
+"
+
+-- file opened in w+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(15)
+int(15)
+bool(false)
+string(%d) ""water","fruit
+"
+
+-- file opened in x+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(15)
+int(15)
+bool(false)
+string(15) ""water","fruit
+"
+
+-- file opened in x+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(15)
+int(15)
+bool(false)
+string(15) ""water","fruit
+"
+
+-- file opened in x+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(15)
+int(15)
+bool(false)
+string(%d) ""water","fruit
+"
+
+-- file opened in r+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(16) ""water","fruit"
+"
+
+-- file opened in r+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(16) ""water","fruit"
+"
+
+-- file opened in r+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(%d) ""water","fruit"
+"
+
+-- file opened in a+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(16) ""water","fruit"
+"
+
+-- file opened in a+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(16) ""water","fruit"
+"
+
+-- file opened in a+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(%d) ""water","fruit"
+"
+
+-- file opened in w+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(16) ""water","fruit"
+"
+
+-- file opened in w+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(16) ""water","fruit"
+"
+
+-- file opened in w+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(%d) ""water","fruit"
+"
+
+-- file opened in x+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(16) ""water","fruit"
+"
+
+-- file opened in x+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(16) ""water","fruit"
+"
+
+-- file opened in x+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(%d) ""water","fruit"
+"
+
+-- file opened in r+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(18) "%^water^ ^fruit^%
+"
+
+-- file opened in r+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(18) "%^water^ ^fruit^%
+"
+
+-- file opened in r+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(%d) "%^water^ ^fruit^%
+"
+
+-- file opened in a+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(18) "%^water^ ^fruit^%
+"
+
+-- file opened in a+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(18) "%^water^ ^fruit^%
+"
+
+-- file opened in a+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(%d) "%^water^ ^fruit^%
+"
+
+-- file opened in w+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(18) "%^water^ ^fruit^%
+"
+
+-- file opened in w+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(18) "%^water^ ^fruit^%
+"
+
+-- file opened in w+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(%d) "%^water^ ^fruit^%
+"
+
+-- file opened in x+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(18) "%^water^ ^fruit^%
+"
+
+-- file opened in x+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(18) "%^water^ ^fruit^%
+"
+
+-- file opened in x+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(%d) "%^water^ ^fruit^%
+"
+
+-- file opened in r+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in r+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in r+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(%d) "&water&:&fruit&
+"
+
+-- file opened in a+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in a+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in a+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(%d) "&water&:&fruit&
+"
+
+-- file opened in w+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in w+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in w+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(%d) "&water&:&fruit&
+"
+
+-- file opened in x+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in x+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(16) "&water&:&fruit&
+"
+
+-- file opened in x+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(%d) "&water&:&fruit&
+"
+
+-- file opened in r+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in r+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in r+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(%d) "=water===fruit=
+"
+
+-- file opened in a+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in a+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in a+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(%d) "=water===fruit=
+"
+
+-- file opened in w+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in w+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in w+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(%d) "=water===fruit=
+"
+
+-- file opened in x+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in x+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(16) "=water===fruit=
+"
+
+-- file opened in x+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(16)
+int(16)
+bool(false)
+string(%d) "=water===fruit=
+"
+
+-- file opened in r+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in r+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in r+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(%d) "-water--fruit-air
+"
+
+-- file opened in a+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in a+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in a+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(%d) "-water--fruit-air
+"
+
+-- file opened in w+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in w+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in w+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(%d) "-water--fruit-air
+"
+
+-- file opened in x+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in x+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(18) "-water--fruit-air
+"
+
+-- file opened in x+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(18)
+int(18)
+bool(false)
+string(%d) "-water--fruit-air
+"
+
+-- file opened in r+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in r+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in r+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(22)
+int(22)
+bool(false)
+string(%d) "-water---fruit---air-
+"
+
+-- file opened in a+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in a+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in a+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(22)
+int(22)
+bool(false)
+string(%d) "-water---fruit---air-
+"
+
+-- file opened in w+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in w+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in w+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(22)
+int(22)
+bool(false)
+string(%d) "-water---fruit---air-
+"
+
+-- file opened in x+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in x+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(22)
+int(22)
+bool(false)
+string(22) "-water---fruit---air-
+"
+
+-- file opened in x+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(22)
+int(22)
+bool(false)
+string(%d) "-water---fruit---air-
+"
+
+-- file opened in r+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(24)
+int(24)
+bool(false)
+string(24) "&""""&:&"&:,:":&,&:,,,,
+"
+
+-- file opened in r+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(24)
+int(24)
+bool(false)
+string(24) "&""""&:&"&:,:":&,&:,,,,
+"
+
+-- file opened in r+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(24)
+int(24)
+bool(false)
+string(%d) "&""""&:&"&:,:":&,&:,,,,
+"
+
+-- file opened in a+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(24)
+int(24)
+bool(false)
+string(24) "&""""&:&"&:,:":&,&:,,,,
+"
+
+-- file opened in a+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(24)
+int(24)
+bool(false)
+string(24) "&""""&:&"&:,:":&,&:,,,,
+"
+
+-- file opened in a+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(24)
+int(24)
+bool(false)
+string(%d) "&""""&:&"&:,:":&,&:,,,,
+"
+
+-- file opened in w+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(24)
+int(24)
+bool(false)
+string(24) "&""""&:&"&:,:":&,&:,,,,
+"
+
+-- file opened in w+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(24)
+int(24)
+bool(false)
+string(24) "&""""&:&"&:,:":&,&:,,,,
+"
+
+-- file opened in w+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(24)
+int(24)
+bool(false)
+string(%d) "&""""&:&"&:,:":&,&:,,,,
+"
+
+-- file opened in x+ --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(24)
+int(24)
+bool(false)
+string(24) "&""""&:&"&:,:":&,&:,,,,
+"
+
+-- file opened in x+b --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(24)
+int(24)
+bool(false)
+string(24) "&""""&:&"&:,:":&,&:,,,,
+"
+
+-- file opened in x+t --
+
+Notice: fputcsv(): delimiter must be a single character in %s on line %d
+
+Notice: fputcsv(): enclosure must be a single character in %s on line %d
+int(24)
+int(24)
+bool(false)
+string(%d) "&""""&:&"&:,:":&,&:,,,,
+"
+Done
+
diff --git a/ext/standard/tests/file/fread_basic.phpt b/ext/standard/tests/file/fread_basic.phpt
new file mode 100644
index 0000000..44e5342
--- /dev/null
+++ b/ext/standard/tests/file/fread_basic.phpt
@@ -0,0 +1,640 @@
+--TEST--
+Test fread() function : basic functionality
+--FILE--
+<?php
+/*
+ Prototype: string fread ( resource $handle [, int $length] );
+ Description: reads up to length bytes from the file pointer referenced by handle.
+ Reading stops when up to length bytes have been read, EOF (end of file) is
+ reached, (for network streams) when a packet becomes available, or (after
+ opening userspace stream) when 8192 bytes have been read whichever comes first.
+*/
+
+// include the file.inc for common functions for test
+include ("file.inc");
+
+/* Function : function check_size(string $data, int $expect_size)
+ Description : Check the length of the data, and compare the size with $expect_size
+ $data : Text data.
+ $expect_size : Expected data length
+*/
+function check_size($data, $expect_size) {
+
+ $size=strlen($data);
+ if ( $size == $expect_size)
+ echo "OK\n";
+ else
+ echo "Error: Expected: $expect_size, Actual: $size";
+ }
+
+
+echo "*** Testing fread() basic operations ***\n";
+/*
+ test fread with file opened in "r" and "rb" mode only
+ Content with numeric and strings with it
+*/
+$file_modes = array( "r", "rb", "rt", "r+", "r+b", "r+t");
+$file_content_types = array("numeric","text","text_with_new_line","alphanumeric");
+
+ foreach($file_content_types as $file_content_type) {
+ echo "\n-- Testing fread) with file having data of type ". $file_content_type ." --\n";
+ /* create files with $file_content_type */
+ create_files ( dirname(__FILE__), 1, $file_content_type, 0755, 1, "w", "fread_basic");
+ $filename = dirname(__FILE__)."/fread_basic1.tmp"; // this is name of the file created by create_files()
+
+ /* open the file using $files_modes and perform fread() on it */
+ for($inner_loop_counter = 0;
+ $inner_loop_counter < count($file_modes);
+ $inner_loop_counter++) {
+
+ echo "-- File opened in mode ".$file_modes[$inner_loop_counter]." --\n";
+ $file_handle = fopen($filename, $file_modes[$inner_loop_counter]);
+ if (!$file_handle) {
+ echo "Error: failed to fopen() file: $filename!";
+ exit();
+ }
+
+ /* read file by giving the acutal length, check the length and content by calculating the
+ hash using md5() function
+ */
+ /* Reading 1024 bytes from file, expecting 1024 bytes */ ;
+
+ var_dump(ftell($file_handle));
+ var_dump( feof($file_handle) );
+ echo "Reading 1024 bytes from file, expecting 1024 bytes ... ";
+ $data_from_file=fread($file_handle, 1024);
+ check_size($data_from_file,1024);
+ var_dump(ftell($file_handle));
+ var_dump( feof($file_handle) );
+ var_dump( md5($data_from_file) ); // calculate the hash and dump it
+
+ /* read file by giving size more than its size */
+ var_dump(rewind($file_handle));
+ var_dump(ftell($file_handle));
+ var_dump( feof($file_handle) );
+ /*reading 1030 bytes from file, expecting 1024 bytes */ ;
+ echo "Reading 1030 bytes from file, expecting 1024 bytes ... ";
+ $data_from_file=fread($file_handle, 1030);// request for 6 bytes more than its size
+ check_size($data_from_file,1024);
+ var_dump(ftell($file_handle));
+ var_dump( feof($file_handle) );
+ var_dump( md5($data_from_file) ); // calculate the hash and dump it
+
+ // reading 1000 bytes within the file max size
+ var_dump(rewind($file_handle));
+ var_dump(ftell($file_handle));
+ var_dump( feof($file_handle) );
+ /*reading 1000 bytes from file, expecting 1000 bytes */ ;
+ echo "Reading 1000 bytes from file, expecting 1000 bytes ... ";
+ $data_from_file=fread($file_handle, 1000);// request for 24 bytes less than its size
+ check_size($data_from_file,1000);
+ var_dump(ftell($file_handle));
+ var_dump( feof($file_handle) );
+ var_dump( md5($data_from_file) ); // calculate the hash and dump it
+ var_dump(fclose($file_handle)); // now close the file
+ } // end of inner for loop
+
+ // delete the file created
+ delete_file($filename); // delete file with name
+} // end of outer foreach loop
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fread() basic operations ***
+
+-- Testing fread) with file having data of type numeric --
+-- File opened in mode r --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+bool(true)
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+bool(true)
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "4501f99f2b79d0345f26f1394aca58a3"
+bool(true)
+-- File opened in mode rb --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+bool(true)
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+bool(true)
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "4501f99f2b79d0345f26f1394aca58a3"
+bool(true)
+-- File opened in mode rt --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+bool(true)
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+bool(true)
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "4501f99f2b79d0345f26f1394aca58a3"
+bool(true)
+-- File opened in mode r+ --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+bool(true)
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+bool(true)
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "4501f99f2b79d0345f26f1394aca58a3"
+bool(true)
+-- File opened in mode r+b --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+bool(true)
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+bool(true)
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "4501f99f2b79d0345f26f1394aca58a3"
+bool(true)
+-- File opened in mode r+t --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+bool(true)
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+bool(true)
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "4501f99f2b79d0345f26f1394aca58a3"
+bool(true)
+
+-- Testing fread) with file having data of type text --
+-- File opened in mode r --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "e486000c4c8452774f746a27658d87fa"
+bool(true)
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "e486000c4c8452774f746a27658d87fa"
+bool(true)
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "2ec76a59f8c44b8f8a0f5139f61bb1bd"
+bool(true)
+-- File opened in mode rb --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "e486000c4c8452774f746a27658d87fa"
+bool(true)
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "e486000c4c8452774f746a27658d87fa"
+bool(true)
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "2ec76a59f8c44b8f8a0f5139f61bb1bd"
+bool(true)
+-- File opened in mode rt --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "e486000c4c8452774f746a27658d87fa"
+bool(true)
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "e486000c4c8452774f746a27658d87fa"
+bool(true)
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "2ec76a59f8c44b8f8a0f5139f61bb1bd"
+bool(true)
+-- File opened in mode r+ --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "e486000c4c8452774f746a27658d87fa"
+bool(true)
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "e486000c4c8452774f746a27658d87fa"
+bool(true)
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "2ec76a59f8c44b8f8a0f5139f61bb1bd"
+bool(true)
+-- File opened in mode r+b --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "e486000c4c8452774f746a27658d87fa"
+bool(true)
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "e486000c4c8452774f746a27658d87fa"
+bool(true)
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "2ec76a59f8c44b8f8a0f5139f61bb1bd"
+bool(true)
+-- File opened in mode r+t --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "e486000c4c8452774f746a27658d87fa"
+bool(true)
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "e486000c4c8452774f746a27658d87fa"
+bool(true)
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "2ec76a59f8c44b8f8a0f5139f61bb1bd"
+bool(true)
+
+-- Testing fread) with file having data of type text_with_new_line --
+-- File opened in mode r --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "b09c8026a64a88d36d4c2f17983964bb"
+bool(true)
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "b09c8026a64a88d36d4c2f17983964bb"
+bool(true)
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "a148fa8110bbac875d84fc9d7056c0a1"
+bool(true)
+-- File opened in mode rb --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "b09c8026a64a88d36d4c2f17983964bb"
+bool(true)
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "b09c8026a64a88d36d4c2f17983964bb"
+bool(true)
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "a148fa8110bbac875d84fc9d7056c0a1"
+bool(true)
+-- File opened in mode rt --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "b09c8026a64a88d36d4c2f17983964bb"
+bool(true)
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "b09c8026a64a88d36d4c2f17983964bb"
+bool(true)
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "a148fa8110bbac875d84fc9d7056c0a1"
+bool(true)
+-- File opened in mode r+ --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "b09c8026a64a88d36d4c2f17983964bb"
+bool(true)
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "b09c8026a64a88d36d4c2f17983964bb"
+bool(true)
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "a148fa8110bbac875d84fc9d7056c0a1"
+bool(true)
+-- File opened in mode r+b --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "b09c8026a64a88d36d4c2f17983964bb"
+bool(true)
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "b09c8026a64a88d36d4c2f17983964bb"
+bool(true)
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "a148fa8110bbac875d84fc9d7056c0a1"
+bool(true)
+-- File opened in mode r+t --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "b09c8026a64a88d36d4c2f17983964bb"
+bool(true)
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "b09c8026a64a88d36d4c2f17983964bb"
+bool(true)
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "a148fa8110bbac875d84fc9d7056c0a1"
+bool(true)
+
+-- Testing fread) with file having data of type alphanumeric --
+-- File opened in mode r --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "3fabd48d8eaa65c14e0d93d6880c560c"
+bool(true)
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "3fabd48d8eaa65c14e0d93d6880c560c"
+bool(true)
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "a49d752f980184c7f44568e930f89c72"
+bool(true)
+-- File opened in mode rb --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "3fabd48d8eaa65c14e0d93d6880c560c"
+bool(true)
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "3fabd48d8eaa65c14e0d93d6880c560c"
+bool(true)
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "a49d752f980184c7f44568e930f89c72"
+bool(true)
+-- File opened in mode rt --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "3fabd48d8eaa65c14e0d93d6880c560c"
+bool(true)
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "3fabd48d8eaa65c14e0d93d6880c560c"
+bool(true)
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "a49d752f980184c7f44568e930f89c72"
+bool(true)
+-- File opened in mode r+ --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "3fabd48d8eaa65c14e0d93d6880c560c"
+bool(true)
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "3fabd48d8eaa65c14e0d93d6880c560c"
+bool(true)
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "a49d752f980184c7f44568e930f89c72"
+bool(true)
+-- File opened in mode r+b --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "3fabd48d8eaa65c14e0d93d6880c560c"
+bool(true)
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "3fabd48d8eaa65c14e0d93d6880c560c"
+bool(true)
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "a49d752f980184c7f44568e930f89c72"
+bool(true)
+-- File opened in mode r+t --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "3fabd48d8eaa65c14e0d93d6880c560c"
+bool(true)
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "3fabd48d8eaa65c14e0d93d6880c560c"
+bool(true)
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "a49d752f980184c7f44568e930f89c72"
+bool(true)
+Done
diff --git a/ext/standard/tests/file/fread_error.phpt b/ext/standard/tests/file/fread_error.phpt
new file mode 100644
index 0000000..45a5ad1
--- /dev/null
+++ b/ext/standard/tests/file/fread_error.phpt
@@ -0,0 +1,114 @@
+--TEST--
+Test fread() function : error conditions
+--FILE--
+<?php
+/*
+ Prototype: string fread ( resource $handle [, int $length] );
+ Description: reads up to length bytes from the file pointer referenced by handle.
+ Reading stops when up to length bytes have been read, EOF (end of file) is
+ reached, (for network streams) when a packet becomes available, or (after
+ opening userspace stream) when 8192 bytes have been read whichever comes first.
+*/
+
+echo "*** Testing error conditions ***\n";
+$filename = __FILE__;
+$file_handle = fopen($filename, "r");
+
+// zero argument
+echo "-- Testing fread() with zero argument --\n";
+var_dump( fread() );
+
+// more than expected no. of args
+echo "-- Testing fread() with more than expected number of arguments --\n";
+var_dump( fread($file_handle, 10, $file_handle) );
+
+// invalid length argument
+echo "-- Testing fread() with invalid length arguments --\n";
+$len = 0;
+var_dump( fread($file_handle, $len) );
+$len = -10;
+var_dump( fread($file_handle, $len) );
+
+// test invalid arguments : non-resources
+echo "-- Testing fread() with invalid arguments --\n";
+$invalid_args = array (
+ "string",
+ 10,
+ 10.5,
+ true,
+ array(1,2,3),
+ new stdclass,
+);
+/* loop to test fread() with different invalid type of args */
+for($loop_counter = 1; $loop_counter <= count($invalid_args); $loop_counter++) {
+ echo "-- Iteration $loop_counter --\n";
+ var_dump( fread($invalid_args[$loop_counter - 1], 10) );
+}
+
+// fwrite() on a file handle which is already closed
+echo "-- Testing fwrite() with closed/unset file handle --\n";
+fclose($file_handle);
+var_dump( fread($file_handle,$file_content_type) );
+
+// fwrite on a file handle which is unset
+$fp = fopen($filename, "r");
+unset($fp); //unset file handle
+var_dump( fread(@$fp,10) );
+var_dump( fclose(@$fp) );
+
+echo "Done\n";
+--EXPECTF--
+*** Testing error conditions ***
+-- Testing fread() with zero argument --
+
+Warning: fread() expects exactly 2 parameters, 0 given in %s on line %d
+bool(false)
+-- Testing fread() with more than expected number of arguments --
+
+Warning: fread() expects exactly 2 parameters, 3 given in %s on line %d
+bool(false)
+-- Testing fread() with invalid length arguments --
+
+Warning: fread(): Length parameter must be greater than 0 in %s on line %d
+bool(false)
+
+Warning: fread(): Length parameter must be greater than 0 in %s on line %d
+bool(false)
+-- Testing fread() with invalid arguments --
+-- Iteration 1 --
+
+Warning: fread() expects parameter 1 to be resource, string given in %s on line %d
+bool(false)
+-- Iteration 2 --
+
+Warning: fread() expects parameter 1 to be resource, integer given in %s on line %d
+bool(false)
+-- Iteration 3 --
+
+Warning: fread() expects parameter 1 to be resource, double given in %s on line %d
+bool(false)
+-- Iteration 4 --
+
+Warning: fread() expects parameter 1 to be resource, boolean given in %s on line %d
+bool(false)
+-- Iteration 5 --
+
+Warning: fread() expects parameter 1 to be resource, array given in %s on line %d
+bool(false)
+-- Iteration 6 --
+
+Warning: fread() expects parameter 1 to be resource, object given in %s on line %d
+bool(false)
+-- Testing fwrite() with closed/unset file handle --
+
+Notice: Undefined variable: file_content_type in %s on line %d
+
+Warning: fread(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: fread() expects parameter 1 to be resource, null given in %s on line %d
+bool(false)
+
+Warning: fclose() expects parameter 1 to be resource, null given in %s on line %d
+bool(false)
+Done
diff --git a/ext/standard/tests/file/fread_fwrite_basic.phpt b/ext/standard/tests/file/fread_fwrite_basic.phpt
new file mode 100644
index 0000000..0f5c4ed
--- /dev/null
+++ b/ext/standard/tests/file/fread_fwrite_basic.phpt
@@ -0,0 +1,72 @@
+--TEST--
+fread & fwrite - Test reading and writing using a single resource
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+
+/*
+ * proto int fwrite(resource fp, string str [, int length])
+ * Function is implemented in ext/standard/file.c
+ */
+
+ /*
+ Prototype: string fread ( resource $handle [, int $length] );
+ Description: reads up to length bytes from the file pointer referenced by handle.
+ Reading stops when up to length bytes have been read, EOF (end of file) is
+ reached, (for network streams) when a packet becomes available, or (after
+ opening userspace stream) when 8192 bytes have been read whichever comes first.
+*/
+
+
+$outputfile = __FILE__.".tmp";
+
+echo "--- testing rw moving about the file ---\n";
+$h = fopen($outputfile, 'wb+');
+$out1 = "The 1st prrt";
+$out2 = " part of the ttxt";
+$out3 = "text";
+fwrite($h, $out1);
+fseek($h, 0, SEEK_SET);
+echo "start:".fread($h, strlen($out1) - 5). "\n";
+fwrite($h, $out2);
+echo "at end:".fread($h,100)."\n";
+var_dump(feof($h));
+fseek($h, -4, SEEK_CUR);
+fwrite($h, $out3);
+fseek($h, 0, SEEK_SET);
+echo "final:".fread($h, 100)."\n";
+fclose($h);
+
+echo "--- testing eof ---\n";
+$h = fopen($outputfile, 'ab+');
+fread($h,1024);
+var_dump(feof($h));
+fread($h,1);
+var_dump(feof($h));
+$out = "extra";
+fwrite($h, $out);
+var_dump(feof($h));
+fread($h,1);
+var_dump(feof($h));
+fseek($h, -strlen($out) + 1, SEEK_CUR);
+echo "last bytes: ".fread($h, strlen($out))."\n";
+fclose($h);
+
+unlink($outputfile);
+
+echo "Done";
+?>
+--EXPECT--
+--- testing rw moving about the file ---
+start:The 1st
+at end:
+bool(true)
+final:The 1st part of the text
+--- testing eof ---
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+last bytes: xtra
+Done \ No newline at end of file
diff --git a/ext/standard/tests/file/fread_socket_variation1.phpt b/ext/standard/tests/file/fread_socket_variation1.phpt
new file mode 100644
index 0000000..a615d2f
--- /dev/null
+++ b/ext/standard/tests/file/fread_socket_variation1.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Testing fread() on a TCP server socket
+--FILE--
+<?php
+
+$tcp_socket = stream_socket_server('tcp://127.0.0.1:31337');
+
+socket_set_timeout($tcp_socket, 0, 1000);
+
+var_dump(fread($tcp_socket, 1));
+
+fclose($tcp_socket);
+
+?>
+--EXPECT--
+string(0) ""
diff --git a/ext/standard/tests/file/fread_variation1.phpt b/ext/standard/tests/file/fread_variation1.phpt
new file mode 100644
index 0000000..c46dbe2
--- /dev/null
+++ b/ext/standard/tests/file/fread_variation1.phpt
@@ -0,0 +1,657 @@
+--TEST--
+Test fread() function : usage variations - read some/all chars, read/write modes
+--FILE--
+<?php
+/*
+ Prototype: string fread ( resource $handle [, int $length] );
+ Description: reads up to length bytes from the file pointer referenced by handle.
+ Reading stops when up to length bytes have been read, EOF (end of file) is
+ reached, (for network streams) when a packet becomes available, or (after
+ opening userspace stream) when 8192 bytes have been read whichever comes first.
+*/
+
+/* Read content less than file size &
+ Read entire file
+*/
+
+// include the file.inc for common functions for test
+include ("file.inc");
+
+/* Function : function check_read(resource $file_handle, int $read_size, int $expect_size)
+ Description : Read data from file of size $read_size and verifies that $expected_size no. of
+ bytes are read.
+ $file_handle : File Handle
+ $read_size : No. of bytes to be read.
+ $expect_size : Expected data length
+ Returns: returns the data read
+*/
+function check_read($file_handle, $read_size, $expect_size) {
+ // print file pointer position before read
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ // read the data of size $read_size
+ echo "Reading $read_size bytes from file, expecting $expect_size bytes ... ";
+ $data_from_file = fread($file_handle, $read_size);
+
+ // check if data read is of expected size
+ if ( strlen($data_from_file) == $expect_size)
+ echo "OK\n";
+ else
+ echo "Error reading file, total number of bytes read = ".strlen($data_from_file)."\n";
+
+ // file pointer position after read
+ var_dump( ftell($file_handle) );
+ // check if file pointer at eof()
+ var_dump( feof($file_handle) );
+
+ return $data_from_file;
+}
+
+echo "*** Testing fread() : usage variations ***\n";
+
+$file_modes = array("a+","a+b","a+t",
+ "w+","w+b","w+t",
+ "x+","x+b","x+t");
+
+$file_content_types = array("numeric","text","text_with_new_line", "alphanumeric");
+
+foreach($file_content_types as $file_content_type) {
+ echo "\n-- Testing fread() with file having content of type ". $file_content_type ." --\n";
+
+ /* open the file using $files_modes and perform fread() on it */
+ foreach($file_modes as $file_mode) {
+ if(!strstr($file_mode,"x")){
+ /* create files with $file_content_type */
+ create_files ( dirname(__FILE__), 1, $file_content_type, 0755, 1, "w", "fread_variation");
+ }
+
+ $filename = dirname(__FILE__)."/fread_variation1.tmp"; // this is name of the file created by create_files()
+ echo "-- File opened in mode ".$file_mode." --\n";
+ $file_handle = fopen($filename, $file_mode);
+ if (!$file_handle) {
+ echo "Error: failed to fopen() file: $filename!";
+ exit();
+ }
+
+ if(strstr($file_mode,"w") || strstr($file_mode,"x") ) {
+ fill_file($file_handle, $file_content_type, 1024);
+ }
+
+ rewind($file_handle);
+ echo "-- Reading entire file content, expeceted : 1024 bytes --\n";
+ // read from file, by giving the file actual size,
+ $data_from_file = check_read($file_handle, 1024, (strstr($file_mode, "+") ? 1024 : 1024 ) );
+ // calculate the hash and dump it, if data read, expecting here no data was read
+ if ( $data_from_file != false)
+ var_dump( md5($data_from_file) );
+
+ // reading file by giving less than its size
+ echo "-- Reading file content less than max. file size, expeceted : 1000 bytes --\n";
+ rewind($file_handle);
+ $data_from_file = check_read($file_handle, 1000, (strstr($file_mode, "+") ? 1000 : 1000 ) );
+ // calculate the hash and dump it, if data read, expecting here no data was read
+ if ( $data_from_file != false)
+ var_dump( md5($data_from_file) );
+
+ // now close the file
+ fclose($file_handle);
+
+ // delete the file created
+ delete_file($filename); // delete file
+ } // end of inner foreach loop
+}// end of outer foreach loop
+
+echo"Done\n";
+?>
+--EXPECTF--
+*** Testing fread() : usage variations ***
+
+-- Testing fread() with file having content of type numeric --
+-- File opened in mode a+ --
+-- Reading entire file content, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+-- Reading file content less than max. file size, expeceted : 1000 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "4501f99f2b79d0345f26f1394aca58a3"
+-- File opened in mode a+b --
+-- Reading entire file content, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+-- Reading file content less than max. file size, expeceted : 1000 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "4501f99f2b79d0345f26f1394aca58a3"
+-- File opened in mode a+t --
+-- Reading entire file content, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+-- Reading file content less than max. file size, expeceted : 1000 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "4501f99f2b79d0345f26f1394aca58a3"
+-- File opened in mode w+ --
+-- Reading entire file content, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+-- Reading file content less than max. file size, expeceted : 1000 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "4501f99f2b79d0345f26f1394aca58a3"
+-- File opened in mode w+b --
+-- Reading entire file content, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+-- Reading file content less than max. file size, expeceted : 1000 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "4501f99f2b79d0345f26f1394aca58a3"
+-- File opened in mode w+t --
+-- Reading entire file content, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+-- Reading file content less than max. file size, expeceted : 1000 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "4501f99f2b79d0345f26f1394aca58a3"
+-- File opened in mode x+ --
+-- Reading entire file content, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+-- Reading file content less than max. file size, expeceted : 1000 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "4501f99f2b79d0345f26f1394aca58a3"
+-- File opened in mode x+b --
+-- Reading entire file content, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+-- Reading file content less than max. file size, expeceted : 1000 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "4501f99f2b79d0345f26f1394aca58a3"
+-- File opened in mode x+t --
+-- Reading entire file content, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+-- Reading file content less than max. file size, expeceted : 1000 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "4501f99f2b79d0345f26f1394aca58a3"
+
+-- Testing fread() with file having content of type text --
+-- File opened in mode a+ --
+-- Reading entire file content, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "e486000c4c8452774f746a27658d87fa"
+-- Reading file content less than max. file size, expeceted : 1000 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "2ec76a59f8c44b8f8a0f5139f61bb1bd"
+-- File opened in mode a+b --
+-- Reading entire file content, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "e486000c4c8452774f746a27658d87fa"
+-- Reading file content less than max. file size, expeceted : 1000 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "2ec76a59f8c44b8f8a0f5139f61bb1bd"
+-- File opened in mode a+t --
+-- Reading entire file content, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "e486000c4c8452774f746a27658d87fa"
+-- Reading file content less than max. file size, expeceted : 1000 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "2ec76a59f8c44b8f8a0f5139f61bb1bd"
+-- File opened in mode w+ --
+-- Reading entire file content, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "e486000c4c8452774f746a27658d87fa"
+-- Reading file content less than max. file size, expeceted : 1000 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "2ec76a59f8c44b8f8a0f5139f61bb1bd"
+-- File opened in mode w+b --
+-- Reading entire file content, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "e486000c4c8452774f746a27658d87fa"
+-- Reading file content less than max. file size, expeceted : 1000 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "2ec76a59f8c44b8f8a0f5139f61bb1bd"
+-- File opened in mode w+t --
+-- Reading entire file content, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "e486000c4c8452774f746a27658d87fa"
+-- Reading file content less than max. file size, expeceted : 1000 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "2ec76a59f8c44b8f8a0f5139f61bb1bd"
+-- File opened in mode x+ --
+-- Reading entire file content, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "e486000c4c8452774f746a27658d87fa"
+-- Reading file content less than max. file size, expeceted : 1000 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "2ec76a59f8c44b8f8a0f5139f61bb1bd"
+-- File opened in mode x+b --
+-- Reading entire file content, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "e486000c4c8452774f746a27658d87fa"
+-- Reading file content less than max. file size, expeceted : 1000 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "2ec76a59f8c44b8f8a0f5139f61bb1bd"
+-- File opened in mode x+t --
+-- Reading entire file content, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "e486000c4c8452774f746a27658d87fa"
+-- Reading file content less than max. file size, expeceted : 1000 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "2ec76a59f8c44b8f8a0f5139f61bb1bd"
+
+-- Testing fread() with file having content of type text_with_new_line --
+-- File opened in mode a+ --
+-- Reading entire file content, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "b09c8026a64a88d36d4c2f17983964bb"
+-- Reading file content less than max. file size, expeceted : 1000 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "a148fa8110bbac875d84fc9d7056c0a1"
+-- File opened in mode a+b --
+-- Reading entire file content, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "b09c8026a64a88d36d4c2f17983964bb"
+-- Reading file content less than max. file size, expeceted : 1000 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "a148fa8110bbac875d84fc9d7056c0a1"
+-- File opened in mode a+t --
+-- Reading entire file content, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "b09c8026a64a88d36d4c2f17983964bb"
+-- Reading file content less than max. file size, expeceted : 1000 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "a148fa8110bbac875d84fc9d7056c0a1"
+-- File opened in mode w+ --
+-- Reading entire file content, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "b09c8026a64a88d36d4c2f17983964bb"
+-- Reading file content less than max. file size, expeceted : 1000 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "a148fa8110bbac875d84fc9d7056c0a1"
+-- File opened in mode w+b --
+-- Reading entire file content, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "b09c8026a64a88d36d4c2f17983964bb"
+-- Reading file content less than max. file size, expeceted : 1000 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "a148fa8110bbac875d84fc9d7056c0a1"
+-- File opened in mode w+t --
+-- Reading entire file content, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "b09c8026a64a88d36d4c2f17983964bb"
+-- Reading file content less than max. file size, expeceted : 1000 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "a148fa8110bbac875d84fc9d7056c0a1"
+-- File opened in mode x+ --
+-- Reading entire file content, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "b09c8026a64a88d36d4c2f17983964bb"
+-- Reading file content less than max. file size, expeceted : 1000 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "a148fa8110bbac875d84fc9d7056c0a1"
+-- File opened in mode x+b --
+-- Reading entire file content, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "b09c8026a64a88d36d4c2f17983964bb"
+-- Reading file content less than max. file size, expeceted : 1000 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "a148fa8110bbac875d84fc9d7056c0a1"
+-- File opened in mode x+t --
+-- Reading entire file content, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "b09c8026a64a88d36d4c2f17983964bb"
+-- Reading file content less than max. file size, expeceted : 1000 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "a148fa8110bbac875d84fc9d7056c0a1"
+
+-- Testing fread() with file having content of type alphanumeric --
+-- File opened in mode a+ --
+-- Reading entire file content, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "3fabd48d8eaa65c14e0d93d6880c560c"
+-- Reading file content less than max. file size, expeceted : 1000 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "a49d752f980184c7f44568e930f89c72"
+-- File opened in mode a+b --
+-- Reading entire file content, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "3fabd48d8eaa65c14e0d93d6880c560c"
+-- Reading file content less than max. file size, expeceted : 1000 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "a49d752f980184c7f44568e930f89c72"
+-- File opened in mode a+t --
+-- Reading entire file content, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "3fabd48d8eaa65c14e0d93d6880c560c"
+-- Reading file content less than max. file size, expeceted : 1000 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "a49d752f980184c7f44568e930f89c72"
+-- File opened in mode w+ --
+-- Reading entire file content, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "3fabd48d8eaa65c14e0d93d6880c560c"
+-- Reading file content less than max. file size, expeceted : 1000 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "a49d752f980184c7f44568e930f89c72"
+-- File opened in mode w+b --
+-- Reading entire file content, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "3fabd48d8eaa65c14e0d93d6880c560c"
+-- Reading file content less than max. file size, expeceted : 1000 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "a49d752f980184c7f44568e930f89c72"
+-- File opened in mode w+t --
+-- Reading entire file content, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "3fabd48d8eaa65c14e0d93d6880c560c"
+-- Reading file content less than max. file size, expeceted : 1000 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "a49d752f980184c7f44568e930f89c72"
+-- File opened in mode x+ --
+-- Reading entire file content, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "3fabd48d8eaa65c14e0d93d6880c560c"
+-- Reading file content less than max. file size, expeceted : 1000 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "a49d752f980184c7f44568e930f89c72"
+-- File opened in mode x+b --
+-- Reading entire file content, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "3fabd48d8eaa65c14e0d93d6880c560c"
+-- Reading file content less than max. file size, expeceted : 1000 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "a49d752f980184c7f44568e930f89c72"
+-- File opened in mode x+t --
+-- Reading entire file content, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(false)
+string(32) "3fabd48d8eaa65c14e0d93d6880c560c"
+-- Reading file content less than max. file size, expeceted : 1000 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 1000 bytes ... OK
+int(1000)
+bool(false)
+string(32) "a49d752f980184c7f44568e930f89c72"
+Done \ No newline at end of file
diff --git a/ext/standard/tests/file/fread_variation2.phpt b/ext/standard/tests/file/fread_variation2.phpt
new file mode 100644
index 0000000..23813a6
--- /dev/null
+++ b/ext/standard/tests/file/fread_variation2.phpt
@@ -0,0 +1,656 @@
+--TEST--
+Test fread() function : usage variations - read some/all chars, write only mode (Bug #42036)
+--FILE--
+<?php
+/*
+ Prototype: string fread ( resource $handle [, int $length] );
+ Description: reads up to length bytes from the file pointer referenced by handle.
+ Reading stops when up to length bytes have been read, EOF (end of file) is
+ reached, (for network streams) when a packet becomes available, or (after
+ opening userspace stream) when 8192 bytes have been read whichever comes first.
+*/
+
+/* Try reading some or all content of the file opened in write only mode */
+
+// include the file.inc for common functions for test
+include ("file.inc");
+
+/* Function : function check_read(resource $file_handle, int $read_size, int $expect_size)
+ Description : Read data from file of size $read_size and verifies that $expected_size no. of
+ bytes are read.
+ $file_handle : File Handle
+ $read_size : No. of bytes to be read.
+ $expect_size : Expected data length
+ Returns: returns the data read
+*/
+function check_read($file_handle, $read_size, $expect_size) {
+ // print file pointer position before read
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ // read the data of size $read_size
+ echo "Reading $read_size bytes from file, expecting $expect_size bytes ... ";
+ $data_from_file = fread($file_handle, $read_size);
+
+ // check if data read is of expected size
+ if ( strlen($data_from_file) == $expect_size)
+ echo "OK\n";
+ else
+ echo "Error reading file, total number of bytes read = ".strlen($data_from_file)."\n";
+
+ // file pointer position after read
+ var_dump( ftell($file_handle) );
+ // check if file pointer at eof()
+ var_dump( feof($file_handle) );
+ echo "\n";
+
+ return $data_from_file;
+}
+
+echo "*** Testing fread() : usage variations ***\n";
+
+$file_modes = array("a","ab","at",
+ "w","wb","wt",
+ "x","xb","xt" );
+
+$file_content_types = array("numeric","text","text_with_new_line", "alphanumeric");
+
+foreach($file_content_types as $file_content_type) {
+ echo "\n-- Testing fread() with file having content of type ". $file_content_type ." --\n";
+
+ /* open the file using $files_modes and perform fread() on it */
+ foreach($file_modes as $file_mode) {
+ if(!strstr($file_mode,"x")){
+ /* create files with $file_content_type */
+ create_files ( dirname(__FILE__), 1, $file_content_type, 0755, 1, "w", "fread_variation", 2);
+ }
+
+ $filename = dirname(__FILE__)."/fread_variation2.tmp"; // this is name of the file created by create_files()
+ echo "-- File opened in mode ".$file_mode." --\n";
+ $file_handle = fopen($filename, $file_mode);
+ if (!$file_handle) {
+ echo "Error: failed to fopen() file: $filename!";
+ exit();
+ }
+
+ if(strstr($file_mode,"w") || strstr($file_mode,"x") ) {
+ fill_file($file_handle, $file_content_type, 1024);
+ }
+
+ rewind($file_handle);
+ echo "-- Reading entire file content, expeceted : 0 bytes --\n";
+ // read from file, by giving the file actual size,
+ $data_from_file = check_read($file_handle, 1024, (strstr($file_mode, "+") ? 1024 : 0 ) );
+ // calculate the hash and dump it, if data read, expecting here no data was read
+ if ( $data_from_file != false)
+ var_dump( md5($data_from_file) );
+
+ // reading file by giving less than its size
+ echo "-- Reading file content less than max. file size, expeceted : 0 bytes --\n";
+ rewind($file_handle);
+ $data_from_file = check_read($file_handle, 1000, (strstr($file_mode, "+") ? 1000 : 0 ) );
+ // calculate the hash and dump it, if data read, expecting here no data was read
+ if ( $data_from_file != false)
+ var_dump( md5($data_from_file) );
+
+ // now close the file
+ fclose($file_handle);
+
+ // delete the file created
+ delete_file($filename); // delete file
+ } // end of inner foreach loop
+}// end of outer foreach loop
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fread() : usage variations ***
+
+-- Testing fread() with file having content of type numeric --
+-- File opened in mode a --
+-- Reading entire file content, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- Reading file content less than max. file size, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- File opened in mode ab --
+-- Reading entire file content, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- Reading file content less than max. file size, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- File opened in mode at --
+-- Reading entire file content, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- Reading file content less than max. file size, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- File opened in mode w --
+-- Reading entire file content, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- Reading file content less than max. file size, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- File opened in mode wb --
+-- Reading entire file content, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- Reading file content less than max. file size, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- File opened in mode wt --
+-- Reading entire file content, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- Reading file content less than max. file size, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- File opened in mode x --
+-- Reading entire file content, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- Reading file content less than max. file size, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- File opened in mode xb --
+-- Reading entire file content, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- Reading file content less than max. file size, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- File opened in mode xt --
+-- Reading entire file content, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- Reading file content less than max. file size, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+
+-- Testing fread() with file having content of type text --
+-- File opened in mode a --
+-- Reading entire file content, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- Reading file content less than max. file size, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- File opened in mode ab --
+-- Reading entire file content, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- Reading file content less than max. file size, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- File opened in mode at --
+-- Reading entire file content, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- Reading file content less than max. file size, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- File opened in mode w --
+-- Reading entire file content, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- Reading file content less than max. file size, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- File opened in mode wb --
+-- Reading entire file content, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- Reading file content less than max. file size, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- File opened in mode wt --
+-- Reading entire file content, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- Reading file content less than max. file size, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- File opened in mode x --
+-- Reading entire file content, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- Reading file content less than max. file size, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- File opened in mode xb --
+-- Reading entire file content, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- Reading file content less than max. file size, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- File opened in mode xt --
+-- Reading entire file content, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- Reading file content less than max. file size, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+
+-- Testing fread() with file having content of type text_with_new_line --
+-- File opened in mode a --
+-- Reading entire file content, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- Reading file content less than max. file size, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- File opened in mode ab --
+-- Reading entire file content, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- Reading file content less than max. file size, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- File opened in mode at --
+-- Reading entire file content, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- Reading file content less than max. file size, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- File opened in mode w --
+-- Reading entire file content, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- Reading file content less than max. file size, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- File opened in mode wb --
+-- Reading entire file content, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- Reading file content less than max. file size, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- File opened in mode wt --
+-- Reading entire file content, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- Reading file content less than max. file size, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- File opened in mode x --
+-- Reading entire file content, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- Reading file content less than max. file size, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- File opened in mode xb --
+-- Reading entire file content, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- Reading file content less than max. file size, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- File opened in mode xt --
+-- Reading entire file content, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- Reading file content less than max. file size, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+
+-- Testing fread() with file having content of type alphanumeric --
+-- File opened in mode a --
+-- Reading entire file content, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- Reading file content less than max. file size, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- File opened in mode ab --
+-- Reading entire file content, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- Reading file content less than max. file size, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- File opened in mode at --
+-- Reading entire file content, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- Reading file content less than max. file size, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- File opened in mode w --
+-- Reading entire file content, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- Reading file content less than max. file size, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- File opened in mode wb --
+-- Reading entire file content, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- Reading file content less than max. file size, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- File opened in mode wt --
+-- Reading entire file content, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- Reading file content less than max. file size, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- File opened in mode x --
+-- Reading entire file content, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- Reading file content less than max. file size, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- File opened in mode xb --
+-- Reading entire file content, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- Reading file content less than max. file size, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- File opened in mode xt --
+-- Reading entire file content, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1024 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+-- Reading file content less than max. file size, expeceted : 0 bytes --
+int(0)
+bool(false)
+Reading 1000 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+
+Done
diff --git a/ext/standard/tests/file/fread_variation3-win32.phpt b/ext/standard/tests/file/fread_variation3-win32.phpt
new file mode 100644
index 0000000..5491555
--- /dev/null
+++ b/ext/standard/tests/file/fread_variation3-win32.phpt
@@ -0,0 +1,498 @@
+--TEST--
+Test fread() function : usage variations - read beyond file size, read/write mode
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip...only valid for Windows');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: string fread ( resource $handle [, int $length] );
+ Description: reads up to length bytes from the file pointer referenced by handle.
+ Reading stops when up to length bytes have been read, EOF (end of file) is
+ reached, (for network streams) when a packet becomes available, or (after
+ opening userspace stream) when 8192 bytes have been read whichever comes first.
+*/
+
+// include the file.inc for common functions for test
+include ("file.inc");
+
+/* Function : function check_read(resource $file_handle, int $read_size, int $expect_size)
+ Description : Read data from file of size $read_size and verifies that $expected_size no. of
+ bytes are read.
+ $file_handle : File Handle
+ $read_size : No. of bytes to be read.
+ $expect_size : Expected data length
+ Returns: returns the data read
+*/
+function check_read($file_handle, $read_size, $expect_size) {
+ // print file pointer position before read
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ // read the data of size $read_size
+ echo "Reading $read_size bytes from file, expecting $expect_size bytes ... ";
+ $data_from_file = fread($file_handle, $read_size);
+
+ // check if data read is of expected size
+ if ( strlen($data_from_file) == $expect_size)
+ echo "OK\n";
+ else
+ echo "Error reading file, total number of bytes read = ".strlen($data_from_file)."\n";
+
+ // file pointer position after read
+ var_dump( ftell($file_handle) );
+ // check if file pointer at eof()
+ var_dump( feof($file_handle) );
+
+ return $data_from_file;
+}
+
+echo "*** Testing fread() : usage variations ***\n";
+
+$file_modes = array("a+","a+b","a+t",
+ "w+","w+b","w+t",
+ "x+","x+b","x+t");
+
+$file_content_types = array("numeric","text","text_with_new_line");
+
+foreach($file_content_types as $file_content_type) {
+ echo "\n-- Testing fread() with file having content of type ". $file_content_type ." --\n";
+
+ /* open the file using $files_modes and perform fread() on it */
+ foreach($file_modes as $file_mode) {
+ if(!strstr($file_mode,"x")){
+ /* create files with $file_content_type */
+ create_files ( dirname(__FILE__), 1, $file_content_type, 0755, 1, "w", "fread_variation", 3);
+ }
+
+ $filename = dirname(__FILE__)."/fread_variation3.tmp"; // this is name of the file created by create_files()
+ echo "-- File opened in mode ".$file_mode." --\n";
+ $file_handle = fopen($filename, $file_mode);
+ if (!$file_handle) {
+ echo "Error: failed to fopen() file: $filename!";
+ exit();
+ }
+
+ if(strstr($file_mode,"w") || strstr($file_mode,"x") ) {
+ $data_to_be_written="";
+ fill_file($file_handle, $file_content_type, 1024);
+ }
+
+ rewind($file_handle);
+
+ // read file by giving size more than its size
+ echo "-- Reading beyond filesize, expeceted : 1024 bytes --\n";
+ rewind($file_handle);
+ $data_from_file = check_read($file_handle, 1030, ( strstr($file_mode, "+") ? 1024 : 1024) );
+ if ( $data_from_file != false)
+ var_dump( md5($data_from_file) );
+
+ rewind($file_handle);
+ echo "-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --\n";
+ // try fread when file pointer at end
+ fseek($file_handle, 0, SEEK_END);
+ //reading file when file pointer at end
+ $data_from_file = check_read($file_handle, 10, 0);
+ if ( $data_from_file != false)
+ var_dump( md5($data_from_file) );
+
+ // now close the file
+ fclose($file_handle);
+
+ // delete the file created
+ delete_file($filename); // delete file
+ } // end of inner foreach loop
+}// end of outer foreach loop
+
+echo"Done\n";
+?>
+--EXPECTF--
+*** Testing fread() : usage variations ***
+
+-- Testing fread() with file having content of type numeric --
+-- File opened in mode a+ --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode a+b --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode a+t --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode w+ --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode w+b --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode w+t --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode x+ --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode x+b --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode x+t --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+
+-- Testing fread() with file having content of type text --
+-- File opened in mode a+ --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "e486000c4c8452774f746a27658d87fa"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode a+b --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "e486000c4c8452774f746a27658d87fa"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode a+t --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "e486000c4c8452774f746a27658d87fa"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode w+ --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "e486000c4c8452774f746a27658d87fa"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode w+b --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "e486000c4c8452774f746a27658d87fa"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode w+t --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "e486000c4c8452774f746a27658d87fa"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode x+ --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "e486000c4c8452774f746a27658d87fa"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode x+b --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "e486000c4c8452774f746a27658d87fa"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode x+t --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "e486000c4c8452774f746a27658d87fa"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+
+-- Testing fread() with file having content of type text_with_new_line --
+-- File opened in mode a+ --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "b09c8026a64a88d36d4c2f17983964bb"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode a+b --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "b09c8026a64a88d36d4c2f17983964bb"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode a+t --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "b09c8026a64a88d36d4c2f17983964bb"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode w+ --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "b09c8026a64a88d36d4c2f17983964bb"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode w+b --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "b09c8026a64a88d36d4c2f17983964bb"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode w+t --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "b09c8026a64a88d36d4c2f17983964bb"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1137)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1137)
+bool(true)
+-- File opened in mode x+ --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "b09c8026a64a88d36d4c2f17983964bb"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode x+b --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "b09c8026a64a88d36d4c2f17983964bb"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode x+t --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "b09c8026a64a88d36d4c2f17983964bb"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1137)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1137)
+bool(true)
+Done \ No newline at end of file
diff --git a/ext/standard/tests/file/fread_variation3.phpt b/ext/standard/tests/file/fread_variation3.phpt
new file mode 100644
index 0000000..949e7b8
--- /dev/null
+++ b/ext/standard/tests/file/fread_variation3.phpt
@@ -0,0 +1,498 @@
+--TEST--
+Test fread() function : usage variations - read beyond file size, read/write mode
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip...Not valid for Windows');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: string fread ( resource $handle [, int $length] );
+ Description: reads up to length bytes from the file pointer referenced by handle.
+ Reading stops when up to length bytes have been read, EOF (end of file) is
+ reached, (for network streams) when a packet becomes available, or (after
+ opening userspace stream) when 8192 bytes have been read whichever comes first.
+*/
+
+// include the file.inc for common functions for test
+include ("file.inc");
+
+/* Function : function check_read(resource $file_handle, int $read_size, int $expect_size)
+ Description : Read data from file of size $read_size and verifies that $expected_size no. of
+ bytes are read.
+ $file_handle : File Handle
+ $read_size : No. of bytes to be read.
+ $expect_size : Expected data length
+ Returns: returns the data read
+*/
+function check_read($file_handle, $read_size, $expect_size) {
+ // print file pointer position before read
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ // read the data of size $read_size
+ echo "Reading $read_size bytes from file, expecting $expect_size bytes ... ";
+ $data_from_file = fread($file_handle, $read_size);
+
+ // check if data read is of expected size
+ if ( strlen($data_from_file) == $expect_size)
+ echo "OK\n";
+ else
+ echo "Error reading file, total number of bytes read = ".strlen($data_from_file)."\n";
+
+ // file pointer position after read
+ var_dump( ftell($file_handle) );
+ // check if file pointer at eof()
+ var_dump( feof($file_handle) );
+
+ return $data_from_file;
+}
+
+echo "*** Testing fread() : usage variations ***\n";
+
+$file_modes = array("a+","a+b","a+t",
+ "w+","w+b","w+t",
+ "x+","x+b","x+t");
+
+$file_content_types = array("numeric","text","text_with_new_line");
+
+foreach($file_content_types as $file_content_type) {
+ echo "\n-- Testing fread() with file having content of type ". $file_content_type ." --\n";
+
+ /* open the file using $files_modes and perform fread() on it */
+ foreach($file_modes as $file_mode) {
+ if(!strstr($file_mode,"x")){
+ /* create files with $file_content_type */
+ create_files ( dirname(__FILE__), 1, $file_content_type, 0755, 1, "w", "fread_variation", 3);
+ }
+
+ $filename = dirname(__FILE__)."/fread_variation3.tmp"; // this is name of the file created by create_files()
+ echo "-- File opened in mode ".$file_mode." --\n";
+ $file_handle = fopen($filename, $file_mode);
+ if (!$file_handle) {
+ echo "Error: failed to fopen() file: $filename!";
+ exit();
+ }
+
+ if(strstr($file_mode,"w") || strstr($file_mode,"x") ) {
+ $data_to_be_written="";
+ fill_file($file_handle, $file_content_type, 1024);
+ }
+
+ rewind($file_handle);
+
+ // read file by giving size more than its size
+ echo "-- Reading beyond filesize, expeceted : 1024 bytes --\n";
+ rewind($file_handle);
+ $data_from_file = check_read($file_handle, 1030, ( strstr($file_mode, "+") ? 1024 : 1024) );
+ if ( $data_from_file != false)
+ var_dump( md5($data_from_file) );
+
+ rewind($file_handle);
+ echo "-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --\n";
+ // try fread when file pointer at end
+ fseek($file_handle, 0, SEEK_END);
+ //reading file when file pointer at end
+ $data_from_file = check_read($file_handle, 10, 0);
+ if ( $data_from_file != false)
+ var_dump( md5($data_from_file) );
+
+ // now close the file
+ fclose($file_handle);
+
+ // delete the file created
+ delete_file($filename); // delete file
+ } // end of inner foreach loop
+}// end of outer foreach loop
+
+echo"Done\n";
+?>
+--EXPECTF--
+*** Testing fread() : usage variations ***
+
+-- Testing fread() with file having content of type numeric --
+-- File opened in mode a+ --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode a+b --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode a+t --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode w+ --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode w+b --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode w+t --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode x+ --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode x+b --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode x+t --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+
+-- Testing fread() with file having content of type text --
+-- File opened in mode a+ --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "e486000c4c8452774f746a27658d87fa"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode a+b --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "e486000c4c8452774f746a27658d87fa"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode a+t --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "e486000c4c8452774f746a27658d87fa"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode w+ --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "e486000c4c8452774f746a27658d87fa"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode w+b --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "e486000c4c8452774f746a27658d87fa"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode w+t --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "e486000c4c8452774f746a27658d87fa"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode x+ --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "e486000c4c8452774f746a27658d87fa"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode x+b --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "e486000c4c8452774f746a27658d87fa"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode x+t --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "e486000c4c8452774f746a27658d87fa"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+
+-- Testing fread() with file having content of type text_with_new_line --
+-- File opened in mode a+ --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "b09c8026a64a88d36d4c2f17983964bb"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode a+b --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "b09c8026a64a88d36d4c2f17983964bb"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode a+t --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "b09c8026a64a88d36d4c2f17983964bb"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode w+ --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "b09c8026a64a88d36d4c2f17983964bb"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode w+b --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "b09c8026a64a88d36d4c2f17983964bb"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode w+t --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "b09c8026a64a88d36d4c2f17983964bb"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode x+ --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "b09c8026a64a88d36d4c2f17983964bb"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode x+b --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "b09c8026a64a88d36d4c2f17983964bb"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+-- File opened in mode x+t --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 1024 bytes ... OK
+int(1024)
+bool(true)
+string(32) "b09c8026a64a88d36d4c2f17983964bb"
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(true)
+Done \ No newline at end of file
diff --git a/ext/standard/tests/file/fread_variation4-win32.phpt b/ext/standard/tests/file/fread_variation4-win32.phpt
new file mode 100644
index 0000000..77d733a
--- /dev/null
+++ b/ext/standard/tests/file/fread_variation4-win32.phpt
@@ -0,0 +1,469 @@
+--TEST--
+Test fread() function : usage variations - read beyond file size, write only mode
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip...only valid for Windows');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: string fread ( resource $handle [, int $length] );
+ Description: reads up to length bytes from the file pointer referenced by handle.
+ Reading stops when up to length bytes have been read, EOF (end of file) is
+ reached, (for network streams) when a packet becomes available, or (after
+ opening userspace stream) when 8192 bytes have been read whichever comes first.
+*/
+
+// include the file.inc for common functions for test
+include ("file.inc");
+
+/* Function : function check_read(resource $file_handle, int $read_size, int $expect_size)
+ Description : Read data from file of size $read_size and verifies that $expected_size no. of
+ bytes are read.
+ $file_handle : File Handle
+ $read_size : No. of bytes to be read.
+ $expect_size : Expected data length
+ Returns: returns the data read
+*/
+function check_read($file_handle, $read_size, $expect_size) {
+ // print file pointer position before read
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ // read the data of size $read_size
+ echo "Reading $read_size bytes from file, expecting $expect_size bytes ... ";
+ $data_from_file = fread($file_handle, $read_size);
+
+ // check if data read is of expected size
+ if ( strlen($data_from_file) == $expect_size)
+ echo "OK\n";
+ else
+ echo "Error reading file, total number of bytes read = ".strlen($data_from_file)."\n";
+
+ // file pointer position after read
+ var_dump( ftell($file_handle) );
+ // check if file pointer at eof()
+ var_dump( feof($file_handle) );
+
+ return $data_from_file;
+}
+
+echo "*** Testing fread() : usage variations ***\n";
+
+$file_modes = array("a","ab","at",
+ "w","wb","wt",
+ "x","xb","xt" );
+
+$file_content_types = array("numeric","text","text_with_new_line");
+
+foreach($file_content_types as $file_content_type) {
+ echo "\n-- Testing fread() with file having content of type ". $file_content_type ." --\n";
+
+ /* open the file using $files_modes and perform fread() on it */
+ foreach($file_modes as $file_mode) {
+ if(!strstr($file_mode,"x")){
+ /* create files with $file_content_type */
+ create_files ( dirname(__FILE__), 1, $file_content_type, 0755, 1, "w", "fread_variation", 4);
+ }
+
+ $filename = dirname(__FILE__)."/fread_variation4.tmp"; // this is name of the file created by create_files()
+ echo "-- File opened in mode ".$file_mode." --\n";
+ $file_handle = fopen($filename, $file_mode);
+ if (!$file_handle) {
+ echo "Error: failed to fopen() file: $filename!";
+ exit();
+ }
+
+ if(strstr($file_mode,"w") || strstr($file_mode,"x") ) {
+ fill_file($file_handle, $file_content_type, 1024);
+ }
+
+ rewind($file_handle);
+ echo "-- Reading beyond filesize, expeceted : 1024 bytes --\n";
+ // read file by giving size more than its size
+ rewind($file_handle);
+ $data_from_file = check_read($file_handle, 1030, ( strstr($file_mode, "+") ? 1024 : 0) );
+ if ( $data_from_file != false)
+ var_dump( md5($data_from_file) );
+
+ echo "-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --\n";
+ rewind($file_handle);
+ // try fread when file pointer at end
+ fseek($file_handle, 0, SEEK_END);
+ //reading file when file pointer at end
+ $data_from_file = check_read($file_handle, 10, 0);
+ if ( $data_from_file != false)
+ var_dump( md5($data_from_file) );
+
+ // now close the file
+ fclose($file_handle);
+
+ // delete the file created
+ delete_file($filename); // delete file
+ } // end of inner foreach loop
+}// end of outer foreach loop
+
+echo"Done\n";
+?>
+--EXPECTF--
+*** Testing fread() : usage variations ***
+
+-- Testing fread() with file having content of type numeric --
+-- File opened in mode a --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode ab --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode at --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode w --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode wb --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode wt --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode x --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode xb --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode xt --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+
+-- Testing fread() with file having content of type text --
+-- File opened in mode a --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode ab --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode at --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode w --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode wb --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode wt --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode x --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode xb --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode xt --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+
+-- Testing fread() with file having content of type text_with_new_line --
+-- File opened in mode a --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode ab --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode at --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode w --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode wb --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode wt --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1137)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1137)
+bool(false)
+-- File opened in mode x --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode xb --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode xt --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1137)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1137)
+bool(false)
+Done \ No newline at end of file
diff --git a/ext/standard/tests/file/fread_variation4.phpt b/ext/standard/tests/file/fread_variation4.phpt
new file mode 100644
index 0000000..fdff8de
--- /dev/null
+++ b/ext/standard/tests/file/fread_variation4.phpt
@@ -0,0 +1,469 @@
+--TEST--
+Test fread() function : usage variations - read beyond file size, write only mode
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. Not valid for Windows');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: string fread ( resource $handle [, int $length] );
+ Description: reads up to length bytes from the file pointer referenced by handle.
+ Reading stops when up to length bytes have been read, EOF (end of file) is
+ reached, (for network streams) when a packet becomes available, or (after
+ opening userspace stream) when 8192 bytes have been read whichever comes first.
+*/
+
+// include the file.inc for common functions for test
+include ("file.inc");
+
+/* Function : function check_read(resource $file_handle, int $read_size, int $expect_size)
+ Description : Read data from file of size $read_size and verifies that $expected_size no. of
+ bytes are read.
+ $file_handle : File Handle
+ $read_size : No. of bytes to be read.
+ $expect_size : Expected data length
+ Returns: returns the data read
+*/
+function check_read($file_handle, $read_size, $expect_size) {
+ // print file pointer position before read
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+
+ // read the data of size $read_size
+ echo "Reading $read_size bytes from file, expecting $expect_size bytes ... ";
+ $data_from_file = fread($file_handle, $read_size);
+
+ // check if data read is of expected size
+ if ( strlen($data_from_file) == $expect_size)
+ echo "OK\n";
+ else
+ echo "Error reading file, total number of bytes read = ".strlen($data_from_file)."\n";
+
+ // file pointer position after read
+ var_dump( ftell($file_handle) );
+ // check if file pointer at eof()
+ var_dump( feof($file_handle) );
+
+ return $data_from_file;
+}
+
+echo "*** Testing fread() : usage variations ***\n";
+
+$file_modes = array("a","ab","at",
+ "w","wb","wt",
+ "x","xb","xt" );
+
+$file_content_types = array("numeric","text","text_with_new_line");
+
+foreach($file_content_types as $file_content_type) {
+ echo "\n-- Testing fread() with file having content of type ". $file_content_type ." --\n";
+
+ /* open the file using $files_modes and perform fread() on it */
+ foreach($file_modes as $file_mode) {
+ if(!strstr($file_mode,"x")){
+ /* create files with $file_content_type */
+ create_files ( dirname(__FILE__), 1, $file_content_type, 0755, 1, "w", "fread_variation", 4);
+ }
+
+ $filename = dirname(__FILE__)."/fread_variation4.tmp"; // this is name of the file created by create_files()
+ echo "-- File opened in mode ".$file_mode." --\n";
+ $file_handle = fopen($filename, $file_mode);
+ if (!$file_handle) {
+ echo "Error: failed to fopen() file: $filename!";
+ exit();
+ }
+
+ if(strstr($file_mode,"w") || strstr($file_mode,"x") ) {
+ fill_file($file_handle, $file_content_type, 1024);
+ }
+
+ rewind($file_handle);
+ echo "-- Reading beyond filesize, expeceted : 1024 bytes --\n";
+ // read file by giving size more than its size
+ rewind($file_handle);
+ $data_from_file = check_read($file_handle, 1030, ( strstr($file_mode, "+") ? 1024 : 0) );
+ if ( $data_from_file != false)
+ var_dump( md5($data_from_file) );
+
+ echo "-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --\n";
+ rewind($file_handle);
+ // try fread when file pointer at end
+ fseek($file_handle, 0, SEEK_END);
+ //reading file when file pointer at end
+ $data_from_file = check_read($file_handle, 10, 0);
+ if ( $data_from_file != false)
+ var_dump( md5($data_from_file) );
+
+ // now close the file
+ fclose($file_handle);
+
+ // delete the file created
+ delete_file($filename); // delete file
+ } // end of inner foreach loop
+}// end of outer foreach loop
+
+echo"Done\n";
+?>
+--EXPECTF--
+*** Testing fread() : usage variations ***
+
+-- Testing fread() with file having content of type numeric --
+-- File opened in mode a --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode ab --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode at --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode w --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode wb --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode wt --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode x --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode xb --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode xt --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+
+-- Testing fread() with file having content of type text --
+-- File opened in mode a --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode ab --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode at --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode w --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode wb --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode wt --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode x --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode xb --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode xt --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+
+-- Testing fread() with file having content of type text_with_new_line --
+-- File opened in mode a --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode ab --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode at --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode w --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode wb --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode wt --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode x --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode xb --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+-- File opened in mode xt --
+-- Reading beyond filesize, expeceted : 1024 bytes --
+int(0)
+bool(false)
+Reading 1030 bytes from file, expecting 0 bytes ... OK
+int(0)
+bool(false)
+-- Reading beyond filesize when file pointer pointing to EOF, expeceted : 0 bytes --
+int(1024)
+bool(false)
+Reading 10 bytes from file, expecting 0 bytes ... OK
+int(1024)
+bool(false)
+Done \ No newline at end of file
diff --git a/ext/standard/tests/file/fscanf.phpt b/ext/standard/tests/file/fscanf.phpt
new file mode 100644
index 0000000..c37bdeb
--- /dev/null
+++ b/ext/standard/tests/file/fscanf.phpt
@@ -0,0 +1,100 @@
+--TEST--
+fscanf() tests
+--FILE--
+<?php
+
+$filename = dirname(__FILE__)."/fscanf.dat";
+
+var_dump(fscanf());
+var_dump(fscanf(array()));
+var_dump(fscanf(array(), array(), new stdclass));
+
+file_put_contents($filename, "data");
+
+$fp = fopen($filename, "rt");
+var_dump(fscanf($fp, "%d", $v));
+var_dump($v);
+fclose($fp);
+
+$fp = fopen($filename, "rt");
+var_dump(fscanf($fp, "%s", $v));
+var_dump($v);
+fclose($fp);
+
+$fp = fopen($filename, "rt");
+var_dump(fscanf($fp, "%s", $v, $v1));
+var_dump($v);
+var_dump($v1);
+fclose($fp);
+
+$v = array();
+$v1 = array();
+$fp = fopen($filename, "rt");
+var_dump(fscanf($fp, "", $v, $v1));
+var_dump($v);
+var_dump($v1);
+fclose($fp);
+
+$v = array();
+$v1 = array();
+$fp = fopen($filename, "rt");
+var_dump(fscanf($fp, "%.a", $v, $v1));
+var_dump($v);
+var_dump($v1);
+fclose($fp);
+
+@unlink($filename);
+touch($filename);
+
+$fp = fopen($filename, "rt");
+var_dump(fscanf($fp, "%s", $v));
+var_dump($v);
+fclose($fp);
+
+file_put_contents($filename, "data");
+
+$fp = fopen($filename, "rt");
+var_dump(fscanf($fp, "%s%d", $v));
+
+@unlink($filename);
+echo "Done\n";
+?>
+--EXPECTF--
+Warning: fscanf() expects at least 2 parameters, 0 given in %s on line %d
+NULL
+
+Warning: fscanf() expects at least 2 parameters, 1 given in %s on line %d
+NULL
+
+Warning: fscanf() expects parameter 1 to be resource, array given in %s on line %d
+NULL
+int(0)
+NULL
+int(1)
+string(4) "data"
+
+Warning: fscanf(): Variable is not assigned by any conversion specifiers in %s on line %d
+int(-1)
+string(4) "data"
+NULL
+
+Warning: fscanf(): Variable is not assigned by any conversion specifiers in %s on line %d
+int(-1)
+array(0) {
+}
+array(0) {
+}
+
+Warning: fscanf(): Bad scan conversion character "." in %s on line %d
+int(-1)
+array(0) {
+}
+array(0) {
+}
+bool(false)
+array(0) {
+}
+
+Warning: fscanf(): Different numbers of variable names and field specifiers in %s on line %d
+int(-1)
+Done
diff --git a/ext/standard/tests/file/fscanf_error.phpt b/ext/standard/tests/file/fscanf_error.phpt
new file mode 100644
index 0000000..85c0ac4
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_error.phpt
@@ -0,0 +1,99 @@
+--TEST--
+Test fscanf() function: error conditions
+
+--FILE--
+<?php
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+echo "*** Testing fscanf() for error conditions ***\n";
+$file_path = dirname(__FILE__);
+
+$filename = "$file_path/fscanf_error.tmp";
+$file_handle = fopen($filename, 'w');
+if ($file_handle == false)
+ exit("Error:failed to open file $filename");
+fwrite($file_handle, "hello world");
+fclose($file_handle);
+
+// zero argument
+var_dump( fscanf() );
+
+// single argument
+$file_handle = fopen($filename, 'r');
+if ($file_handle == false)
+ exit("Error:failed to open file $filename");
+var_dump( fscanf($file_handle) );
+fclose($file_handle);
+
+// invalid file handle
+var_dump( fscanf($file_handle, "%s") );
+
+// number of formats in format strings not matching the no of variables
+$file_handle = fopen($filename, 'r');
+if ($file_handle == false)
+ exit("Error:failed to open file $filename");
+var_dump( fscanf($file_handle, "%d%s%f", $int_var, $string_var) );
+fclose($file_handle);
+
+// different invalid format strings
+$invalid_formats = array( $undefined_var, undefined_constant,
+ "%", "%h", "%.", "%d%m"
+ );
+
+
+// looping to use various invalid formats with fscanf()
+foreach($invalid_formats as $format) {
+ $file_handle = fopen($filename, 'r');
+ if ($file_handle == false)
+ exit("Error:failed to open file $filename");
+ var_dump( fscanf($file_handle, $format) );
+ fclose($file_handle);
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_error.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Testing fscanf() for error conditions ***
+
+Warning: fscanf() expects at least 2 parameters, 0 given in %s on line %d
+NULL
+
+Warning: fscanf() expects at least 2 parameters, 1 given in %s on line %d
+NULL
+
+Warning: fscanf(): %d is not a valid File-Handle resource in %s on line %d
+bool(false)
+
+Warning: fscanf(): Different numbers of variable names and field specifiers in %s on line %d
+int(-1)
+
+Notice: Undefined variable: undefined_var in %s on line %d
+
+Notice: Use of undefined constant undefined_constant - assumed 'undefined_constant' in %s on line %d
+array(0) {
+}
+array(0) {
+}
+
+Warning: fscanf(): Bad scan conversion character " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character "." in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character "m" in %s on line %d
+NULL
+
+*** Done ***
diff --git a/ext/standard/tests/file/fscanf_variation1.phpt b/ext/standard/tests/file/fscanf_variation1.phpt
new file mode 100644
index 0000000..b0c41e5
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation1.phpt
@@ -0,0 +1,50 @@
+--TEST--
+Test fscanf() function: usage variations - return type without third argument
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* test fscanf() for its return type */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Testing fscanf(): for its return type without third argument ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation1.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+@fwrite($file_handle, "hello_world ");
+@fwrite($file_handle, 12345);
+fclose($file_handle);
+
+// open file for reading
+$file_handle = fopen($filename, "r");
+// capturing the return value from fscanf() called without third argument
+$return_value = fscanf($file_handle, "%s");
+var_dump( is_array($return_value), $return_value); // return type is an array
+fclose($file_handle);
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation1.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Testing fscanf(): for its return type without third argument ***
+bool(true)
+array(1) {
+ [0]=>
+ string(11) "hello_world"
+}
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation10.phpt b/ext/standard/tests/file/fscanf_variation10.phpt
new file mode 100644
index 0000000..a46c112
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation10.phpt
@@ -0,0 +1,222 @@
+--TEST--
+Test fscanf() function: usage variations - float formats with resource
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan resource type using different float format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different float format types with resource ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation10.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+
+// resource type variable
+$fp = fopen (__FILE__, "r");
+$dfp = opendir ( dirname(__FILE__) );
+
+// array of resource types
+$resource_types = array (
+ $fp,
+ $dfp
+);
+
+$float_formats = array( "%f",
+ "%hf", "%lf", "%Lf",
+ " %f", "%f ", "% f",
+ "\t%f", "\n%f", "%4f",
+ "%30f", "%[0-9]", "%*f"
+ );
+
+$counter = 1;
+
+// writing to the file
+foreach($resource_types as $value) {
+ @fprintf($file_handle, $value);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different formats formats
+foreach($float_formats as $float_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$float_format) );
+ }
+ $counter++;
+}
+
+// closing the resources
+fclose($fp);
+closedir($dfp);
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation10.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different float format types with resource ***
+
+-- iteration 1 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 2 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 3 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 4 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 5 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 6 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 9 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 10 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 11 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 13 --
+array(0) {
+}
+array(0) {
+}
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation11.phpt b/ext/standard/tests/file/fscanf_variation11.phpt
new file mode 100644
index 0000000..27de2ae
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation11.phpt
@@ -0,0 +1,713 @@
+--TEST--
+Test fscanf() function: usage variations - float formats with arrays
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan arrays using different float format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different float format types with arrays ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation11.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+// array types
+$array_types = array (
+ 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)
+);
+
+$float_formats = array( "%f",
+ "%hf", "%lf", "%Lf",
+ " %f", "%f ", "% f",
+ "\t%f", "\n%f", "%4f",
+ "%30f", "%[0-9]", "%*f"
+ );
+
+$counter = 1;
+
+// writing to the file
+foreach($array_types as $value) {
+ @fprintf($file_handle, $value);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different float formats
+foreach($float_formats as $float_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$float_format) );
+ }
+ $counter++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation11.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different float format types with arrays ***
+
+-- iteration 1 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 2 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 3 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 4 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 5 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 6 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 9 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 10 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 11 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 13 --
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation12.phpt b/ext/standard/tests/file/fscanf_variation12.phpt
new file mode 100644
index 0000000..33bfb67
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation12.phpt
@@ -0,0 +1,946 @@
+--TEST--
+Test fscanf() function: usage variations - float formats with strings
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan strings using different float format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different float format types with strings ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation12.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+// array of strings
+$strings = array (
+ "",
+ '',
+ "0",
+ '0',
+ "1",
+ '1',
+ "\x01",
+ '\x01',
+ "\01",
+ '\01',
+ 'string',
+ "string",
+ "true",
+ "FALSE",
+ 'false',
+ 'TRUE',
+ "NULL",
+ 'null'
+);
+
+$float_formats = array( "%f", "%hf", "%lf", "%Lf", " %f", "%f ", "% f", "\t%f", "\n%f", "%4f", "%30f", "%[0-9]", "%*f");
+
+$counter = 1;
+
+// writing to the file
+foreach($strings as $string) {
+ @fprintf($file_handle, $string);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different float formats
+foreach($float_formats as $float_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$float_format) );
+ }
+ $counter++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation12.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different float format types with strings ***
+
+-- iteration 1 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 2 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 3 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 4 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 5 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 6 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 9 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 10 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 11 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 13 --
+NULL
+NULL
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation13.phpt b/ext/standard/tests/file/fscanf_variation13.phpt
new file mode 100644
index 0000000..49525b4
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation13.phpt
@@ -0,0 +1,246 @@
+--TEST--
+Test fscanf() function: usage variations - float formats with boolean
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan boolean data using different float format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different float format types with boolean data ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation13.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+// array of boolean types
+$bool_types = array (
+ true,
+ false,
+ TRUE,
+ FALSE,
+);
+
+$float_formats = array( "%f", "%hf", "%lf", "%Lf", " %f", "%f ", "% f", "\t%f", "\n%f", "%4f", "%30f", "%[0-9]", "%*f");
+
+$counter = 1;
+
+// writing to the file
+foreach($bool_types as $value) {
+ @fprintf($file_handle, $value);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different float formats
+foreach($float_formats as $float_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$float_format) );
+ }
+ $counter++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation13.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different float format types with boolean data ***
+
+-- iteration 1 --
+array(1) {
+ [0]=>
+ float(1)
+}
+NULL
+array(1) {
+ [0]=>
+ float(1)
+}
+NULL
+bool(false)
+
+-- iteration 2 --
+array(1) {
+ [0]=>
+ float(1)
+}
+NULL
+array(1) {
+ [0]=>
+ float(1)
+}
+NULL
+bool(false)
+
+-- iteration 3 --
+array(1) {
+ [0]=>
+ float(1)
+}
+NULL
+array(1) {
+ [0]=>
+ float(1)
+}
+NULL
+bool(false)
+
+-- iteration 4 --
+array(1) {
+ [0]=>
+ float(1)
+}
+NULL
+array(1) {
+ [0]=>
+ float(1)
+}
+NULL
+bool(false)
+
+-- iteration 5 --
+array(1) {
+ [0]=>
+ float(1)
+}
+NULL
+array(1) {
+ [0]=>
+ float(1)
+}
+NULL
+bool(false)
+
+-- iteration 6 --
+array(1) {
+ [0]=>
+ float(1)
+}
+NULL
+array(1) {
+ [0]=>
+ float(1)
+}
+NULL
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+array(1) {
+ [0]=>
+ float(1)
+}
+NULL
+array(1) {
+ [0]=>
+ float(1)
+}
+NULL
+bool(false)
+
+-- iteration 9 --
+array(1) {
+ [0]=>
+ float(1)
+}
+NULL
+array(1) {
+ [0]=>
+ float(1)
+}
+NULL
+bool(false)
+
+-- iteration 10 --
+array(1) {
+ [0]=>
+ float(1)
+}
+NULL
+array(1) {
+ [0]=>
+ float(1)
+}
+NULL
+bool(false)
+
+-- iteration 11 --
+array(1) {
+ [0]=>
+ float(1)
+}
+NULL
+array(1) {
+ [0]=>
+ float(1)
+}
+NULL
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 13 --
+array(0) {
+}
+NULL
+array(0) {
+}
+NULL
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation14.phpt b/ext/standard/tests/file/fscanf_variation14.phpt
new file mode 100644
index 0000000..2b497c9
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation14.phpt
@@ -0,0 +1,1079 @@
+--TEST--
+Test fscanf() function: usage variations - string formats with strings
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan different strings using different string format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different string format types with different string ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation14.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+// different valid strings
+
+/* string created using Heredoc (<<<) */
+$heredoc_string = <<<EOT
+This is string defined
+using heredoc.
+EOT;
+/* heredoc string with only numerics */
+$heredoc_numeric_string = <<<EOT
+123456 3993
+4849 string
+EOT;
+/* null heardoc string */
+$heredoc_empty_string = <<<EOT
+EOT;
+$heredoc_null_string = <<<EOT
+NULL
+EOT;
+
+$valid_strings = array(
+ "",
+ " ",
+ '',
+ ' ',
+ "string",
+ 'string',
+ "NULL",
+ 'null',
+ "FALSE",
+ 'true',
+ "\x0b",
+ "\0",
+ '\0',
+ '\060',
+ "\070",
+ "0x55F",
+ "055",
+ "@#$#$%%$^^$%^%^$^&",
+ $heredoc_string,
+ $heredoc_numeric_string,
+ $heredoc_empty_string,
+ $heredoc_null_string
+);
+
+// various string formats
+$string_formats = array( "%s",
+ "%hs", "%ls", "%Ls",
+ " %s", "%s ", "% s",
+ "\t%s", "\n%s", "%4s",
+ "%30s", "%[a-zA-Z0-9]", "%*s"
+ );
+
+$counter = 1;
+
+// writing to the file
+foreach($valid_strings as $string) {
+ @fprintf($file_handle, $string);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different string formats
+foreach($string_formats as $string_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$string_format) );
+ }
+ $counter++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation14.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different string format types with different string ***
+
+-- iteration 1 --
+NULL
+NULL
+NULL
+NULL
+array(1) {
+ [0]=>
+ string(6) "string"
+}
+array(1) {
+ [0]=>
+ string(6) "string"
+}
+array(1) {
+ [0]=>
+ string(4) "NULL"
+}
+array(1) {
+ [0]=>
+ string(4) "null"
+}
+array(1) {
+ [0]=>
+ string(5) "FALSE"
+}
+array(1) {
+ [0]=>
+ string(4) "true"
+}
+NULL
+NULL
+array(1) {
+ [0]=>
+ string(2) "\0"
+}
+array(1) {
+ [0]=>
+ string(4) "\060"
+}
+array(1) {
+ [0]=>
+ string(1) "8"
+}
+array(1) {
+ [0]=>
+ string(5) "0x55F"
+}
+array(1) {
+ [0]=>
+ string(3) "055"
+}
+NULL
+array(1) {
+ [0]=>
+ string(4) "This"
+}
+array(1) {
+ [0]=>
+ string(5) "using"
+}
+array(1) {
+ [0]=>
+ string(6) "123456"
+}
+array(1) {
+ [0]=>
+ string(4) "4849"
+}
+NULL
+array(1) {
+ [0]=>
+ string(4) "NULL"
+}
+bool(false)
+
+-- iteration 2 --
+NULL
+NULL
+NULL
+NULL
+array(1) {
+ [0]=>
+ string(6) "string"
+}
+array(1) {
+ [0]=>
+ string(6) "string"
+}
+array(1) {
+ [0]=>
+ string(4) "NULL"
+}
+array(1) {
+ [0]=>
+ string(4) "null"
+}
+array(1) {
+ [0]=>
+ string(5) "FALSE"
+}
+array(1) {
+ [0]=>
+ string(4) "true"
+}
+NULL
+NULL
+array(1) {
+ [0]=>
+ string(2) "\0"
+}
+array(1) {
+ [0]=>
+ string(4) "\060"
+}
+array(1) {
+ [0]=>
+ string(1) "8"
+}
+array(1) {
+ [0]=>
+ string(5) "0x55F"
+}
+array(1) {
+ [0]=>
+ string(3) "055"
+}
+NULL
+array(1) {
+ [0]=>
+ string(4) "This"
+}
+array(1) {
+ [0]=>
+ string(5) "using"
+}
+array(1) {
+ [0]=>
+ string(6) "123456"
+}
+array(1) {
+ [0]=>
+ string(4) "4849"
+}
+NULL
+array(1) {
+ [0]=>
+ string(4) "NULL"
+}
+bool(false)
+
+-- iteration 3 --
+NULL
+NULL
+NULL
+NULL
+array(1) {
+ [0]=>
+ string(6) "string"
+}
+array(1) {
+ [0]=>
+ string(6) "string"
+}
+array(1) {
+ [0]=>
+ string(4) "NULL"
+}
+array(1) {
+ [0]=>
+ string(4) "null"
+}
+array(1) {
+ [0]=>
+ string(5) "FALSE"
+}
+array(1) {
+ [0]=>
+ string(4) "true"
+}
+NULL
+NULL
+array(1) {
+ [0]=>
+ string(2) "\0"
+}
+array(1) {
+ [0]=>
+ string(4) "\060"
+}
+array(1) {
+ [0]=>
+ string(1) "8"
+}
+array(1) {
+ [0]=>
+ string(5) "0x55F"
+}
+array(1) {
+ [0]=>
+ string(3) "055"
+}
+NULL
+array(1) {
+ [0]=>
+ string(4) "This"
+}
+array(1) {
+ [0]=>
+ string(5) "using"
+}
+array(1) {
+ [0]=>
+ string(6) "123456"
+}
+array(1) {
+ [0]=>
+ string(4) "4849"
+}
+NULL
+array(1) {
+ [0]=>
+ string(4) "NULL"
+}
+bool(false)
+
+-- iteration 4 --
+NULL
+NULL
+NULL
+NULL
+array(1) {
+ [0]=>
+ string(6) "string"
+}
+array(1) {
+ [0]=>
+ string(6) "string"
+}
+array(1) {
+ [0]=>
+ string(4) "NULL"
+}
+array(1) {
+ [0]=>
+ string(4) "null"
+}
+array(1) {
+ [0]=>
+ string(5) "FALSE"
+}
+array(1) {
+ [0]=>
+ string(4) "true"
+}
+NULL
+NULL
+array(1) {
+ [0]=>
+ string(2) "\0"
+}
+array(1) {
+ [0]=>
+ string(4) "\060"
+}
+array(1) {
+ [0]=>
+ string(1) "8"
+}
+array(1) {
+ [0]=>
+ string(5) "0x55F"
+}
+array(1) {
+ [0]=>
+ string(3) "055"
+}
+NULL
+array(1) {
+ [0]=>
+ string(4) "This"
+}
+array(1) {
+ [0]=>
+ string(5) "using"
+}
+array(1) {
+ [0]=>
+ string(6) "123456"
+}
+array(1) {
+ [0]=>
+ string(4) "4849"
+}
+NULL
+array(1) {
+ [0]=>
+ string(4) "NULL"
+}
+bool(false)
+
+-- iteration 5 --
+NULL
+NULL
+NULL
+NULL
+array(1) {
+ [0]=>
+ string(6) "string"
+}
+array(1) {
+ [0]=>
+ string(6) "string"
+}
+array(1) {
+ [0]=>
+ string(4) "NULL"
+}
+array(1) {
+ [0]=>
+ string(4) "null"
+}
+array(1) {
+ [0]=>
+ string(5) "FALSE"
+}
+array(1) {
+ [0]=>
+ string(4) "true"
+}
+NULL
+NULL
+array(1) {
+ [0]=>
+ string(2) "\0"
+}
+array(1) {
+ [0]=>
+ string(4) "\060"
+}
+array(1) {
+ [0]=>
+ string(1) "8"
+}
+array(1) {
+ [0]=>
+ string(5) "0x55F"
+}
+array(1) {
+ [0]=>
+ string(3) "055"
+}
+NULL
+array(1) {
+ [0]=>
+ string(4) "This"
+}
+array(1) {
+ [0]=>
+ string(5) "using"
+}
+array(1) {
+ [0]=>
+ string(6) "123456"
+}
+array(1) {
+ [0]=>
+ string(4) "4849"
+}
+NULL
+array(1) {
+ [0]=>
+ string(4) "NULL"
+}
+bool(false)
+
+-- iteration 6 --
+NULL
+NULL
+NULL
+NULL
+array(1) {
+ [0]=>
+ string(6) "string"
+}
+array(1) {
+ [0]=>
+ string(6) "string"
+}
+array(1) {
+ [0]=>
+ string(4) "NULL"
+}
+array(1) {
+ [0]=>
+ string(4) "null"
+}
+array(1) {
+ [0]=>
+ string(5) "FALSE"
+}
+array(1) {
+ [0]=>
+ string(4) "true"
+}
+NULL
+NULL
+array(1) {
+ [0]=>
+ string(2) "\0"
+}
+array(1) {
+ [0]=>
+ string(4) "\060"
+}
+array(1) {
+ [0]=>
+ string(1) "8"
+}
+array(1) {
+ [0]=>
+ string(5) "0x55F"
+}
+array(1) {
+ [0]=>
+ string(3) "055"
+}
+NULL
+array(1) {
+ [0]=>
+ string(4) "This"
+}
+array(1) {
+ [0]=>
+ string(5) "using"
+}
+array(1) {
+ [0]=>
+ string(6) "123456"
+}
+array(1) {
+ [0]=>
+ string(4) "4849"
+}
+NULL
+array(1) {
+ [0]=>
+ string(4) "NULL"
+}
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+NULL
+NULL
+NULL
+NULL
+array(1) {
+ [0]=>
+ string(6) "string"
+}
+array(1) {
+ [0]=>
+ string(6) "string"
+}
+array(1) {
+ [0]=>
+ string(4) "NULL"
+}
+array(1) {
+ [0]=>
+ string(4) "null"
+}
+array(1) {
+ [0]=>
+ string(5) "FALSE"
+}
+array(1) {
+ [0]=>
+ string(4) "true"
+}
+NULL
+NULL
+array(1) {
+ [0]=>
+ string(2) "\0"
+}
+array(1) {
+ [0]=>
+ string(4) "\060"
+}
+array(1) {
+ [0]=>
+ string(1) "8"
+}
+array(1) {
+ [0]=>
+ string(5) "0x55F"
+}
+array(1) {
+ [0]=>
+ string(3) "055"
+}
+NULL
+array(1) {
+ [0]=>
+ string(4) "This"
+}
+array(1) {
+ [0]=>
+ string(5) "using"
+}
+array(1) {
+ [0]=>
+ string(6) "123456"
+}
+array(1) {
+ [0]=>
+ string(4) "4849"
+}
+NULL
+array(1) {
+ [0]=>
+ string(4) "NULL"
+}
+bool(false)
+
+-- iteration 9 --
+NULL
+NULL
+NULL
+NULL
+array(1) {
+ [0]=>
+ string(6) "string"
+}
+array(1) {
+ [0]=>
+ string(6) "string"
+}
+array(1) {
+ [0]=>
+ string(4) "NULL"
+}
+array(1) {
+ [0]=>
+ string(4) "null"
+}
+array(1) {
+ [0]=>
+ string(5) "FALSE"
+}
+array(1) {
+ [0]=>
+ string(4) "true"
+}
+NULL
+NULL
+array(1) {
+ [0]=>
+ string(2) "\0"
+}
+array(1) {
+ [0]=>
+ string(4) "\060"
+}
+array(1) {
+ [0]=>
+ string(1) "8"
+}
+array(1) {
+ [0]=>
+ string(5) "0x55F"
+}
+array(1) {
+ [0]=>
+ string(3) "055"
+}
+NULL
+array(1) {
+ [0]=>
+ string(4) "This"
+}
+array(1) {
+ [0]=>
+ string(5) "using"
+}
+array(1) {
+ [0]=>
+ string(6) "123456"
+}
+array(1) {
+ [0]=>
+ string(4) "4849"
+}
+NULL
+array(1) {
+ [0]=>
+ string(4) "NULL"
+}
+bool(false)
+
+-- iteration 10 --
+NULL
+NULL
+NULL
+NULL
+array(1) {
+ [0]=>
+ string(4) "stri"
+}
+array(1) {
+ [0]=>
+ string(4) "stri"
+}
+array(1) {
+ [0]=>
+ string(4) "NULL"
+}
+array(1) {
+ [0]=>
+ string(4) "null"
+}
+array(1) {
+ [0]=>
+ string(4) "FALS"
+}
+array(1) {
+ [0]=>
+ string(4) "true"
+}
+NULL
+NULL
+array(1) {
+ [0]=>
+ string(2) "\0"
+}
+array(1) {
+ [0]=>
+ string(4) "\060"
+}
+array(1) {
+ [0]=>
+ string(1) "8"
+}
+array(1) {
+ [0]=>
+ string(4) "0x55"
+}
+array(1) {
+ [0]=>
+ string(3) "055"
+}
+NULL
+array(1) {
+ [0]=>
+ string(4) "This"
+}
+array(1) {
+ [0]=>
+ string(4) "usin"
+}
+array(1) {
+ [0]=>
+ string(4) "1234"
+}
+array(1) {
+ [0]=>
+ string(4) "4849"
+}
+NULL
+array(1) {
+ [0]=>
+ string(4) "NULL"
+}
+bool(false)
+
+-- iteration 11 --
+NULL
+NULL
+NULL
+NULL
+array(1) {
+ [0]=>
+ string(6) "string"
+}
+array(1) {
+ [0]=>
+ string(6) "string"
+}
+array(1) {
+ [0]=>
+ string(4) "NULL"
+}
+array(1) {
+ [0]=>
+ string(4) "null"
+}
+array(1) {
+ [0]=>
+ string(5) "FALSE"
+}
+array(1) {
+ [0]=>
+ string(4) "true"
+}
+NULL
+NULL
+array(1) {
+ [0]=>
+ string(2) "\0"
+}
+array(1) {
+ [0]=>
+ string(4) "\060"
+}
+array(1) {
+ [0]=>
+ string(1) "8"
+}
+array(1) {
+ [0]=>
+ string(5) "0x55F"
+}
+array(1) {
+ [0]=>
+ string(3) "055"
+}
+NULL
+array(1) {
+ [0]=>
+ string(4) "This"
+}
+array(1) {
+ [0]=>
+ string(5) "using"
+}
+array(1) {
+ [0]=>
+ string(6) "123456"
+}
+array(1) {
+ [0]=>
+ string(4) "4849"
+}
+NULL
+array(1) {
+ [0]=>
+ string(4) "NULL"
+}
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(6) "string"
+}
+array(1) {
+ [0]=>
+ string(6) "string"
+}
+array(1) {
+ [0]=>
+ string(4) "NULL"
+}
+array(1) {
+ [0]=>
+ string(4) "null"
+}
+array(1) {
+ [0]=>
+ string(5) "FALSE"
+}
+array(1) {
+ [0]=>
+ string(4) "true"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+NULL
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(1) "8"
+}
+array(1) {
+ [0]=>
+ string(5) "0x55F"
+}
+array(1) {
+ [0]=>
+ string(3) "055"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(4) "This"
+}
+array(1) {
+ [0]=>
+ string(5) "using"
+}
+array(1) {
+ [0]=>
+ string(6) "123456"
+}
+array(1) {
+ [0]=>
+ string(4) "4849"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(4) "NULL"
+}
+bool(false)
+
+-- iteration 13 --
+NULL
+NULL
+NULL
+NULL
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+NULL
+NULL
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+NULL
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+NULL
+array(0) {
+}
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation15.phpt b/ext/standard/tests/file/fscanf_variation15.phpt
new file mode 100644
index 0000000..76422db
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation15.phpt
@@ -0,0 +1,863 @@
+--TEST--
+Test fscanf() function: usage variations - string formats with float values
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan float values using different string format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different string format types with float values ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation15.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+// array of float type values
+
+$float_values = array (
+ -2147483649,
+ 2147483648,
+ -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
+);
+
+$string_formats = array( "%s",
+ "%hs", "%ls", "%Ls",
+ " %s", "%s ", "% s",
+ "\t%s", "\n%s", "%4s",
+ "%30s", "%[a-zA-Z0-9]", "%*s");
+
+$counter = 1;
+
+// writing to the file
+foreach($float_values as $value) {
+ @fprintf($file_handle, $value);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different string formats
+foreach($string_formats as $string_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$string_format) );
+ }
+ $counter++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation15.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different string format types with float values ***
+
+-- iteration 1 --
+array(1) {
+ [0]=>
+ string(11) "-2147483649"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483649"
+}
+array(1) {
+ [0]=>
+ string(11) "34359738369"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483649"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483649"
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(4) "-0.1"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(6) "100000"
+}
+array(1) {
+ [0]=>
+ string(8) "-1000000"
+}
+array(1) {
+ [0]=>
+ string(9) "100000000"
+}
+array(1) {
+ [0]=>
+ string(11) "-1000000000"
+}
+array(1) {
+ [0]=>
+ string(2) "10"
+}
+array(1) {
+ [0]=>
+ string(7) "1050000"
+}
+bool(false)
+
+-- iteration 2 --
+array(1) {
+ [0]=>
+ string(11) "-2147483649"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483649"
+}
+array(1) {
+ [0]=>
+ string(11) "34359738369"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483649"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483649"
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(4) "-0.1"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(6) "100000"
+}
+array(1) {
+ [0]=>
+ string(8) "-1000000"
+}
+array(1) {
+ [0]=>
+ string(9) "100000000"
+}
+array(1) {
+ [0]=>
+ string(11) "-1000000000"
+}
+array(1) {
+ [0]=>
+ string(2) "10"
+}
+array(1) {
+ [0]=>
+ string(7) "1050000"
+}
+bool(false)
+
+-- iteration 3 --
+array(1) {
+ [0]=>
+ string(11) "-2147483649"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483649"
+}
+array(1) {
+ [0]=>
+ string(11) "34359738369"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483649"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483649"
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(4) "-0.1"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(6) "100000"
+}
+array(1) {
+ [0]=>
+ string(8) "-1000000"
+}
+array(1) {
+ [0]=>
+ string(9) "100000000"
+}
+array(1) {
+ [0]=>
+ string(11) "-1000000000"
+}
+array(1) {
+ [0]=>
+ string(2) "10"
+}
+array(1) {
+ [0]=>
+ string(7) "1050000"
+}
+bool(false)
+
+-- iteration 4 --
+array(1) {
+ [0]=>
+ string(11) "-2147483649"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483649"
+}
+array(1) {
+ [0]=>
+ string(11) "34359738369"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483649"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483649"
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(4) "-0.1"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(6) "100000"
+}
+array(1) {
+ [0]=>
+ string(8) "-1000000"
+}
+array(1) {
+ [0]=>
+ string(9) "100000000"
+}
+array(1) {
+ [0]=>
+ string(11) "-1000000000"
+}
+array(1) {
+ [0]=>
+ string(2) "10"
+}
+array(1) {
+ [0]=>
+ string(7) "1050000"
+}
+bool(false)
+
+-- iteration 5 --
+array(1) {
+ [0]=>
+ string(11) "-2147483649"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483649"
+}
+array(1) {
+ [0]=>
+ string(11) "34359738369"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483649"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483649"
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(4) "-0.1"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(6) "100000"
+}
+array(1) {
+ [0]=>
+ string(8) "-1000000"
+}
+array(1) {
+ [0]=>
+ string(9) "100000000"
+}
+array(1) {
+ [0]=>
+ string(11) "-1000000000"
+}
+array(1) {
+ [0]=>
+ string(2) "10"
+}
+array(1) {
+ [0]=>
+ string(7) "1050000"
+}
+bool(false)
+
+-- iteration 6 --
+array(1) {
+ [0]=>
+ string(11) "-2147483649"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483649"
+}
+array(1) {
+ [0]=>
+ string(11) "34359738369"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483649"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483649"
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(4) "-0.1"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(6) "100000"
+}
+array(1) {
+ [0]=>
+ string(8) "-1000000"
+}
+array(1) {
+ [0]=>
+ string(9) "100000000"
+}
+array(1) {
+ [0]=>
+ string(11) "-1000000000"
+}
+array(1) {
+ [0]=>
+ string(2) "10"
+}
+array(1) {
+ [0]=>
+ string(7) "1050000"
+}
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+array(1) {
+ [0]=>
+ string(11) "-2147483649"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483649"
+}
+array(1) {
+ [0]=>
+ string(11) "34359738369"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483649"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483649"
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(4) "-0.1"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(6) "100000"
+}
+array(1) {
+ [0]=>
+ string(8) "-1000000"
+}
+array(1) {
+ [0]=>
+ string(9) "100000000"
+}
+array(1) {
+ [0]=>
+ string(11) "-1000000000"
+}
+array(1) {
+ [0]=>
+ string(2) "10"
+}
+array(1) {
+ [0]=>
+ string(7) "1050000"
+}
+bool(false)
+
+-- iteration 9 --
+array(1) {
+ [0]=>
+ string(11) "-2147483649"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483649"
+}
+array(1) {
+ [0]=>
+ string(11) "34359738369"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483649"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483649"
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(4) "-0.1"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(6) "100000"
+}
+array(1) {
+ [0]=>
+ string(8) "-1000000"
+}
+array(1) {
+ [0]=>
+ string(9) "100000000"
+}
+array(1) {
+ [0]=>
+ string(11) "-1000000000"
+}
+array(1) {
+ [0]=>
+ string(2) "10"
+}
+array(1) {
+ [0]=>
+ string(7) "1050000"
+}
+bool(false)
+
+-- iteration 10 --
+array(1) {
+ [0]=>
+ string(4) "-214"
+}
+array(1) {
+ [0]=>
+ string(4) "2147"
+}
+array(1) {
+ [0]=>
+ string(4) "-214"
+}
+array(1) {
+ [0]=>
+ string(4) "3435"
+}
+array(1) {
+ [0]=>
+ string(4) "2147"
+}
+array(1) {
+ [0]=>
+ string(4) "-214"
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(4) "-0.1"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(4) "1000"
+}
+array(1) {
+ [0]=>
+ string(4) "-100"
+}
+array(1) {
+ [0]=>
+ string(4) "1000"
+}
+array(1) {
+ [0]=>
+ string(4) "-100"
+}
+array(1) {
+ [0]=>
+ string(2) "10"
+}
+array(1) {
+ [0]=>
+ string(4) "1050"
+}
+bool(false)
+
+-- iteration 11 --
+array(1) {
+ [0]=>
+ string(11) "-2147483649"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483649"
+}
+array(1) {
+ [0]=>
+ string(11) "34359738369"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483649"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483649"
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(4) "-0.1"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(6) "100000"
+}
+array(1) {
+ [0]=>
+ string(8) "-1000000"
+}
+array(1) {
+ [0]=>
+ string(9) "100000000"
+}
+array(1) {
+ [0]=>
+ string(11) "-1000000000"
+}
+array(1) {
+ [0]=>
+ string(2) "10"
+}
+array(1) {
+ [0]=>
+ string(7) "1050000"
+}
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(11) "34359738369"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483649"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(6) "100000"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(9) "100000000"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(2) "10"
+}
+array(1) {
+ [0]=>
+ string(7) "1050000"
+}
+bool(false)
+
+-- iteration 13 --
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation16.phpt b/ext/standard/tests/file/fscanf_variation16.phpt
new file mode 100644
index 0000000..8025767
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation16.phpt
@@ -0,0 +1,221 @@
+--TEST--
+Test fscanf() function: usage variations - string formats with resource
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan resource type using different string format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different string format types with resource ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation16.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+
+// resource type variable
+$fp = fopen (__FILE__, "r");
+$dfp = opendir ( dirname(__FILE__) );
+
+// array of resource types
+$resource_types = array (
+ $fp,
+ $dfp
+);
+
+$string_formats = array( "%s",
+ "%hs", "%ls", "%Ls",
+ " %s", "%s ", "% s",
+ "\t%s", "\n%s", "%4s",
+ "%30s", "%[a-zA-Z0-9]", "%*s");
+
+$counter = 1;
+
+// writing to the file
+foreach($resource_types as $value) {
+ @fprintf($file_handle, $value);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different string formats
+foreach($string_formats as $string_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$string_format) );
+ }
+ $counter++;
+}
+
+// closing the resources
+fclose($fp);
+closedir($dfp);
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation16.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different string format types with resource ***
+
+-- iteration 1 --
+array(1) {
+ [0]=>
+ string(8) "Resource"
+}
+array(1) {
+ [0]=>
+ string(8) "Resource"
+}
+bool(false)
+
+-- iteration 2 --
+array(1) {
+ [0]=>
+ string(8) "Resource"
+}
+array(1) {
+ [0]=>
+ string(8) "Resource"
+}
+bool(false)
+
+-- iteration 3 --
+array(1) {
+ [0]=>
+ string(8) "Resource"
+}
+array(1) {
+ [0]=>
+ string(8) "Resource"
+}
+bool(false)
+
+-- iteration 4 --
+array(1) {
+ [0]=>
+ string(8) "Resource"
+}
+array(1) {
+ [0]=>
+ string(8) "Resource"
+}
+bool(false)
+
+-- iteration 5 --
+array(1) {
+ [0]=>
+ string(8) "Resource"
+}
+array(1) {
+ [0]=>
+ string(8) "Resource"
+}
+bool(false)
+
+-- iteration 6 --
+array(1) {
+ [0]=>
+ string(8) "Resource"
+}
+array(1) {
+ [0]=>
+ string(8) "Resource"
+}
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+array(1) {
+ [0]=>
+ string(8) "Resource"
+}
+array(1) {
+ [0]=>
+ string(8) "Resource"
+}
+bool(false)
+
+-- iteration 9 --
+array(1) {
+ [0]=>
+ string(8) "Resource"
+}
+array(1) {
+ [0]=>
+ string(8) "Resource"
+}
+bool(false)
+
+-- iteration 10 --
+array(1) {
+ [0]=>
+ string(4) "Reso"
+}
+array(1) {
+ [0]=>
+ string(4) "Reso"
+}
+bool(false)
+
+-- iteration 11 --
+array(1) {
+ [0]=>
+ string(8) "Resource"
+}
+array(1) {
+ [0]=>
+ string(8) "Resource"
+}
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ string(8) "Resource"
+}
+array(1) {
+ [0]=>
+ string(8) "Resource"
+}
+bool(false)
+
+-- iteration 13 --
+array(0) {
+}
+array(0) {
+}
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation17.phpt b/ext/standard/tests/file/fscanf_variation17.phpt
new file mode 100644
index 0000000..2db8871
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation17.phpt
@@ -0,0 +1,712 @@
+--TEST--
+Test fscanf() function: usage variations - string formats with arrays
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan arrays using different string format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different string format types with arrays ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation17.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+// array types
+$array_types = array (
+ 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)
+);
+
+$string_formats = array( "%s",
+ "%hs", "%ls", "%Ls",
+ " %s", "%s ", "% s",
+ "\t%s", "\n%s", "%4s",
+ "%30s", "%[a-zA-Z0-9]", "%*s");
+
+$counter = 1;
+
+// writing to the file
+foreach($array_types as $value) {
+ @fprintf($file_handle, $value);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different string formats
+foreach($string_formats as $string_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$string_format) );
+ }
+ $counter++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation17.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different string format types with arrays ***
+
+-- iteration 1 --
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+bool(false)
+
+-- iteration 2 --
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+bool(false)
+
+-- iteration 3 --
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+bool(false)
+
+-- iteration 4 --
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+bool(false)
+
+-- iteration 5 --
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+bool(false)
+
+-- iteration 6 --
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+bool(false)
+
+-- iteration 9 --
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+bool(false)
+
+-- iteration 10 --
+array(1) {
+ [0]=>
+ string(4) "Arra"
+}
+array(1) {
+ [0]=>
+ string(4) "Arra"
+}
+array(1) {
+ [0]=>
+ string(4) "Arra"
+}
+array(1) {
+ [0]=>
+ string(4) "Arra"
+}
+array(1) {
+ [0]=>
+ string(4) "Arra"
+}
+array(1) {
+ [0]=>
+ string(4) "Arra"
+}
+array(1) {
+ [0]=>
+ string(4) "Arra"
+}
+array(1) {
+ [0]=>
+ string(4) "Arra"
+}
+array(1) {
+ [0]=>
+ string(4) "Arra"
+}
+array(1) {
+ [0]=>
+ string(4) "Arra"
+}
+array(1) {
+ [0]=>
+ string(4) "Arra"
+}
+array(1) {
+ [0]=>
+ string(4) "Arra"
+}
+bool(false)
+
+-- iteration 11 --
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+bool(false)
+
+-- iteration 13 --
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation18.phpt b/ext/standard/tests/file/fscanf_variation18.phpt
new file mode 100644
index 0000000..71b7298
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation18.phpt
@@ -0,0 +1,1014 @@
+--TEST--
+Test fscanf() function: usage variations - string formats with integer values
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan integer values using different string format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different string format types with integer values ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation18.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+// array of string type values
+
+$integer_values = 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
+);
+
+$string_formats = array( "%s",
+ "%hs", "%ls", "%Ls",
+ " %s", "%s ", "% s",
+ "\t%s", "\n%s", "%4s",
+ "%30s", "%[a-zA-Z0-9]", "%*s"
+ );
+
+$counter = 1;
+
+// writing to the file
+foreach($integer_values as $value) {
+ @fprintf($file_handle, $value);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different string formats
+foreach($string_formats as $string_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$string_format) );
+ }
+ $counter++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation18.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different string format types with integer values ***
+
+-- iteration 1 --
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(2) "-1"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483648"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483647"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483640"
+}
+array(1) {
+ [0]=>
+ string(4) "4667"
+}
+array(1) {
+ [0]=>
+ string(4) "4779"
+}
+array(1) {
+ [0]=>
+ string(4) "4095"
+}
+array(1) {
+ [0]=>
+ string(3) "250"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483648"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+array(1) {
+ [0]=>
+ string(2) "83"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483648"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+bool(false)
+
+-- iteration 2 --
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(2) "-1"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483648"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483647"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483640"
+}
+array(1) {
+ [0]=>
+ string(4) "4667"
+}
+array(1) {
+ [0]=>
+ string(4) "4779"
+}
+array(1) {
+ [0]=>
+ string(4) "4095"
+}
+array(1) {
+ [0]=>
+ string(3) "250"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483648"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+array(1) {
+ [0]=>
+ string(2) "83"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483648"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+bool(false)
+
+-- iteration 3 --
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(2) "-1"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483648"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483647"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483640"
+}
+array(1) {
+ [0]=>
+ string(4) "4667"
+}
+array(1) {
+ [0]=>
+ string(4) "4779"
+}
+array(1) {
+ [0]=>
+ string(4) "4095"
+}
+array(1) {
+ [0]=>
+ string(3) "250"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483648"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+array(1) {
+ [0]=>
+ string(2) "83"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483648"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+bool(false)
+
+-- iteration 4 --
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(2) "-1"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483648"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483647"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483640"
+}
+array(1) {
+ [0]=>
+ string(4) "4667"
+}
+array(1) {
+ [0]=>
+ string(4) "4779"
+}
+array(1) {
+ [0]=>
+ string(4) "4095"
+}
+array(1) {
+ [0]=>
+ string(3) "250"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483648"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+array(1) {
+ [0]=>
+ string(2) "83"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483648"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+bool(false)
+
+-- iteration 5 --
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(2) "-1"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483648"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483647"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483640"
+}
+array(1) {
+ [0]=>
+ string(4) "4667"
+}
+array(1) {
+ [0]=>
+ string(4) "4779"
+}
+array(1) {
+ [0]=>
+ string(4) "4095"
+}
+array(1) {
+ [0]=>
+ string(3) "250"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483648"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+array(1) {
+ [0]=>
+ string(2) "83"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483648"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+bool(false)
+
+-- iteration 6 --
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(2) "-1"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483648"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483647"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483640"
+}
+array(1) {
+ [0]=>
+ string(4) "4667"
+}
+array(1) {
+ [0]=>
+ string(4) "4779"
+}
+array(1) {
+ [0]=>
+ string(4) "4095"
+}
+array(1) {
+ [0]=>
+ string(3) "250"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483648"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+array(1) {
+ [0]=>
+ string(2) "83"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483648"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(2) "-1"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483648"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483647"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483640"
+}
+array(1) {
+ [0]=>
+ string(4) "4667"
+}
+array(1) {
+ [0]=>
+ string(4) "4779"
+}
+array(1) {
+ [0]=>
+ string(4) "4095"
+}
+array(1) {
+ [0]=>
+ string(3) "250"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483648"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+array(1) {
+ [0]=>
+ string(2) "83"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483648"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+bool(false)
+
+-- iteration 9 --
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(2) "-1"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483648"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483647"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483640"
+}
+array(1) {
+ [0]=>
+ string(4) "4667"
+}
+array(1) {
+ [0]=>
+ string(4) "4779"
+}
+array(1) {
+ [0]=>
+ string(4) "4095"
+}
+array(1) {
+ [0]=>
+ string(3) "250"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483648"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+array(1) {
+ [0]=>
+ string(2) "83"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483648"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+bool(false)
+
+-- iteration 10 --
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(2) "-1"
+}
+array(1) {
+ [0]=>
+ string(4) "-214"
+}
+array(1) {
+ [0]=>
+ string(4) "-214"
+}
+array(1) {
+ [0]=>
+ string(4) "2147"
+}
+array(1) {
+ [0]=>
+ string(4) "2147"
+}
+array(1) {
+ [0]=>
+ string(4) "4667"
+}
+array(1) {
+ [0]=>
+ string(4) "4779"
+}
+array(1) {
+ [0]=>
+ string(4) "4095"
+}
+array(1) {
+ [0]=>
+ string(3) "250"
+}
+array(1) {
+ [0]=>
+ string(4) "-214"
+}
+array(1) {
+ [0]=>
+ string(4) "2147"
+}
+array(1) {
+ [0]=>
+ string(4) "2147"
+}
+array(1) {
+ [0]=>
+ string(2) "83"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(4) "-214"
+}
+array(1) {
+ [0]=>
+ string(4) "2147"
+}
+bool(false)
+
+-- iteration 11 --
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(2) "-1"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483648"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483647"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483640"
+}
+array(1) {
+ [0]=>
+ string(4) "4667"
+}
+array(1) {
+ [0]=>
+ string(4) "4779"
+}
+array(1) {
+ [0]=>
+ string(4) "4095"
+}
+array(1) {
+ [0]=>
+ string(3) "250"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483648"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+array(1) {
+ [0]=>
+ string(2) "83"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483648"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483640"
+}
+array(1) {
+ [0]=>
+ string(4) "4667"
+}
+array(1) {
+ [0]=>
+ string(4) "4779"
+}
+array(1) {
+ [0]=>
+ string(4) "4095"
+}
+array(1) {
+ [0]=>
+ string(3) "250"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+array(1) {
+ [0]=>
+ string(2) "83"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+bool(false)
+
+-- iteration 13 --
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation19.phpt b/ext/standard/tests/file/fscanf_variation19.phpt
new file mode 100644
index 0000000..08edc52
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation19.phpt
@@ -0,0 +1,250 @@
+--TEST--
+Test fscanf() function: usage variations - string formats with boolean
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan boolean data using different string format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different string format types with boolean data ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation19.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+// array of boolean types
+$bool_types = array (
+ true,
+ false,
+ TRUE,
+ FALSE,
+);
+
+$string_formats = array( "%s",
+ "%hs", "%ls", "%Ls",
+ " %s", "%s ", "% s",
+ "\t%s", "\n%s", "%4s",
+ "%30s", "%[a-zA-Z0-9]", "%*s");
+
+$counter = 1;
+
+// writing to the file
+foreach($bool_types as $value) {
+ @fprintf($file_handle, $value);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different string formats
+foreach($string_formats as $string_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$string_format) );
+ }
+ $counter++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation19.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different string format types with boolean data ***
+
+-- iteration 1 --
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+NULL
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+NULL
+bool(false)
+
+-- iteration 2 --
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+NULL
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+NULL
+bool(false)
+
+-- iteration 3 --
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+NULL
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+NULL
+bool(false)
+
+-- iteration 4 --
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+NULL
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+NULL
+bool(false)
+
+-- iteration 5 --
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+NULL
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+NULL
+bool(false)
+
+-- iteration 6 --
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+NULL
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+NULL
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+NULL
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+NULL
+bool(false)
+
+-- iteration 9 --
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+NULL
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+NULL
+bool(false)
+
+-- iteration 10 --
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+NULL
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+NULL
+bool(false)
+
+-- iteration 11 --
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+NULL
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+NULL
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 13 --
+array(0) {
+}
+NULL
+array(0) {
+}
+NULL
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation2.phpt b/ext/standard/tests/file/fscanf_variation2.phpt
new file mode 100644
index 0000000..77ae474
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation2.phpt
@@ -0,0 +1,1008 @@
+--TEST--
+Test fscanf() function: usage variations - integer formats with integer values
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan different integer values using different interger format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different integer format types with different integer values ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation2.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+// 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
+);
+// various integer formats
+$int_formats = array( "%d", "%hd", "%ld", "%Ld", " %d", "%d ", "% d", "\t%d", "\n%d", "%4d", "%30d", "%[0-9]", "%*d");
+
+$counter = 1;
+
+// writing to the file
+foreach($valid_ints as $int_value) {
+ @fprintf($file_handle, $int_value);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different integer formats
+foreach($int_formats as $int_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$int_format) );
+ }
+ $counter++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation2.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different integer format types with different integer values ***
+
+-- iteration 1 --
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-1)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(-2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483640)
+}
+array(1) {
+ [0]=>
+ int(4667)
+}
+array(1) {
+ [0]=>
+ int(4779)
+}
+array(1) {
+ [0]=>
+ int(4095)
+}
+array(1) {
+ [0]=>
+ int(250)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(83)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+bool(false)
+
+-- iteration 2 --
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-1)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(-2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483640)
+}
+array(1) {
+ [0]=>
+ int(4667)
+}
+array(1) {
+ [0]=>
+ int(4779)
+}
+array(1) {
+ [0]=>
+ int(4095)
+}
+array(1) {
+ [0]=>
+ int(250)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(83)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+bool(false)
+
+-- iteration 3 --
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-1)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(-2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483640)
+}
+array(1) {
+ [0]=>
+ int(4667)
+}
+array(1) {
+ [0]=>
+ int(4779)
+}
+array(1) {
+ [0]=>
+ int(4095)
+}
+array(1) {
+ [0]=>
+ int(250)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(83)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+bool(false)
+
+-- iteration 4 --
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-1)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(-2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483640)
+}
+array(1) {
+ [0]=>
+ int(4667)
+}
+array(1) {
+ [0]=>
+ int(4779)
+}
+array(1) {
+ [0]=>
+ int(4095)
+}
+array(1) {
+ [0]=>
+ int(250)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(83)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+bool(false)
+
+-- iteration 5 --
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-1)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(-2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483640)
+}
+array(1) {
+ [0]=>
+ int(4667)
+}
+array(1) {
+ [0]=>
+ int(4779)
+}
+array(1) {
+ [0]=>
+ int(4095)
+}
+array(1) {
+ [0]=>
+ int(250)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(83)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+bool(false)
+
+-- iteration 6 --
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-1)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(-2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483640)
+}
+array(1) {
+ [0]=>
+ int(4667)
+}
+array(1) {
+ [0]=>
+ int(4779)
+}
+array(1) {
+ [0]=>
+ int(4095)
+}
+array(1) {
+ [0]=>
+ int(250)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(83)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-1)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(-2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483640)
+}
+array(1) {
+ [0]=>
+ int(4667)
+}
+array(1) {
+ [0]=>
+ int(4779)
+}
+array(1) {
+ [0]=>
+ int(4095)
+}
+array(1) {
+ [0]=>
+ int(250)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(83)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+bool(false)
+
+-- iteration 9 --
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-1)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(-2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483640)
+}
+array(1) {
+ [0]=>
+ int(4667)
+}
+array(1) {
+ [0]=>
+ int(4779)
+}
+array(1) {
+ [0]=>
+ int(4095)
+}
+array(1) {
+ [0]=>
+ int(250)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(83)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+bool(false)
+
+-- iteration 10 --
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-1)
+}
+array(1) {
+ [0]=>
+ int(-214)
+}
+array(1) {
+ [0]=>
+ int(-214)
+}
+array(1) {
+ [0]=>
+ int(2147)
+}
+array(1) {
+ [0]=>
+ int(2147)
+}
+array(1) {
+ [0]=>
+ int(4667)
+}
+array(1) {
+ [0]=>
+ int(4779)
+}
+array(1) {
+ [0]=>
+ int(4095)
+}
+array(1) {
+ [0]=>
+ int(250)
+}
+array(1) {
+ [0]=>
+ int(-214)
+}
+array(1) {
+ [0]=>
+ int(2147)
+}
+array(1) {
+ [0]=>
+ int(2147)
+}
+array(1) {
+ [0]=>
+ int(83)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-214)
+}
+array(1) {
+ [0]=>
+ int(2147)
+}
+bool(false)
+
+-- iteration 11 --
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-1)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(-2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483640)
+}
+array(1) {
+ [0]=>
+ int(4667)
+}
+array(1) {
+ [0]=>
+ int(4779)
+}
+array(1) {
+ [0]=>
+ int(4095)
+}
+array(1) {
+ [0]=>
+ int(250)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(83)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483640"
+}
+array(1) {
+ [0]=>
+ string(4) "4667"
+}
+array(1) {
+ [0]=>
+ string(4) "4779"
+}
+array(1) {
+ [0]=>
+ string(4) "4095"
+}
+array(1) {
+ [0]=>
+ string(3) "250"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+array(1) {
+ [0]=>
+ string(2) "83"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+bool(false)
+
+-- iteration 13 --
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation20.phpt b/ext/standard/tests/file/fscanf_variation20.phpt
new file mode 100644
index 0000000..7ce609c
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation20.phpt
@@ -0,0 +1,1012 @@
+--TEST--
+Test fscanf() function: usage variations - char formats with integer values
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan different integer values using different char format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different char format types with different integer values ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation20.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+// 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
+);
+// various char formats
+$char_formats = array( "%c",
+ "%hc", "%lc", "%Lc",
+ " %c", "%c ", "% c",
+ "\t%c", "\n%c", "%4c",
+ "%30c", "%[a-bA-B@#$&]", "%*c");
+
+$counter = 1;
+
+// writing to the file
+foreach($valid_ints as $int_value) {
+ @fprintf($file_handle, $int_value);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different char formats
+foreach($char_formats as $char_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$char_format) );
+ }
+ $counter++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation20.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different char format types with different integer values ***
+
+-- iteration 1 --
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "4"
+}
+array(1) {
+ [0]=>
+ string(1) "4"
+}
+array(1) {
+ [0]=>
+ string(1) "4"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "8"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+bool(false)
+
+-- iteration 2 --
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "4"
+}
+array(1) {
+ [0]=>
+ string(1) "4"
+}
+array(1) {
+ [0]=>
+ string(1) "4"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "8"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+bool(false)
+
+-- iteration 3 --
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "4"
+}
+array(1) {
+ [0]=>
+ string(1) "4"
+}
+array(1) {
+ [0]=>
+ string(1) "4"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "8"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+bool(false)
+
+-- iteration 4 --
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "4"
+}
+array(1) {
+ [0]=>
+ string(1) "4"
+}
+array(1) {
+ [0]=>
+ string(1) "4"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "8"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+bool(false)
+
+-- iteration 5 --
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "4"
+}
+array(1) {
+ [0]=>
+ string(1) "4"
+}
+array(1) {
+ [0]=>
+ string(1) "4"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "8"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+bool(false)
+
+-- iteration 6 --
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "4"
+}
+array(1) {
+ [0]=>
+ string(1) "4"
+}
+array(1) {
+ [0]=>
+ string(1) "4"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "8"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "4"
+}
+array(1) {
+ [0]=>
+ string(1) "4"
+}
+array(1) {
+ [0]=>
+ string(1) "4"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "8"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+bool(false)
+
+-- iteration 9 --
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "4"
+}
+array(1) {
+ [0]=>
+ string(1) "4"
+}
+array(1) {
+ [0]=>
+ string(1) "4"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "8"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+bool(false)
+
+-- iteration 10 --
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(2) "-1"
+}
+array(1) {
+ [0]=>
+ string(4) "-214"
+}
+array(1) {
+ [0]=>
+ string(4) "-214"
+}
+array(1) {
+ [0]=>
+ string(4) "2147"
+}
+array(1) {
+ [0]=>
+ string(4) "2147"
+}
+array(1) {
+ [0]=>
+ string(4) "4667"
+}
+array(1) {
+ [0]=>
+ string(4) "4779"
+}
+array(1) {
+ [0]=>
+ string(4) "4095"
+}
+array(1) {
+ [0]=>
+ string(3) "250"
+}
+array(1) {
+ [0]=>
+ string(4) "-214"
+}
+array(1) {
+ [0]=>
+ string(4) "2147"
+}
+array(1) {
+ [0]=>
+ string(4) "2147"
+}
+array(1) {
+ [0]=>
+ string(2) "83"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(4) "-214"
+}
+array(1) {
+ [0]=>
+ string(4) "2147"
+}
+bool(false)
+
+-- iteration 11 --
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(2) "-1"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483648"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483647"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483640"
+}
+array(1) {
+ [0]=>
+ string(4) "4667"
+}
+array(1) {
+ [0]=>
+ string(4) "4779"
+}
+array(1) {
+ [0]=>
+ string(4) "4095"
+}
+array(1) {
+ [0]=>
+ string(3) "250"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483648"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+array(1) {
+ [0]=>
+ string(2) "83"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483648"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 13 --
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation21.phpt b/ext/standard/tests/file/fscanf_variation21.phpt
new file mode 100644
index 0000000..51381ce
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation21.phpt
@@ -0,0 +1,863 @@
+--TEST--
+Test fscanf() function: usage variations - char formats with float values
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan float values using different char format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different char format types with float values ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation21.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+// array of float type values
+
+$float_values = array (
+ -2147483649,
+ 2147483648,
+ -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
+);
+
+$char_formats = array( "%c",
+ "%hc", "%lc", "%Lc",
+ " %c", "%c ", "% c",
+ "\t%c", "\n%c", "%4c",
+ "%30c", "%[a-zA-Z@#$&0-9]", "%*c");
+
+$counter = 1;
+
+// writing to the file
+foreach($float_values as $value) {
+ @fprintf($file_handle, $value);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different char formats
+foreach($char_formats as $char_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$char_format) );
+ }
+ $counter++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation21.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different char format types with float values ***
+
+-- iteration 1 --
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "3"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+bool(false)
+
+-- iteration 2 --
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "3"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+bool(false)
+
+-- iteration 3 --
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "3"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+bool(false)
+
+-- iteration 4 --
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "3"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+bool(false)
+
+-- iteration 5 --
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "3"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+bool(false)
+
+-- iteration 6 --
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "3"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "3"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+bool(false)
+
+-- iteration 9 --
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "3"
+}
+array(1) {
+ [0]=>
+ string(1) "2"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+bool(false)
+
+-- iteration 10 --
+array(1) {
+ [0]=>
+ string(4) "-214"
+}
+array(1) {
+ [0]=>
+ string(4) "2147"
+}
+array(1) {
+ [0]=>
+ string(4) "-214"
+}
+array(1) {
+ [0]=>
+ string(4) "3435"
+}
+array(1) {
+ [0]=>
+ string(4) "2147"
+}
+array(1) {
+ [0]=>
+ string(4) "-214"
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(4) "-0.1"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(4) "1000"
+}
+array(1) {
+ [0]=>
+ string(4) "-100"
+}
+array(1) {
+ [0]=>
+ string(4) "1000"
+}
+array(1) {
+ [0]=>
+ string(4) "-100"
+}
+array(1) {
+ [0]=>
+ string(2) "10"
+}
+array(1) {
+ [0]=>
+ string(4) "1050"
+}
+bool(false)
+
+-- iteration 11 --
+array(1) {
+ [0]=>
+ string(11) "-2147483649"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483649"
+}
+array(1) {
+ [0]=>
+ string(11) "34359738369"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483649"
+}
+array(1) {
+ [0]=>
+ string(11) "-2147483649"
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(4) "-0.1"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(6) "100000"
+}
+array(1) {
+ [0]=>
+ string(8) "-1000000"
+}
+array(1) {
+ [0]=>
+ string(9) "100000000"
+}
+array(1) {
+ [0]=>
+ string(11) "-1000000000"
+}
+array(1) {
+ [0]=>
+ string(2) "10"
+}
+array(1) {
+ [0]=>
+ string(7) "1050000"
+}
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(11) "34359738369"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483649"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(6) "100000"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(9) "100000000"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(2) "10"
+}
+array(1) {
+ [0]=>
+ string(7) "1050000"
+}
+bool(false)
+
+-- iteration 13 --
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation22.phpt b/ext/standard/tests/file/fscanf_variation22.phpt
new file mode 100644
index 0000000..a380950
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation22.phpt
@@ -0,0 +1,221 @@
+--TEST--
+Test fscanf() function: usage variations - char formats with resource
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan resource type using different char format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different char format types with resource ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation22.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+
+// resource type variable
+$fp = fopen (__FILE__, "r");
+$dfp = opendir ( dirname(__FILE__) );
+
+// array of resource types
+$resource_types = array (
+ $fp,
+ $dfp
+);
+
+$char_formats = array( "%c",
+ "%hc", "%lc", "%Lc",
+ " %c", "%c ", "% c",
+ "\t%c", "\n%c", "%4c",
+ "%30c", "%[a-zA-Z@#$&0-9]", "%*c");
+
+$counter = 1;
+
+// writing to the file
+foreach($resource_types as $value) {
+ @fprintf($file_handle, $value);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different char formats
+foreach($char_formats as $char_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$char_format) );
+ }
+ $counter++;
+}
+
+// closing the resources
+fclose($fp);
+closedir($dfp);
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation22.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different char format types with resource ***
+
+-- iteration 1 --
+array(1) {
+ [0]=>
+ string(1) "R"
+}
+array(1) {
+ [0]=>
+ string(1) "R"
+}
+bool(false)
+
+-- iteration 2 --
+array(1) {
+ [0]=>
+ string(1) "R"
+}
+array(1) {
+ [0]=>
+ string(1) "R"
+}
+bool(false)
+
+-- iteration 3 --
+array(1) {
+ [0]=>
+ string(1) "R"
+}
+array(1) {
+ [0]=>
+ string(1) "R"
+}
+bool(false)
+
+-- iteration 4 --
+array(1) {
+ [0]=>
+ string(1) "R"
+}
+array(1) {
+ [0]=>
+ string(1) "R"
+}
+bool(false)
+
+-- iteration 5 --
+array(1) {
+ [0]=>
+ string(1) "R"
+}
+array(1) {
+ [0]=>
+ string(1) "R"
+}
+bool(false)
+
+-- iteration 6 --
+array(1) {
+ [0]=>
+ string(1) "R"
+}
+array(1) {
+ [0]=>
+ string(1) "R"
+}
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+array(1) {
+ [0]=>
+ string(1) "R"
+}
+array(1) {
+ [0]=>
+ string(1) "R"
+}
+bool(false)
+
+-- iteration 9 --
+array(1) {
+ [0]=>
+ string(1) "R"
+}
+array(1) {
+ [0]=>
+ string(1) "R"
+}
+bool(false)
+
+-- iteration 10 --
+array(1) {
+ [0]=>
+ string(4) "Reso"
+}
+array(1) {
+ [0]=>
+ string(4) "Reso"
+}
+bool(false)
+
+-- iteration 11 --
+array(1) {
+ [0]=>
+ string(8) "Resource"
+}
+array(1) {
+ [0]=>
+ string(8) "Resource"
+}
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ string(8) "Resource"
+}
+array(1) {
+ [0]=>
+ string(8) "Resource"
+}
+bool(false)
+
+-- iteration 13 --
+array(0) {
+}
+array(0) {
+}
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation23.phpt b/ext/standard/tests/file/fscanf_variation23.phpt
new file mode 100644
index 0000000..d536c28
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation23.phpt
@@ -0,0 +1,712 @@
+--TEST--
+Test fscanf() function: usage variations - char formats with arrays
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan arrays using different char format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different char format types with arrays ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation23.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+// array types
+$array_types = array (
+ 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)
+);
+
+$char_formats = array( "%c",
+ "%hc", "%lc", "%Lc",
+ " %c", "%c ", "% c",
+ "\t%c", "\n%c", "%4c",
+ "%30c", "%[a-zA-Z@#$&0-9]", "%*c");
+
+$counter = 1;
+
+// writing to the file
+foreach($array_types as $value) {
+ @fprintf($file_handle, $value);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different char formats
+foreach($char_formats as $char_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$char_format) );
+ }
+ $counter++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation23.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different char format types with arrays ***
+
+-- iteration 1 --
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+bool(false)
+
+-- iteration 2 --
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+bool(false)
+
+-- iteration 3 --
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+bool(false)
+
+-- iteration 4 --
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+bool(false)
+
+-- iteration 5 --
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+bool(false)
+
+-- iteration 6 --
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+bool(false)
+
+-- iteration 9 --
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+array(1) {
+ [0]=>
+ string(1) "A"
+}
+bool(false)
+
+-- iteration 10 --
+array(1) {
+ [0]=>
+ string(4) "Arra"
+}
+array(1) {
+ [0]=>
+ string(4) "Arra"
+}
+array(1) {
+ [0]=>
+ string(4) "Arra"
+}
+array(1) {
+ [0]=>
+ string(4) "Arra"
+}
+array(1) {
+ [0]=>
+ string(4) "Arra"
+}
+array(1) {
+ [0]=>
+ string(4) "Arra"
+}
+array(1) {
+ [0]=>
+ string(4) "Arra"
+}
+array(1) {
+ [0]=>
+ string(4) "Arra"
+}
+array(1) {
+ [0]=>
+ string(4) "Arra"
+}
+array(1) {
+ [0]=>
+ string(4) "Arra"
+}
+array(1) {
+ [0]=>
+ string(4) "Arra"
+}
+array(1) {
+ [0]=>
+ string(4) "Arra"
+}
+bool(false)
+
+-- iteration 11 --
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+array(1) {
+ [0]=>
+ string(5) "Array"
+}
+bool(false)
+
+-- iteration 13 --
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation24.phpt b/ext/standard/tests/file/fscanf_variation24.phpt
new file mode 100644
index 0000000..ddca007
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation24.phpt
@@ -0,0 +1,994 @@
+--TEST--
+Test fscanf() function: usage variations - char formats with strings
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan strings using different char format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different char format types with strings ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation24.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+// array of strings
+$strings = array (
+ "",
+ '',
+ "0",
+ '0',
+ "1",
+ '1',
+ "\x01",
+ '\x01',
+ "\01",
+ '\01',
+ 'string',
+ "string",
+ "true",
+ "FALSE",
+ 'false',
+ 'TRUE',
+ "NULL",
+ 'null'
+);
+
+$char_formats = array( "%c",
+ "%hc", "%lc", "%Lc",
+ " %c", "%c ", "% c",
+ "\t%c", "\n%c", "%4c",
+ "%30c", "%[a-zA-Z@#$&0-9]", "%*c");
+
+$counter = 1;
+
+// writing to the file
+foreach($strings as $string) {
+ @fprintf($file_handle, $string);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different char formats
+foreach($char_formats as $char_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$char_format) );
+ }
+ $counter++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation24.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different char format types with strings ***
+
+-- iteration 1 --
+array(1) {
+ [0]=>
+ string(0) ""
+}
+array(1) {
+ [0]=>
+ string(0) ""
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) ""
+}
+array(1) {
+ [0]=>
+ string(1) "\"
+}
+array(1) {
+ [0]=>
+ string(1) ""
+}
+array(1) {
+ [0]=>
+ string(1) "\"
+}
+array(1) {
+ [0]=>
+ string(1) "s"
+}
+array(1) {
+ [0]=>
+ string(1) "s"
+}
+array(1) {
+ [0]=>
+ string(1) "t"
+}
+array(1) {
+ [0]=>
+ string(1) "F"
+}
+array(1) {
+ [0]=>
+ string(1) "f"
+}
+array(1) {
+ [0]=>
+ string(1) "T"
+}
+array(1) {
+ [0]=>
+ string(1) "N"
+}
+array(1) {
+ [0]=>
+ string(1) "n"
+}
+bool(false)
+
+-- iteration 2 --
+array(1) {
+ [0]=>
+ string(0) ""
+}
+array(1) {
+ [0]=>
+ string(0) ""
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) ""
+}
+array(1) {
+ [0]=>
+ string(1) "\"
+}
+array(1) {
+ [0]=>
+ string(1) ""
+}
+array(1) {
+ [0]=>
+ string(1) "\"
+}
+array(1) {
+ [0]=>
+ string(1) "s"
+}
+array(1) {
+ [0]=>
+ string(1) "s"
+}
+array(1) {
+ [0]=>
+ string(1) "t"
+}
+array(1) {
+ [0]=>
+ string(1) "F"
+}
+array(1) {
+ [0]=>
+ string(1) "f"
+}
+array(1) {
+ [0]=>
+ string(1) "T"
+}
+array(1) {
+ [0]=>
+ string(1) "N"
+}
+array(1) {
+ [0]=>
+ string(1) "n"
+}
+bool(false)
+
+-- iteration 3 --
+array(1) {
+ [0]=>
+ string(0) ""
+}
+array(1) {
+ [0]=>
+ string(0) ""
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) ""
+}
+array(1) {
+ [0]=>
+ string(1) "\"
+}
+array(1) {
+ [0]=>
+ string(1) ""
+}
+array(1) {
+ [0]=>
+ string(1) "\"
+}
+array(1) {
+ [0]=>
+ string(1) "s"
+}
+array(1) {
+ [0]=>
+ string(1) "s"
+}
+array(1) {
+ [0]=>
+ string(1) "t"
+}
+array(1) {
+ [0]=>
+ string(1) "F"
+}
+array(1) {
+ [0]=>
+ string(1) "f"
+}
+array(1) {
+ [0]=>
+ string(1) "T"
+}
+array(1) {
+ [0]=>
+ string(1) "N"
+}
+array(1) {
+ [0]=>
+ string(1) "n"
+}
+bool(false)
+
+-- iteration 4 --
+array(1) {
+ [0]=>
+ string(0) ""
+}
+array(1) {
+ [0]=>
+ string(0) ""
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) ""
+}
+array(1) {
+ [0]=>
+ string(1) "\"
+}
+array(1) {
+ [0]=>
+ string(1) ""
+}
+array(1) {
+ [0]=>
+ string(1) "\"
+}
+array(1) {
+ [0]=>
+ string(1) "s"
+}
+array(1) {
+ [0]=>
+ string(1) "s"
+}
+array(1) {
+ [0]=>
+ string(1) "t"
+}
+array(1) {
+ [0]=>
+ string(1) "F"
+}
+array(1) {
+ [0]=>
+ string(1) "f"
+}
+array(1) {
+ [0]=>
+ string(1) "T"
+}
+array(1) {
+ [0]=>
+ string(1) "N"
+}
+array(1) {
+ [0]=>
+ string(1) "n"
+}
+bool(false)
+
+-- iteration 5 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) ""
+}
+array(1) {
+ [0]=>
+ string(1) "\"
+}
+array(1) {
+ [0]=>
+ string(1) ""
+}
+array(1) {
+ [0]=>
+ string(1) "\"
+}
+array(1) {
+ [0]=>
+ string(1) "s"
+}
+array(1) {
+ [0]=>
+ string(1) "s"
+}
+array(1) {
+ [0]=>
+ string(1) "t"
+}
+array(1) {
+ [0]=>
+ string(1) "F"
+}
+array(1) {
+ [0]=>
+ string(1) "f"
+}
+array(1) {
+ [0]=>
+ string(1) "T"
+}
+array(1) {
+ [0]=>
+ string(1) "N"
+}
+array(1) {
+ [0]=>
+ string(1) "n"
+}
+bool(false)
+
+-- iteration 6 --
+array(1) {
+ [0]=>
+ string(0) ""
+}
+array(1) {
+ [0]=>
+ string(0) ""
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) ""
+}
+array(1) {
+ [0]=>
+ string(1) "\"
+}
+array(1) {
+ [0]=>
+ string(1) ""
+}
+array(1) {
+ [0]=>
+ string(1) "\"
+}
+array(1) {
+ [0]=>
+ string(1) "s"
+}
+array(1) {
+ [0]=>
+ string(1) "s"
+}
+array(1) {
+ [0]=>
+ string(1) "t"
+}
+array(1) {
+ [0]=>
+ string(1) "F"
+}
+array(1) {
+ [0]=>
+ string(1) "f"
+}
+array(1) {
+ [0]=>
+ string(1) "T"
+}
+array(1) {
+ [0]=>
+ string(1) "N"
+}
+array(1) {
+ [0]=>
+ string(1) "n"
+}
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) ""
+}
+array(1) {
+ [0]=>
+ string(1) "\"
+}
+array(1) {
+ [0]=>
+ string(1) ""
+}
+array(1) {
+ [0]=>
+ string(1) "\"
+}
+array(1) {
+ [0]=>
+ string(1) "s"
+}
+array(1) {
+ [0]=>
+ string(1) "s"
+}
+array(1) {
+ [0]=>
+ string(1) "t"
+}
+array(1) {
+ [0]=>
+ string(1) "F"
+}
+array(1) {
+ [0]=>
+ string(1) "f"
+}
+array(1) {
+ [0]=>
+ string(1) "T"
+}
+array(1) {
+ [0]=>
+ string(1) "N"
+}
+array(1) {
+ [0]=>
+ string(1) "n"
+}
+bool(false)
+
+-- iteration 9 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) ""
+}
+array(1) {
+ [0]=>
+ string(1) "\"
+}
+array(1) {
+ [0]=>
+ string(1) ""
+}
+array(1) {
+ [0]=>
+ string(1) "\"
+}
+array(1) {
+ [0]=>
+ string(1) "s"
+}
+array(1) {
+ [0]=>
+ string(1) "s"
+}
+array(1) {
+ [0]=>
+ string(1) "t"
+}
+array(1) {
+ [0]=>
+ string(1) "F"
+}
+array(1) {
+ [0]=>
+ string(1) "f"
+}
+array(1) {
+ [0]=>
+ string(1) "T"
+}
+array(1) {
+ [0]=>
+ string(1) "N"
+}
+array(1) {
+ [0]=>
+ string(1) "n"
+}
+bool(false)
+
+-- iteration 10 --
+array(1) {
+ [0]=>
+ string(0) ""
+}
+array(1) {
+ [0]=>
+ string(0) ""
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) ""
+}
+array(1) {
+ [0]=>
+ string(4) "\x01"
+}
+array(1) {
+ [0]=>
+ string(1) ""
+}
+array(1) {
+ [0]=>
+ string(3) "\01"
+}
+array(1) {
+ [0]=>
+ string(4) "stri"
+}
+array(1) {
+ [0]=>
+ string(4) "stri"
+}
+array(1) {
+ [0]=>
+ string(4) "true"
+}
+array(1) {
+ [0]=>
+ string(4) "FALS"
+}
+array(1) {
+ [0]=>
+ string(4) "fals"
+}
+array(1) {
+ [0]=>
+ string(4) "TRUE"
+}
+array(1) {
+ [0]=>
+ string(4) "NULL"
+}
+array(1) {
+ [0]=>
+ string(4) "null"
+}
+bool(false)
+
+-- iteration 11 --
+array(1) {
+ [0]=>
+ string(0) ""
+}
+array(1) {
+ [0]=>
+ string(0) ""
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) ""
+}
+array(1) {
+ [0]=>
+ string(4) "\x01"
+}
+array(1) {
+ [0]=>
+ string(1) ""
+}
+array(1) {
+ [0]=>
+ string(3) "\01"
+}
+array(1) {
+ [0]=>
+ string(6) "string"
+}
+array(1) {
+ [0]=>
+ string(6) "string"
+}
+array(1) {
+ [0]=>
+ string(4) "true"
+}
+array(1) {
+ [0]=>
+ string(5) "FALSE"
+}
+array(1) {
+ [0]=>
+ string(5) "false"
+}
+array(1) {
+ [0]=>
+ string(4) "TRUE"
+}
+array(1) {
+ [0]=>
+ string(4) "NULL"
+}
+array(1) {
+ [0]=>
+ string(4) "null"
+}
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(6) "string"
+}
+array(1) {
+ [0]=>
+ string(6) "string"
+}
+array(1) {
+ [0]=>
+ string(4) "true"
+}
+array(1) {
+ [0]=>
+ string(5) "FALSE"
+}
+array(1) {
+ [0]=>
+ string(5) "false"
+}
+array(1) {
+ [0]=>
+ string(4) "TRUE"
+}
+array(1) {
+ [0]=>
+ string(4) "NULL"
+}
+array(1) {
+ [0]=>
+ string(4) "null"
+}
+bool(false)
+
+-- iteration 13 --
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation25.phpt b/ext/standard/tests/file/fscanf_variation25.phpt
new file mode 100644
index 0000000..d874aba
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation25.phpt
@@ -0,0 +1,294 @@
+--TEST--
+Test fscanf() function: usage variations - char formats with boolean
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan boolean data using different char format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different char format types with boolean data ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation25.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+// array of boolean types
+$bool_types = array (
+ true,
+ false,
+ TRUE,
+ FALSE,
+);
+
+$char_formats = array( "%c",
+ "%hc", "%lc", "%Lc",
+ " %c", "%c ", "% c",
+ "\t%c", "\n%c", "%4c",
+ "%30c", "%[a-zA-Z@#$&0-9]", "%*c");
+
+$counter = 1;
+
+// writing to the file
+foreach($bool_types as $value) {
+ @fprintf($file_handle, $value);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different char formats
+foreach($char_formats as $char_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$char_format) );
+ }
+ $counter++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation25.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different char format types with boolean data ***
+
+-- iteration 1 --
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(0) ""
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(0) ""
+}
+bool(false)
+
+-- iteration 2 --
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(0) ""
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(0) ""
+}
+bool(false)
+
+-- iteration 3 --
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(0) ""
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(0) ""
+}
+bool(false)
+
+-- iteration 4 --
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(0) ""
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(0) ""
+}
+bool(false)
+
+-- iteration 5 --
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+NULL
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+NULL
+bool(false)
+
+-- iteration 6 --
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(0) ""
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(0) ""
+}
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+NULL
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+NULL
+bool(false)
+
+-- iteration 9 --
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+NULL
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+NULL
+bool(false)
+
+-- iteration 10 --
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(0) ""
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(0) ""
+}
+bool(false)
+
+-- iteration 11 --
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(0) ""
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(0) ""
+}
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 13 --
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation26.phpt b/ext/standard/tests/file/fscanf_variation26.phpt
new file mode 100644
index 0000000..1a883f4
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation26.phpt
@@ -0,0 +1,356 @@
+--TEST--
+Test fscanf() function: usage variations - char formats with chars
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan different chars using different char format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different char format types with chars ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation26.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+// array of chars
+$char_types = array( 'a', "a", 67, -67, 99 );
+
+$char_formats = array( "%c",
+ "%hc", "%lc", "%Lc",
+ " %c", "%c ", "% c",
+ "\t%c", "\n%c", "%4c",
+ "%30c", "%[a-zA-Z@#$&0-9]", "%*c");
+
+$counter = 1;
+
+// writing to the file
+foreach($char_types as $char) {
+ @fprintf($file_handle, $char);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different char formats
+foreach($char_formats as $char_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$char_format) );
+ }
+ $counter++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation26.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different char format types with chars ***
+
+-- iteration 1 --
+array(1) {
+ [0]=>
+ string(1) "a"
+}
+array(1) {
+ [0]=>
+ string(1) "a"
+}
+array(1) {
+ [0]=>
+ string(1) "6"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "9"
+}
+bool(false)
+
+-- iteration 2 --
+array(1) {
+ [0]=>
+ string(1) "a"
+}
+array(1) {
+ [0]=>
+ string(1) "a"
+}
+array(1) {
+ [0]=>
+ string(1) "6"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "9"
+}
+bool(false)
+
+-- iteration 3 --
+array(1) {
+ [0]=>
+ string(1) "a"
+}
+array(1) {
+ [0]=>
+ string(1) "a"
+}
+array(1) {
+ [0]=>
+ string(1) "6"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "9"
+}
+bool(false)
+
+-- iteration 4 --
+array(1) {
+ [0]=>
+ string(1) "a"
+}
+array(1) {
+ [0]=>
+ string(1) "a"
+}
+array(1) {
+ [0]=>
+ string(1) "6"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "9"
+}
+bool(false)
+
+-- iteration 5 --
+array(1) {
+ [0]=>
+ string(1) "a"
+}
+array(1) {
+ [0]=>
+ string(1) "a"
+}
+array(1) {
+ [0]=>
+ string(1) "6"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "9"
+}
+bool(false)
+
+-- iteration 6 --
+array(1) {
+ [0]=>
+ string(1) "a"
+}
+array(1) {
+ [0]=>
+ string(1) "a"
+}
+array(1) {
+ [0]=>
+ string(1) "6"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "9"
+}
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+array(1) {
+ [0]=>
+ string(1) "a"
+}
+array(1) {
+ [0]=>
+ string(1) "a"
+}
+array(1) {
+ [0]=>
+ string(1) "6"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "9"
+}
+bool(false)
+
+-- iteration 9 --
+array(1) {
+ [0]=>
+ string(1) "a"
+}
+array(1) {
+ [0]=>
+ string(1) "a"
+}
+array(1) {
+ [0]=>
+ string(1) "6"
+}
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+array(1) {
+ [0]=>
+ string(1) "9"
+}
+bool(false)
+
+-- iteration 10 --
+array(1) {
+ [0]=>
+ string(1) "a"
+}
+array(1) {
+ [0]=>
+ string(1) "a"
+}
+array(1) {
+ [0]=>
+ string(2) "67"
+}
+array(1) {
+ [0]=>
+ string(3) "-67"
+}
+array(1) {
+ [0]=>
+ string(2) "99"
+}
+bool(false)
+
+-- iteration 11 --
+array(1) {
+ [0]=>
+ string(1) "a"
+}
+array(1) {
+ [0]=>
+ string(1) "a"
+}
+array(1) {
+ [0]=>
+ string(2) "67"
+}
+array(1) {
+ [0]=>
+ string(3) "-67"
+}
+array(1) {
+ [0]=>
+ string(2) "99"
+}
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ string(1) "a"
+}
+array(1) {
+ [0]=>
+ string(1) "a"
+}
+array(1) {
+ [0]=>
+ string(2) "67"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(2) "99"
+}
+bool(false)
+
+-- iteration 13 --
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation27.phpt b/ext/standard/tests/file/fscanf_variation27.phpt
new file mode 100644
index 0000000..7a691fc
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation27.phpt
@@ -0,0 +1,1013 @@
+--TEST--
+Test fscanf() function: usage variations - octal formats with integer values
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan different integer values using different octal format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different octal format types with different integer values ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation27.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+// 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
+);
+// various octal formats
+$octal_formats = array( "%o",
+ "%ho", "%lo", "%Lo",
+ " %o", "%o ", "% o",
+ "\t%o", "\n%o", "%4o",
+ "%30o", "%[0-7]", "%*o"
+ );
+
+$counter = 1;
+
+// writing to the file
+foreach($valid_ints as $int_value) {
+ @fprintf($file_handle, $int_value);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different octal formats
+foreach($octal_formats as $octal_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$octal_format) );
+ }
+ $counter++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation27.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different octal format types with different integer values ***
+
+-- iteration 1 --
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-1)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ int(2487)
+}
+array(1) {
+ [0]=>
+ int(319)
+}
+array(1) {
+ [0]=>
+ int(32)
+}
+array(1) {
+ [0]=>
+ int(168)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+bool(false)
+
+-- iteration 2 --
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-1)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ int(2487)
+}
+array(1) {
+ [0]=>
+ int(319)
+}
+array(1) {
+ [0]=>
+ int(32)
+}
+array(1) {
+ [0]=>
+ int(168)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+bool(false)
+
+-- iteration 3 --
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-1)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ int(2487)
+}
+array(1) {
+ [0]=>
+ int(319)
+}
+array(1) {
+ [0]=>
+ int(32)
+}
+array(1) {
+ [0]=>
+ int(168)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+bool(false)
+
+-- iteration 4 --
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-1)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ int(2487)
+}
+array(1) {
+ [0]=>
+ int(319)
+}
+array(1) {
+ [0]=>
+ int(32)
+}
+array(1) {
+ [0]=>
+ int(168)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+bool(false)
+
+-- iteration 5 --
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-1)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ int(2487)
+}
+array(1) {
+ [0]=>
+ int(319)
+}
+array(1) {
+ [0]=>
+ int(32)
+}
+array(1) {
+ [0]=>
+ int(168)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+bool(false)
+
+-- iteration 6 --
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-1)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ int(2487)
+}
+array(1) {
+ [0]=>
+ int(319)
+}
+array(1) {
+ [0]=>
+ int(32)
+}
+array(1) {
+ [0]=>
+ int(168)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-1)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ int(2487)
+}
+array(1) {
+ [0]=>
+ int(319)
+}
+array(1) {
+ [0]=>
+ int(32)
+}
+array(1) {
+ [0]=>
+ int(168)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+bool(false)
+
+-- iteration 9 --
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-1)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ int(2487)
+}
+array(1) {
+ [0]=>
+ int(319)
+}
+array(1) {
+ [0]=>
+ int(32)
+}
+array(1) {
+ [0]=>
+ int(168)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+bool(false)
+
+-- iteration 10 --
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-1)
+}
+array(1) {
+ [0]=>
+ int(-140)
+}
+array(1) {
+ [0]=>
+ int(-140)
+}
+array(1) {
+ [0]=>
+ int(1127)
+}
+array(1) {
+ [0]=>
+ int(1127)
+}
+array(1) {
+ [0]=>
+ int(2487)
+}
+array(1) {
+ [0]=>
+ int(319)
+}
+array(1) {
+ [0]=>
+ int(32)
+}
+array(1) {
+ [0]=>
+ int(168)
+}
+array(1) {
+ [0]=>
+ int(-140)
+}
+array(1) {
+ [0]=>
+ int(1127)
+}
+array(1) {
+ [0]=>
+ int(1127)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-140)
+}
+array(1) {
+ [0]=>
+ int(1127)
+}
+bool(false)
+
+-- iteration 11 --
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-1)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ int(2487)
+}
+array(1) {
+ [0]=>
+ int(319)
+}
+array(1) {
+ [0]=>
+ int(32)
+}
+array(1) {
+ [0]=>
+ int(168)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(5) "21474"
+}
+array(1) {
+ [0]=>
+ string(5) "21474"
+}
+array(1) {
+ [0]=>
+ string(4) "4667"
+}
+array(1) {
+ [0]=>
+ string(3) "477"
+}
+array(1) {
+ [0]=>
+ string(2) "40"
+}
+array(1) {
+ [0]=>
+ string(3) "250"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(5) "21474"
+}
+array(1) {
+ [0]=>
+ string(5) "21474"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(5) "21474"
+}
+bool(false)
+
+-- iteration 13 --
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation28.phpt b/ext/standard/tests/file/fscanf_variation28.phpt
new file mode 100644
index 0000000..97f7208
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation28.phpt
@@ -0,0 +1,863 @@
+--TEST--
+Test fscanf() function: usage variations - octal formats with float values
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan float values using different octal format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different octal format types with float values ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation28.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+// array of float type values
+
+$float_values = array (
+ -2147483649,
+ 2147483648,
+ -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
+);
+
+$octal_formats = array( "%o",
+ "%ho", "%lo", "%Lo",
+ " %o", "%o ", "% o",
+ "\t%o", "\n%o", "%4o",
+ "%30o", "%[0-7]", "%*o"
+ );
+
+$counter = 1;
+
+// writing to the file
+foreach($float_values as $value) {
+ @fprintf($file_handle, $value);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different octal formats
+foreach($octal_formats as $octal_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$octal_format) );
+ }
+ $counter++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation28.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different octal format types with float values ***
+
+-- iteration 1 --
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(1821)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(32768)
+}
+array(1) {
+ [0]=>
+ int(-262144)
+}
+array(1) {
+ [0]=>
+ int(16777216)
+}
+array(1) {
+ [0]=>
+ int(-134217728)
+}
+array(1) {
+ [0]=>
+ int(8)
+}
+array(1) {
+ [0]=>
+ int(282624)
+}
+bool(false)
+
+-- iteration 2 --
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(1821)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(32768)
+}
+array(1) {
+ [0]=>
+ int(-262144)
+}
+array(1) {
+ [0]=>
+ int(16777216)
+}
+array(1) {
+ [0]=>
+ int(-134217728)
+}
+array(1) {
+ [0]=>
+ int(8)
+}
+array(1) {
+ [0]=>
+ int(282624)
+}
+bool(false)
+
+-- iteration 3 --
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(1821)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(32768)
+}
+array(1) {
+ [0]=>
+ int(-262144)
+}
+array(1) {
+ [0]=>
+ int(16777216)
+}
+array(1) {
+ [0]=>
+ int(-134217728)
+}
+array(1) {
+ [0]=>
+ int(8)
+}
+array(1) {
+ [0]=>
+ int(282624)
+}
+bool(false)
+
+-- iteration 4 --
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(1821)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(32768)
+}
+array(1) {
+ [0]=>
+ int(-262144)
+}
+array(1) {
+ [0]=>
+ int(16777216)
+}
+array(1) {
+ [0]=>
+ int(-134217728)
+}
+array(1) {
+ [0]=>
+ int(8)
+}
+array(1) {
+ [0]=>
+ int(282624)
+}
+bool(false)
+
+-- iteration 5 --
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(1821)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(32768)
+}
+array(1) {
+ [0]=>
+ int(-262144)
+}
+array(1) {
+ [0]=>
+ int(16777216)
+}
+array(1) {
+ [0]=>
+ int(-134217728)
+}
+array(1) {
+ [0]=>
+ int(8)
+}
+array(1) {
+ [0]=>
+ int(282624)
+}
+bool(false)
+
+-- iteration 6 --
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(1821)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(32768)
+}
+array(1) {
+ [0]=>
+ int(-262144)
+}
+array(1) {
+ [0]=>
+ int(16777216)
+}
+array(1) {
+ [0]=>
+ int(-134217728)
+}
+array(1) {
+ [0]=>
+ int(8)
+}
+array(1) {
+ [0]=>
+ int(282624)
+}
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(1821)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(32768)
+}
+array(1) {
+ [0]=>
+ int(-262144)
+}
+array(1) {
+ [0]=>
+ int(16777216)
+}
+array(1) {
+ [0]=>
+ int(-134217728)
+}
+array(1) {
+ [0]=>
+ int(8)
+}
+array(1) {
+ [0]=>
+ int(282624)
+}
+bool(false)
+
+-- iteration 9 --
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(1821)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(32768)
+}
+array(1) {
+ [0]=>
+ int(-262144)
+}
+array(1) {
+ [0]=>
+ int(16777216)
+}
+array(1) {
+ [0]=>
+ int(-134217728)
+}
+array(1) {
+ [0]=>
+ int(8)
+}
+array(1) {
+ [0]=>
+ int(282624)
+}
+bool(false)
+
+-- iteration 10 --
+array(1) {
+ [0]=>
+ int(-140)
+}
+array(1) {
+ [0]=>
+ int(1127)
+}
+array(1) {
+ [0]=>
+ int(-140)
+}
+array(1) {
+ [0]=>
+ int(1821)
+}
+array(1) {
+ [0]=>
+ int(1127)
+}
+array(1) {
+ [0]=>
+ int(-140)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(512)
+}
+array(1) {
+ [0]=>
+ int(-64)
+}
+array(1) {
+ [0]=>
+ int(512)
+}
+array(1) {
+ [0]=>
+ int(-64)
+}
+array(1) {
+ [0]=>
+ int(8)
+}
+array(1) {
+ [0]=>
+ int(552)
+}
+bool(false)
+
+-- iteration 11 --
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(1821)
+}
+array(1) {
+ [0]=>
+ int(9020)
+}
+array(1) {
+ [0]=>
+ int(-9020)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(32768)
+}
+array(1) {
+ [0]=>
+ int(-262144)
+}
+array(1) {
+ [0]=>
+ int(16777216)
+}
+array(1) {
+ [0]=>
+ int(-134217728)
+}
+array(1) {
+ [0]=>
+ int(8)
+}
+array(1) {
+ [0]=>
+ int(282624)
+}
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(5) "21474"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(4) "3435"
+}
+array(1) {
+ [0]=>
+ string(5) "21474"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(6) "100000"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(9) "100000000"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(2) "10"
+}
+array(1) {
+ [0]=>
+ string(7) "1050000"
+}
+bool(false)
+
+-- iteration 13 --
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+bool(false)
+
+*** Done ***
diff --git a/ext/standard/tests/file/fscanf_variation29.phpt b/ext/standard/tests/file/fscanf_variation29.phpt
new file mode 100644
index 0000000..ce7083b
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation29.phpt
@@ -0,0 +1,222 @@
+--TEST--
+Test fscanf() function: usage variations - octal formats with resource
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan resource type using different octal format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different octal format types with resource ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation29.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+
+// resource type variable
+$fp = fopen (__FILE__, "r");
+$dfp = opendir ( dirname(__FILE__) );
+
+// array of resource types
+$resource_types = array (
+ $fp,
+ $dfp
+);
+
+$octal_formats = array( "%o",
+ "%ho", "%lo", "%Lo",
+ " %o", "%o ", "% o",
+ "\t%o", "\n%o", "%4o",
+ "%30o", "%[0-7]", "%*o"
+ );
+
+$counter = 1;
+
+// writing to the file
+foreach($resource_types as $value) {
+ @fprintf($file_handle, $value);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different octal formats
+foreach($octal_formats as $octal_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$octal_format) );
+ }
+ $counter++;
+}
+
+// closing the resources
+fclose($fp);
+closedir($dfp);
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation29.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different octal format types with resource ***
+
+-- iteration 1 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 2 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 3 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 4 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 5 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 6 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 9 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 10 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 11 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 13 --
+array(0) {
+}
+array(0) {
+}
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation3.phpt b/ext/standard/tests/file/fscanf_variation3.phpt
new file mode 100644
index 0000000..8faff9d
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation3.phpt
@@ -0,0 +1,865 @@
+--TEST--
+Test fscanf() function: usage variations - integer formats with float values
+--SKIPIF--
+<?php
+if (PHP_INT_SIZE != 4) {
+ die("skip this test is for 32bit platform only");
+}
+?>
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan float values using different integer format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different integer format types with float values ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation3.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+// array of float type values
+
+$float_values = array (
+ -2147483649,
+ 2147483648,
+ -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
+);
+
+$int_formats = array( "%d", "%hd", "%ld", "%Ld", " %d", "%d ", "% d", "\t%d", "\n%d", "%4d", "%30d", "%[0-9]", "%*d");
+
+$counter = 1;
+
+// writing to the file
+foreach($float_values as $value) {
+ @fprintf($file_handle, $value);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different integer formats
+foreach($int_formats as $int_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$int_format) );
+ }
+ $counter++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation3.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different integer format types with float values ***
+
+-- iteration 1 --
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(100000)
+}
+array(1) {
+ [0]=>
+ int(-1000000)
+}
+array(1) {
+ [0]=>
+ int(100000000)
+}
+array(1) {
+ [0]=>
+ int(-1000000000)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(1050000)
+}
+bool(false)
+
+-- iteration 2 --
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(100000)
+}
+array(1) {
+ [0]=>
+ int(-1000000)
+}
+array(1) {
+ [0]=>
+ int(100000000)
+}
+array(1) {
+ [0]=>
+ int(-1000000000)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(1050000)
+}
+bool(false)
+
+-- iteration 3 --
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(100000)
+}
+array(1) {
+ [0]=>
+ int(-1000000)
+}
+array(1) {
+ [0]=>
+ int(100000000)
+}
+array(1) {
+ [0]=>
+ int(-1000000000)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(1050000)
+}
+bool(false)
+
+-- iteration 4 --
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(100000)
+}
+array(1) {
+ [0]=>
+ int(-1000000)
+}
+array(1) {
+ [0]=>
+ int(100000000)
+}
+array(1) {
+ [0]=>
+ int(-1000000000)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(1050000)
+}
+bool(false)
+
+-- iteration 5 --
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(100000)
+}
+array(1) {
+ [0]=>
+ int(-1000000)
+}
+array(1) {
+ [0]=>
+ int(100000000)
+}
+array(1) {
+ [0]=>
+ int(-1000000000)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(1050000)
+}
+bool(false)
+
+-- iteration 6 --
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(100000)
+}
+array(1) {
+ [0]=>
+ int(-1000000)
+}
+array(1) {
+ [0]=>
+ int(100000000)
+}
+array(1) {
+ [0]=>
+ int(-1000000000)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(1050000)
+}
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(100000)
+}
+array(1) {
+ [0]=>
+ int(-1000000)
+}
+array(1) {
+ [0]=>
+ int(100000000)
+}
+array(1) {
+ [0]=>
+ int(-1000000000)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(1050000)
+}
+bool(false)
+
+-- iteration 9 --
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(100000)
+}
+array(1) {
+ [0]=>
+ int(-1000000)
+}
+array(1) {
+ [0]=>
+ int(100000000)
+}
+array(1) {
+ [0]=>
+ int(-1000000000)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(1050000)
+}
+bool(false)
+
+-- iteration 10 --
+array(1) {
+ [0]=>
+ int(-214)
+}
+array(1) {
+ [0]=>
+ int(2147)
+}
+array(1) {
+ [0]=>
+ int(-214)
+}
+array(1) {
+ [0]=>
+ int(3435)
+}
+array(1) {
+ [0]=>
+ int(2147)
+}
+array(1) {
+ [0]=>
+ int(-214)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1000)
+}
+array(1) {
+ [0]=>
+ int(-100)
+}
+array(1) {
+ [0]=>
+ int(1000)
+}
+array(1) {
+ [0]=>
+ int(-100)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(1050)
+}
+bool(false)
+
+-- iteration 11 --
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(100000)
+}
+array(1) {
+ [0]=>
+ int(-1000000)
+}
+array(1) {
+ [0]=>
+ int(100000000)
+}
+array(1) {
+ [0]=>
+ int(-1000000000)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(1050000)
+}
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(11) "34359738369"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483649"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(6) "100000"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(9) "100000000"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(2) "10"
+}
+array(1) {
+ [0]=>
+ string(7) "1050000"
+}
+bool(false)
+
+-- iteration 13 --
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation30.phpt b/ext/standard/tests/file/fscanf_variation30.phpt
new file mode 100644
index 0000000..b4cb350
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation30.phpt
@@ -0,0 +1,713 @@
+--TEST--
+Test fscanf() function: usage variations - octal formats with arrays
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan arrays using different octal format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different octal format types with arrays ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation30.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+// array types
+$array_types = array (
+ 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)
+);
+
+$octal_formats = array ( "%o",
+ "%ho", "%lo", "%Lo",
+ " %o", "%o ", "% o",
+ "\t%o", "\n%o", "%4o",
+ "%30o", "%[0-7]", "%*o"
+ );
+
+$counter = 1;
+
+// writing to the file
+foreach($array_types as $value) {
+ @fprintf($file_handle, $value);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different octal formats
+foreach($octal_formats as $octal_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$octal_format) );
+ }
+ $counter++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation30.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different octal format types with arrays ***
+
+-- iteration 1 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 2 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 3 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 4 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 5 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 6 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 9 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 10 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 11 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 13 --
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation31.phpt b/ext/standard/tests/file/fscanf_variation31.phpt
new file mode 100644
index 0000000..f6bc746
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation31.phpt
@@ -0,0 +1,946 @@
+--TEST--
+Test fscanf() function: usage variations - octal formats with strings
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan strings using different octal format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different octal format types with strings ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation31.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+// array of strings
+$strings = array (
+ "",
+ '',
+ "0",
+ '0',
+ "1",
+ '1',
+ "\x01",
+ '\x01',
+ "\01",
+ '\01',
+ 'string',
+ "string",
+ "true",
+ "FALSE",
+ 'false',
+ 'TRUE',
+ "NULL",
+ 'null'
+);
+
+$octal_formats = array( "%o", "%ho", "%lo", "%Lo", " %o", "%o ", "% o", "\t%o", "\n%o", "%4o", "%30o", "%[0-9]", "%*o");
+
+$counter = 1;
+
+// writing to the file
+foreach($strings as $string) {
+ @fprintf($file_handle, $string);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different octal formats
+foreach($octal_formats as $octal_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$octal_format) );
+ }
+ $counter++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation31.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different octal format types with strings ***
+
+-- iteration 1 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 2 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 3 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 4 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 5 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 6 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 9 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 10 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 11 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 13 --
+NULL
+NULL
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation32.phpt b/ext/standard/tests/file/fscanf_variation32.phpt
new file mode 100644
index 0000000..52e4540
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation32.phpt
@@ -0,0 +1,251 @@
+--TEST--
+Test fscanf() function: usage variations - octal formats with boolean
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan boolean data using different octal format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different octal format types with boolean data ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation32.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+// array of boolean types
+$bool_types = array (
+ true,
+ false,
+ TRUE,
+ FALSE,
+);
+
+$octal_formats = array( "%o",
+ "%ho", "%lo", "%Lo",
+ " %o", "%o ", "% o",
+ "\t%o", "\n%o", "%4o",
+ "%30o", "%[0-7]", "%*o"
+ );
+
+$counter = 1;
+
+// writing to the file
+foreach($bool_types as $value) {
+ @fprintf($file_handle, $value);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different octal formats
+foreach($octal_formats as $octal_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$octal_format) );
+ }
+ $counter++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation32.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different octal format types with boolean data ***
+
+-- iteration 1 --
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+bool(false)
+
+-- iteration 2 --
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+bool(false)
+
+-- iteration 3 --
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+bool(false)
+
+-- iteration 4 --
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+bool(false)
+
+-- iteration 5 --
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+bool(false)
+
+-- iteration 6 --
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+bool(false)
+
+-- iteration 9 --
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+bool(false)
+
+-- iteration 10 --
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+bool(false)
+
+-- iteration 11 --
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 13 --
+array(0) {
+}
+NULL
+array(0) {
+}
+NULL
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation33.phpt b/ext/standard/tests/file/fscanf_variation33.phpt
new file mode 100644
index 0000000..7ecff33
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation33.phpt
@@ -0,0 +1,1019 @@
+--TEST--
+Test fscanf() function: usage variations - hexa formats with integer values
+--SKIPIF--
+<?php
+if (PHP_INT_SIZE != 4) {
+ die("skip this test is for 32bit platform only");
+}
+?>
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan different integer values using different hexa format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different hexa format types with different integer values ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation33.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+// 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
+);
+// various hexa formats
+$hexa_formats = array( "%x",
+ "%xx", "%lx", "%Lx",
+ " %x", "%x ", "% x",
+ "\t%x", "\n%x", "%4x",
+ "%30x", "%[0-9A-Fa-f]", "%*x"
+ );
+
+$counter = 1;
+
+// writing to the file
+foreach($valid_ints as $int_value) {
+ @fprintf($file_handle, $int_value);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different hexa formats
+foreach($hexa_formats as $hexa_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$hexa_format) );
+ }
+ $counter++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation33.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different hexa format types with different integer values ***
+
+-- iteration 1 --
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-1)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(18023)
+}
+array(1) {
+ [0]=>
+ int(18297)
+}
+array(1) {
+ [0]=>
+ int(16533)
+}
+array(1) {
+ [0]=>
+ int(592)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(131)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+bool(false)
+
+-- iteration 2 --
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-1)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(18023)
+}
+array(1) {
+ [0]=>
+ int(18297)
+}
+array(1) {
+ [0]=>
+ int(16533)
+}
+array(1) {
+ [0]=>
+ int(592)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(131)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+bool(false)
+
+-- iteration 3 --
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-1)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(18023)
+}
+array(1) {
+ [0]=>
+ int(18297)
+}
+array(1) {
+ [0]=>
+ int(16533)
+}
+array(1) {
+ [0]=>
+ int(592)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(131)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+bool(false)
+
+-- iteration 4 --
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-1)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(18023)
+}
+array(1) {
+ [0]=>
+ int(18297)
+}
+array(1) {
+ [0]=>
+ int(16533)
+}
+array(1) {
+ [0]=>
+ int(592)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(131)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+bool(false)
+
+-- iteration 5 --
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-1)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(18023)
+}
+array(1) {
+ [0]=>
+ int(18297)
+}
+array(1) {
+ [0]=>
+ int(16533)
+}
+array(1) {
+ [0]=>
+ int(592)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(131)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+bool(false)
+
+-- iteration 6 --
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-1)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(18023)
+}
+array(1) {
+ [0]=>
+ int(18297)
+}
+array(1) {
+ [0]=>
+ int(16533)
+}
+array(1) {
+ [0]=>
+ int(592)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(131)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-1)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(18023)
+}
+array(1) {
+ [0]=>
+ int(18297)
+}
+array(1) {
+ [0]=>
+ int(16533)
+}
+array(1) {
+ [0]=>
+ int(592)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(131)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+bool(false)
+
+-- iteration 9 --
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-1)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(18023)
+}
+array(1) {
+ [0]=>
+ int(18297)
+}
+array(1) {
+ [0]=>
+ int(16533)
+}
+array(1) {
+ [0]=>
+ int(592)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(131)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+bool(false)
+
+-- iteration 10 --
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-1)
+}
+array(1) {
+ [0]=>
+ int(-532)
+}
+array(1) {
+ [0]=>
+ int(-532)
+}
+array(1) {
+ [0]=>
+ int(8519)
+}
+array(1) {
+ [0]=>
+ int(8519)
+}
+array(1) {
+ [0]=>
+ int(18023)
+}
+array(1) {
+ [0]=>
+ int(18297)
+}
+array(1) {
+ [0]=>
+ int(16533)
+}
+array(1) {
+ [0]=>
+ int(592)
+}
+array(1) {
+ [0]=>
+ int(-532)
+}
+array(1) {
+ [0]=>
+ int(8519)
+}
+array(1) {
+ [0]=>
+ int(8519)
+}
+array(1) {
+ [0]=>
+ int(131)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-532)
+}
+array(1) {
+ [0]=>
+ int(8519)
+}
+bool(false)
+
+-- iteration 11 --
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-1)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(18023)
+}
+array(1) {
+ [0]=>
+ int(18297)
+}
+array(1) {
+ [0]=>
+ int(16533)
+}
+array(1) {
+ [0]=>
+ int(592)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(131)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483640"
+}
+array(1) {
+ [0]=>
+ string(4) "4667"
+}
+array(1) {
+ [0]=>
+ string(4) "4779"
+}
+array(1) {
+ [0]=>
+ string(4) "4095"
+}
+array(1) {
+ [0]=>
+ string(3) "250"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+array(1) {
+ [0]=>
+ string(2) "83"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+bool(false)
+
+-- iteration 13 --
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation34.phpt b/ext/standard/tests/file/fscanf_variation34.phpt
new file mode 100644
index 0000000..2acdc8b
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation34.phpt
@@ -0,0 +1,869 @@
+--TEST--
+Test fscanf() function: usage variations - hexa formats with float values
+--SKIPIF--
+<?php
+if (PHP_INT_SIZE != 4) {
+ die("skip this test is for 32bit platform only");
+}
+?>
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan float values using different hexa format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different hexa format types with float values ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation34.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+// array of float type values
+
+$float_values = array (
+ -2147483649,
+ 2147483648,
+ -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
+);
+
+$hexa_formats = array( "%x",
+ "%hx", "%lx", "%Lx",
+ " %x", "%x ", "% x",
+ "\t%x", "\n%x", "%4x",
+ "%30x", "%[0-9A-Za-z]", "%*x");
+
+$counter = 1;
+
+// writing to the file
+foreach($float_values as $value) {
+ @fprintf($file_handle, $value);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different hexa formats
+foreach($hexa_formats as $hexa_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$hexa_format) );
+ }
+ $counter++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation34.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different hexa format types with float values ***
+
+-- iteration 1 --
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1048576)
+}
+array(1) {
+ [0]=>
+ int(-16777216)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(16)
+}
+array(1) {
+ [0]=>
+ int(17104896)
+}
+bool(false)
+
+-- iteration 2 --
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1048576)
+}
+array(1) {
+ [0]=>
+ int(-16777216)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(16)
+}
+array(1) {
+ [0]=>
+ int(17104896)
+}
+bool(false)
+
+-- iteration 3 --
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1048576)
+}
+array(1) {
+ [0]=>
+ int(-16777216)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(16)
+}
+array(1) {
+ [0]=>
+ int(17104896)
+}
+bool(false)
+
+-- iteration 4 --
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1048576)
+}
+array(1) {
+ [0]=>
+ int(-16777216)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(16)
+}
+array(1) {
+ [0]=>
+ int(17104896)
+}
+bool(false)
+
+-- iteration 5 --
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1048576)
+}
+array(1) {
+ [0]=>
+ int(-16777216)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(16)
+}
+array(1) {
+ [0]=>
+ int(17104896)
+}
+bool(false)
+
+-- iteration 6 --
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1048576)
+}
+array(1) {
+ [0]=>
+ int(-16777216)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(16)
+}
+array(1) {
+ [0]=>
+ int(17104896)
+}
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1048576)
+}
+array(1) {
+ [0]=>
+ int(-16777216)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(16)
+}
+array(1) {
+ [0]=>
+ int(17104896)
+}
+bool(false)
+
+-- iteration 9 --
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1048576)
+}
+array(1) {
+ [0]=>
+ int(-16777216)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(16)
+}
+array(1) {
+ [0]=>
+ int(17104896)
+}
+bool(false)
+
+-- iteration 10 --
+array(1) {
+ [0]=>
+ int(-532)
+}
+array(1) {
+ [0]=>
+ int(8519)
+}
+array(1) {
+ [0]=>
+ int(-532)
+}
+array(1) {
+ [0]=>
+ int(13365)
+}
+array(1) {
+ [0]=>
+ int(8519)
+}
+array(1) {
+ [0]=>
+ int(-532)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(4096)
+}
+array(1) {
+ [0]=>
+ int(-256)
+}
+array(1) {
+ [0]=>
+ int(4096)
+}
+array(1) {
+ [0]=>
+ int(-256)
+}
+array(1) {
+ [0]=>
+ int(16)
+}
+array(1) {
+ [0]=>
+ int(4176)
+}
+bool(false)
+
+-- iteration 11 --
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1048576)
+}
+array(1) {
+ [0]=>
+ int(-16777216)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(-2147483648)
+}
+array(1) {
+ [0]=>
+ int(16)
+}
+array(1) {
+ [0]=>
+ int(17104896)
+}
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(11) "34359738369"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483649"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(6) "100000"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(9) "100000000"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(2) "10"
+}
+array(1) {
+ [0]=>
+ string(7) "1050000"
+}
+bool(false)
+
+-- iteration 13 --
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation35.phpt b/ext/standard/tests/file/fscanf_variation35.phpt
new file mode 100644
index 0000000..1f98bd8
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation35.phpt
@@ -0,0 +1,217 @@
+--TEST--
+Test fscanf() function: usage variations - hexa formats with resource
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan resource type using different hexa format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different hexa format types with resource ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation35.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+
+// resource type variable
+$fp = fopen (__FILE__, "r");
+$dfp = opendir ( dirname(__FILE__) );
+
+// array of resource types
+$resource_types = array (
+ $fp,
+ $dfp
+);
+
+$hexa_formats = array( "%x", "%hx", "%lx", "%Lx", " %x", "%x ", "% x", "\t%x", "\n%x", "%4x", "%30x", "%[0-9]", "%*x");
+
+$counter = 1;
+
+// writing to the file
+foreach($resource_types as $value) {
+ @fprintf($file_handle, $value);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different hexa formats
+foreach($hexa_formats as $hexa_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$hexa_format) );
+ }
+ $counter++;
+}
+
+// closing the resources
+fclose($fp);
+closedir($dfp);
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation35.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different hexa format types with resource ***
+
+-- iteration 1 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 2 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 3 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 4 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 5 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 6 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 9 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 10 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 11 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 13 --
+array(0) {
+}
+array(0) {
+}
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation36.phpt b/ext/standard/tests/file/fscanf_variation36.phpt
new file mode 100644
index 0000000..44ff295
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation36.phpt
@@ -0,0 +1,708 @@
+--TEST--
+Test fscanf() function: usage variations - hexa formats with arrays
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan arrays using different hexa format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different hexa format types with arrays ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation36.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+// array types
+$array_types = array (
+ 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)
+);
+
+$hexa_formats = array( "%x", "%hx", "%lx", "%Lx", " %x", "%x ", "% x", "\t%x", "\n%x", "%4x", "%30x", "%[0-9]", "%*x");
+
+$counter = 1;
+
+// writing to the file
+foreach($array_types as $value) {
+ @fprintf($file_handle, $value);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different hexa formats
+foreach($hexa_formats as $hexa_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$hexa_format) );
+ }
+ $counter++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation36.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different hexa format types with arrays ***
+
+-- iteration 1 --
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+bool(false)
+
+-- iteration 2 --
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+bool(false)
+
+-- iteration 3 --
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+bool(false)
+
+-- iteration 4 --
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+bool(false)
+
+-- iteration 5 --
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+bool(false)
+
+-- iteration 6 --
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+bool(false)
+
+-- iteration 9 --
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+bool(false)
+
+-- iteration 10 --
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+bool(false)
+
+-- iteration 11 --
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 13 --
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation37.phpt b/ext/standard/tests/file/fscanf_variation37.phpt
new file mode 100644
index 0000000..7ab302d
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation37.phpt
@@ -0,0 +1,946 @@
+--TEST--
+Test fscanf() function: usage variations - hexa formats with strings
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan strings using different hexa format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different hexa format types with strings ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation37.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+// array of strings
+$strings = array (
+ "",
+ '',
+ "0",
+ '0',
+ "1",
+ '1',
+ "\x01",
+ '\x01',
+ "\01",
+ '\01',
+ 'string',
+ "string",
+ "true",
+ "FALSE",
+ 'false',
+ 'TRUE',
+ "NULL",
+ 'null'
+);
+
+$hexa_formats = array( "%x", "%hx", "%lx", "%Lx", " %x", "%x ", "% x", "\t%x", "\n%x", "%4x", "%30x", "%[0-9]", "%*x");
+
+$counter = 1;
+
+// writing to the file
+foreach($strings as $string) {
+ @fprintf($file_handle, $string);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different hexa formats
+foreach($hexa_formats as $hexa_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$hexa_format) );
+ }
+ $counter++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation37.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different hexa format types with strings ***
+
+-- iteration 1 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ int(250)
+}
+array(1) {
+ [0]=>
+ int(250)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 2 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ int(250)
+}
+array(1) {
+ [0]=>
+ int(250)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 3 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ int(250)
+}
+array(1) {
+ [0]=>
+ int(250)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 4 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ int(250)
+}
+array(1) {
+ [0]=>
+ int(250)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 5 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ int(250)
+}
+array(1) {
+ [0]=>
+ int(250)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 6 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ int(250)
+}
+array(1) {
+ [0]=>
+ int(250)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ int(250)
+}
+array(1) {
+ [0]=>
+ int(250)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 9 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ int(250)
+}
+array(1) {
+ [0]=>
+ int(250)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 10 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ int(250)
+}
+array(1) {
+ [0]=>
+ int(250)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 11 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ int(250)
+}
+array(1) {
+ [0]=>
+ int(250)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 13 --
+NULL
+NULL
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation38.phpt b/ext/standard/tests/file/fscanf_variation38.phpt
new file mode 100644
index 0000000..32a7f77
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation38.phpt
@@ -0,0 +1,246 @@
+--TEST--
+Test fscanf() function: usage variations - hexa formats with boolean
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan boolean data using different hexa format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different hexa format types with boolean data ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation38.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+// array of boolean types
+$bool_types = array (
+ true,
+ false,
+ TRUE,
+ FALSE,
+);
+
+$hexa_formats = array( "%x", "%hx", "%lx", "%Lx", " %x", "%x ", "% x", "\t%x", "\n%x", "%4x", "%30x", "%[0-9]", "%*x");
+
+$counter = 1;
+
+// writing to the file
+foreach($bool_types as $value) {
+ @fprintf($file_handle, $value);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different hexa formats
+foreach($hexa_formats as $hexa_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$hexa_format) );
+ }
+ $counter++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation38.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different hexa format types with boolean data ***
+
+-- iteration 1 --
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+bool(false)
+
+-- iteration 2 --
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+bool(false)
+
+-- iteration 3 --
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+bool(false)
+
+-- iteration 4 --
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+bool(false)
+
+-- iteration 5 --
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+bool(false)
+
+-- iteration 6 --
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+bool(false)
+
+-- iteration 9 --
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+bool(false)
+
+-- iteration 10 --
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+bool(false)
+
+-- iteration 11 --
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 13 --
+array(0) {
+}
+NULL
+array(0) {
+}
+NULL
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation39.phpt b/ext/standard/tests/file/fscanf_variation39.phpt
new file mode 100644
index 0000000..1b17015
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation39.phpt
@@ -0,0 +1,1014 @@
+--TEST--
+Test fscanf() function: usage variations - unsigned int formats with integer values
+--SKIPIF--
+<?php
+if (PHP_INT_SIZE != 4) {
+ die("skip this test is for 32bit platform only");
+}
+?>
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan different integer values using different unsigned int format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different unsigned int format types with different integer values ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation39.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+// different valid integer values
+$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
+);
+// various unsigned int formats
+$unsigned_formats = array( "%u", "%hu", "%lu", "%Lu", " %u", "%u ", "% u", "\t%u", "\n%u", "%4u", "%30u", "%[0-9]", "%*u");
+
+$counter = 1;
+
+// writing to the file
+foreach($valid_ints as $int_value) {
+ @fprintf($file_handle, $int_value);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different unsigned int formats
+foreach($unsigned_formats as $unsigned_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$unsigned_format) );
+ }
+ $counter++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation39.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different unsigned int format types with different integer values ***
+
+-- iteration 1 --
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ string(10) "4294967295"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483649"
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483640)
+}
+array(1) {
+ [0]=>
+ int(4667)
+}
+array(1) {
+ [0]=>
+ int(4779)
+}
+array(1) {
+ [0]=>
+ int(4095)
+}
+array(1) {
+ [0]=>
+ int(250)
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(83)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+bool(false)
+
+-- iteration 2 --
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ string(10) "4294967295"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483649"
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483640)
+}
+array(1) {
+ [0]=>
+ int(4667)
+}
+array(1) {
+ [0]=>
+ int(4779)
+}
+array(1) {
+ [0]=>
+ int(4095)
+}
+array(1) {
+ [0]=>
+ int(250)
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(83)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+bool(false)
+
+-- iteration 3 --
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ string(10) "4294967295"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483649"
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483640)
+}
+array(1) {
+ [0]=>
+ int(4667)
+}
+array(1) {
+ [0]=>
+ int(4779)
+}
+array(1) {
+ [0]=>
+ int(4095)
+}
+array(1) {
+ [0]=>
+ int(250)
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(83)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+bool(false)
+
+-- iteration 4 --
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ string(10) "4294967295"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483649"
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483640)
+}
+array(1) {
+ [0]=>
+ int(4667)
+}
+array(1) {
+ [0]=>
+ int(4779)
+}
+array(1) {
+ [0]=>
+ int(4095)
+}
+array(1) {
+ [0]=>
+ int(250)
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(83)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+bool(false)
+
+-- iteration 5 --
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ string(10) "4294967295"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483649"
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483640)
+}
+array(1) {
+ [0]=>
+ int(4667)
+}
+array(1) {
+ [0]=>
+ int(4779)
+}
+array(1) {
+ [0]=>
+ int(4095)
+}
+array(1) {
+ [0]=>
+ int(250)
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(83)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+bool(false)
+
+-- iteration 6 --
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ string(10) "4294967295"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483649"
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483640)
+}
+array(1) {
+ [0]=>
+ int(4667)
+}
+array(1) {
+ [0]=>
+ int(4779)
+}
+array(1) {
+ [0]=>
+ int(4095)
+}
+array(1) {
+ [0]=>
+ int(250)
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(83)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ string(10) "4294967295"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483649"
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483640)
+}
+array(1) {
+ [0]=>
+ int(4667)
+}
+array(1) {
+ [0]=>
+ int(4779)
+}
+array(1) {
+ [0]=>
+ int(4095)
+}
+array(1) {
+ [0]=>
+ int(250)
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(83)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+bool(false)
+
+-- iteration 9 --
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ string(10) "4294967295"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483649"
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483640)
+}
+array(1) {
+ [0]=>
+ int(4667)
+}
+array(1) {
+ [0]=>
+ int(4779)
+}
+array(1) {
+ [0]=>
+ int(4095)
+}
+array(1) {
+ [0]=>
+ int(250)
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(83)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+bool(false)
+
+-- iteration 10 --
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ string(10) "4294967295"
+}
+array(1) {
+ [0]=>
+ string(10) "4294967082"
+}
+array(1) {
+ [0]=>
+ string(10) "4294967082"
+}
+array(1) {
+ [0]=>
+ int(2147)
+}
+array(1) {
+ [0]=>
+ int(2147)
+}
+array(1) {
+ [0]=>
+ int(4667)
+}
+array(1) {
+ [0]=>
+ int(4779)
+}
+array(1) {
+ [0]=>
+ int(4095)
+}
+array(1) {
+ [0]=>
+ int(250)
+}
+array(1) {
+ [0]=>
+ string(10) "4294967082"
+}
+array(1) {
+ [0]=>
+ int(2147)
+}
+array(1) {
+ [0]=>
+ int(2147)
+}
+array(1) {
+ [0]=>
+ int(83)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ string(10) "4294967082"
+}
+array(1) {
+ [0]=>
+ int(2147)
+}
+bool(false)
+
+-- iteration 11 --
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ string(10) "4294967295"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483649"
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483640)
+}
+array(1) {
+ [0]=>
+ int(4667)
+}
+array(1) {
+ [0]=>
+ int(4779)
+}
+array(1) {
+ [0]=>
+ int(4095)
+}
+array(1) {
+ [0]=>
+ int(250)
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(83)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483640"
+}
+array(1) {
+ [0]=>
+ string(4) "4667"
+}
+array(1) {
+ [0]=>
+ string(4) "4779"
+}
+array(1) {
+ [0]=>
+ string(4) "4095"
+}
+array(1) {
+ [0]=>
+ string(3) "250"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+array(1) {
+ [0]=>
+ string(2) "83"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+bool(false)
+
+-- iteration 13 --
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation4.phpt b/ext/standard/tests/file/fscanf_variation4.phpt
new file mode 100644
index 0000000..0d9cd9d
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation4.phpt
@@ -0,0 +1,218 @@
+--TEST--
+Test fscanf() function: usage variations - integer formats with resource
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan resource type using different integer format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different integer format types with resource ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation4.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+// non-integer type of data
+
+// resource type variable
+$fp = fopen (__FILE__, "r");
+$dfp = opendir ( dirname(__FILE__) );
+
+// array of resource types
+$resource_types = array (
+ $fp,
+ $dfp
+);
+
+$int_formats = array( "%d", "%hd", "%ld", "%Ld", " %d", "%d ", "% d", "\t%d", "\n%d", "%4d", "%30d", "%[0-9]", "%*d");
+
+$counter = 1;
+
+// writing to the file
+foreach($resource_types as $value) {
+ @fprintf($file_handle, $value);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different integer formats
+foreach($int_formats as $int_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$int_format) );
+ }
+ $counter++;
+}
+
+// closing the resources
+fclose($fp);
+closedir($dfp);
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation4.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different integer format types with resource ***
+
+-- iteration 1 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 2 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 3 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 4 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 5 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 6 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 9 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 10 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 11 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 13 --
+array(0) {
+}
+array(0) {
+}
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation40.phpt b/ext/standard/tests/file/fscanf_variation40.phpt
new file mode 100644
index 0000000..f3a0c96
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation40.phpt
@@ -0,0 +1,865 @@
+--TEST--
+Test fscanf() function: usage variations - unsigned formats with float values
+--SKIPIF--
+<?php
+if (PHP_INT_SIZE != 4) {
+ die("skip this test is for 32bit platform only");
+}
+?>
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan float values using different unsigned format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different unsigned format types with float values ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation40.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+// array of float type values
+
+$float_values = array (
+ -2147483649,
+ 2147483648,
+ -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
+);
+
+$unsigned_formats = array( "%u", "%hu", "%lu", "%Lu", " %u", "%u ", "% u", "\t%u", "\n%u", "%4u", "%30u", "%[0-9]", "%*u");
+
+$counter = 1;
+
+// writing to the file
+foreach($float_values as $value) {
+ @fprintf($file_handle, $value);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different unsigned formats
+foreach($unsigned_formats as $unsigned_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$unsigned_format) );
+ }
+ $counter++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation40.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different unsigned format types with float values ***
+
+-- iteration 1 --
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ string(10) "4294967295"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483649"
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(100000)
+}
+array(1) {
+ [0]=>
+ string(10) "4293967296"
+}
+array(1) {
+ [0]=>
+ int(100000000)
+}
+array(1) {
+ [0]=>
+ string(10) "3294967296"
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(1050000)
+}
+bool(false)
+
+-- iteration 2 --
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ string(10) "4294967295"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483649"
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(100000)
+}
+array(1) {
+ [0]=>
+ string(10) "4293967296"
+}
+array(1) {
+ [0]=>
+ int(100000000)
+}
+array(1) {
+ [0]=>
+ string(10) "3294967296"
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(1050000)
+}
+bool(false)
+
+-- iteration 3 --
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ string(10) "4294967295"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483649"
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(100000)
+}
+array(1) {
+ [0]=>
+ string(10) "4293967296"
+}
+array(1) {
+ [0]=>
+ int(100000000)
+}
+array(1) {
+ [0]=>
+ string(10) "3294967296"
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(1050000)
+}
+bool(false)
+
+-- iteration 4 --
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ string(10) "4294967295"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483649"
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(100000)
+}
+array(1) {
+ [0]=>
+ string(10) "4293967296"
+}
+array(1) {
+ [0]=>
+ int(100000000)
+}
+array(1) {
+ [0]=>
+ string(10) "3294967296"
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(1050000)
+}
+bool(false)
+
+-- iteration 5 --
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ string(10) "4294967295"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483649"
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(100000)
+}
+array(1) {
+ [0]=>
+ string(10) "4293967296"
+}
+array(1) {
+ [0]=>
+ int(100000000)
+}
+array(1) {
+ [0]=>
+ string(10) "3294967296"
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(1050000)
+}
+bool(false)
+
+-- iteration 6 --
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ string(10) "4294967295"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483649"
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(100000)
+}
+array(1) {
+ [0]=>
+ string(10) "4293967296"
+}
+array(1) {
+ [0]=>
+ int(100000000)
+}
+array(1) {
+ [0]=>
+ string(10) "3294967296"
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(1050000)
+}
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ string(10) "4294967295"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483649"
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(100000)
+}
+array(1) {
+ [0]=>
+ string(10) "4293967296"
+}
+array(1) {
+ [0]=>
+ int(100000000)
+}
+array(1) {
+ [0]=>
+ string(10) "3294967296"
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(1050000)
+}
+bool(false)
+
+-- iteration 9 --
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ string(10) "4294967295"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483649"
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(100000)
+}
+array(1) {
+ [0]=>
+ string(10) "4293967296"
+}
+array(1) {
+ [0]=>
+ int(100000000)
+}
+array(1) {
+ [0]=>
+ string(10) "3294967296"
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(1050000)
+}
+bool(false)
+
+-- iteration 10 --
+array(1) {
+ [0]=>
+ string(10) "4294967082"
+}
+array(1) {
+ [0]=>
+ int(2147)
+}
+array(1) {
+ [0]=>
+ string(10) "4294967082"
+}
+array(1) {
+ [0]=>
+ int(3435)
+}
+array(1) {
+ [0]=>
+ int(2147)
+}
+array(1) {
+ [0]=>
+ string(10) "4294967082"
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1000)
+}
+array(1) {
+ [0]=>
+ string(10) "4294967196"
+}
+array(1) {
+ [0]=>
+ int(1000)
+}
+array(1) {
+ [0]=>
+ string(10) "4294967196"
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(1050)
+}
+bool(false)
+
+-- iteration 11 --
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ string(10) "4294967295"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483649"
+}
+array(1) {
+ [0]=>
+ int(2147483647)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(100000)
+}
+array(1) {
+ [0]=>
+ string(10) "4293967296"
+}
+array(1) {
+ [0]=>
+ int(100000000)
+}
+array(1) {
+ [0]=>
+ string(10) "3294967296"
+}
+array(1) {
+ [0]=>
+ int(10)
+}
+array(1) {
+ [0]=>
+ int(1050000)
+}
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(11) "34359738369"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483649"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(6) "100000"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(9) "100000000"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(2) "10"
+}
+array(1) {
+ [0]=>
+ string(7) "1050000"
+}
+bool(false)
+
+-- iteration 13 --
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation41.phpt b/ext/standard/tests/file/fscanf_variation41.phpt
new file mode 100644
index 0000000..080ce98
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation41.phpt
@@ -0,0 +1,217 @@
+--TEST--
+Test fscanf() function: usage variations - unsigned formats with resource
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan resource type using different unsigned format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different unsigned format types with resource ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation41.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+
+// resource type variable
+$fp = fopen (__FILE__, "r");
+$dfp = opendir ( dirname(__FILE__) );
+
+// array of resource types
+$resource_types = array (
+ $fp,
+ $dfp
+);
+
+$unsigned_formats = array( "%u", "%hu", "%lu", "%Lu", " %u", "%u ", "% u", "\t%u", "\n%u", "%4u", "%30u", "%[0-9]", "%*u");
+
+$counter = 1;
+
+// writing to the file
+foreach($resource_types as $value) {
+ @fprintf($file_handle, $value);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different unsigned formats
+foreach($unsigned_formats as $unsigned_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$unsigned_format) );
+ }
+ $counter++;
+}
+
+// closing the resources
+fclose($fp);
+closedir($dfp);
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation41.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different unsigned format types with resource ***
+
+-- iteration 1 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 2 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 3 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 4 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 5 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 6 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 9 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 10 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 11 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 13 --
+array(0) {
+}
+array(0) {
+}
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation42.phpt b/ext/standard/tests/file/fscanf_variation42.phpt
new file mode 100644
index 0000000..978187c
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation42.phpt
@@ -0,0 +1,708 @@
+--TEST--
+Test fscanf() function: usage variations - unsigned formats with arrays
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan arrays using different unsigned format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different unsigned format types with arrays ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation42.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+// array types
+$array_types = array (
+ 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)
+);
+
+$unsigned_formats = array( "%u", "%hu", "%lu", "%Lu", " %u", "%u ", "% u", "\t%u", "\n%u", "%4u", "%30u", "%[0-9]", "%*u");
+
+$counter = 1;
+
+// writing to the file
+foreach($array_types as $value) {
+ @fprintf($file_handle, $value);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different unsigned formats
+foreach($unsigned_formats as $unsigned_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$unsigned_format) );
+ }
+ $counter++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation42.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different unsigned format types with arrays ***
+
+-- iteration 1 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 2 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 3 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 4 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 5 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 6 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 9 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 10 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 11 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 13 --
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation43.phpt b/ext/standard/tests/file/fscanf_variation43.phpt
new file mode 100644
index 0000000..8a0052f
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation43.phpt
@@ -0,0 +1,946 @@
+--TEST--
+Test fscanf() function: usage variations - unsigned formats with strings
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan strings using different unsigned format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different unsigned format types with strings ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation43.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+// array of strings
+$strings = array (
+ "",
+ '',
+ "0",
+ '0',
+ "1",
+ '1',
+ "\x01",
+ '\x01',
+ "\01",
+ '\01',
+ 'string',
+ "string",
+ "true",
+ "FALSE",
+ 'false',
+ 'TRUE',
+ "NULL",
+ 'null'
+);
+
+$unsigned_formats = array( "%u", "%hu", "%lu", "%Lu", " %u", "%u ", "% u", "\t%u", "\n%u", "%4u", "%30u", "%[0-9]", "%*u");
+
+$counter = 1;
+
+// writing to the file
+foreach($strings as $string) {
+ @fprintf($file_handle, $string);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different unsigned formats
+foreach($unsigned_formats as $unsigned_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$unsigned_format) );
+ }
+ $counter++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation43.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different unsigned format types with strings ***
+
+-- iteration 1 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 2 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 3 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 4 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 5 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 6 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 9 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 10 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 11 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 13 --
+NULL
+NULL
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation44.phpt b/ext/standard/tests/file/fscanf_variation44.phpt
new file mode 100644
index 0000000..0b30b61
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation44.phpt
@@ -0,0 +1,246 @@
+--TEST--
+Test fscanf() function: usage variations - unsigned formats with boolean
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan boolean data using different unsigned format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different unsigned format types with boolean data ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation44.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+// array of boolean types
+$bool_types = array (
+ true,
+ false,
+ TRUE,
+ FALSE,
+);
+
+$unsigned_formats = array( "%u", "%hu", "%lu", "%Lu", " %u", "%u ", "% u", "\t%u", "\n%u", "%4u", "%30u", "%[0-9]", "%*u");
+
+$counter = 1;
+
+// writing to the file
+foreach($bool_types as $value) {
+ @fprintf($file_handle, $value);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different unsigned formats
+foreach($unsigned_formats as $unsigned_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$unsigned_format) );
+ }
+ $counter++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation44.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different unsigned format types with boolean data ***
+
+-- iteration 1 --
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+bool(false)
+
+-- iteration 2 --
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+bool(false)
+
+-- iteration 3 --
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+bool(false)
+
+-- iteration 4 --
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+bool(false)
+
+-- iteration 5 --
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+bool(false)
+
+-- iteration 6 --
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+bool(false)
+
+-- iteration 9 --
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+bool(false)
+
+-- iteration 10 --
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+bool(false)
+
+-- iteration 11 --
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 13 --
+array(0) {
+}
+NULL
+array(0) {
+}
+NULL
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation45.phpt b/ext/standard/tests/file/fscanf_variation45.phpt
new file mode 100644
index 0000000..7db0cc9
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation45.phpt
@@ -0,0 +1,1008 @@
+--TEST--
+Test fscanf() function: usage variations - scientific formats with integer values
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan different integer values using different scientific format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different scientific format types with different integer values ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation45.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+// 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
+);
+// various scientific formats
+$scientific_formats = array( "%e", "%he", "%le", "%Le", " %e", "%e ", "% e", "\t%e", "\n%e", "%4e", "%30e", "%[0-1]", "%*e");
+
+$counter = 1;
+
+// writing to the file
+foreach($valid_ints as $int_value) {
+ @fprintf($file_handle, $int_value);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different scientific formats
+foreach($scientific_formats as $scientific_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$scientific_format) );
+ }
+ $counter++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation45.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different scientific format types with different integer values ***
+
+-- iteration 1 --
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(-1)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(-2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483640)
+}
+array(1) {
+ [0]=>
+ float(4667)
+}
+array(1) {
+ [0]=>
+ float(4779)
+}
+array(1) {
+ [0]=>
+ float(4095)
+}
+array(1) {
+ [0]=>
+ float(250)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(83)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+bool(false)
+
+-- iteration 2 --
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(-1)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(-2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483640)
+}
+array(1) {
+ [0]=>
+ float(4667)
+}
+array(1) {
+ [0]=>
+ float(4779)
+}
+array(1) {
+ [0]=>
+ float(4095)
+}
+array(1) {
+ [0]=>
+ float(250)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(83)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+bool(false)
+
+-- iteration 3 --
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(-1)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(-2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483640)
+}
+array(1) {
+ [0]=>
+ float(4667)
+}
+array(1) {
+ [0]=>
+ float(4779)
+}
+array(1) {
+ [0]=>
+ float(4095)
+}
+array(1) {
+ [0]=>
+ float(250)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(83)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+bool(false)
+
+-- iteration 4 --
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(-1)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(-2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483640)
+}
+array(1) {
+ [0]=>
+ float(4667)
+}
+array(1) {
+ [0]=>
+ float(4779)
+}
+array(1) {
+ [0]=>
+ float(4095)
+}
+array(1) {
+ [0]=>
+ float(250)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(83)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+bool(false)
+
+-- iteration 5 --
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(-1)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(-2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483640)
+}
+array(1) {
+ [0]=>
+ float(4667)
+}
+array(1) {
+ [0]=>
+ float(4779)
+}
+array(1) {
+ [0]=>
+ float(4095)
+}
+array(1) {
+ [0]=>
+ float(250)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(83)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+bool(false)
+
+-- iteration 6 --
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(-1)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(-2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483640)
+}
+array(1) {
+ [0]=>
+ float(4667)
+}
+array(1) {
+ [0]=>
+ float(4779)
+}
+array(1) {
+ [0]=>
+ float(4095)
+}
+array(1) {
+ [0]=>
+ float(250)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(83)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(-1)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(-2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483640)
+}
+array(1) {
+ [0]=>
+ float(4667)
+}
+array(1) {
+ [0]=>
+ float(4779)
+}
+array(1) {
+ [0]=>
+ float(4095)
+}
+array(1) {
+ [0]=>
+ float(250)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(83)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+bool(false)
+
+-- iteration 9 --
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(-1)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(-2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483640)
+}
+array(1) {
+ [0]=>
+ float(4667)
+}
+array(1) {
+ [0]=>
+ float(4779)
+}
+array(1) {
+ [0]=>
+ float(4095)
+}
+array(1) {
+ [0]=>
+ float(250)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(83)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+bool(false)
+
+-- iteration 10 --
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(-1)
+}
+array(1) {
+ [0]=>
+ float(-214)
+}
+array(1) {
+ [0]=>
+ float(-214)
+}
+array(1) {
+ [0]=>
+ float(2147)
+}
+array(1) {
+ [0]=>
+ float(2147)
+}
+array(1) {
+ [0]=>
+ float(4667)
+}
+array(1) {
+ [0]=>
+ float(4779)
+}
+array(1) {
+ [0]=>
+ float(4095)
+}
+array(1) {
+ [0]=>
+ float(250)
+}
+array(1) {
+ [0]=>
+ float(-214)
+}
+array(1) {
+ [0]=>
+ float(2147)
+}
+array(1) {
+ [0]=>
+ float(2147)
+}
+array(1) {
+ [0]=>
+ float(83)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(-214)
+}
+array(1) {
+ [0]=>
+ float(2147)
+}
+bool(false)
+
+-- iteration 11 --
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(-1)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(-2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483640)
+}
+array(1) {
+ [0]=>
+ float(4667)
+}
+array(1) {
+ [0]=>
+ float(4779)
+}
+array(1) {
+ [0]=>
+ float(4095)
+}
+array(1) {
+ [0]=>
+ float(250)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(83)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 13 --
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation46.phpt b/ext/standard/tests/file/fscanf_variation46.phpt
new file mode 100644
index 0000000..7145c86
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation46.phpt
@@ -0,0 +1,859 @@
+--TEST--
+Test fscanf() function: usage variations - scientific formats with float values
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan float values using different scientific format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different scientific format types with float values ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation46.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+// array of float type values
+
+$float_values = array (
+ -2147483649,
+ 2147483648,
+ -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
+);
+
+$scientific_formats = array( "%e", "%he", "%le", "%Le", " %e", "%e ", "% e", "\t%e", "\n%e", "%4e", "%30e", "%[0-9]", "%*e");
+
+$counter = 1;
+
+// writing to the file
+foreach($float_values as $value) {
+ @fprintf($file_handle, $value);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different scientific formats
+foreach($scientific_formats as $scientific_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$scientific_format) );
+ }
+ $counter++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation46.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different scientific format types with float values ***
+
+-- iteration 1 --
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(2147483648)
+}
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(34359738369)
+}
+array(1) {
+ [0]=>
+ float(2147483649)
+}
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(-0.1)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(100000)
+}
+array(1) {
+ [0]=>
+ float(-1000000)
+}
+array(1) {
+ [0]=>
+ float(100000000)
+}
+array(1) {
+ [0]=>
+ float(-1000000000)
+}
+array(1) {
+ [0]=>
+ float(10)
+}
+array(1) {
+ [0]=>
+ float(1050000)
+}
+bool(false)
+
+-- iteration 2 --
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(2147483648)
+}
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(34359738369)
+}
+array(1) {
+ [0]=>
+ float(2147483649)
+}
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(-0.1)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(100000)
+}
+array(1) {
+ [0]=>
+ float(-1000000)
+}
+array(1) {
+ [0]=>
+ float(100000000)
+}
+array(1) {
+ [0]=>
+ float(-1000000000)
+}
+array(1) {
+ [0]=>
+ float(10)
+}
+array(1) {
+ [0]=>
+ float(1050000)
+}
+bool(false)
+
+-- iteration 3 --
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(2147483648)
+}
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(34359738369)
+}
+array(1) {
+ [0]=>
+ float(2147483649)
+}
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(-0.1)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(100000)
+}
+array(1) {
+ [0]=>
+ float(-1000000)
+}
+array(1) {
+ [0]=>
+ float(100000000)
+}
+array(1) {
+ [0]=>
+ float(-1000000000)
+}
+array(1) {
+ [0]=>
+ float(10)
+}
+array(1) {
+ [0]=>
+ float(1050000)
+}
+bool(false)
+
+-- iteration 4 --
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(2147483648)
+}
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(34359738369)
+}
+array(1) {
+ [0]=>
+ float(2147483649)
+}
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(-0.1)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(100000)
+}
+array(1) {
+ [0]=>
+ float(-1000000)
+}
+array(1) {
+ [0]=>
+ float(100000000)
+}
+array(1) {
+ [0]=>
+ float(-1000000000)
+}
+array(1) {
+ [0]=>
+ float(10)
+}
+array(1) {
+ [0]=>
+ float(1050000)
+}
+bool(false)
+
+-- iteration 5 --
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(2147483648)
+}
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(34359738369)
+}
+array(1) {
+ [0]=>
+ float(2147483649)
+}
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(-0.1)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(100000)
+}
+array(1) {
+ [0]=>
+ float(-1000000)
+}
+array(1) {
+ [0]=>
+ float(100000000)
+}
+array(1) {
+ [0]=>
+ float(-1000000000)
+}
+array(1) {
+ [0]=>
+ float(10)
+}
+array(1) {
+ [0]=>
+ float(1050000)
+}
+bool(false)
+
+-- iteration 6 --
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(2147483648)
+}
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(34359738369)
+}
+array(1) {
+ [0]=>
+ float(2147483649)
+}
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(-0.1)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(100000)
+}
+array(1) {
+ [0]=>
+ float(-1000000)
+}
+array(1) {
+ [0]=>
+ float(100000000)
+}
+array(1) {
+ [0]=>
+ float(-1000000000)
+}
+array(1) {
+ [0]=>
+ float(10)
+}
+array(1) {
+ [0]=>
+ float(1050000)
+}
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(2147483648)
+}
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(34359738369)
+}
+array(1) {
+ [0]=>
+ float(2147483649)
+}
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(-0.1)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(100000)
+}
+array(1) {
+ [0]=>
+ float(-1000000)
+}
+array(1) {
+ [0]=>
+ float(100000000)
+}
+array(1) {
+ [0]=>
+ float(-1000000000)
+}
+array(1) {
+ [0]=>
+ float(10)
+}
+array(1) {
+ [0]=>
+ float(1050000)
+}
+bool(false)
+
+-- iteration 9 --
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(2147483648)
+}
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(34359738369)
+}
+array(1) {
+ [0]=>
+ float(2147483649)
+}
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(-0.1)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(100000)
+}
+array(1) {
+ [0]=>
+ float(-1000000)
+}
+array(1) {
+ [0]=>
+ float(100000000)
+}
+array(1) {
+ [0]=>
+ float(-1000000000)
+}
+array(1) {
+ [0]=>
+ float(10)
+}
+array(1) {
+ [0]=>
+ float(1050000)
+}
+bool(false)
+
+-- iteration 10 --
+array(1) {
+ [0]=>
+ float(-214)
+}
+array(1) {
+ [0]=>
+ float(2147)
+}
+array(1) {
+ [0]=>
+ float(-214)
+}
+array(1) {
+ [0]=>
+ float(3435)
+}
+array(1) {
+ [0]=>
+ float(2147)
+}
+array(1) {
+ [0]=>
+ float(-214)
+}
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(-0.1)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(1000)
+}
+array(1) {
+ [0]=>
+ float(-100)
+}
+array(1) {
+ [0]=>
+ float(1000)
+}
+array(1) {
+ [0]=>
+ float(-100)
+}
+array(1) {
+ [0]=>
+ float(10)
+}
+array(1) {
+ [0]=>
+ float(1050)
+}
+bool(false)
+
+-- iteration 11 --
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(2147483648)
+}
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(34359738369)
+}
+array(1) {
+ [0]=>
+ float(2147483649)
+}
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(-0.1)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(100000)
+}
+array(1) {
+ [0]=>
+ float(-1000000)
+}
+array(1) {
+ [0]=>
+ float(100000000)
+}
+array(1) {
+ [0]=>
+ float(-1000000000)
+}
+array(1) {
+ [0]=>
+ float(10)
+}
+array(1) {
+ [0]=>
+ float(1050000)
+}
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(11) "34359738369"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483649"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(6) "100000"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(9) "100000000"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(2) "10"
+}
+array(1) {
+ [0]=>
+ string(7) "1050000"
+}
+bool(false)
+
+-- iteration 13 --
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation47.phpt b/ext/standard/tests/file/fscanf_variation47.phpt
new file mode 100644
index 0000000..7010571
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation47.phpt
@@ -0,0 +1,217 @@
+--TEST--
+Test fscanf() function: usage variations - scientific formats with resource
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan resource type using different scientific format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different scientific format types with resource ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation47.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+
+// resource type variable
+$fp = fopen (__FILE__, "r");
+$dfp = opendir ( dirname(__FILE__) );
+
+// array of resource types
+$resource_types = array (
+ $fp,
+ $dfp
+);
+
+$scientific_formats = array( "%e", "%he", "%le", "%Le", " %e", "%e ", "% e", "\t%e", "\n%e", "%4e", "%30e", "%[0-9]", "%*e");
+
+$counter = 1;
+
+// writing to the file
+foreach($resource_types as $value) {
+ @fprintf($file_handle, $value);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different scientific formats
+foreach($scientific_formats as $scientific_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$scientific_format) );
+ }
+ $counter++;
+}
+
+// closing the resources
+fclose($fp);
+closedir($dfp);
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation47.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different scientific format types with resource ***
+
+-- iteration 1 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 2 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 3 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 4 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 5 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 6 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 9 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 10 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 11 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 13 --
+array(0) {
+}
+array(0) {
+}
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation48.phpt b/ext/standard/tests/file/fscanf_variation48.phpt
new file mode 100644
index 0000000..5b61e5b
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation48.phpt
@@ -0,0 +1,707 @@
+--TEST--
+Test fscanf() function: usage variations - scientific formats with arrays
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan arrays using different scientific format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different scientific format types with arrays ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation48.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+// array types
+$array_types = array (
+ 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)
+);
+
+$scientific_formats = array( "%e", "%he", "%le", "%Le", " %e", "%e ", "% e", "\t%e", "\n%e", "%4e", "%30e", "%[0-9]", "%*e");
+
+$counter = 1;
+
+// writing to the file
+foreach($array_types as $value) {
+ @fprintf($file_handle, $value);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different scientific formats
+foreach($scientific_formats as $scientific_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$scientific_format) );
+ }
+ $counter++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation48.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different scientific format types with arrays ***
+
+-- iteration 1 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 2 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 3 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 4 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 5 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 6 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 9 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 10 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 11 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 13 --
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+bool(false)
+
+*** Done ***
diff --git a/ext/standard/tests/file/fscanf_variation49.phpt b/ext/standard/tests/file/fscanf_variation49.phpt
new file mode 100644
index 0000000..4e314fb
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation49.phpt
@@ -0,0 +1,946 @@
+--TEST--
+Test fscanf() function: usage variations - scientific formats with strings
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan strings using different scientific format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different scientific format types with strings ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation49.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+// array of strings
+$strings = array (
+ "",
+ '',
+ "0",
+ '0',
+ "1",
+ '1',
+ "\x01",
+ '\x01',
+ "\01",
+ '\01',
+ 'string',
+ "string",
+ "true",
+ "FALSE",
+ 'false',
+ 'TRUE',
+ "NULL",
+ 'null'
+);
+
+$scientific_formats = array( "%e", "%he", "%le", "%Le", " %e", "%e ", "% e", "\t%e", "\n%e", "%4e", "%30e", "%[0-9]", "%*e");
+
+$counter = 1;
+
+// writing to the file
+foreach($strings as $string) {
+ @fprintf($file_handle, $string);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different scientific formats
+foreach($scientific_formats as $scientific_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$scientific_format) );
+ }
+ $counter++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation49.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different scientific format types with strings ***
+
+-- iteration 1 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 2 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 3 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 4 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 5 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 6 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 9 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 10 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 11 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 13 --
+NULL
+NULL
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation5.phpt b/ext/standard/tests/file/fscanf_variation5.phpt
new file mode 100644
index 0000000..750e604
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation5.phpt
@@ -0,0 +1,708 @@
+--TEST--
+Test fscanf() function: usage variations - integer formats with arrays
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan arrays using different integer format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different integer format types with arrays ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation5.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+// array types
+$array_types = array (
+ 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)
+);
+
+$int_formats = array( "%d", "%hd", "%ld", "%Ld", " %d", "%d ", "% d", "\t%d", "\n%d", "%4d", "%30d", "%[0-9]", "%*d");
+
+$counter = 1;
+
+// writing to the file
+foreach($array_types as $value) {
+ @fprintf($file_handle, $value);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different integer formats
+foreach($int_formats as $int_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$int_format) );
+ }
+ $counter++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation5.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different integer format types with arrays ***
+
+-- iteration 1 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 2 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 3 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 4 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 5 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 6 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 9 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 10 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 11 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 13 --
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation50.phpt b/ext/standard/tests/file/fscanf_variation50.phpt
new file mode 100644
index 0000000..e46dbdb
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation50.phpt
@@ -0,0 +1,246 @@
+--TEST--
+Test fscanf() function: usage variations - scientific formats with boolean
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan boolean data using different scientific format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different scientific format types with boolean data ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation50.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+// array of boolean types
+$bool_types = array (
+ true,
+ false,
+ TRUE,
+ FALSE,
+);
+
+$scientific_formats = array( "%e", "%he", "%le", "%Le", " %e", "%e ", "% e", "\t%e", "\n%e", "%4e", "%30e", "%[0-9]", "%*e");
+
+$counter = 1;
+
+// writing to the file
+foreach($bool_types as $value) {
+ @fprintf($file_handle, $value);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different scientific formats
+foreach($scientific_formats as $scientific_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$scientific_format) );
+ }
+ $counter++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation50.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different scientific format types with boolean data ***
+
+-- iteration 1 --
+array(1) {
+ [0]=>
+ float(1)
+}
+NULL
+array(1) {
+ [0]=>
+ float(1)
+}
+NULL
+bool(false)
+
+-- iteration 2 --
+array(1) {
+ [0]=>
+ float(1)
+}
+NULL
+array(1) {
+ [0]=>
+ float(1)
+}
+NULL
+bool(false)
+
+-- iteration 3 --
+array(1) {
+ [0]=>
+ float(1)
+}
+NULL
+array(1) {
+ [0]=>
+ float(1)
+}
+NULL
+bool(false)
+
+-- iteration 4 --
+array(1) {
+ [0]=>
+ float(1)
+}
+NULL
+array(1) {
+ [0]=>
+ float(1)
+}
+NULL
+bool(false)
+
+-- iteration 5 --
+array(1) {
+ [0]=>
+ float(1)
+}
+NULL
+array(1) {
+ [0]=>
+ float(1)
+}
+NULL
+bool(false)
+
+-- iteration 6 --
+array(1) {
+ [0]=>
+ float(1)
+}
+NULL
+array(1) {
+ [0]=>
+ float(1)
+}
+NULL
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+array(1) {
+ [0]=>
+ float(1)
+}
+NULL
+array(1) {
+ [0]=>
+ float(1)
+}
+NULL
+bool(false)
+
+-- iteration 9 --
+array(1) {
+ [0]=>
+ float(1)
+}
+NULL
+array(1) {
+ [0]=>
+ float(1)
+}
+NULL
+bool(false)
+
+-- iteration 10 --
+array(1) {
+ [0]=>
+ float(1)
+}
+NULL
+array(1) {
+ [0]=>
+ float(1)
+}
+NULL
+bool(false)
+
+-- iteration 11 --
+array(1) {
+ [0]=>
+ float(1)
+}
+NULL
+array(1) {
+ [0]=>
+ float(1)
+}
+NULL
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 13 --
+array(0) {
+}
+NULL
+array(0) {
+}
+NULL
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation51.phpt b/ext/standard/tests/file/fscanf_variation51.phpt
new file mode 100644
index 0000000..0f5ab5a
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation51.phpt
@@ -0,0 +1,153 @@
+--TEST--
+Test fscanf() function: usage variations - file opened in write only mode
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan a file for read when file is opened inwrite only mode */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): to read from a file opened in write only mode ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation51.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+//writing data to the file
+@fwrite($file_handle,"sample text\n");
+
+//closing the file
+fclose($file_handle);
+
+// various formats
+$formats = array( "%d", "%f", "%e", "%u", " %s", "%x", "%o");
+
+$counter = 1;
+
+// various write only modes
+$modes = array("w", "wb", "wt",
+ "a", "ab", "at",
+ "x", "xb", "xt"
+ );
+
+$counter = 1;
+// reading the values from file using different integer formats
+foreach($modes as $mode) {
+
+ $file_handle = fopen($filename, $mode);
+ if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+ }
+ echo "\n-- iteration $counter --\n";
+
+ foreach($formats as $format) {
+ var_dump( fscanf($file_handle,$format) );
+ rewind($file_handle);
+ }
+ $counter++;
+ fclose($file_handle);
+ unlink($filename);
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation51.tmp";
+if(file_exists($filename)) {
+ unlink($filename);
+}
+?>
+--EXPECT--
+*** Test fscanf(): to read from a file opened in write only mode ***
+
+-- iteration 1 --
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+-- iteration 2 --
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+-- iteration 3 --
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+-- iteration 4 --
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+-- iteration 5 --
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+-- iteration 6 --
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+-- iteration 7 --
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+-- iteration 8 --
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+-- iteration 9 --
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation52.phpt b/ext/standard/tests/file/fscanf_variation52.phpt
new file mode 100644
index 0000000..bf82ab8
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation52.phpt
@@ -0,0 +1,178 @@
+--TEST--
+Test fscanf() function: usage variations - empty file
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan an empty file */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): to read an empty file ***\n";
+
+// various formats
+$formats = array( "%d", "%f", "%e", "%u", " %s", "%x", "%o");
+
+$counter = 1;
+
+// various read modes
+$modes = array("r", "rb", "rt", "r+", "r+b", "r+t",
+ "w+", "w+b", "w+t",
+ "a+", "a+b", "a+t"
+ );
+
+$counter = 1;
+// reading the values from file using different integer formats
+foreach($modes as $mode) {
+
+ // create an empty file
+ $filename = "$file_path/fscanf_variation52.tmp";
+ $file_handle = fopen($filename, "w");
+ if($file_handle == false)
+ exit("Error:failed to open file $filename");
+ //closing the file
+ fclose($file_handle);
+
+ // opening file in $mode mode
+ $file_handle = fopen($filename, $mode);
+ if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+ }
+ echo "\n-- iteration $counter --\n";
+
+ foreach($formats as $format) {
+ var_dump( fscanf($file_handle,$format) );
+ rewind($file_handle);
+ }
+ $counter++;
+ fclose($file_handle);
+ unlink($filename);
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation52.tmp";
+if(file_exists($filename)) {
+ unlink($filename);
+}
+?>
+--EXPECT--
+*** Test fscanf(): to read an empty file ***
+
+-- iteration 1 --
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+-- iteration 2 --
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+-- iteration 3 --
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+-- iteration 4 --
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+-- iteration 5 --
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+-- iteration 6 --
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+-- iteration 7 --
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+-- iteration 8 --
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+-- iteration 9 --
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+-- iteration 10 --
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+-- iteration 11 --
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+-- iteration 12 --
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation53.phpt b/ext/standard/tests/file/fscanf_variation53.phpt
new file mode 100644
index 0000000..b65bccf
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation53.phpt
@@ -0,0 +1,229 @@
+--TEST--
+Test fscanf() function: usage variations - file pointer pointing to EOF
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to read a file when file pointer is pointing to EOF */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): to read a file when file pointer is pointing to EOF ***\n";
+
+// various formats
+$formats = array( "%d", "%f", "%e", "%u", " %s", "%x", "%o");
+
+$counter = 1;
+
+// various read modes
+$modes = array("r", "rb", "rt", "r+", "r+b", "r+t",
+ "w+", "w+b", "w+t",
+ "a+", "a+b", "a+t"
+ );
+
+$counter = 1;
+// reading the values from file using different integer formats
+foreach($modes as $mode) {
+
+ // create an empty file
+ $filename = "$file_path/fscanf_variation52.tmp";
+ $file_handle = fopen($filename, "w");
+ if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+ //writing data to the file
+ @fwrite($file_handle, "Sample text\n");
+
+ // writing a blank line
+ @fwrite($file_handle, "\n");
+
+ //closing the file
+ fclose($file_handle);
+
+ // opening file in $mode mode
+ $file_handle = fopen($filename, $mode);
+ if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+ }
+ echo "\n-- iteration $counter --\n";
+
+ // current location
+ var_dump( ftell($file_handle) );
+
+ // set the file pointer to eof
+ var_dump( fseek($file_handle, 0, SEEK_END) );
+
+ // current location
+ var_dump( ftell($file_handle) );
+
+ foreach($formats as $format) {
+ var_dump( fscanf($file_handle,$format) );
+ }
+ $counter++;
+ fclose($file_handle);
+ unlink($filename);
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation53.tmp";
+if(file_exists($filename)) {
+ unlink($filename);
+}
+?>
+--EXPECT--
+*** Test fscanf(): to read a file when file pointer is pointing to EOF ***
+
+-- iteration 1 --
+int(0)
+int(0)
+int(13)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+-- iteration 2 --
+int(0)
+int(0)
+int(13)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+-- iteration 3 --
+int(0)
+int(0)
+int(13)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+-- iteration 4 --
+int(0)
+int(0)
+int(13)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+-- iteration 5 --
+int(0)
+int(0)
+int(13)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+-- iteration 6 --
+int(0)
+int(0)
+int(13)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+-- iteration 7 --
+int(0)
+int(0)
+int(0)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+-- iteration 8 --
+int(0)
+int(0)
+int(0)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+-- iteration 9 --
+int(0)
+int(0)
+int(0)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+-- iteration 10 --
+int(0)
+int(0)
+int(13)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+-- iteration 11 --
+int(0)
+int(0)
+int(13)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+-- iteration 12 --
+int(0)
+int(0)
+int(13)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation54.phpt b/ext/standard/tests/file/fscanf_variation54.phpt
new file mode 100644
index 0000000..0937e5b
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation54.phpt
@@ -0,0 +1,101 @@
+--TEST--
+Test fscanf() function: usage variations - objects
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan a file to read objects */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): to read objects from a file ***\n";
+
+// declare a class
+class foo
+{
+ public $var1 = 1;
+ public $var2 = 2;
+ function __toString() {
+ return "Object";
+ }
+}
+
+// create an object
+$obj = new foo(); //creating new object
+
+// create a file
+$filename = "$file_path/fscanf_variation54.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+//writing object to the file
+fwrite($file_handle, $obj);
+
+//closing the file
+fclose($file_handle);
+
+// various formats
+$formats = array( "%d", "%f", "%e", "%u", " %s", "%x", "%o");
+
+$counter = 1;
+
+// opening file for read
+$file_handle = fopen($filename, "r");
+ if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+ }
+echo "\n-- iteration $counter --\n";
+
+foreach($formats as $format) {
+ var_dump( fscanf($file_handle,$format) );
+ rewind($file_handle);
+}
+
+fclose($file_handle);
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation54.tmp";
+unlink($filename);
+?>
+--EXPECT--
+*** Test fscanf(): to read objects from a file ***
+
+-- iteration 1 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(6) "Object"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation55.phpt b/ext/standard/tests/file/fscanf_variation55.phpt
new file mode 100644
index 0000000..1777f79
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation55.phpt
@@ -0,0 +1,1691 @@
+--TEST--
+Test fscanf() function: usage variations - tracking file pointer while reading
+--SKIPIF--
+<?php
+if (PHP_INT_SIZE != 4) {
+ die("skip this test is for 32bit platform only");
+}
+?>
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/*
+ Test fscanf() to scan data using different format types and also
+ tracking the file pointer movement along with reading
+ */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): tracking file pointer along with reading data from file ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation55.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+// different valid data
+$valid_data = array(
+ 12345, // integer value
+ -12345,
+ 123.45, // float value
+ -123.45,
+ 0x123B, // hexadecimal value
+ 0x12ab,
+ 0123, // octal value
+ -0123,
+ "abcde", // string
+ 'abcde',
+ 10e3, // exponential value
+ 10e-3
+);
+// various formats
+$int_formats = array( "%d", "%f", "%s", "%o", "%x", "%u", "%c", "%e");
+
+$counter = 1;
+
+// writing to the file
+foreach($valid_data as $data) {
+ @fprintf($file_handle, $data);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+$modes = array("r", "rb", "rt");
+
+foreach($modes as $mode) {
+
+ echo "\n*** File opened in $mode mode ***\n";
+ // opening the file for reading
+ $file_handle = fopen($filename, $mode);
+ if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+ }
+
+ $counter = 1;
+ // reading different data from file using different formats
+ foreach($int_formats as $int_format) {
+ // current file pointer position
+ var_dump( ftell($file_handle) );
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ // current file pointer position after rewind operation
+ var_dump( ftell($file_handle) );
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( ftell($file_handle) );
+ var_dump( fscanf($file_handle,$int_format) );
+ }
+ $counter++;
+ } // end of inner for loop
+} // end of outer for loop
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation55.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): tracking file pointer along with reading data from file ***
+
+*** File opened in r mode ***
+int(0)
+int(0)
+
+-- iteration 1 --
+int(0)
+array(1) {
+ [0]=>
+ int(12345)
+}
+int(6)
+array(1) {
+ [0]=>
+ int(-12345)
+}
+int(13)
+array(1) {
+ [0]=>
+ int(123)
+}
+int(20)
+array(1) {
+ [0]=>
+ int(-123)
+}
+int(28)
+array(1) {
+ [0]=>
+ int(4667)
+}
+int(33)
+array(1) {
+ [0]=>
+ int(4779)
+}
+int(38)
+array(1) {
+ [0]=>
+ int(83)
+}
+int(41)
+array(1) {
+ [0]=>
+ int(-83)
+}
+int(45)
+array(1) {
+ [0]=>
+ NULL
+}
+int(51)
+array(1) {
+ [0]=>
+ NULL
+}
+int(57)
+array(1) {
+ [0]=>
+ int(10000)
+}
+int(63)
+array(1) {
+ [0]=>
+ int(0)
+}
+int(68)
+bool(false)
+int(68)
+int(0)
+
+-- iteration 2 --
+int(0)
+array(1) {
+ [0]=>
+ float(12345)
+}
+int(6)
+array(1) {
+ [0]=>
+ float(-12345)
+}
+int(13)
+array(1) {
+ [0]=>
+ float(123.45)
+}
+int(20)
+array(1) {
+ [0]=>
+ float(-123.45)
+}
+int(28)
+array(1) {
+ [0]=>
+ float(4667)
+}
+int(33)
+array(1) {
+ [0]=>
+ float(4779)
+}
+int(38)
+array(1) {
+ [0]=>
+ float(83)
+}
+int(41)
+array(1) {
+ [0]=>
+ float(-83)
+}
+int(45)
+array(1) {
+ [0]=>
+ NULL
+}
+int(51)
+array(1) {
+ [0]=>
+ NULL
+}
+int(57)
+array(1) {
+ [0]=>
+ float(10000)
+}
+int(63)
+array(1) {
+ [0]=>
+ float(0.01)
+}
+int(68)
+bool(false)
+int(68)
+int(0)
+
+-- iteration 3 --
+int(0)
+array(1) {
+ [0]=>
+ string(5) "12345"
+}
+int(6)
+array(1) {
+ [0]=>
+ string(6) "-12345"
+}
+int(13)
+array(1) {
+ [0]=>
+ string(6) "123.45"
+}
+int(20)
+array(1) {
+ [0]=>
+ string(7) "-123.45"
+}
+int(28)
+array(1) {
+ [0]=>
+ string(4) "4667"
+}
+int(33)
+array(1) {
+ [0]=>
+ string(4) "4779"
+}
+int(38)
+array(1) {
+ [0]=>
+ string(2) "83"
+}
+int(41)
+array(1) {
+ [0]=>
+ string(3) "-83"
+}
+int(45)
+array(1) {
+ [0]=>
+ string(5) "abcde"
+}
+int(51)
+array(1) {
+ [0]=>
+ string(5) "abcde"
+}
+int(57)
+array(1) {
+ [0]=>
+ string(5) "10000"
+}
+int(63)
+array(1) {
+ [0]=>
+ string(4) "0.01"
+}
+int(68)
+bool(false)
+int(68)
+int(0)
+
+-- iteration 4 --
+int(0)
+array(1) {
+ [0]=>
+ int(5349)
+}
+int(6)
+array(1) {
+ [0]=>
+ int(-5349)
+}
+int(13)
+array(1) {
+ [0]=>
+ int(83)
+}
+int(20)
+array(1) {
+ [0]=>
+ int(-83)
+}
+int(28)
+array(1) {
+ [0]=>
+ int(2487)
+}
+int(33)
+array(1) {
+ [0]=>
+ int(319)
+}
+int(38)
+array(1) {
+ [0]=>
+ NULL
+}
+int(41)
+array(1) {
+ [0]=>
+ NULL
+}
+int(45)
+array(1) {
+ [0]=>
+ NULL
+}
+int(51)
+array(1) {
+ [0]=>
+ NULL
+}
+int(57)
+array(1) {
+ [0]=>
+ int(4096)
+}
+int(63)
+array(1) {
+ [0]=>
+ int(0)
+}
+int(68)
+bool(false)
+int(68)
+int(0)
+
+-- iteration 5 --
+int(0)
+array(1) {
+ [0]=>
+ int(74565)
+}
+int(6)
+array(1) {
+ [0]=>
+ int(-74565)
+}
+int(13)
+array(1) {
+ [0]=>
+ int(291)
+}
+int(20)
+array(1) {
+ [0]=>
+ int(-291)
+}
+int(28)
+array(1) {
+ [0]=>
+ int(18023)
+}
+int(33)
+array(1) {
+ [0]=>
+ int(18297)
+}
+int(38)
+array(1) {
+ [0]=>
+ int(131)
+}
+int(41)
+array(1) {
+ [0]=>
+ int(-131)
+}
+int(45)
+array(1) {
+ [0]=>
+ int(703710)
+}
+int(51)
+array(1) {
+ [0]=>
+ int(703710)
+}
+int(57)
+array(1) {
+ [0]=>
+ int(65536)
+}
+int(63)
+array(1) {
+ [0]=>
+ int(0)
+}
+int(68)
+bool(false)
+int(68)
+int(0)
+
+-- iteration 6 --
+int(0)
+array(1) {
+ [0]=>
+ int(12345)
+}
+int(6)
+array(1) {
+ [0]=>
+ string(10) "4294954951"
+}
+int(13)
+array(1) {
+ [0]=>
+ int(123)
+}
+int(20)
+array(1) {
+ [0]=>
+ string(10) "4294967173"
+}
+int(28)
+array(1) {
+ [0]=>
+ int(4667)
+}
+int(33)
+array(1) {
+ [0]=>
+ int(4779)
+}
+int(38)
+array(1) {
+ [0]=>
+ int(83)
+}
+int(41)
+array(1) {
+ [0]=>
+ string(10) "4294967213"
+}
+int(45)
+array(1) {
+ [0]=>
+ NULL
+}
+int(51)
+array(1) {
+ [0]=>
+ NULL
+}
+int(57)
+array(1) {
+ [0]=>
+ int(10000)
+}
+int(63)
+array(1) {
+ [0]=>
+ int(0)
+}
+int(68)
+bool(false)
+int(68)
+int(0)
+
+-- iteration 7 --
+int(0)
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+int(6)
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+int(13)
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+int(20)
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+int(28)
+array(1) {
+ [0]=>
+ string(1) "4"
+}
+int(33)
+array(1) {
+ [0]=>
+ string(1) "4"
+}
+int(38)
+array(1) {
+ [0]=>
+ string(1) "8"
+}
+int(41)
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+int(45)
+array(1) {
+ [0]=>
+ string(1) "a"
+}
+int(51)
+array(1) {
+ [0]=>
+ string(1) "a"
+}
+int(57)
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+int(63)
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+int(68)
+bool(false)
+int(68)
+int(0)
+
+-- iteration 8 --
+int(0)
+array(1) {
+ [0]=>
+ float(12345)
+}
+int(6)
+array(1) {
+ [0]=>
+ float(-12345)
+}
+int(13)
+array(1) {
+ [0]=>
+ float(123.45)
+}
+int(20)
+array(1) {
+ [0]=>
+ float(-123.45)
+}
+int(28)
+array(1) {
+ [0]=>
+ float(4667)
+}
+int(33)
+array(1) {
+ [0]=>
+ float(4779)
+}
+int(38)
+array(1) {
+ [0]=>
+ float(83)
+}
+int(41)
+array(1) {
+ [0]=>
+ float(-83)
+}
+int(45)
+array(1) {
+ [0]=>
+ NULL
+}
+int(51)
+array(1) {
+ [0]=>
+ NULL
+}
+int(57)
+array(1) {
+ [0]=>
+ float(10000)
+}
+int(63)
+array(1) {
+ [0]=>
+ float(0.01)
+}
+int(68)
+bool(false)
+
+*** File opened in rb mode ***
+int(0)
+int(0)
+
+-- iteration 1 --
+int(0)
+array(1) {
+ [0]=>
+ int(12345)
+}
+int(6)
+array(1) {
+ [0]=>
+ int(-12345)
+}
+int(13)
+array(1) {
+ [0]=>
+ int(123)
+}
+int(20)
+array(1) {
+ [0]=>
+ int(-123)
+}
+int(28)
+array(1) {
+ [0]=>
+ int(4667)
+}
+int(33)
+array(1) {
+ [0]=>
+ int(4779)
+}
+int(38)
+array(1) {
+ [0]=>
+ int(83)
+}
+int(41)
+array(1) {
+ [0]=>
+ int(-83)
+}
+int(45)
+array(1) {
+ [0]=>
+ NULL
+}
+int(51)
+array(1) {
+ [0]=>
+ NULL
+}
+int(57)
+array(1) {
+ [0]=>
+ int(10000)
+}
+int(63)
+array(1) {
+ [0]=>
+ int(0)
+}
+int(68)
+bool(false)
+int(68)
+int(0)
+
+-- iteration 2 --
+int(0)
+array(1) {
+ [0]=>
+ float(12345)
+}
+int(6)
+array(1) {
+ [0]=>
+ float(-12345)
+}
+int(13)
+array(1) {
+ [0]=>
+ float(123.45)
+}
+int(20)
+array(1) {
+ [0]=>
+ float(-123.45)
+}
+int(28)
+array(1) {
+ [0]=>
+ float(4667)
+}
+int(33)
+array(1) {
+ [0]=>
+ float(4779)
+}
+int(38)
+array(1) {
+ [0]=>
+ float(83)
+}
+int(41)
+array(1) {
+ [0]=>
+ float(-83)
+}
+int(45)
+array(1) {
+ [0]=>
+ NULL
+}
+int(51)
+array(1) {
+ [0]=>
+ NULL
+}
+int(57)
+array(1) {
+ [0]=>
+ float(10000)
+}
+int(63)
+array(1) {
+ [0]=>
+ float(0.01)
+}
+int(68)
+bool(false)
+int(68)
+int(0)
+
+-- iteration 3 --
+int(0)
+array(1) {
+ [0]=>
+ string(5) "12345"
+}
+int(6)
+array(1) {
+ [0]=>
+ string(6) "-12345"
+}
+int(13)
+array(1) {
+ [0]=>
+ string(6) "123.45"
+}
+int(20)
+array(1) {
+ [0]=>
+ string(7) "-123.45"
+}
+int(28)
+array(1) {
+ [0]=>
+ string(4) "4667"
+}
+int(33)
+array(1) {
+ [0]=>
+ string(4) "4779"
+}
+int(38)
+array(1) {
+ [0]=>
+ string(2) "83"
+}
+int(41)
+array(1) {
+ [0]=>
+ string(3) "-83"
+}
+int(45)
+array(1) {
+ [0]=>
+ string(5) "abcde"
+}
+int(51)
+array(1) {
+ [0]=>
+ string(5) "abcde"
+}
+int(57)
+array(1) {
+ [0]=>
+ string(5) "10000"
+}
+int(63)
+array(1) {
+ [0]=>
+ string(4) "0.01"
+}
+int(68)
+bool(false)
+int(68)
+int(0)
+
+-- iteration 4 --
+int(0)
+array(1) {
+ [0]=>
+ int(5349)
+}
+int(6)
+array(1) {
+ [0]=>
+ int(-5349)
+}
+int(13)
+array(1) {
+ [0]=>
+ int(83)
+}
+int(20)
+array(1) {
+ [0]=>
+ int(-83)
+}
+int(28)
+array(1) {
+ [0]=>
+ int(2487)
+}
+int(33)
+array(1) {
+ [0]=>
+ int(319)
+}
+int(38)
+array(1) {
+ [0]=>
+ NULL
+}
+int(41)
+array(1) {
+ [0]=>
+ NULL
+}
+int(45)
+array(1) {
+ [0]=>
+ NULL
+}
+int(51)
+array(1) {
+ [0]=>
+ NULL
+}
+int(57)
+array(1) {
+ [0]=>
+ int(4096)
+}
+int(63)
+array(1) {
+ [0]=>
+ int(0)
+}
+int(68)
+bool(false)
+int(68)
+int(0)
+
+-- iteration 5 --
+int(0)
+array(1) {
+ [0]=>
+ int(74565)
+}
+int(6)
+array(1) {
+ [0]=>
+ int(-74565)
+}
+int(13)
+array(1) {
+ [0]=>
+ int(291)
+}
+int(20)
+array(1) {
+ [0]=>
+ int(-291)
+}
+int(28)
+array(1) {
+ [0]=>
+ int(18023)
+}
+int(33)
+array(1) {
+ [0]=>
+ int(18297)
+}
+int(38)
+array(1) {
+ [0]=>
+ int(131)
+}
+int(41)
+array(1) {
+ [0]=>
+ int(-131)
+}
+int(45)
+array(1) {
+ [0]=>
+ int(703710)
+}
+int(51)
+array(1) {
+ [0]=>
+ int(703710)
+}
+int(57)
+array(1) {
+ [0]=>
+ int(65536)
+}
+int(63)
+array(1) {
+ [0]=>
+ int(0)
+}
+int(68)
+bool(false)
+int(68)
+int(0)
+
+-- iteration 6 --
+int(0)
+array(1) {
+ [0]=>
+ int(12345)
+}
+int(6)
+array(1) {
+ [0]=>
+ string(10) "4294954951"
+}
+int(13)
+array(1) {
+ [0]=>
+ int(123)
+}
+int(20)
+array(1) {
+ [0]=>
+ string(10) "4294967173"
+}
+int(28)
+array(1) {
+ [0]=>
+ int(4667)
+}
+int(33)
+array(1) {
+ [0]=>
+ int(4779)
+}
+int(38)
+array(1) {
+ [0]=>
+ int(83)
+}
+int(41)
+array(1) {
+ [0]=>
+ string(10) "4294967213"
+}
+int(45)
+array(1) {
+ [0]=>
+ NULL
+}
+int(51)
+array(1) {
+ [0]=>
+ NULL
+}
+int(57)
+array(1) {
+ [0]=>
+ int(10000)
+}
+int(63)
+array(1) {
+ [0]=>
+ int(0)
+}
+int(68)
+bool(false)
+int(68)
+int(0)
+
+-- iteration 7 --
+int(0)
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+int(6)
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+int(13)
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+int(20)
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+int(28)
+array(1) {
+ [0]=>
+ string(1) "4"
+}
+int(33)
+array(1) {
+ [0]=>
+ string(1) "4"
+}
+int(38)
+array(1) {
+ [0]=>
+ string(1) "8"
+}
+int(41)
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+int(45)
+array(1) {
+ [0]=>
+ string(1) "a"
+}
+int(51)
+array(1) {
+ [0]=>
+ string(1) "a"
+}
+int(57)
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+int(63)
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+int(68)
+bool(false)
+int(68)
+int(0)
+
+-- iteration 8 --
+int(0)
+array(1) {
+ [0]=>
+ float(12345)
+}
+int(6)
+array(1) {
+ [0]=>
+ float(-12345)
+}
+int(13)
+array(1) {
+ [0]=>
+ float(123.45)
+}
+int(20)
+array(1) {
+ [0]=>
+ float(-123.45)
+}
+int(28)
+array(1) {
+ [0]=>
+ float(4667)
+}
+int(33)
+array(1) {
+ [0]=>
+ float(4779)
+}
+int(38)
+array(1) {
+ [0]=>
+ float(83)
+}
+int(41)
+array(1) {
+ [0]=>
+ float(-83)
+}
+int(45)
+array(1) {
+ [0]=>
+ NULL
+}
+int(51)
+array(1) {
+ [0]=>
+ NULL
+}
+int(57)
+array(1) {
+ [0]=>
+ float(10000)
+}
+int(63)
+array(1) {
+ [0]=>
+ float(0.01)
+}
+int(68)
+bool(false)
+
+*** File opened in rt mode ***
+int(0)
+int(0)
+
+-- iteration 1 --
+int(0)
+array(1) {
+ [0]=>
+ int(12345)
+}
+int(6)
+array(1) {
+ [0]=>
+ int(-12345)
+}
+int(13)
+array(1) {
+ [0]=>
+ int(123)
+}
+int(20)
+array(1) {
+ [0]=>
+ int(-123)
+}
+int(28)
+array(1) {
+ [0]=>
+ int(4667)
+}
+int(33)
+array(1) {
+ [0]=>
+ int(4779)
+}
+int(38)
+array(1) {
+ [0]=>
+ int(83)
+}
+int(41)
+array(1) {
+ [0]=>
+ int(-83)
+}
+int(45)
+array(1) {
+ [0]=>
+ NULL
+}
+int(51)
+array(1) {
+ [0]=>
+ NULL
+}
+int(57)
+array(1) {
+ [0]=>
+ int(10000)
+}
+int(63)
+array(1) {
+ [0]=>
+ int(0)
+}
+int(68)
+bool(false)
+int(68)
+int(0)
+
+-- iteration 2 --
+int(0)
+array(1) {
+ [0]=>
+ float(12345)
+}
+int(6)
+array(1) {
+ [0]=>
+ float(-12345)
+}
+int(13)
+array(1) {
+ [0]=>
+ float(123.45)
+}
+int(20)
+array(1) {
+ [0]=>
+ float(-123.45)
+}
+int(28)
+array(1) {
+ [0]=>
+ float(4667)
+}
+int(33)
+array(1) {
+ [0]=>
+ float(4779)
+}
+int(38)
+array(1) {
+ [0]=>
+ float(83)
+}
+int(41)
+array(1) {
+ [0]=>
+ float(-83)
+}
+int(45)
+array(1) {
+ [0]=>
+ NULL
+}
+int(51)
+array(1) {
+ [0]=>
+ NULL
+}
+int(57)
+array(1) {
+ [0]=>
+ float(10000)
+}
+int(63)
+array(1) {
+ [0]=>
+ float(0.01)
+}
+int(68)
+bool(false)
+int(68)
+int(0)
+
+-- iteration 3 --
+int(0)
+array(1) {
+ [0]=>
+ string(5) "12345"
+}
+int(6)
+array(1) {
+ [0]=>
+ string(6) "-12345"
+}
+int(13)
+array(1) {
+ [0]=>
+ string(6) "123.45"
+}
+int(20)
+array(1) {
+ [0]=>
+ string(7) "-123.45"
+}
+int(28)
+array(1) {
+ [0]=>
+ string(4) "4667"
+}
+int(33)
+array(1) {
+ [0]=>
+ string(4) "4779"
+}
+int(38)
+array(1) {
+ [0]=>
+ string(2) "83"
+}
+int(41)
+array(1) {
+ [0]=>
+ string(3) "-83"
+}
+int(45)
+array(1) {
+ [0]=>
+ string(5) "abcde"
+}
+int(51)
+array(1) {
+ [0]=>
+ string(5) "abcde"
+}
+int(57)
+array(1) {
+ [0]=>
+ string(5) "10000"
+}
+int(63)
+array(1) {
+ [0]=>
+ string(4) "0.01"
+}
+int(68)
+bool(false)
+int(68)
+int(0)
+
+-- iteration 4 --
+int(0)
+array(1) {
+ [0]=>
+ int(5349)
+}
+int(6)
+array(1) {
+ [0]=>
+ int(-5349)
+}
+int(13)
+array(1) {
+ [0]=>
+ int(83)
+}
+int(20)
+array(1) {
+ [0]=>
+ int(-83)
+}
+int(28)
+array(1) {
+ [0]=>
+ int(2487)
+}
+int(33)
+array(1) {
+ [0]=>
+ int(319)
+}
+int(38)
+array(1) {
+ [0]=>
+ NULL
+}
+int(41)
+array(1) {
+ [0]=>
+ NULL
+}
+int(45)
+array(1) {
+ [0]=>
+ NULL
+}
+int(51)
+array(1) {
+ [0]=>
+ NULL
+}
+int(57)
+array(1) {
+ [0]=>
+ int(4096)
+}
+int(63)
+array(1) {
+ [0]=>
+ int(0)
+}
+int(68)
+bool(false)
+int(68)
+int(0)
+
+-- iteration 5 --
+int(0)
+array(1) {
+ [0]=>
+ int(74565)
+}
+int(6)
+array(1) {
+ [0]=>
+ int(-74565)
+}
+int(13)
+array(1) {
+ [0]=>
+ int(291)
+}
+int(20)
+array(1) {
+ [0]=>
+ int(-291)
+}
+int(28)
+array(1) {
+ [0]=>
+ int(18023)
+}
+int(33)
+array(1) {
+ [0]=>
+ int(18297)
+}
+int(38)
+array(1) {
+ [0]=>
+ int(131)
+}
+int(41)
+array(1) {
+ [0]=>
+ int(-131)
+}
+int(45)
+array(1) {
+ [0]=>
+ int(703710)
+}
+int(51)
+array(1) {
+ [0]=>
+ int(703710)
+}
+int(57)
+array(1) {
+ [0]=>
+ int(65536)
+}
+int(63)
+array(1) {
+ [0]=>
+ int(0)
+}
+int(68)
+bool(false)
+int(68)
+int(0)
+
+-- iteration 6 --
+int(0)
+array(1) {
+ [0]=>
+ int(12345)
+}
+int(6)
+array(1) {
+ [0]=>
+ string(10) "4294954951"
+}
+int(13)
+array(1) {
+ [0]=>
+ int(123)
+}
+int(20)
+array(1) {
+ [0]=>
+ string(10) "4294967173"
+}
+int(28)
+array(1) {
+ [0]=>
+ int(4667)
+}
+int(33)
+array(1) {
+ [0]=>
+ int(4779)
+}
+int(38)
+array(1) {
+ [0]=>
+ int(83)
+}
+int(41)
+array(1) {
+ [0]=>
+ string(10) "4294967213"
+}
+int(45)
+array(1) {
+ [0]=>
+ NULL
+}
+int(51)
+array(1) {
+ [0]=>
+ NULL
+}
+int(57)
+array(1) {
+ [0]=>
+ int(10000)
+}
+int(63)
+array(1) {
+ [0]=>
+ int(0)
+}
+int(68)
+bool(false)
+int(68)
+int(0)
+
+-- iteration 7 --
+int(0)
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+int(6)
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+int(13)
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+int(20)
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+int(28)
+array(1) {
+ [0]=>
+ string(1) "4"
+}
+int(33)
+array(1) {
+ [0]=>
+ string(1) "4"
+}
+int(38)
+array(1) {
+ [0]=>
+ string(1) "8"
+}
+int(41)
+array(1) {
+ [0]=>
+ string(1) "-"
+}
+int(45)
+array(1) {
+ [0]=>
+ string(1) "a"
+}
+int(51)
+array(1) {
+ [0]=>
+ string(1) "a"
+}
+int(57)
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+int(63)
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+int(68)
+bool(false)
+int(68)
+int(0)
+
+-- iteration 8 --
+int(0)
+array(1) {
+ [0]=>
+ float(12345)
+}
+int(6)
+array(1) {
+ [0]=>
+ float(-12345)
+}
+int(13)
+array(1) {
+ [0]=>
+ float(123.45)
+}
+int(20)
+array(1) {
+ [0]=>
+ float(-123.45)
+}
+int(28)
+array(1) {
+ [0]=>
+ float(4667)
+}
+int(33)
+array(1) {
+ [0]=>
+ float(4779)
+}
+int(38)
+array(1) {
+ [0]=>
+ float(83)
+}
+int(41)
+array(1) {
+ [0]=>
+ float(-83)
+}
+int(45)
+array(1) {
+ [0]=>
+ NULL
+}
+int(51)
+array(1) {
+ [0]=>
+ NULL
+}
+int(57)
+array(1) {
+ [0]=>
+ float(10000)
+}
+int(63)
+array(1) {
+ [0]=>
+ float(0.01)
+}
+int(68)
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation6.phpt b/ext/standard/tests/file/fscanf_variation6.phpt
new file mode 100644
index 0000000..74446f0
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation6.phpt
@@ -0,0 +1,946 @@
+--TEST--
+Test fscanf() function: usage variations - integer formats with strings
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan strings using different integer format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different integer format types with strings ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation6.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+// array of strings
+$strings = array (
+ "",
+ '',
+ "0",
+ '0',
+ "1",
+ '1',
+ "\x01",
+ '\x01',
+ "\01",
+ '\01',
+ 'string',
+ "string",
+ "true",
+ "FALSE",
+ 'false',
+ 'TRUE',
+ "NULL",
+ 'null'
+);
+
+$int_formats = array( "%d", "%hd", "%ld", "%Ld", " %d", "%d ", "% d", "\t%d", "\n%d", "%4d", "%30d", "%[0-9]", "%*d");
+
+$counter = 1;
+
+// writing to the file
+foreach($strings as $string) {
+ @fprintf($file_handle, $string);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different integer formats
+foreach($int_formats as $int_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$int_format) );
+ }
+ $counter++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation6.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different integer format types with strings ***
+
+-- iteration 1 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 2 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 3 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 4 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 5 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 6 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 9 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 10 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 11 --
+NULL
+NULL
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(0)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 13 --
+NULL
+NULL
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation7.phpt b/ext/standard/tests/file/fscanf_variation7.phpt
new file mode 100644
index 0000000..33354e7
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation7.phpt
@@ -0,0 +1,246 @@
+--TEST--
+Test fscanf() function: usage variations - integer formats with boolean
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan boolean data using different integer format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different integer format types with boolean data ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation7.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+// array of boolean types
+$bool_types = array (
+ true,
+ false,
+ TRUE,
+ FALSE,
+);
+
+$int_formats = array( "%d", "%hd", "%ld", "%Ld", " %d", "%d ", "% d", "\t%d", "\n%d", "%4d", "%30d", "%[0-9]", "%*d");
+
+$counter = 1;
+
+// writing to the file
+foreach($bool_types as $value) {
+ @fprintf($file_handle, $value);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different integer formats
+foreach($int_formats as $int_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$int_format) );
+ }
+ $counter++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation7.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different integer format types with boolean data ***
+
+-- iteration 1 --
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+bool(false)
+
+-- iteration 2 --
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+bool(false)
+
+-- iteration 3 --
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+bool(false)
+
+-- iteration 4 --
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+bool(false)
+
+-- iteration 5 --
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+bool(false)
+
+-- iteration 6 --
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+bool(false)
+
+-- iteration 9 --
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+bool(false)
+
+-- iteration 10 --
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+bool(false)
+
+-- iteration 11 --
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+array(1) {
+ [0]=>
+ int(1)
+}
+NULL
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 13 --
+array(0) {
+}
+NULL
+array(0) {
+}
+NULL
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation8.phpt b/ext/standard/tests/file/fscanf_variation8.phpt
new file mode 100644
index 0000000..b1f5f4e
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation8.phpt
@@ -0,0 +1,1614 @@
+--TEST--
+Test fscanf() function: usage variations - float formats with float values
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan different float values using different format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different float format types with different float values ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation8.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+// 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,
+ -1e5,
+ 1e-5,
+ -1e-5,
+ 1e+5,
+ -1e+5,
+ 1E5,
+ -1E5,
+ 1E+5,
+ -1E+5,
+ 1E-5,
+ -1E-5,
+ .5e+7,
+ -.5e+7,
+ .6e-19,
+ -.6e-19,
+ .05E+44,
+ -.05E+44,
+ .0034E-30,
+ -.0034E-30
+);
+
+// various float formats
+$float_formats = array( "%f",
+ "%hf", "%lf", "%Lf",
+ " %f", "%f ", "% f",
+ "\t%f", "\n%f", "%4f",
+ "%30f", "%[0-9]", "%*f",
+ );
+
+$counter = 1;
+
+// writing to the file
+foreach($valid_floats as $float_value) {
+ @fprintf($file_handle, $float_value);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different float formats
+foreach($float_formats as $float_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$float_format) );
+ }
+ $counter++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation8.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different float format types with different float values ***
+
+-- iteration 1 --
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(2147483648)
+}
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(34359738369)
+}
+array(1) {
+ [0]=>
+ float(2147483649)
+}
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(-0.1)
+}
+array(1) {
+ [0]=>
+ float(10)
+}
+array(1) {
+ [0]=>
+ float(1050000)
+}
+array(1) {
+ [0]=>
+ float(100000)
+}
+array(1) {
+ [0]=>
+ float(-100000)
+}
+array(1) {
+ [0]=>
+ float(1.0E-5)
+}
+array(1) {
+ [0]=>
+ float(-1.0E-5)
+}
+array(1) {
+ [0]=>
+ float(100000)
+}
+array(1) {
+ [0]=>
+ float(-100000)
+}
+array(1) {
+ [0]=>
+ float(100000)
+}
+array(1) {
+ [0]=>
+ float(-100000)
+}
+array(1) {
+ [0]=>
+ float(100000)
+}
+array(1) {
+ [0]=>
+ float(-100000)
+}
+array(1) {
+ [0]=>
+ float(1.0E-5)
+}
+array(1) {
+ [0]=>
+ float(-1.0E-5)
+}
+array(1) {
+ [0]=>
+ float(5000000)
+}
+array(1) {
+ [0]=>
+ float(-5000000)
+}
+array(1) {
+ [0]=>
+ float(6.0E-20)
+}
+array(1) {
+ [0]=>
+ float(-6.0E-20)
+}
+array(1) {
+ [0]=>
+ float(5.0E+42)
+}
+array(1) {
+ [0]=>
+ float(-5.0E+42)
+}
+array(1) {
+ [0]=>
+ float(3.4E-33)
+}
+array(1) {
+ [0]=>
+ float(-3.4E-33)
+}
+bool(false)
+
+-- iteration 2 --
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(2147483648)
+}
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(34359738369)
+}
+array(1) {
+ [0]=>
+ float(2147483649)
+}
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(-0.1)
+}
+array(1) {
+ [0]=>
+ float(10)
+}
+array(1) {
+ [0]=>
+ float(1050000)
+}
+array(1) {
+ [0]=>
+ float(100000)
+}
+array(1) {
+ [0]=>
+ float(-100000)
+}
+array(1) {
+ [0]=>
+ float(1.0E-5)
+}
+array(1) {
+ [0]=>
+ float(-1.0E-5)
+}
+array(1) {
+ [0]=>
+ float(100000)
+}
+array(1) {
+ [0]=>
+ float(-100000)
+}
+array(1) {
+ [0]=>
+ float(100000)
+}
+array(1) {
+ [0]=>
+ float(-100000)
+}
+array(1) {
+ [0]=>
+ float(100000)
+}
+array(1) {
+ [0]=>
+ float(-100000)
+}
+array(1) {
+ [0]=>
+ float(1.0E-5)
+}
+array(1) {
+ [0]=>
+ float(-1.0E-5)
+}
+array(1) {
+ [0]=>
+ float(5000000)
+}
+array(1) {
+ [0]=>
+ float(-5000000)
+}
+array(1) {
+ [0]=>
+ float(6.0E-20)
+}
+array(1) {
+ [0]=>
+ float(-6.0E-20)
+}
+array(1) {
+ [0]=>
+ float(5.0E+42)
+}
+array(1) {
+ [0]=>
+ float(-5.0E+42)
+}
+array(1) {
+ [0]=>
+ float(3.4E-33)
+}
+array(1) {
+ [0]=>
+ float(-3.4E-33)
+}
+bool(false)
+
+-- iteration 3 --
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(2147483648)
+}
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(34359738369)
+}
+array(1) {
+ [0]=>
+ float(2147483649)
+}
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(-0.1)
+}
+array(1) {
+ [0]=>
+ float(10)
+}
+array(1) {
+ [0]=>
+ float(1050000)
+}
+array(1) {
+ [0]=>
+ float(100000)
+}
+array(1) {
+ [0]=>
+ float(-100000)
+}
+array(1) {
+ [0]=>
+ float(1.0E-5)
+}
+array(1) {
+ [0]=>
+ float(-1.0E-5)
+}
+array(1) {
+ [0]=>
+ float(100000)
+}
+array(1) {
+ [0]=>
+ float(-100000)
+}
+array(1) {
+ [0]=>
+ float(100000)
+}
+array(1) {
+ [0]=>
+ float(-100000)
+}
+array(1) {
+ [0]=>
+ float(100000)
+}
+array(1) {
+ [0]=>
+ float(-100000)
+}
+array(1) {
+ [0]=>
+ float(1.0E-5)
+}
+array(1) {
+ [0]=>
+ float(-1.0E-5)
+}
+array(1) {
+ [0]=>
+ float(5000000)
+}
+array(1) {
+ [0]=>
+ float(-5000000)
+}
+array(1) {
+ [0]=>
+ float(6.0E-20)
+}
+array(1) {
+ [0]=>
+ float(-6.0E-20)
+}
+array(1) {
+ [0]=>
+ float(5.0E+42)
+}
+array(1) {
+ [0]=>
+ float(-5.0E+42)
+}
+array(1) {
+ [0]=>
+ float(3.4E-33)
+}
+array(1) {
+ [0]=>
+ float(-3.4E-33)
+}
+bool(false)
+
+-- iteration 4 --
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(2147483648)
+}
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(34359738369)
+}
+array(1) {
+ [0]=>
+ float(2147483649)
+}
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(-0.1)
+}
+array(1) {
+ [0]=>
+ float(10)
+}
+array(1) {
+ [0]=>
+ float(1050000)
+}
+array(1) {
+ [0]=>
+ float(100000)
+}
+array(1) {
+ [0]=>
+ float(-100000)
+}
+array(1) {
+ [0]=>
+ float(1.0E-5)
+}
+array(1) {
+ [0]=>
+ float(-1.0E-5)
+}
+array(1) {
+ [0]=>
+ float(100000)
+}
+array(1) {
+ [0]=>
+ float(-100000)
+}
+array(1) {
+ [0]=>
+ float(100000)
+}
+array(1) {
+ [0]=>
+ float(-100000)
+}
+array(1) {
+ [0]=>
+ float(100000)
+}
+array(1) {
+ [0]=>
+ float(-100000)
+}
+array(1) {
+ [0]=>
+ float(1.0E-5)
+}
+array(1) {
+ [0]=>
+ float(-1.0E-5)
+}
+array(1) {
+ [0]=>
+ float(5000000)
+}
+array(1) {
+ [0]=>
+ float(-5000000)
+}
+array(1) {
+ [0]=>
+ float(6.0E-20)
+}
+array(1) {
+ [0]=>
+ float(-6.0E-20)
+}
+array(1) {
+ [0]=>
+ float(5.0E+42)
+}
+array(1) {
+ [0]=>
+ float(-5.0E+42)
+}
+array(1) {
+ [0]=>
+ float(3.4E-33)
+}
+array(1) {
+ [0]=>
+ float(-3.4E-33)
+}
+bool(false)
+
+-- iteration 5 --
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(2147483648)
+}
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(34359738369)
+}
+array(1) {
+ [0]=>
+ float(2147483649)
+}
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(-0.1)
+}
+array(1) {
+ [0]=>
+ float(10)
+}
+array(1) {
+ [0]=>
+ float(1050000)
+}
+array(1) {
+ [0]=>
+ float(100000)
+}
+array(1) {
+ [0]=>
+ float(-100000)
+}
+array(1) {
+ [0]=>
+ float(1.0E-5)
+}
+array(1) {
+ [0]=>
+ float(-1.0E-5)
+}
+array(1) {
+ [0]=>
+ float(100000)
+}
+array(1) {
+ [0]=>
+ float(-100000)
+}
+array(1) {
+ [0]=>
+ float(100000)
+}
+array(1) {
+ [0]=>
+ float(-100000)
+}
+array(1) {
+ [0]=>
+ float(100000)
+}
+array(1) {
+ [0]=>
+ float(-100000)
+}
+array(1) {
+ [0]=>
+ float(1.0E-5)
+}
+array(1) {
+ [0]=>
+ float(-1.0E-5)
+}
+array(1) {
+ [0]=>
+ float(5000000)
+}
+array(1) {
+ [0]=>
+ float(-5000000)
+}
+array(1) {
+ [0]=>
+ float(6.0E-20)
+}
+array(1) {
+ [0]=>
+ float(-6.0E-20)
+}
+array(1) {
+ [0]=>
+ float(5.0E+42)
+}
+array(1) {
+ [0]=>
+ float(-5.0E+42)
+}
+array(1) {
+ [0]=>
+ float(3.4E-33)
+}
+array(1) {
+ [0]=>
+ float(-3.4E-33)
+}
+bool(false)
+
+-- iteration 6 --
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(2147483648)
+}
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(34359738369)
+}
+array(1) {
+ [0]=>
+ float(2147483649)
+}
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(-0.1)
+}
+array(1) {
+ [0]=>
+ float(10)
+}
+array(1) {
+ [0]=>
+ float(1050000)
+}
+array(1) {
+ [0]=>
+ float(100000)
+}
+array(1) {
+ [0]=>
+ float(-100000)
+}
+array(1) {
+ [0]=>
+ float(1.0E-5)
+}
+array(1) {
+ [0]=>
+ float(-1.0E-5)
+}
+array(1) {
+ [0]=>
+ float(100000)
+}
+array(1) {
+ [0]=>
+ float(-100000)
+}
+array(1) {
+ [0]=>
+ float(100000)
+}
+array(1) {
+ [0]=>
+ float(-100000)
+}
+array(1) {
+ [0]=>
+ float(100000)
+}
+array(1) {
+ [0]=>
+ float(-100000)
+}
+array(1) {
+ [0]=>
+ float(1.0E-5)
+}
+array(1) {
+ [0]=>
+ float(-1.0E-5)
+}
+array(1) {
+ [0]=>
+ float(5000000)
+}
+array(1) {
+ [0]=>
+ float(-5000000)
+}
+array(1) {
+ [0]=>
+ float(6.0E-20)
+}
+array(1) {
+ [0]=>
+ float(-6.0E-20)
+}
+array(1) {
+ [0]=>
+ float(5.0E+42)
+}
+array(1) {
+ [0]=>
+ float(-5.0E+42)
+}
+array(1) {
+ [0]=>
+ float(3.4E-33)
+}
+array(1) {
+ [0]=>
+ float(-3.4E-33)
+}
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(2147483648)
+}
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(34359738369)
+}
+array(1) {
+ [0]=>
+ float(2147483649)
+}
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(-0.1)
+}
+array(1) {
+ [0]=>
+ float(10)
+}
+array(1) {
+ [0]=>
+ float(1050000)
+}
+array(1) {
+ [0]=>
+ float(100000)
+}
+array(1) {
+ [0]=>
+ float(-100000)
+}
+array(1) {
+ [0]=>
+ float(1.0E-5)
+}
+array(1) {
+ [0]=>
+ float(-1.0E-5)
+}
+array(1) {
+ [0]=>
+ float(100000)
+}
+array(1) {
+ [0]=>
+ float(-100000)
+}
+array(1) {
+ [0]=>
+ float(100000)
+}
+array(1) {
+ [0]=>
+ float(-100000)
+}
+array(1) {
+ [0]=>
+ float(100000)
+}
+array(1) {
+ [0]=>
+ float(-100000)
+}
+array(1) {
+ [0]=>
+ float(1.0E-5)
+}
+array(1) {
+ [0]=>
+ float(-1.0E-5)
+}
+array(1) {
+ [0]=>
+ float(5000000)
+}
+array(1) {
+ [0]=>
+ float(-5000000)
+}
+array(1) {
+ [0]=>
+ float(6.0E-20)
+}
+array(1) {
+ [0]=>
+ float(-6.0E-20)
+}
+array(1) {
+ [0]=>
+ float(5.0E+42)
+}
+array(1) {
+ [0]=>
+ float(-5.0E+42)
+}
+array(1) {
+ [0]=>
+ float(3.4E-33)
+}
+array(1) {
+ [0]=>
+ float(-3.4E-33)
+}
+bool(false)
+
+-- iteration 9 --
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(2147483648)
+}
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(34359738369)
+}
+array(1) {
+ [0]=>
+ float(2147483649)
+}
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(-0.1)
+}
+array(1) {
+ [0]=>
+ float(10)
+}
+array(1) {
+ [0]=>
+ float(1050000)
+}
+array(1) {
+ [0]=>
+ float(100000)
+}
+array(1) {
+ [0]=>
+ float(-100000)
+}
+array(1) {
+ [0]=>
+ float(1.0E-5)
+}
+array(1) {
+ [0]=>
+ float(-1.0E-5)
+}
+array(1) {
+ [0]=>
+ float(100000)
+}
+array(1) {
+ [0]=>
+ float(-100000)
+}
+array(1) {
+ [0]=>
+ float(100000)
+}
+array(1) {
+ [0]=>
+ float(-100000)
+}
+array(1) {
+ [0]=>
+ float(100000)
+}
+array(1) {
+ [0]=>
+ float(-100000)
+}
+array(1) {
+ [0]=>
+ float(1.0E-5)
+}
+array(1) {
+ [0]=>
+ float(-1.0E-5)
+}
+array(1) {
+ [0]=>
+ float(5000000)
+}
+array(1) {
+ [0]=>
+ float(-5000000)
+}
+array(1) {
+ [0]=>
+ float(6.0E-20)
+}
+array(1) {
+ [0]=>
+ float(-6.0E-20)
+}
+array(1) {
+ [0]=>
+ float(5.0E+42)
+}
+array(1) {
+ [0]=>
+ float(-5.0E+42)
+}
+array(1) {
+ [0]=>
+ float(3.4E-33)
+}
+array(1) {
+ [0]=>
+ float(-3.4E-33)
+}
+bool(false)
+
+-- iteration 10 --
+array(1) {
+ [0]=>
+ float(-214)
+}
+array(1) {
+ [0]=>
+ float(2147)
+}
+array(1) {
+ [0]=>
+ float(-214)
+}
+array(1) {
+ [0]=>
+ float(3435)
+}
+array(1) {
+ [0]=>
+ float(2147)
+}
+array(1) {
+ [0]=>
+ float(-214)
+}
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(-0.1)
+}
+array(1) {
+ [0]=>
+ float(10)
+}
+array(1) {
+ [0]=>
+ float(1050)
+}
+array(1) {
+ [0]=>
+ float(1000)
+}
+array(1) {
+ [0]=>
+ float(-100)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(-1)
+}
+array(1) {
+ [0]=>
+ float(1000)
+}
+array(1) {
+ [0]=>
+ float(-100)
+}
+array(1) {
+ [0]=>
+ float(1000)
+}
+array(1) {
+ [0]=>
+ float(-100)
+}
+array(1) {
+ [0]=>
+ float(1000)
+}
+array(1) {
+ [0]=>
+ float(-100)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(-1)
+}
+array(1) {
+ [0]=>
+ float(5000)
+}
+array(1) {
+ [0]=>
+ float(-500)
+}
+array(1) {
+ [0]=>
+ float(6)
+}
+array(1) {
+ [0]=>
+ float(-6)
+}
+array(1) {
+ [0]=>
+ float(5)
+}
+array(1) {
+ [0]=>
+ float(-5)
+}
+array(1) {
+ [0]=>
+ float(3.4)
+}
+array(1) {
+ [0]=>
+ float(-3.4)
+}
+bool(false)
+
+-- iteration 11 --
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(2147483648)
+}
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(34359738369)
+}
+array(1) {
+ [0]=>
+ float(2147483649)
+}
+array(1) {
+ [0]=>
+ float(-2147483649)
+}
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(-0.1)
+}
+array(1) {
+ [0]=>
+ float(10)
+}
+array(1) {
+ [0]=>
+ float(1050000)
+}
+array(1) {
+ [0]=>
+ float(100000)
+}
+array(1) {
+ [0]=>
+ float(-100000)
+}
+array(1) {
+ [0]=>
+ float(1.0E-5)
+}
+array(1) {
+ [0]=>
+ float(-1.0E-5)
+}
+array(1) {
+ [0]=>
+ float(100000)
+}
+array(1) {
+ [0]=>
+ float(-100000)
+}
+array(1) {
+ [0]=>
+ float(100000)
+}
+array(1) {
+ [0]=>
+ float(-100000)
+}
+array(1) {
+ [0]=>
+ float(100000)
+}
+array(1) {
+ [0]=>
+ float(-100000)
+}
+array(1) {
+ [0]=>
+ float(1.0E-5)
+}
+array(1) {
+ [0]=>
+ float(-1.0E-5)
+}
+array(1) {
+ [0]=>
+ float(5000000)
+}
+array(1) {
+ [0]=>
+ float(-5000000)
+}
+array(1) {
+ [0]=>
+ float(6.0E-20)
+}
+array(1) {
+ [0]=>
+ float(-6.0E-20)
+}
+array(1) {
+ [0]=>
+ float(5.0E+42)
+}
+array(1) {
+ [0]=>
+ float(-5.0E+42)
+}
+array(1) {
+ [0]=>
+ float(3.4E-33)
+}
+array(1) {
+ [0]=>
+ float(-3.4E-33)
+}
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(10) "2147483648"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(11) "34359738369"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483649"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(2) "10"
+}
+array(1) {
+ [0]=>
+ string(7) "1050000"
+}
+array(1) {
+ [0]=>
+ string(6) "100000"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(6) "100000"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(6) "100000"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(6) "100000"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(7) "5000000"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(1) "6"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(1) "5"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(1) "3"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+bool(false)
+
+-- iteration 13 --
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fscanf_variation9.phpt b/ext/standard/tests/file/fscanf_variation9.phpt
new file mode 100644
index 0000000..f3551f0
--- /dev/null
+++ b/ext/standard/tests/file/fscanf_variation9.phpt
@@ -0,0 +1,1015 @@
+--TEST--
+Test fscanf() function: usage variations - float formats with integer values
+--SKIPIF--
+<?php
+if (PHP_INT_SIZE != 4) {
+ die("skip this test is for 32bit platform only");
+}
+?>
+--FILE--
+<?php
+
+/*
+ Prototype: mixed fscanf ( resource $handle, string $format [, mixed &$...] );
+ Description: Parses input from a file according to a format
+*/
+
+/* Test fscanf() to scan integer values using different float format types */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test fscanf(): different float format types with integer values ***\n";
+
+// create a file
+$filename = "$file_path/fscanf_variation9.tmp";
+$file_handle = fopen($filename, "w");
+if($file_handle == false)
+ exit("Error:failed to open file $filename");
+
+// array of float type values
+
+$integer_values = 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
+);
+
+$float_formats = array( "%f", "%hf", "%lf", "%Lf", " %f", "%f ", "% f", "\t%f", "\n%f", "%4f", "%30f", "%[0-9]", "%*f");
+
+$counter = 1;
+
+// writing to the file
+foreach($integer_values as $value) {
+ @fprintf($file_handle, $value);
+ @fprintf($file_handle, "\n");
+}
+// closing the file
+fclose($file_handle);
+
+// opening the file for reading
+$file_handle = fopen($filename, "r");
+if($file_handle == false) {
+ exit("Error:failed to open file $filename");
+}
+
+$counter = 1;
+// reading the values from file using different float formats
+foreach($float_formats as $float_format) {
+ // rewind the file so that for every foreach iteration the file pointer starts from bof
+ rewind($file_handle);
+ echo "\n-- iteration $counter --\n";
+ while( !feof($file_handle) ) {
+ var_dump( fscanf($file_handle,$float_format) );
+ }
+ $counter++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$filename = "$file_path/fscanf_variation9.tmp";
+unlink($filename);
+?>
+--EXPECTF--
+*** Test fscanf(): different float format types with integer values ***
+
+-- iteration 1 --
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(-1)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(-2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483640)
+}
+array(1) {
+ [0]=>
+ float(4667)
+}
+array(1) {
+ [0]=>
+ float(4779)
+}
+array(1) {
+ [0]=>
+ float(4095)
+}
+array(1) {
+ [0]=>
+ float(250)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(83)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+bool(false)
+
+-- iteration 2 --
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(-1)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(-2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483640)
+}
+array(1) {
+ [0]=>
+ float(4667)
+}
+array(1) {
+ [0]=>
+ float(4779)
+}
+array(1) {
+ [0]=>
+ float(4095)
+}
+array(1) {
+ [0]=>
+ float(250)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(83)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+bool(false)
+
+-- iteration 3 --
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(-1)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(-2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483640)
+}
+array(1) {
+ [0]=>
+ float(4667)
+}
+array(1) {
+ [0]=>
+ float(4779)
+}
+array(1) {
+ [0]=>
+ float(4095)
+}
+array(1) {
+ [0]=>
+ float(250)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(83)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+bool(false)
+
+-- iteration 4 --
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(-1)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(-2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483640)
+}
+array(1) {
+ [0]=>
+ float(4667)
+}
+array(1) {
+ [0]=>
+ float(4779)
+}
+array(1) {
+ [0]=>
+ float(4095)
+}
+array(1) {
+ [0]=>
+ float(250)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(83)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+bool(false)
+
+-- iteration 5 --
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(-1)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(-2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483640)
+}
+array(1) {
+ [0]=>
+ float(4667)
+}
+array(1) {
+ [0]=>
+ float(4779)
+}
+array(1) {
+ [0]=>
+ float(4095)
+}
+array(1) {
+ [0]=>
+ float(250)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(83)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+bool(false)
+
+-- iteration 6 --
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(-1)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(-2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483640)
+}
+array(1) {
+ [0]=>
+ float(4667)
+}
+array(1) {
+ [0]=>
+ float(4779)
+}
+array(1) {
+ [0]=>
+ float(4095)
+}
+array(1) {
+ [0]=>
+ float(250)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(83)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+bool(false)
+
+-- iteration 7 --
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+
+Warning: fscanf(): Bad scan conversion character " " in %s on line %d
+NULL
+bool(false)
+
+-- iteration 8 --
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(-1)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(-2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483640)
+}
+array(1) {
+ [0]=>
+ float(4667)
+}
+array(1) {
+ [0]=>
+ float(4779)
+}
+array(1) {
+ [0]=>
+ float(4095)
+}
+array(1) {
+ [0]=>
+ float(250)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(83)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+bool(false)
+
+-- iteration 9 --
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(-1)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(-2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483640)
+}
+array(1) {
+ [0]=>
+ float(4667)
+}
+array(1) {
+ [0]=>
+ float(4779)
+}
+array(1) {
+ [0]=>
+ float(4095)
+}
+array(1) {
+ [0]=>
+ float(250)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(83)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+bool(false)
+
+-- iteration 10 --
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(-1)
+}
+array(1) {
+ [0]=>
+ float(-214)
+}
+array(1) {
+ [0]=>
+ float(-214)
+}
+array(1) {
+ [0]=>
+ float(2147)
+}
+array(1) {
+ [0]=>
+ float(2147)
+}
+array(1) {
+ [0]=>
+ float(4667)
+}
+array(1) {
+ [0]=>
+ float(4779)
+}
+array(1) {
+ [0]=>
+ float(4095)
+}
+array(1) {
+ [0]=>
+ float(250)
+}
+array(1) {
+ [0]=>
+ float(-214)
+}
+array(1) {
+ [0]=>
+ float(2147)
+}
+array(1) {
+ [0]=>
+ float(2147)
+}
+array(1) {
+ [0]=>
+ float(83)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(-214)
+}
+array(1) {
+ [0]=>
+ float(2147)
+}
+bool(false)
+
+-- iteration 11 --
+array(1) {
+ [0]=>
+ float(0)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(-1)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(-2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483640)
+}
+array(1) {
+ [0]=>
+ float(4667)
+}
+array(1) {
+ [0]=>
+ float(4779)
+}
+array(1) {
+ [0]=>
+ float(4095)
+}
+array(1) {
+ [0]=>
+ float(250)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+array(1) {
+ [0]=>
+ float(83)
+}
+array(1) {
+ [0]=>
+ float(1)
+}
+array(1) {
+ [0]=>
+ float(-2147483648)
+}
+array(1) {
+ [0]=>
+ float(2147483647)
+}
+bool(false)
+
+-- iteration 12 --
+array(1) {
+ [0]=>
+ string(1) "0"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483640"
+}
+array(1) {
+ [0]=>
+ string(4) "4667"
+}
+array(1) {
+ [0]=>
+ string(4) "4779"
+}
+array(1) {
+ [0]=>
+ string(4) "4095"
+}
+array(1) {
+ [0]=>
+ string(3) "250"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+array(1) {
+ [0]=>
+ string(2) "83"
+}
+array(1) {
+ [0]=>
+ string(1) "1"
+}
+array(1) {
+ [0]=>
+ NULL
+}
+array(1) {
+ [0]=>
+ string(10) "2147483647"
+}
+bool(false)
+
+-- iteration 13 --
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/fseek_dir_basic.phpt b/ext/standard/tests/file/fseek_dir_basic.phpt
new file mode 100644
index 0000000..cde0bf2
--- /dev/null
+++ b/ext/standard/tests/file/fseek_dir_basic.phpt
@@ -0,0 +1,96 @@
+--TEST--
+Testing fseek() on a directory stream
+--FILE--
+<?php
+
+// include the file.inc for Function: function create_files()
+require(dirname(__FILE__) . '/file.inc');
+
+$path = dirname(__FILE__) . '/fseek_dir_basic';
+mkdir($path);
+create_files($path, 3);
+
+echo "call readdir():\n";
+var_dump($dh = opendir($path));
+$files = array();
+while( FALSE !== ($files[] = readdir($dh)) ) {}
+sort($files);
+var_dump($files);
+$files = array();
+
+echo "\ncall fseek() on directory resource:\n";
+var_dump(fseek($dh, 20));
+
+echo "call readdir():\n";
+while( FALSE !== ($files[] = readdir($dh)) ) {}
+sort($files);
+var_dump($files);
+$files = array();
+
+echo "\ncall fseek() with different arguments on directory resource:\n";
+var_dump(fseek($dh, 20, SEEK_END));
+
+echo "call readdir():\n";
+while( FALSE !== ($files[] = readdir($dh)) ) {}
+sort($files);
+var_dump($files);
+
+delete_files($path, 3);
+closedir($dh);
+var_dump(rmdir($path));
+
+?>
+--EXPECTF--
+call readdir():
+resource(%d) of type (stream)
+array(6) {
+ [0]=>
+ bool(false)
+ [1]=>
+ string(1) "."
+ [2]=>
+ string(2) ".."
+ [3]=>
+ string(9) "file1.tmp"
+ [4]=>
+ string(9) "file2.tmp"
+ [5]=>
+ string(9) "file3.tmp"
+}
+
+call fseek() on directory resource:
+int(0)
+call readdir():
+array(6) {
+ [0]=>
+ bool(false)
+ [1]=>
+ string(1) "."
+ [2]=>
+ string(2) ".."
+ [3]=>
+ string(9) "file1.tmp"
+ [4]=>
+ string(9) "file2.tmp"
+ [5]=>
+ string(9) "file3.tmp"
+}
+
+call fseek() with different arguments on directory resource:
+int(0)
+call readdir():
+array(6) {
+ [0]=>
+ bool(false)
+ [1]=>
+ string(1) "."
+ [2]=>
+ string(2) ".."
+ [3]=>
+ string(9) "file1.tmp"
+ [4]=>
+ string(9) "file2.tmp"
+ [5]=>
+ string(9) "file3.tmp"
+}
+bool(true)
diff --git a/ext/standard/tests/file/fseek_ftell_rewind_basic1.phpt b/ext/standard/tests/file/fseek_ftell_rewind_basic1.phpt
new file mode 100644
index 0000000..a9a54ab
--- /dev/null
+++ b/ext/standard/tests/file/fseek_ftell_rewind_basic1.phpt
@@ -0,0 +1,453 @@
+--TEST--
+Test fseek(), ftell() & rewind() functions : Basic functionality - all r and a modes
+--FILE--
+<?php
+/* Prototype: int fseek ( resource $handle, int $offset [, int $whence] );
+ Description: Seeks on a file pointer
+
+ Prototype: bool rewind ( resource $handle );
+ Description: Rewind the position of a file pointer
+
+ Prototype: int ftell ( resource $handle );
+ Description: Tells file pointer read/write position
+*/
+
+// include the file.inc for common functions for test
+include ("file.inc");
+
+/* Testing fseek(),ftell(),rewind() functions on all read and append modes */
+echo "*** Testing fseek(), ftell(), rewind() : basic operations ***\n";
+$file_modes = array( "r","rb","rt","r+","r+b","r+t",
+ "a","ab","at","a+","a+b","a+t");
+$file_content_types = array( "text_with_new_line","alphanumeric");
+
+$whence_set = array(SEEK_SET,SEEK_CUR,SEEK_END);
+$whence_string = array("SEEK_SET", "SEEK_CUR", "SEEK_END");
+
+$filename = dirname(__FILE__)."/fseek_ftell_rewind_basic1.tmp"; // this is name of the file created by create_files()
+ /* open the file using $files_modes and perform fseek(),ftell() and rewind() on it */
+foreach($file_content_types as $file_content_type){
+ echo "\n-- File having data of type ". $file_content_type ." --\n";
+
+ foreach($file_modes as $file_mode) {
+ echo "-- File opened in mode ".$file_mode." --\n";
+
+ create_files ( dirname(__FILE__), 1, $file_content_type, 0755, 512, "w", "fseek_ftell_rewind_basic"
+ ,1,"bytes",".tmp"); //create a file with 512 bytes size
+ $file_handle = fopen($filename, $file_mode);
+ if (!$file_handle) {
+ echo "Error: failed to fopen() file: $filename!";
+ exit();
+ }
+ // set the file pointer to 0
+ var_dump( rewind($file_handle) ); // Confirm file pointer moves correctly
+ var_dump( ftell($file_handle) ); // confirm the file pointer position
+
+ foreach($whence_set as $whence){
+ echo "-- Testing fseek() with whence = $whence_string[$whence] --\n";
+ var_dump( fseek($file_handle,10,$whence) ); //expecting int(0)
+ var_dump( ftell($file_handle) ); // confirm the file pointer position
+ var_dump( feof($file_handle) ); //ensure that file pointer is not at end
+ } //end of whence loop
+
+ //close the file and check the size
+ fclose($file_handle);
+ var_dump( filesize($filename) );
+
+ delete_file($filename); // delete file with name
+ } //end of file_modes loop
+} //end of file_content_types loop
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fseek(), ftell(), rewind() : basic operations ***
+
+-- File having data of type text_with_new_line --
+-- File opened in mode r --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode rb --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode rt --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode r+ --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode r+b --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode r+t --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode a --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode ab --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode at --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode a+ --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode a+b --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode a+t --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+
+-- File having data of type alphanumeric --
+-- File opened in mode r --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode rb --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode rt --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode r+ --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode r+b --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode r+t --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode a --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode ab --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode at --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode a+ --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode a+b --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode a+t --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+Done
diff --git a/ext/standard/tests/file/fseek_ftell_rewind_basic2-win32.phpt b/ext/standard/tests/file/fseek_ftell_rewind_basic2-win32.phpt
new file mode 100644
index 0000000..18ecf9a
--- /dev/null
+++ b/ext/standard/tests/file/fseek_ftell_rewind_basic2-win32.phpt
@@ -0,0 +1,464 @@
+--TEST--
+Test fseek(), ftell() & rewind() functions : basic functionality - all w and x modes
+--SKIPIF--
+<?php
+if( substr(PHP_OS, 0, 3) != "WIN" )
+ die("skip.. only valid for Windows");
+?>
+
+--FILE--
+<?php
+/* Prototype: int fseek ( resource $handle, int $offset [, int $whence] );
+ Description: Seeks on a file pointer
+
+ Prototype: bool rewind ( resource $handle );
+ Description: Rewind the position of a file pointer
+
+ Prototype: int ftell ( resource $handle );
+ Description: Tells file pointer read/write position
+*/
+
+// include the file.inc for common functions for test
+include ("file.inc");
+
+/* Testing fseek(),ftell(),rewind() functions on all write and create with write modes */
+
+echo "*** Testing fseek(), ftell(), rewind() : basic operations ***\n";
+$file_modes = array( "w","wb","wt","w+","w+b","w+t",
+ "x","xb","xt","x+","x+b","x+t");
+
+$file_content_types = array("text_with_new_line","alphanumeric");
+
+$whence_set = array(SEEK_SET,SEEK_CUR,SEEK_END);
+$whence_string = array("SEEK_SET", "SEEK_CUR", "SEEK_END");
+
+$filename = dirname(__FILE__)."/fseek_ftell_rewind_basic2.tmp"; // this is name of the file created by create_files()
+
+foreach($file_content_types as $file_content_type){
+ echo "\n-- File having data of type ". $file_content_type ." --\n";
+
+ /* open the file using $files_modes and perform fseek(),ftell() and rewind() on it */
+ foreach($file_modes as $file_mode) {
+ echo "-- File opened in mode ".$file_mode." --\n";
+
+ $file_handle = fopen($filename, $file_mode);
+ if (!$file_handle) {
+ echo "Error: failed to fopen() file: $filename!";
+ exit();
+ }
+ $data_to_be_written="";
+ fill_buffer($data_to_be_written, $file_content_type, 512); //get the data of size 512
+ $data_to_be_written = $data_to_be_written;
+ fwrite($file_handle,(binary)$data_to_be_written);
+
+ // set file pointer to 0
+ var_dump( rewind($file_handle) ); // set to begining of file
+ var_dump( ftell($file_handle) );
+
+ foreach($whence_set as $whence){
+ echo "-- Testing fseek() with whence = $whence_string[$whence] --\n";
+ var_dump( fseek($file_handle, 10, $whence) ); //expecting int(0)
+ var_dump( ftell($file_handle) ); // confirm the file pointer position
+ var_dump( feof($file_handle) ); //ensure that file pointer is not at end
+ } //end of whence loop
+
+ //close the file and check the size
+ fclose($file_handle);
+ var_dump( filesize($filename) );
+
+ delete_file($filename); // delete file with name
+ } //end of file_mode loop
+} //end of File content type loop
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fseek(), ftell(), rewind() : basic operations ***
+
+-- File having data of type text_with_new_line --
+-- File opened in mode w --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode wb --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode wt --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(579)
+bool(false)
+int(569)
+-- File opened in mode w+ --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode w+b --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode w+t --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(579)
+bool(false)
+int(569)
+-- File opened in mode x --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode xb --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode xt --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(579)
+bool(false)
+int(569)
+-- File opened in mode x+ --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode x+b --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode x+t --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(579)
+bool(false)
+int(569)
+
+-- File having data of type alphanumeric --
+-- File opened in mode w --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode wb --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode wt --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode w+ --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode w+b --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode w+t --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode x --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode xb --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode xt --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode x+ --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode x+b --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode x+t --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+Done
diff --git a/ext/standard/tests/file/fseek_ftell_rewind_basic2.phpt b/ext/standard/tests/file/fseek_ftell_rewind_basic2.phpt
new file mode 100644
index 0000000..8660094
--- /dev/null
+++ b/ext/standard/tests/file/fseek_ftell_rewind_basic2.phpt
@@ -0,0 +1,463 @@
+--TEST--
+Test fseek(), ftell() & rewind() functions : basic functionality - all w and x modes
+--SKIPIF--
+<?php
+if( substr(PHP_OS, 0, 3) == "WIN" )
+ die("skip.. Not valid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype: int fseek ( resource $handle, int $offset [, int $whence] );
+ Description: Seeks on a file pointer
+
+ Prototype: bool rewind ( resource $handle );
+ Description: Rewind the position of a file pointer
+
+ Prototype: int ftell ( resource $handle );
+ Description: Tells file pointer read/write position
+*/
+
+// include the file.inc for common functions for test
+include ("file.inc");
+
+/* Testing fseek(),ftell(),rewind() functions on all write and create with write modes */
+
+echo "*** Testing fseek(), ftell(), rewind() : basic operations ***\n";
+$file_modes = array( "w","wb","wt","w+","w+b","w+t",
+ "x","xb","xt","x+","x+b","x+t");
+
+$file_content_types = array("text_with_new_line","alphanumeric");
+
+$whence_set = array(SEEK_SET,SEEK_CUR,SEEK_END);
+$whence_string = array("SEEK_SET", "SEEK_CUR", "SEEK_END");
+
+$filename = dirname(__FILE__)."/fseek_ftell_rewind_basic2.tmp"; // this is name of the file created by create_files()
+
+foreach($file_content_types as $file_content_type){
+ echo "\n-- File having data of type ". $file_content_type ." --\n";
+
+ /* open the file using $files_modes and perform fseek(),ftell() and rewind() on it */
+ foreach($file_modes as $file_mode) {
+ echo "-- File opened in mode ".$file_mode." --\n";
+
+ $file_handle = fopen($filename, $file_mode);
+ if (!$file_handle) {
+ echo "Error: failed to fopen() file: $filename!";
+ exit();
+ }
+ $data_to_be_written="";
+ fill_buffer($data_to_be_written, $file_content_type, 512); //get the data of size 512
+ $data_to_be_written = $data_to_be_written;
+ fwrite($file_handle,(binary)$data_to_be_written);
+
+ // set file pointer to 0
+ var_dump( rewind($file_handle) ); // set to begining of file
+ var_dump( ftell($file_handle) );
+
+ foreach($whence_set as $whence){
+ echo "-- Testing fseek() with whence = $whence_string[$whence] --\n";
+ var_dump( fseek($file_handle, 10, $whence) ); //expecting int(0)
+ var_dump( ftell($file_handle) ); // confirm the file pointer position
+ var_dump( feof($file_handle) ); //ensure that file pointer is not at end
+ } //end of whence loop
+
+ //close the file and check the size
+ fclose($file_handle);
+ var_dump( filesize($filename) );
+
+ delete_file($filename); // delete file with name
+ } //end of file_mode loop
+} //end of File content type loop
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fseek(), ftell(), rewind() : basic operations ***
+
+-- File having data of type text_with_new_line --
+-- File opened in mode w --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode wb --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode wt --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode w+ --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode w+b --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode w+t --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode x --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode xb --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode xt --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode x+ --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode x+b --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode x+t --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+
+-- File having data of type alphanumeric --
+-- File opened in mode w --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode wb --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode wt --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode w+ --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode w+b --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode w+t --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode x --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode xb --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode xt --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode x+ --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode x+b --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+-- File opened in mode x+t --
+bool(true)
+int(0)
+-- Testing fseek() with whence = SEEK_SET --
+int(0)
+int(10)
+bool(false)
+-- Testing fseek() with whence = SEEK_CUR --
+int(0)
+int(20)
+bool(false)
+-- Testing fseek() with whence = SEEK_END --
+int(0)
+int(522)
+bool(false)
+int(512)
+Done
diff --git a/ext/standard/tests/file/fseek_ftell_rewind_error1.phpt b/ext/standard/tests/file/fseek_ftell_rewind_error1.phpt
new file mode 100644
index 0000000..1779383
--- /dev/null
+++ b/ext/standard/tests/file/fseek_ftell_rewind_error1.phpt
@@ -0,0 +1,99 @@
+--TEST--
+Test fseek(), ftell() & rewind() functions : error conditions - fseek()
+--FILE--
+<?php
+
+/* Prototype: int fseek ( resource $handle, int $offset [, int $whence] );
+ Description: Seeks on a file pointer
+
+ Prototype: bool rewind ( resource $handle );
+ Description: Rewind the position of a file pointer
+
+ Prototype: int ftell ( resource $handle );
+ Description: Tells file pointer read/write position
+*/
+
+echo "*** Testing fseek() : error conditions ***\n";
+// zero argument
+echo "-- Testing fseek() with zero argument --\n";
+var_dump( fseek() );
+
+// unexpected no. of args
+echo "-- Testing fseek() with unexpected number of arguments --\n";
+$fp = fopen(__FILE__, "r");
+var_dump( fseek($fp) );
+var_dump( fseek($fp, 10, $fp,10) );
+
+// test invalid arguments : non-resources
+echo "-- Testing fseek() with invalid arguments --\n";
+$invalid_args = array (
+ "string",
+ 10,
+ 10.5,
+ true,
+ array(1,2,3),
+ new stdclass
+);
+/* loop to test fseek() with different invalid type of args */
+for($loop_counter = 1; $loop_counter <= count($invalid_args); $loop_counter++) {
+ echo "-- Iteration $loop_counter --\n";
+ var_dump( fseek($invalid_args[$loop_counter - 1], 10) );
+}
+
+// fseek() on a file handle which is already closed
+echo "-- Testing fseek() with closed/unset file handle --";
+fclose($fp);
+var_dump(fseek($fp,10));
+
+// fseek() on a file handle which is unset
+$file_handle = fopen(__FILE__, "r");
+unset($file_handle); //unset file handle
+var_dump( fseek(@$file_handle,10));
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fseek() : error conditions ***
+-- Testing fseek() with zero argument --
+
+Warning: fseek() expects at least 2 parameters, 0 given in %s on line %d
+bool(false)
+-- Testing fseek() with unexpected number of arguments --
+
+Warning: fseek() expects at least 2 parameters, 1 given in %s on line %d
+bool(false)
+
+Warning: fseek() expects at most 3 parameters, 4 given in %s on line %d
+bool(false)
+-- Testing fseek() with invalid arguments --
+-- Iteration 1 --
+
+Warning: fseek() expects parameter 1 to be resource, string given in %s on line %d
+bool(false)
+-- Iteration 2 --
+
+Warning: fseek() expects parameter 1 to be resource, integer given in %s on line %d
+bool(false)
+-- Iteration 3 --
+
+Warning: fseek() expects parameter 1 to be resource, double given in %s on line %d
+bool(false)
+-- Iteration 4 --
+
+Warning: fseek() expects parameter 1 to be resource, boolean given in %s on line %d
+bool(false)
+-- Iteration 5 --
+
+Warning: fseek() expects parameter 1 to be resource, array given in %s on line %d
+bool(false)
+-- Iteration 6 --
+
+Warning: fseek() expects parameter 1 to be resource, object given in %s on line %d
+bool(false)
+-- Testing fseek() with closed/unset file handle --
+Warning: fseek(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: fseek() expects parameter 1 to be resource, null given in %s on line %d
+bool(false)
+Done
diff --git a/ext/standard/tests/file/fseek_ftell_rewind_error2.phpt b/ext/standard/tests/file/fseek_ftell_rewind_error2.phpt
new file mode 100644
index 0000000..1f28abc
--- /dev/null
+++ b/ext/standard/tests/file/fseek_ftell_rewind_error2.phpt
@@ -0,0 +1,95 @@
+--TEST--
+Test fseek(), ftell() & rewind() functions : error conditions - ftell()
+--FILE--
+<?php
+
+/* Prototype: int fseek ( resource $handle, int $offset [, int $whence] );
+ Description: Seeks on a file pointer
+
+ Prototype: bool rewind ( resource $handle );
+ Description: Rewind the position of a file pointer
+
+ Prototype: int ftell ( resource $handle );
+ Description: Tells file pointer read/write position
+*/
+
+echo "*** Testing ftell() : error conditions ***\n";
+// zero argument
+echo "-- Testing ftell() with zero argument --\n";
+var_dump( ftell() );
+
+// more than expected no. of args
+echo "-- Testing ftell() with more than expected number of arguments --\n";
+$fp = fopen(__FILE__, "r");
+var_dump( ftell($fp, 10) );
+
+// test invalid arguments : non-resources
+echo "-- Testing ftell() with invalid arguments --\n";
+$invalid_args = array (
+ "string",
+ 10,
+ 10.5,
+ true,
+ array(1,2,3),
+ new stdclass,
+);
+/* loop to test ftell with different invalid type of args */
+for($loop_counter = 1; $loop_counter <= count($invalid_args); $loop_counter++) {
+ echo "-- Iteration $loop_counter --\n";
+ var_dump( ftell($invalid_args[$loop_counter - 1]) );
+}
+
+// ftell on a file handle which is already closed
+echo "-- Testing ftell with closed/unset file handle --";
+fclose($fp);
+var_dump(ftell($fp));
+
+// ftell on a file handle which is unset
+$file_handle = fopen(__FILE__, "r");
+unset($file_handle); //unset file handle
+var_dump( ftell(@$file_handle) );
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing ftell() : error conditions ***
+-- Testing ftell() with zero argument --
+
+Warning: ftell() expects exactly 1 parameter, 0 given in %s on line %d
+bool(false)
+-- Testing ftell() with more than expected number of arguments --
+
+Warning: ftell() expects exactly 1 parameter, 2 given in %s on line %d
+bool(false)
+-- Testing ftell() with invalid arguments --
+-- Iteration 1 --
+
+Warning: ftell() expects parameter 1 to be resource, string given in %s on line %d
+bool(false)
+-- Iteration 2 --
+
+Warning: ftell() expects parameter 1 to be resource, integer given in %s on line %d
+bool(false)
+-- Iteration 3 --
+
+Warning: ftell() expects parameter 1 to be resource, double given in %s on line %d
+bool(false)
+-- Iteration 4 --
+
+Warning: ftell() expects parameter 1 to be resource, boolean given in %s on line %d
+bool(false)
+-- Iteration 5 --
+
+Warning: ftell() expects parameter 1 to be resource, array given in %s on line %d
+bool(false)
+-- Iteration 6 --
+
+Warning: ftell() expects parameter 1 to be resource, object given in %s on line %d
+bool(false)
+-- Testing ftell with closed/unset file handle --
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: ftell() expects parameter 1 to be resource, null given in %s on line %d
+bool(false)
+Done
diff --git a/ext/standard/tests/file/fseek_ftell_rewind_error3.phpt b/ext/standard/tests/file/fseek_ftell_rewind_error3.phpt
new file mode 100644
index 0000000..3c928e6
--- /dev/null
+++ b/ext/standard/tests/file/fseek_ftell_rewind_error3.phpt
@@ -0,0 +1,95 @@
+--TEST--
+Test fseek(), ftell() & rewind() functions : error conditions - rewind()
+--FILE--
+<?php
+
+/* Prototype: int fseek ( resource $handle, int $offset [, int $whence] );
+ Description: Seeks on a file pointer
+
+ Prototype: bool rewind ( resource $handle );
+ Description: Rewind the position of a file pointer
+
+ Prototype: int ftell ( resource $handle );
+ Description: Tells file pointer read/write position
+*/
+
+echo "*** Testing rewind() : error conditions ***\n";
+// zero argument
+echo "-- Testing rewind() with zero argument --\n";
+var_dump( rewind() );
+
+// more than expected no. of args
+echo "-- Testing rewind() with more than expected number of arguments --\n";
+$fp = fopen(__FILE__, "r");
+var_dump( rewind($fp, 10) );
+
+// test invalid arguments : non-resources
+echo "-- Testing rewind() with invalid arguments --\n";
+$invalid_args = array (
+ "string",
+ 10,
+ 10.5,
+ true,
+ array(1,2,3),
+ new stdclass,
+);
+/* loop to test rewind with different invalid type of args */
+for($loop_counter = 1; $loop_counter <= count($invalid_args); $loop_counter++) {
+ echo "-- Iteration $loop_counter --\n";
+ var_dump( rewind($invalid_args[$loop_counter - 1]) );
+}
+
+// rewind on a file handle which is already closed
+echo "-- Testing rewind() with closed/unset file handle --";
+fclose($fp);
+var_dump(rewind($fp));
+
+// rewind on a file handle which is unset
+$file_handle = fopen(__FILE__, "r");
+unset($file_handle); //unset file handle
+var_dump( rewind(@$file_handle) );
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing rewind() : error conditions ***
+-- Testing rewind() with zero argument --
+
+Warning: rewind() expects exactly 1 parameter, 0 given in %s on line %d
+bool(false)
+-- Testing rewind() with more than expected number of arguments --
+
+Warning: rewind() expects exactly 1 parameter, 2 given in %s on line %d
+bool(false)
+-- Testing rewind() with invalid arguments --
+-- Iteration 1 --
+
+Warning: rewind() expects parameter 1 to be resource, string given in %s on line %d
+bool(false)
+-- Iteration 2 --
+
+Warning: rewind() expects parameter 1 to be resource, integer given in %s on line %d
+bool(false)
+-- Iteration 3 --
+
+Warning: rewind() expects parameter 1 to be resource, double given in %s on line %d
+bool(false)
+-- Iteration 4 --
+
+Warning: rewind() expects parameter 1 to be resource, boolean given in %s on line %d
+bool(false)
+-- Iteration 5 --
+
+Warning: rewind() expects parameter 1 to be resource, array given in %s on line %d
+bool(false)
+-- Iteration 6 --
+
+Warning: rewind() expects parameter 1 to be resource, object given in %s on line %d
+bool(false)
+-- Testing rewind() with closed/unset file handle --
+Warning: rewind(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: rewind() expects parameter 1 to be resource, null given in %s on line %d
+bool(false)
+Done
diff --git a/ext/standard/tests/file/fseek_ftell_rewind_variation1.phpt b/ext/standard/tests/file/fseek_ftell_rewind_variation1.phpt
new file mode 100644
index 0000000..7f6b2b4
--- /dev/null
+++ b/ext/standard/tests/file/fseek_ftell_rewind_variation1.phpt
@@ -0,0 +1,428 @@
+--TEST--
+Test fseek(), ftell() & rewind() functions : usage variations - all r & a modes, default whence
+--FILE--
+<?php
+/* Prototype: int fseek ( resource $handle, int $offset [, int $whence] );
+ Description: Seeks on a file pointer
+
+ Prototype: bool rewind ( resource $handle );
+ Description: Rewind the position of a file pointer
+
+ Prototype: int ftell ( resource $handle );
+ Description: Tells file pointer read/write position
+*/
+
+// include the file.inc for common functions for test
+include ("file.inc");
+
+/* Testing fseek(),ftell(),rewind() functions
+ 1. All read and append modes
+ 2. Testing fseek() without using argument whence
+*/
+echo "*** Testing fseek(), ftell(), rewind() : default whence & all r and a modes ***\n";
+$file_modes = array( "r","rb","rt","r+","r+b","r+t",
+ "a","ab","at","a+","a+b","a+t");
+$file_content_types = array( "text_with_new_line","alphanumeric");
+
+$offset = array(-1, 0, 1, 513); // different offsets, including negative and beyond size
+
+$filename = dirname(__FILE__)."/fseek_ftell_rewind_variation1.tmp"; // this is name of the file created by create_files()
+
+ /* open the file using $files_modes and perform fseek(),ftell() and rewind() on it */
+foreach($file_content_types as $file_content_type){
+ echo "\n-- File having data of type ". $file_content_type ." --\n";
+
+ foreach($file_modes as $file_mode) {
+ echo "-- File opened in mode ".$file_mode." --\n";
+
+ create_files ( dirname(__FILE__), 1, $file_content_type, 0755, 512, "w", "fseek_ftell_rewind_variation"
+ ,1,"bytes",".tmp"); //create a file with 512 bytes size
+ $file_handle = fopen($filename, $file_mode);
+ if (!$file_handle) {
+ echo "Error: failed to fopen() file: $filename!";
+ exit();
+ }
+ echo "-- Testing fseek() without using argument whence --\n";
+ foreach($offset as $count){
+ var_dump( fseek($file_handle, $count) );
+ var_dump( ftell($file_handle) ); // confirm the file pointer position
+ var_dump( feof($file_handle) ); //ensure that file pointer is not at end
+ } //end of offset loop
+
+ //close the file and check the size
+ fclose($file_handle);
+ var_dump( filesize($filename) );
+
+ delete_file($filename); // delete file with name
+ } //end of file_mode loop
+} //end of file_content_types loop
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fseek(), ftell(), rewind() : default whence & all r and a modes ***
+
+-- File having data of type text_with_new_line --
+-- File opened in mode r --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode rb --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode rt --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode r+ --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode r+b --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode r+t --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode a --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode ab --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode at --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode a+ --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode a+b --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode a+t --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+
+-- File having data of type alphanumeric --
+-- File opened in mode r --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode rb --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode rt --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode r+ --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode r+b --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode r+t --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode a --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode ab --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode at --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode a+ --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode a+b --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode a+t --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+Done
diff --git a/ext/standard/tests/file/fseek_ftell_rewind_variation2-win32.phpt b/ext/standard/tests/file/fseek_ftell_rewind_variation2-win32.phpt
new file mode 100644
index 0000000..ad01c3a
--- /dev/null
+++ b/ext/standard/tests/file/fseek_ftell_rewind_variation2-win32.phpt
@@ -0,0 +1,437 @@
+--TEST--
+Test fseek(), ftell() & rewind() functions : usage variations - all w and x modes, default whence
+--SKIPIF--
+<?php
+if( substr(PHP_OS, 0, 3) != "WIN" )
+ die("skip.. only valid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype: int fseek ( resource $handle, int $offset [, int $whence] );
+ Description: Seeks on a file pointer
+
+ Prototype: bool rewind ( resource $handle );
+ Description: Rewind the position of a file pointer
+
+ Prototype: int ftell ( resource $handle );
+ Description: Tells file pointer read/write position
+*/
+
+// include the file.inc for common functions for test
+include ("file.inc");
+
+/* Testing fseek(),ftell(),rewind() functions
+ 1. All write and create with write modes
+ 2. Testing fseek() without using argument whence
+*/
+
+echo "*** Testing fseek(), ftell(), rewind() : default whence & all w and x modes ***\n";
+$file_modes = array( "w","wb","wt","w+","w+b","w+t",
+ "x","xb","xt","x+","x+b","x+t");
+$file_content_types = array( "text_with_new_line","alphanumeric");
+
+$offset = array(-1, 0, 1, 513); // different offsets, including negative and beyond size
+
+$filename = dirname(__FILE__)."/fseek_ftell_rewind_variation2.tmp"; // this is name of the file created by create_files()
+
+/* open the file using $files_modes and perform fseek(),ftell() and rewind() on it */
+foreach($file_content_types as $file_content_type){
+ echo "\n-- File having data of type ". $file_content_type ." --\n";
+
+ foreach($file_modes as $file_mode) {
+ echo "-- File opened in mode ".$file_mode." --\n";
+ $file_handle = fopen($filename, $file_mode);
+ if (!$file_handle){
+ echo "Error: failed to fopen() file: $filename!";
+ exit();
+ }
+ $data_to_be_written="";
+ fill_buffer($data_to_be_written, $file_content_type, 512); //get the data of size 512
+ $data_to_be_written = $data_to_be_written;
+ fwrite($file_handle,(binary)$data_to_be_written);
+ rewind($file_handle);
+
+ echo "-- Testing fseek() without using argument whence --\n";
+ foreach($offset as $count){
+ var_dump( fseek($file_handle,$count) );
+ var_dump( ftell($file_handle) ); // confirm the file pointer position
+ var_dump( feof($file_handle) ); //ensure that file pointer is not at end
+ } //end of offset loop
+
+ //close the file and check the size
+ fclose($file_handle);
+ var_dump( filesize($filename) );
+
+ delete_file($filename); // delete file with name
+ } //end of file_mode loop
+} //end of file_content_types loop
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fseek(), ftell(), rewind() : default whence & all w and x modes ***
+
+-- File having data of type text_with_new_line --
+-- File opened in mode w --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode wb --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode wt --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(569)
+-- File opened in mode w+ --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode w+b --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode w+t --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(569)
+-- File opened in mode x --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode xb --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode xt --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(569)
+-- File opened in mode x+ --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode x+b --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode x+t --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(569)
+
+-- File having data of type alphanumeric --
+-- File opened in mode w --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode wb --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode wt --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode w+ --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode w+b --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode w+t --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode x --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode xb --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode xt --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode x+ --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode x+b --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode x+t --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+Done
diff --git a/ext/standard/tests/file/fseek_ftell_rewind_variation2.phpt b/ext/standard/tests/file/fseek_ftell_rewind_variation2.phpt
new file mode 100644
index 0000000..67987cb
--- /dev/null
+++ b/ext/standard/tests/file/fseek_ftell_rewind_variation2.phpt
@@ -0,0 +1,437 @@
+--TEST--
+Test fseek(), ftell() & rewind() functions : usage variations - all w and x modes, default whence
+--SKIPIF--
+<?php
+if( substr(PHP_OS, 0, 3) == "WIN" )
+ die("skip.. Not valid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype: int fseek ( resource $handle, int $offset [, int $whence] );
+ Description: Seeks on a file pointer
+
+ Prototype: bool rewind ( resource $handle );
+ Description: Rewind the position of a file pointer
+
+ Prototype: int ftell ( resource $handle );
+ Description: Tells file pointer read/write position
+*/
+
+// include the file.inc for common functions for test
+include ("file.inc");
+
+/* Testing fseek(),ftell(),rewind() functions
+ 1. All write and create with write modes
+ 2. Testing fseek() without using argument whence
+*/
+
+echo "*** Testing fseek(), ftell(), rewind() : default whence & all w and x modes ***\n";
+$file_modes = array( "w","wb","wt","w+","w+b","w+t",
+ "x","xb","xt","x+","x+b","x+t");
+$file_content_types = array( "text_with_new_line","alphanumeric");
+
+$offset = array(-1, 0, 1, 513); // different offsets, including negative and beyond size
+
+$filename = dirname(__FILE__)."/fseek_ftell_rewind_variation2.tmp"; // this is name of the file created by create_files()
+
+/* open the file using $files_modes and perform fseek(),ftell() and rewind() on it */
+foreach($file_content_types as $file_content_type){
+ echo "\n-- File having data of type ". $file_content_type ." --\n";
+
+ foreach($file_modes as $file_mode) {
+ echo "-- File opened in mode ".$file_mode." --\n";
+ $file_handle = fopen($filename, $file_mode);
+ if (!$file_handle){
+ echo "Error: failed to fopen() file: $filename!";
+ exit();
+ }
+ $data_to_be_written="";
+ fill_buffer($data_to_be_written, $file_content_type, 512); //get the data of size 512
+ $data_to_be_written = $data_to_be_written;
+ fwrite($file_handle,(binary)$data_to_be_written);
+ rewind($file_handle);
+
+ echo "-- Testing fseek() without using argument whence --\n";
+ foreach($offset as $count){
+ var_dump( fseek($file_handle,$count) );
+ var_dump( ftell($file_handle) ); // confirm the file pointer position
+ var_dump( feof($file_handle) ); //ensure that file pointer is not at end
+ } //end of offset loop
+
+ //close the file and check the size
+ fclose($file_handle);
+ var_dump( filesize($filename) );
+
+ delete_file($filename); // delete file with name
+ } //end of file_mode loop
+} //end of file_content_types loop
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fseek(), ftell(), rewind() : default whence & all w and x modes ***
+
+-- File having data of type text_with_new_line --
+-- File opened in mode w --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode wb --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode wt --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode w+ --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode w+b --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode w+t --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode x --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode xb --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode xt --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode x+ --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode x+b --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode x+t --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+
+-- File having data of type alphanumeric --
+-- File opened in mode w --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode wb --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode wt --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode w+ --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode w+b --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode w+t --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode x --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode xb --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode xt --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode x+ --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode x+b --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+-- File opened in mode x+t --
+-- Testing fseek() without using argument whence --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(512)
+Done
diff --git a/ext/standard/tests/file/fseek_ftell_rewind_variation3.phpt b/ext/standard/tests/file/fseek_ftell_rewind_variation3.phpt
new file mode 100644
index 0000000..4b84d40
--- /dev/null
+++ b/ext/standard/tests/file/fseek_ftell_rewind_variation3.phpt
@@ -0,0 +1,478 @@
+--TEST--
+Test fseek(), ftell() & rewind() functions : usage variations - all r and a modes, SEEK_SET
+--FILE--
+<?php
+/* Prototype: int fseek ( resource $handle, int $offset [, int $whence] );
+ Description: Seeks on a file pointer
+
+ Prototype: bool rewind ( resource $handle );
+ Description: Rewind the position of a file pointer
+
+ Prototype: int ftell ( resource $handle );
+ Description: Tells file pointer read/write position
+*/
+
+// include the file.inc for common functions for test
+include ("file.inc");
+
+/* Testing fseek(),ftell(),rewind() functions
+ 1. All read and append modes
+ 2. Testing fseek() with whence = SEEK_SET
+*/
+
+echo "*** Testing fseek(), ftell(), rewind() : whence = SEEK_SET & all r and a modes ***\n";
+
+$file_modes = array( "r","rb","rt","r+","r+b","r+t",
+ "a","ab","at","a+","a+b","a+t");
+$file_content_types = array( "text_with_new_line","alphanumeric");
+
+$offset = array(-1, 0, 1, 512, 600); // different offsets
+
+$filename = dirname(__FILE__)."/fseek_ftell_rewind_variation3.tmp"; // this is name of the file created by create_files()
+
+ /* open the file using $files_modes and perform fseek(),ftell() and rewind() on it */
+echo "*** Testing fseek() with whence = SEEK_SET ***\n";
+foreach($file_content_types as $file_content_type){
+ echo "\n-- File having data of type ". $file_content_type ." --\n";
+
+ foreach($file_modes as $file_mode) {
+ echo "-- File opened in mode ".$file_mode." --\n";
+ create_files ( dirname(__FILE__), 1, $file_content_type, 0755, 512, "w", "fseek_ftell_rewind_variation",
+ 3, "bytes", ".tmp"); //create a file with 512 bytes size
+ $file_handle = fopen($filename, $file_mode);
+ if (!$file_handle) {
+ echo "Error: failed to fopen() file: $filename!";
+ exit();
+ }
+ foreach($offset as $count){
+ var_dump( fseek($file_handle,$count,SEEK_SET) );
+ var_dump( ftell($file_handle) ); // confirm the file pointer position
+ var_dump( feof($file_handle) ); //ensure that file pointer is not at end
+ } //end of offset loop
+
+ //close the file and check the size
+ fclose($file_handle);
+ var_dump( filesize($filename) );
+
+ delete_file($filename); // delete file with name
+ } //end of file_mode loop
+} //end of file_content_types loop
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fseek(), ftell(), rewind() : whence = SEEK_SET & all r and a modes ***
+*** Testing fseek() with whence = SEEK_SET ***
+
+-- File having data of type text_with_new_line --
+-- File opened in mode r --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode rb --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode rt --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode r+ --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode r+b --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode r+t --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode a --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode ab --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode at --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode a+ --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode a+b --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode a+t --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+
+-- File having data of type alphanumeric --
+-- File opened in mode r --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode rb --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode rt --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode r+ --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode r+b --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode r+t --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode a --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode ab --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode at --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode a+ --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode a+b --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode a+t --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+Done
diff --git a/ext/standard/tests/file/fseek_ftell_rewind_variation4-win32.phpt b/ext/standard/tests/file/fseek_ftell_rewind_variation4-win32.phpt
new file mode 100644
index 0000000..09c8344
--- /dev/null
+++ b/ext/standard/tests/file/fseek_ftell_rewind_variation4-win32.phpt
@@ -0,0 +1,483 @@
+--TEST--
+Test fseek(), ftell() & rewind() functions : usage variations - all w and x modes, SEEK_SET
+--SKIPIF--
+<?php
+if( substr(PHP_OS, 0, 3) != "WIN" )
+ die("skip.. only valid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype: int fseek ( resource $handle, int $offset [, int $whence] );
+ Description: Seeks on a file pointer
+
+ Prototype: bool rewind ( resource $handle );
+ Description: Rewind the position of a file pointer
+
+ Prototype: int ftell ( resource $handle );
+ Description: Tells file pointer read/write position
+*/
+
+// include the file.inc for common functions for test
+include ("file.inc");
+
+/* Testing fseek(),ftell(),rewind() functions
+ 1. All write and create with write modes
+ 2. Testing fseek() with whence = SEEK_SET
+*/
+echo "*** Testing fseek(), ftell(), rewind() : whence = SEEK_SET & all w and x modes ***\n";
+$file_modes = array( "w","wb","wt","w+","w+b","w+t",
+ "x","xb","xt","x+","x+b","x+t");
+$file_content_types = array( "text_with_new_line","alphanumeric");
+
+$offset = array(-1, 0, 1, 512, 600); // different offsets
+
+$filename = dirname(__FILE__)."/fseek_ftell_rewind_variation4.tmp"; // this is name of the file created by create_files()
+
+ /* open the file using $files_modes and perform fseek(),ftell() and rewind() on it */
+foreach($file_content_types as $file_content_type){
+ echo "\n-- File having data of type ". $file_content_type ." --\n";
+
+ foreach($file_modes as $file_mode) {
+ echo "-- File opened in mode ".$file_mode." --\n";
+ $file_handle = fopen($filename, $file_mode);
+ if (!$file_handle){
+ echo "Error: failed to fopen() file: $filename!";
+ exit();
+ }
+ $data_to_be_written="";
+ fill_buffer($data_to_be_written, $file_content_type, 512); //get the data of size 512
+ $data_to_be_written = $data_to_be_written;
+ fwrite($file_handle,(binary)$data_to_be_written);
+ rewind($file_handle);
+
+ foreach($offset as $count){
+ var_dump( fseek($file_handle,$count,SEEK_SET) );
+ var_dump( ftell($file_handle) ); // confirm the file pointer position
+ var_dump( feof($file_handle) ); //ensure that file pointer is not at end
+ } //end of offset loop
+
+ //close the file and check the size
+ fclose($file_handle);
+ var_dump( filesize($filename) );
+
+ delete_file($filename); // delete file with name
+ } //end of file_mode loop
+} //end of file_content_types loop
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fseek(), ftell(), rewind() : whence = SEEK_SET & all w and x modes ***
+
+-- File having data of type text_with_new_line --
+-- File opened in mode w --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode wb --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode wt --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(569)
+-- File opened in mode w+ --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode w+b --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode w+t --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(569)
+-- File opened in mode x --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode xb --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode xt --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(569)
+-- File opened in mode x+ --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode x+b --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode x+t --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(569)
+
+-- File having data of type alphanumeric --
+-- File opened in mode w --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode wb --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode wt --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode w+ --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode w+b --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode w+t --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode x --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode xb --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode xt --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode x+ --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode x+b --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode x+t --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+Done
diff --git a/ext/standard/tests/file/fseek_ftell_rewind_variation4.phpt b/ext/standard/tests/file/fseek_ftell_rewind_variation4.phpt
new file mode 100644
index 0000000..e4029c7
--- /dev/null
+++ b/ext/standard/tests/file/fseek_ftell_rewind_variation4.phpt
@@ -0,0 +1,483 @@
+--TEST--
+Test fseek(), ftell() & rewind() functions : usage variations - all w and x modes, SEEK_SET
+--SKIPIF--
+<?php
+if( substr(PHP_OS, 0, 3) == "WIN" )
+ die("skip.. Not valid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype: int fseek ( resource $handle, int $offset [, int $whence] );
+ Description: Seeks on a file pointer
+
+ Prototype: bool rewind ( resource $handle );
+ Description: Rewind the position of a file pointer
+
+ Prototype: int ftell ( resource $handle );
+ Description: Tells file pointer read/write position
+*/
+
+// include the file.inc for common functions for test
+include ("file.inc");
+
+/* Testing fseek(),ftell(),rewind() functions
+ 1. All write and create with write modes
+ 2. Testing fseek() with whence = SEEK_SET
+*/
+echo "*** Testing fseek(), ftell(), rewind() : whence = SEEK_SET & all w and x modes ***\n";
+$file_modes = array( "w","wb","wt","w+","w+b","w+t",
+ "x","xb","xt","x+","x+b","x+t");
+$file_content_types = array( "text_with_new_line","alphanumeric");
+
+$offset = array(-1, 0, 1, 512, 600); // different offsets
+
+$filename = dirname(__FILE__)."/fseek_ftell_rewind_variation4.tmp"; // this is name of the file created by create_files()
+
+ /* open the file using $files_modes and perform fseek(),ftell() and rewind() on it */
+foreach($file_content_types as $file_content_type){
+ echo "\n-- File having data of type ". $file_content_type ." --\n";
+
+ foreach($file_modes as $file_mode) {
+ echo "-- File opened in mode ".$file_mode." --\n";
+ $file_handle = fopen($filename, $file_mode);
+ if (!$file_handle){
+ echo "Error: failed to fopen() file: $filename!";
+ exit();
+ }
+ $data_to_be_written="";
+ fill_buffer($data_to_be_written, $file_content_type, 512); //get the data of size 512
+ $data_to_be_written = $data_to_be_written;
+ fwrite($file_handle,(binary)$data_to_be_written);
+ rewind($file_handle);
+
+ foreach($offset as $count){
+ var_dump( fseek($file_handle,$count,SEEK_SET) );
+ var_dump( ftell($file_handle) ); // confirm the file pointer position
+ var_dump( feof($file_handle) ); //ensure that file pointer is not at end
+ } //end of offset loop
+
+ //close the file and check the size
+ fclose($file_handle);
+ var_dump( filesize($filename) );
+
+ delete_file($filename); // delete file with name
+ } //end of file_mode loop
+} //end of file_content_types loop
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fseek(), ftell(), rewind() : whence = SEEK_SET & all w and x modes ***
+
+-- File having data of type text_with_new_line --
+-- File opened in mode w --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode wb --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode wt --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode w+ --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode w+b --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode w+t --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode x --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode xb --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode xt --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode x+ --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode x+b --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode x+t --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+
+-- File having data of type alphanumeric --
+-- File opened in mode w --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode wb --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode wt --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode w+ --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode w+b --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode w+t --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode x --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode xb --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode xt --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode x+ --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode x+b --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+-- File opened in mode x+t --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(600)
+bool(false)
+int(512)
+Done
diff --git a/ext/standard/tests/file/fseek_ftell_rewind_variation5.phpt b/ext/standard/tests/file/fseek_ftell_rewind_variation5.phpt
new file mode 100644
index 0000000..75f2812
--- /dev/null
+++ b/ext/standard/tests/file/fseek_ftell_rewind_variation5.phpt
@@ -0,0 +1,474 @@
+--TEST--
+Test fseek(), ftell() & rewind() functions : usage variations - all r & a modes, SEEK_CUR
+--FILE--
+<?php
+/* Prototype: int fseek ( resource $handle, int $offset [, int $whence] );
+ Description: Seeks on a file pointer
+
+ Prototype: bool rewind ( resource $handle );
+ Description: Rewind the position of a file pointer
+
+ Prototype: int ftell ( resource $handle );
+ Description: Tells file pointer read/write position
+*/
+
+// include the file.inc for common functions for test
+include ("file.inc");
+
+/* Testing fseek(),ftell(),rewind() functions
+ 1. All read and append modes
+ 2. Testing fseek() with whence = SEEK_CUR
+*/
+echo "*** Testing fseek(), ftell(), rewind() : whence = SEEK_CUR & all r and a modes ***\n";
+
+$file_modes = array( "r","rb","rt","r+","r+b","r+t",
+ "a","ab","at","a+","a+b","a+t");
+$file_content_types = array( "text_with_new_line","alphanumeric");
+
+$offset = array(-1, 0, 1, 512, 600);// different offsets
+
+$filename = dirname(__FILE__)."/fseek_ftell_rewind_variation5.tmp"; // this is name of the file created by create_files()
+
+/* open the file using $files_modes and perform fseek(),ftell() and rewind() on it */
+foreach($file_content_types as $file_content_type){
+ echo "-- File having data of type ". $file_content_type ." --\n";
+
+ foreach($file_modes as $file_mode) {
+ echo "-- File opened in mode ".$file_mode." --\n";
+ create_files ( dirname(__FILE__), 1, $file_content_type, 0755, 512, "w", "fseek_ftell_rewind_variation"
+ ,5,"bytes",".tmp"); //create a file with 512 bytes size
+ $file_handle = fopen($filename, $file_mode);
+ if (!$file_handle) {
+ echo "Error: failed to fopen() file: $filename!";
+ exit();
+ }
+ rewind($file_handle);
+ foreach($offset as $count){
+ var_dump( fseek($file_handle,$count,SEEK_CUR) );
+ var_dump( ftell($file_handle) ); // confirm the file pointer position
+ var_dump( feof($file_handle) ); //ensure that file pointer is not at end
+ } //end of offset loop
+
+ //close the file and check the size
+ fclose($file_handle);
+ var_dump( filesize($filename) );
+
+ delete_file($filename); // delete file with name
+ } //end of file_mode loop
+} //end of file_content_types loop
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fseek(), ftell(), rewind() : whence = SEEK_CUR & all r and a modes ***
+-- File having data of type text_with_new_line --
+-- File opened in mode r --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode rb --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode rt --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode r+ --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode r+b --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode r+t --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode a --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode ab --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode at --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode a+ --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode a+b --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode a+t --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File having data of type alphanumeric --
+-- File opened in mode r --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode rb --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode rt --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode r+ --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode r+b --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode r+t --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode a --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode ab --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode at --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode a+ --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode a+b --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode a+t --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+Done
diff --git a/ext/standard/tests/file/fseek_ftell_rewind_variation6-win32.phpt b/ext/standard/tests/file/fseek_ftell_rewind_variation6-win32.phpt
new file mode 100644
index 0000000..d451912
--- /dev/null
+++ b/ext/standard/tests/file/fseek_ftell_rewind_variation6-win32.phpt
@@ -0,0 +1,483 @@
+--TEST--
+Test fseek(), ftell() & rewind() functions : usage variations - all w & x modes, SEEK_CUR
+--SKIPIF--
+<?php
+if( substr(PHP_OS, 0, 3) != "WIN" )
+ die("skip.. only valid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype: int fseek ( resource $handle, int $offset [, int $whence] );
+ Description: Seeks on a file pointer
+
+ Prototype: bool rewind ( resource $handle );
+ Description: Rewind the position of a file pointer
+
+ Prototype: int ftell ( resource $handle );
+ Description: Tells file pointer read/write position
+*/
+
+// include the file.inc for common functions for test
+include ("file.inc");
+
+/* Testing fseek(),ftell(),rewind() functions
+ 1. All write and create with write modes
+ 2. Testing fseek() with whence = SEEK_CUR
+*/
+echo "*** Testing fseek(), ftell(), rewind() : whence = SEEK_CUR & all w and x modes ***\n";
+
+$file_modes = array( "w","wb","wt","w+","w+b","w+t",
+ "x","xb","xt","x+","x+b","x+t");
+$file_content_types = array( "text_with_new_line","alphanumeric");
+
+$offset = array(-1,0,1,512,600); // different offsets
+
+$filename = dirname(__FILE__)."/fseek_ftell_rewind_variation6.tmp"; // this is name of the file created by create_files()
+
+/* open the file using $files_modes and perform fseek(),ftell() and rewind() on it */
+foreach($file_content_types as $file_content_type){
+ echo "\n-- File having data of type ". $file_content_type ." --\n";
+ foreach($file_modes as $file_mode) {
+ echo "-- File opened in mode ".$file_mode." --\n";
+ $file_handle = fopen($filename, $file_mode);
+ if (!$file_handle){
+ echo "Error: failed to fopen() file: $filename!";
+ exit();
+ }
+ $data_to_be_written="";
+ fill_buffer($data_to_be_written, $file_content_type, 512); //get the data of size 512
+ $data_to_be_written = $data_to_be_written;
+ fwrite($file_handle,(binary)$data_to_be_written);
+ rewind($file_handle);
+
+ foreach($offset as $count){
+ var_dump( fseek($file_handle,$count,SEEK_CUR) );
+ var_dump( ftell($file_handle) ); // confirm the file pointer position
+ var_dump( feof($file_handle) ); //ensure that file pointer is not at end
+ } //end of offset loop
+
+ //close the file and check the size
+ fclose($file_handle);
+ var_dump( filesize($filename) );
+
+ delete_file($filename); // delete file with name
+ } //end of file_mode loop
+} //end of file_content_types loop
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fseek(), ftell(), rewind() : whence = SEEK_CUR & all w and x modes ***
+
+-- File having data of type text_with_new_line --
+-- File opened in mode w --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode wb --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode wt --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(569)
+-- File opened in mode w+ --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode w+b --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode w+t --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(569)
+-- File opened in mode x --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode xb --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode xt --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(569)
+-- File opened in mode x+ --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode x+b --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode x+t --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(569)
+
+-- File having data of type alphanumeric --
+-- File opened in mode w --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode wb --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode wt --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode w+ --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode w+b --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode w+t --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode x --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode xb --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode xt --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode x+ --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode x+b --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode x+t --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+Done
diff --git a/ext/standard/tests/file/fseek_ftell_rewind_variation6.phpt b/ext/standard/tests/file/fseek_ftell_rewind_variation6.phpt
new file mode 100644
index 0000000..4451988
--- /dev/null
+++ b/ext/standard/tests/file/fseek_ftell_rewind_variation6.phpt
@@ -0,0 +1,483 @@
+--TEST--
+Test fseek(), ftell() & rewind() functions : usage variations - all w & x modes, SEEK_CUR
+--SKIPIF--
+<?php
+if( substr(PHP_OS, 0, 3) == "WIN" )
+ die("skip.. Not valid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype: int fseek ( resource $handle, int $offset [, int $whence] );
+ Description: Seeks on a file pointer
+
+ Prototype: bool rewind ( resource $handle );
+ Description: Rewind the position of a file pointer
+
+ Prototype: int ftell ( resource $handle );
+ Description: Tells file pointer read/write position
+*/
+
+// include the file.inc for common functions for test
+include ("file.inc");
+
+/* Testing fseek(),ftell(),rewind() functions
+ 1. All write and create with write modes
+ 2. Testing fseek() with whence = SEEK_CUR
+*/
+echo "*** Testing fseek(), ftell(), rewind() : whence = SEEK_CUR & all w and x modes ***\n";
+
+$file_modes = array( "w","wb","wt","w+","w+b","w+t",
+ "x","xb","xt","x+","x+b","x+t");
+$file_content_types = array( "text_with_new_line","alphanumeric");
+
+$offset = array(-1,0,1,512,600); // different offsets
+
+$filename = dirname(__FILE__)."/fseek_ftell_rewind_variation6.tmp"; // this is name of the file created by create_files()
+
+/* open the file using $files_modes and perform fseek(),ftell() and rewind() on it */
+foreach($file_content_types as $file_content_type){
+ echo "\n-- File having data of type ". $file_content_type ." --\n";
+ foreach($file_modes as $file_mode) {
+ echo "-- File opened in mode ".$file_mode." --\n";
+ $file_handle = fopen($filename, $file_mode);
+ if (!$file_handle){
+ echo "Error: failed to fopen() file: $filename!";
+ exit();
+ }
+ $data_to_be_written="";
+ fill_buffer($data_to_be_written, $file_content_type, 512); //get the data of size 512
+ $data_to_be_written = $data_to_be_written;
+ fwrite($file_handle,(binary)$data_to_be_written);
+ rewind($file_handle);
+
+ foreach($offset as $count){
+ var_dump( fseek($file_handle,$count,SEEK_CUR) );
+ var_dump( ftell($file_handle) ); // confirm the file pointer position
+ var_dump( feof($file_handle) ); //ensure that file pointer is not at end
+ } //end of offset loop
+
+ //close the file and check the size
+ fclose($file_handle);
+ var_dump( filesize($filename) );
+
+ delete_file($filename); // delete file with name
+ } //end of file_mode loop
+} //end of file_content_types loop
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fseek(), ftell(), rewind() : whence = SEEK_CUR & all w and x modes ***
+
+-- File having data of type text_with_new_line --
+-- File opened in mode w --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode wb --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode wt --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode w+ --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode w+b --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode w+t --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode x --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode xb --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode xt --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode x+ --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode x+b --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode x+t --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+
+-- File having data of type alphanumeric --
+-- File opened in mode w --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode wb --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode wt --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode w+ --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode w+b --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode w+t --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode x --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode xb --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode xt --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode x+ --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode x+b --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+-- File opened in mode x+t --
+int(-1)
+int(0)
+bool(false)
+int(0)
+int(0)
+bool(false)
+int(0)
+int(1)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1113)
+bool(false)
+int(512)
+Done
diff --git a/ext/standard/tests/file/fseek_ftell_rewind_variation7.phpt b/ext/standard/tests/file/fseek_ftell_rewind_variation7.phpt
new file mode 100644
index 0000000..f0e8e46
--- /dev/null
+++ b/ext/standard/tests/file/fseek_ftell_rewind_variation7.phpt
@@ -0,0 +1,477 @@
+--TEST--
+Test fseek(), ftell() & rewind() functions : usage variations - all r and a modes, SEEK_END
+--FILE--
+<?php
+/* Prototype: int fseek ( resource $handle, int $offset [, int $whence] );
+ Description: Seeks on a file pointer
+
+ Prototype: bool rewind ( resource $handle );
+ Description: Rewind the position of a file pointer
+
+ Prototype: int ftell ( resource $handle );
+ Description: Tells file pointer read/write position
+*/
+
+// include the file.inc for common functions for test
+include ("file.inc");
+
+/* Testing fseek(),ftell(),rewind() functions
+ 1. All read and append modes
+ 2. Testing fseek() with whence = SEEK_END
+*/
+
+echo "*** Testing fseek(), ftell(), rewind() : whence = SEEK_END & all r and a modes ***\n";
+
+$file_modes = array( "r","rb","rt","r+","r+b","r+t",
+ "a","ab","at","a+","a+b","a+t");
+$file_content_types = array( "text_with_new_line","alphanumeric");
+
+$offset = array(-1,0,1,512,600);// different offsets
+
+$filename = dirname(__FILE__)."/fseek_ftell_rewind_variation7.tmp"; // this is name of the file created by create_files()
+
+/* open the file using $files_modes and perform fseek(),ftell() and rewind() on it */
+foreach($file_content_types as $file_content_type){
+ echo "\n-- File having data of type ". $file_content_type ." --\n";
+ foreach($file_modes as $file_mode) {
+ echo "-- File opened in mode ".$file_mode." --\n";
+ create_files ( dirname(__FILE__), 1, $file_content_type, 0755, 512, "w", "fseek_ftell_rewind_variation"
+ ,7,"bytes",".tmp"); //create a file with 512 bytes size
+ $file_handle = fopen($filename, $file_mode);
+ if (!$file_handle) {
+ echo "Error: failed to fopen() file: $filename!";
+ exit();
+ }
+ rewind($file_handle);
+ foreach($offset as $count){
+ var_dump( fseek($file_handle,$count,SEEK_END) );
+ var_dump( ftell($file_handle) ); // confirm the file pointer position
+ var_dump( feof($file_handle) ); //ensure that file pointer is not at end
+ } //end of offset loop
+
+ //close the file and check the size, the size will have increased
+ // by 10 bytes because of holes
+ fclose($file_handle);
+ var_dump( filesize($filename) );
+
+ delete_file($filename); // delete file with name
+ } //end of file_mode loop
+} //end of file_content_types loop
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fseek(), ftell(), rewind() : whence = SEEK_END & all r and a modes ***
+
+-- File having data of type text_with_new_line --
+-- File opened in mode r --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode rb --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode rt --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode r+ --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode r+b --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode r+t --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode a --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode ab --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode at --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode a+ --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode a+b --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode a+t --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+
+-- File having data of type alphanumeric --
+-- File opened in mode r --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode rb --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode rt --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode r+ --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode r+b --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode r+t --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode a --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode ab --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode at --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode a+ --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode a+b --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode a+t --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+Done
diff --git a/ext/standard/tests/file/fseek_ftell_rewind_variation8-win32.phpt b/ext/standard/tests/file/fseek_ftell_rewind_variation8-win32.phpt
new file mode 100644
index 0000000..5586e2b
--- /dev/null
+++ b/ext/standard/tests/file/fseek_ftell_rewind_variation8-win32.phpt
@@ -0,0 +1,484 @@
+--TEST--
+Test fseek(), ftell() & rewind() functions : usage variations - all w and x modes, SEEK_END
+--SKIPIF--
+<?php
+if( substr(PHP_OS, 0, 3) != "WIN" )
+ die("skip.. only valid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype: int fseek ( resource $handle, int $offset [, int $whence] );
+ Description: Seeks on a file pointer
+
+ Prototype: bool rewind ( resource $handle );
+ Description: Rewind the position of a file pointer
+
+ Prototype: int ftell ( resource $handle );
+ Description: Tells file pointer read/write position
+*/
+
+// include the file.inc for common functions for test
+include ("file.inc");
+
+/* Testing fseek(),ftell(),rewind() functions
+ 1. All write and create with write modes
+ 2. Testing fseek() with whence = SEEK_END
+*/
+echo "*** Testing fseek(), ftell(), rewind() : whence = SEEK_END & all r and a modes ***\n";
+
+$file_modes = array( "w","wb","wt","w+","w+b","w+t",
+ "x","xb","xt","x+","x+b","x+t");
+$file_content_types = array( "text_with_new_line","alphanumeric");
+
+$offset = array(-1,0,1,512,600); // different offsets
+
+$filename = dirname(__FILE__)."/fseek_ftell_rewind_variation8.tmp"; // this is name of the file created by create_files()
+
+/* open the file using $files_modes and perform fseek(),ftell() and rewind() on it */
+foreach($file_content_types as $file_content_type){
+ echo "\n-- File having data of type ". $file_content_type ." --\n";
+
+ foreach($file_modes as $file_mode) {
+ echo "-- File opened in mode ".$file_mode." --\n";
+ $file_handle = fopen($filename, $file_mode);
+ if (!$file_handle){
+ echo "Error: failed to fopen() file: $filename!";
+ exit();
+ }
+ $data_to_be_written="";
+ fill_buffer($data_to_be_written, $file_content_type, 512); //get the data of size 512
+ $data_to_be_written = $data_to_be_written;
+ fwrite($file_handle,(binary)$data_to_be_written);
+ rewind($file_handle);
+
+ foreach($offset as $count){
+ var_dump( fseek($file_handle,$count,SEEK_END) );
+ var_dump( ftell($file_handle) ); // confirm the file pointer position
+ var_dump( feof($file_handle) ); //ensure that file pointer is not at end
+ } //end of offset loop
+
+ //close the file and check the size
+ fclose($file_handle);
+ var_dump( filesize($filename) );
+
+ delete_file($filename); // delete file with name
+ } //end of file_mode loop
+} //end of file_content_types loop
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fseek(), ftell(), rewind() : whence = SEEK_END & all r and a modes ***
+
+-- File having data of type text_with_new_line --
+-- File opened in mode w --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode wb --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode wt --
+int(0)
+int(568)
+bool(false)
+int(0)
+int(569)
+bool(false)
+int(0)
+int(570)
+bool(false)
+int(0)
+int(1081)
+bool(false)
+int(0)
+int(1169)
+bool(false)
+int(569)
+-- File opened in mode w+ --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode w+b --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode w+t --
+int(0)
+int(568)
+bool(false)
+int(0)
+int(569)
+bool(false)
+int(0)
+int(570)
+bool(false)
+int(0)
+int(1081)
+bool(false)
+int(0)
+int(1169)
+bool(false)
+int(569)
+-- File opened in mode x --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode xb --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode xt --
+int(0)
+int(568)
+bool(false)
+int(0)
+int(569)
+bool(false)
+int(0)
+int(570)
+bool(false)
+int(0)
+int(1081)
+bool(false)
+int(0)
+int(1169)
+bool(false)
+int(569)
+-- File opened in mode x+ --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode x+b --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode x+t --
+int(0)
+int(568)
+bool(false)
+int(0)
+int(569)
+bool(false)
+int(0)
+int(570)
+bool(false)
+int(0)
+int(1081)
+bool(false)
+int(0)
+int(1169)
+bool(false)
+int(569)
+
+-- File having data of type alphanumeric --
+-- File opened in mode w --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode wb --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode wt --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode w+ --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode w+b --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode w+t --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode x --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode xb --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode xt --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode x+ --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode x+b --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode x+t --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+Done
diff --git a/ext/standard/tests/file/fseek_ftell_rewind_variation8.phpt b/ext/standard/tests/file/fseek_ftell_rewind_variation8.phpt
new file mode 100644
index 0000000..a2a0d67
--- /dev/null
+++ b/ext/standard/tests/file/fseek_ftell_rewind_variation8.phpt
@@ -0,0 +1,484 @@
+--TEST--
+Test fseek(), ftell() & rewind() functions : usage variations - all w and x modes, SEEK_END
+--SKIPIF--
+<?php
+if( substr(PHP_OS, 0, 3) == "WIN" )
+ die("skip.. Not valid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype: int fseek ( resource $handle, int $offset [, int $whence] );
+ Description: Seeks on a file pointer
+
+ Prototype: bool rewind ( resource $handle );
+ Description: Rewind the position of a file pointer
+
+ Prototype: int ftell ( resource $handle );
+ Description: Tells file pointer read/write position
+*/
+
+// include the file.inc for common functions for test
+include ("file.inc");
+
+/* Testing fseek(),ftell(),rewind() functions
+ 1. All write and create with write modes
+ 2. Testing fseek() with whence = SEEK_END
+*/
+echo "*** Testing fseek(), ftell(), rewind() : whence = SEEK_END & all r and a modes ***\n";
+
+$file_modes = array( "w","wb","wt","w+","w+b","w+t",
+ "x","xb","xt","x+","x+b","x+t");
+$file_content_types = array( "text_with_new_line","alphanumeric");
+
+$offset = array(-1,0,1,512,600); // different offsets
+
+$filename = dirname(__FILE__)."/fseek_ftell_rewind_variation8.tmp"; // this is name of the file created by create_files()
+
+/* open the file using $files_modes and perform fseek(),ftell() and rewind() on it */
+foreach($file_content_types as $file_content_type){
+ echo "\n-- File having data of type ". $file_content_type ." --\n";
+
+ foreach($file_modes as $file_mode) {
+ echo "-- File opened in mode ".$file_mode." --\n";
+ $file_handle = fopen($filename, $file_mode);
+ if (!$file_handle){
+ echo "Error: failed to fopen() file: $filename!";
+ exit();
+ }
+ $data_to_be_written="";
+ fill_buffer($data_to_be_written, $file_content_type, 512); //get the data of size 512
+ $data_to_be_written = $data_to_be_written;
+ fwrite($file_handle,(binary)$data_to_be_written);
+ rewind($file_handle);
+
+ foreach($offset as $count){
+ var_dump( fseek($file_handle,$count,SEEK_END) );
+ var_dump( ftell($file_handle) ); // confirm the file pointer position
+ var_dump( feof($file_handle) ); //ensure that file pointer is not at end
+ } //end of offset loop
+
+ //close the file and check the size
+ fclose($file_handle);
+ var_dump( filesize($filename) );
+
+ delete_file($filename); // delete file with name
+ } //end of file_mode loop
+} //end of file_content_types loop
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fseek(), ftell(), rewind() : whence = SEEK_END & all r and a modes ***
+
+-- File having data of type text_with_new_line --
+-- File opened in mode w --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode wb --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode wt --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode w+ --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode w+b --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode w+t --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode x --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode xb --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode xt --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode x+ --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode x+b --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode x+t --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+
+-- File having data of type alphanumeric --
+-- File opened in mode w --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode wb --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode wt --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode w+ --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode w+b --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode w+t --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode x --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode xb --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode xt --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode x+ --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode x+b --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+-- File opened in mode x+t --
+int(0)
+int(511)
+bool(false)
+int(0)
+int(512)
+bool(false)
+int(0)
+int(513)
+bool(false)
+int(0)
+int(1024)
+bool(false)
+int(0)
+int(1112)
+bool(false)
+int(512)
+Done
diff --git a/ext/standard/tests/file/fseek_variation1.phpt b/ext/standard/tests/file/fseek_variation1.phpt
new file mode 100644
index 0000000..fbe4673
--- /dev/null
+++ b/ext/standard/tests/file/fseek_variation1.phpt
@@ -0,0 +1,198 @@
+--TEST--
+Test fseek() function : usage variations - different types for offset
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : proto int fseek(resource fp, int offset [, int whence])
+ * Description: Seek on a file pointer
+ * Source code: ext/standard/file.c
+ * Alias to functions: gzseek
+ */
+
+echo "*** Testing fseek() : usage variations ***\n";
+error_reporting(E_ALL & ~E_NOTICE);
+
+// Initialise function arguments not being substituted (if any)
+
+$fp = fopen(__FILE__, 'r');
+$whence = SEEK_SET;
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+class testClass {
+ public function __toString() {
+ return "testClass";
+ }
+}
+
+
+//array of values to iterate over
+$values = array(
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.7654321E-10,
+ .5,
+
+ // array data
+ array(),
+ array(0),
+ array(1),
+ array(1, 2),
+ array('color' => 'red', 'item' => 'pen'),
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // string data
+ "string",
+ 'string',
+
+ // object data
+ new testClass(),
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for offset
+
+foreach($values as $value) {
+ echo @"\nArg value $value \n";
+ var_dump( fseek($fp, $value, $whence) );
+ var_dump( ftell($fp));
+};
+fclose($fp);
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing fseek() : usage variations ***
+
+Arg value 10.5
+int(0)
+int(10)
+
+Arg value -10.5
+int(-1)
+int(10)
+
+Arg value 1.07654321E-9
+int(0)
+int(0)
+
+Arg value 0.5
+int(0)
+int(0)
+
+Arg value Array
+
+Warning: fseek() expects parameter 2 to be long, array given in %s on line %d
+bool(false)
+int(0)
+
+Arg value Array
+
+Warning: fseek() expects parameter 2 to be long, array given in %s on line %d
+bool(false)
+int(0)
+
+Arg value Array
+
+Warning: fseek() expects parameter 2 to be long, array given in %s on line %d
+bool(false)
+int(0)
+
+Arg value Array
+
+Warning: fseek() expects parameter 2 to be long, array given in %s on line %d
+bool(false)
+int(0)
+
+Arg value Array
+
+Warning: fseek() expects parameter 2 to be long, array given in %s on line %d
+bool(false)
+int(0)
+
+Arg value
+int(0)
+int(0)
+
+Arg value
+int(0)
+int(0)
+
+Arg value 1
+int(0)
+int(1)
+
+Arg value
+int(0)
+int(0)
+
+Arg value 1
+int(0)
+int(1)
+
+Arg value
+int(0)
+int(0)
+
+Arg value
+
+Warning: fseek() expects parameter 2 to be long, string given in %s on line %d
+bool(false)
+int(0)
+
+Arg value
+
+Warning: fseek() expects parameter 2 to be long, string given in %s on line %d
+bool(false)
+int(0)
+
+Arg value string
+
+Warning: fseek() expects parameter 2 to be long, string given in %s on line %d
+bool(false)
+int(0)
+
+Arg value string
+
+Warning: fseek() expects parameter 2 to be long, string given in %s on line %d
+bool(false)
+int(0)
+
+Arg value testClass
+
+Warning: fseek() expects parameter 2 to be long, object given in %s on line %d
+bool(false)
+int(0)
+
+Arg value
+int(0)
+int(0)
+
+Arg value
+int(0)
+int(0)
+Done
+
diff --git a/ext/standard/tests/file/fseek_variation2.phpt b/ext/standard/tests/file/fseek_variation2.phpt
new file mode 100644
index 0000000..f454352
--- /dev/null
+++ b/ext/standard/tests/file/fseek_variation2.phpt
@@ -0,0 +1,159 @@
+--TEST--
+Test fseek() function : usage variations - different types for whence
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : proto int fseek(resource fp, int offset [, int whence])
+ * Description: Seek on a file pointer
+ * Source code: ext/standard/file.c
+ * Alias to functions: gzseek
+ */
+
+echo "*** Testing fseek() : usage variations ***\n";
+error_reporting(E_ALL & ~E_NOTICE);
+$fp = fopen(__FILE__, 'r');
+$offset = 3;
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+//array of values to iterate over
+$values = array(
+
+ // outside of whence range
+ -100,
+ 100,
+
+ // float data
+ 10.5,
+ -10.5,
+ 10.1234567e10,
+ 10.7654321E-10,
+ .5,
+
+ // null data
+ NULL,
+ null,
+
+ // boolean data
+ true,
+ false,
+ TRUE,
+ FALSE,
+
+ // empty data
+ "",
+ '',
+
+ // string data
+ "string",
+ 'string',
+
+ // undefined data
+ $undefined_var,
+
+ // unset data
+ $unset_var,
+);
+
+// loop through each element of the array for whence
+
+foreach($values as $value) {
+ echo "\nArg value $value \n";
+ var_dump( fseek($fp, $offset, $value) );
+ var_dump( ftell($fp));
+};
+
+fclose($fp);
+echo "Done";
+?>
+--EXPECTF--
+*** Testing fseek() : usage variations ***
+
+Arg value -100
+int(-1)
+int(0)
+
+Arg value 100
+int(-1)
+int(0)
+
+Arg value 10.5
+int(-1)
+int(0)
+
+Arg value -10.5
+int(-1)
+int(0)
+
+Arg value 101234567000
+int(-1)
+int(0)
+
+Arg value 1.07654321E-9
+int(0)
+int(3)
+
+Arg value 0.5
+int(0)
+int(3)
+
+Arg value
+int(0)
+int(3)
+
+Arg value
+int(0)
+int(3)
+
+Arg value 1
+int(0)
+int(6)
+
+Arg value
+int(0)
+int(3)
+
+Arg value 1
+int(0)
+int(6)
+
+Arg value
+int(0)
+int(3)
+
+Arg value
+
+Warning: fseek() expects parameter 3 to be long, string given in %s on line %d
+bool(false)
+int(3)
+
+Arg value
+
+Warning: fseek() expects parameter 3 to be long, string given in %s on line %d
+bool(false)
+int(3)
+
+Arg value string
+
+Warning: fseek() expects parameter 3 to be long, string given in %s on line %d
+bool(false)
+int(3)
+
+Arg value string
+
+Warning: fseek() expects parameter 3 to be long, string given in %s on line %d
+bool(false)
+int(3)
+
+Arg value
+int(0)
+int(3)
+
+Arg value
+int(0)
+int(3)
+Done
+
diff --git a/ext/standard/tests/file/fseek_variation3.phpt b/ext/standard/tests/file/fseek_variation3.phpt
new file mode 100644
index 0000000..c29ed31
--- /dev/null
+++ b/ext/standard/tests/file/fseek_variation3.phpt
@@ -0,0 +1,54 @@
+--TEST--
+Test fseek() function : variation functionality beyond file boundaries
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : proto int fseek(resource fp, int offset [, int whence])
+ * Description: Seek on a file pointer
+ * Source code: ext/standard/file.c
+ * Alias to functions: gzseek
+ */
+
+echo "*** Testing fseek() : variation - beyond file boundaries ***\n";
+
+$outputfile = __FILE__.".tmp";
+
+$h = fopen($outputfile, "wb+");
+for ($i = 1; $i < 10; $i++) {
+ fwrite($h, chr(0x30 + $i));
+}
+
+echo "--- fseek beyond start of file ---\n";
+var_dump(fseek($h, -4, SEEK_SET));
+echo "after -4 seek: ".bin2hex(fread($h,1))."\n";
+var_dump(fseek($h, -1, SEEK_CUR));
+echo "after seek back 1: ".bin2hex(fread($h,1))."\n";
+var_dump(fseek($h, -20, SEEK_CUR));
+echo "after seek back 20: ".bin2hex(fread($h,1))."\n";
+
+echo "--- fseek beyond end of file ---\n";
+var_dump(fseek($h, 16, SEEK_SET));
+fwrite($h, b"end");
+fseek($h ,0, SEEK_SET);
+$data = fread($h, 4096);
+echo bin2hex($data)."\n";
+
+fclose($h);
+unlink($outputfile);
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing fseek() : variation - beyond file boundaries ***
+--- fseek beyond start of file ---
+int(-1)
+after -4 seek:
+int(0)
+after seek back 1: 39
+int(-1)
+after seek back 20:
+--- fseek beyond end of file ---
+int(0)
+31323334353637383900000000000000656e64
+Done
diff --git a/ext/standard/tests/file/fstat.phpt b/ext/standard/tests/file/fstat.phpt
new file mode 100644
index 0000000..e1ae3e2
--- /dev/null
+++ b/ext/standard/tests/file/fstat.phpt
@@ -0,0 +1,74 @@
+--TEST--
+fstat() tests
+--FILE--
+<?php
+
+$filename = dirname(__FILE__)."/fstat.dat";
+
+$fp = fopen($filename, "w");
+var_dump(fstat($fp));
+fclose($fp);
+var_dump(fstat($fp));
+
+@unlink($filename);
+echo "Done\n";
+?>
+--EXPECTF--
+array(26) {
+ [0]=>
+ int(%i)
+ [1]=>
+ int(%i)
+ [2]=>
+ int(%i)
+ [3]=>
+ int(%i)
+ [4]=>
+ int(%i)
+ [5]=>
+ int(%i)
+ [6]=>
+ int(%i)
+ [7]=>
+ int(%i)
+ [8]=>
+ int(%i)
+ [9]=>
+ int(%i)
+ [10]=>
+ int(%i)
+ [11]=>
+ int(%i)
+ [12]=>
+ int(%i)
+ ["dev"]=>
+ int(%i)
+ ["ino"]=>
+ int(%i)
+ ["mode"]=>
+ int(%i)
+ ["nlink"]=>
+ int(%i)
+ ["uid"]=>
+ int(%i)
+ ["gid"]=>
+ int(%i)
+ ["rdev"]=>
+ int(%i)
+ ["size"]=>
+ int(%i)
+ ["atime"]=>
+ int(%i)
+ ["mtime"]=>
+ int(%i)
+ ["ctime"]=>
+ int(%i)
+ ["blksize"]=>
+ int(%i)
+ ["blocks"]=>
+ int(%i)
+}
+
+Warning: fstat(): %d is not a valid stream resource in %s on line %d
+bool(false)
+Done
diff --git a/ext/standard/tests/file/fstat_basic.phpt b/ext/standard/tests/file/fstat_basic.phpt
new file mode 100644
index 0000000..a404929
--- /dev/null
+++ b/ext/standard/tests/file/fstat_basic.phpt
@@ -0,0 +1,65 @@
+--TEST--
+Test function fstat() by calling it with its expected arguments
+--FILE--
+<?php
+$fp = fopen (__FILE__, 'r');
+var_dump(fstat( $fp ) );
+fclose($fp);
+?>
+===DONE===
+--EXPECTF--
+array(26) {
+ [0]=>
+ int(%i)
+ [1]=>
+ int(%i)
+ [2]=>
+ int(%i)
+ [3]=>
+ int(%i)
+ [4]=>
+ int(%i)
+ [5]=>
+ int(%i)
+ [6]=>
+ int(%i)
+ [7]=>
+ int(%i)
+ [8]=>
+ int(%i)
+ [9]=>
+ int(%i)
+ [10]=>
+ int(%i)
+ [11]=>
+ int(%i)
+ [12]=>
+ int(%i)
+ ["dev"]=>
+ int(%i)
+ ["ino"]=>
+ int(%i)
+ ["mode"]=>
+ int(%i)
+ ["nlink"]=>
+ int(%i)
+ ["uid"]=>
+ int(%i)
+ ["gid"]=>
+ int(%i)
+ ["rdev"]=>
+ int(%i)
+ ["size"]=>
+ int(%i)
+ ["atime"]=>
+ int(%i)
+ ["mtime"]=>
+ int(%i)
+ ["ctime"]=>
+ int(%i)
+ ["blksize"]=>
+ int(%i)
+ ["blocks"]=>
+ int(%i)
+}
+===DONE=== \ No newline at end of file
diff --git a/ext/standard/tests/file/fstat_error.phpt b/ext/standard/tests/file/fstat_error.phpt
new file mode 100644
index 0000000..d75ddb9
--- /dev/null
+++ b/ext/standard/tests/file/fstat_error.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Test function fstat() by calling it more than or less than its expected arguments
+--FILE--
+<?php
+$fp = fopen (__FILE__, 'r');
+$extra_arg = 'nothing';
+
+var_dump(fstat( $fp, $extra_arg ) );
+var_dump(fstat());
+
+fclose($fp);
+
+?>
+===DONE===
+--EXPECTF--
+
+Warning: fstat() expects exactly 1 parameter, 2 given in %s on line %d
+bool(false)
+
+Warning: fstat() expects exactly 1 parameter, 0 given in %s on line %d
+bool(false)
+===DONE=== \ No newline at end of file
diff --git a/ext/standard/tests/file/fstat_variation1.phpt b/ext/standard/tests/file/fstat_variation1.phpt
new file mode 100644
index 0000000..b2ad541
--- /dev/null
+++ b/ext/standard/tests/file/fstat_variation1.phpt
@@ -0,0 +1,34 @@
+--TEST--
+Test function fstat() by substituting agument 1 with array values.
+--FILE--
+<?php
+$index_array = array(1, 2, 3);
+$assoc_array = array(1 => 'one', 2 => 'two');
+
+$variation_array = array(
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+ );
+
+
+foreach ( $variation_array as $var ) {
+ var_dump(fstat( $var ) );
+}
+?>
+===DONE===
+--EXPECTF--
+
+Warning: fstat() expects parameter 1 to be resource, array given in %s on line %d
+bool(false)
+
+Warning: fstat() expects parameter 1 to be resource, array given in %s on line %d
+bool(false)
+
+Warning: fstat() expects parameter 1 to be resource, array given in %s on line %d
+bool(false)
+
+Warning: fstat() expects parameter 1 to be resource, array given in %s on line %d
+bool(false)
+===DONE=== \ No newline at end of file
diff --git a/ext/standard/tests/file/fstat_variation2.phpt b/ext/standard/tests/file/fstat_variation2.phpt
new file mode 100644
index 0000000..fd62f23
--- /dev/null
+++ b/ext/standard/tests/file/fstat_variation2.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Test function fstat() by substituting agument 1 with boolean values.
+--FILE--
+<?php
+$variation_array = array(
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+ );
+
+
+foreach ( $variation_array as $var ) {
+ var_dump(fstat( $var ) );
+}
+?>
+===DONE===
+--EXPECTF--
+
+Warning: fstat() expects parameter 1 to be resource, boolean given in %s on line %d
+bool(false)
+
+Warning: fstat() expects parameter 1 to be resource, boolean given in %s on line %d
+bool(false)
+
+Warning: fstat() expects parameter 1 to be resource, boolean given in %s on line %d
+bool(false)
+
+Warning: fstat() expects parameter 1 to be resource, boolean given in %s on line %d
+bool(false)
+===DONE=== \ No newline at end of file
diff --git a/ext/standard/tests/file/fstat_variation3.phpt b/ext/standard/tests/file/fstat_variation3.phpt
new file mode 100644
index 0000000..4cd74e3
--- /dev/null
+++ b/ext/standard/tests/file/fstat_variation3.phpt
@@ -0,0 +1,42 @@
+--TEST--
+Test function fstat() by substituting agument 1 with emptyUnsetUndefNull values.
+--FILE--
+<?php
+$unset_var = 10;
+unset($unset_var);
+
+$variation_array = array(
+ 'unset var' => @$unset_var,
+ 'undefined var' => @$undefined_var,
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+ );
+
+
+foreach ( $variation_array as $var ) {
+ var_dump(fstat( $var ) );
+}
+?>
+===DONE===
+--EXPECTF--
+
+Warning: fstat() expects parameter 1 to be resource, null given in %s on line %d
+bool(false)
+
+Warning: fstat() expects parameter 1 to be resource, null given in %s on line %d
+bool(false)
+
+Warning: fstat() expects parameter 1 to be resource, string given in %s on line %d
+bool(false)
+
+Warning: fstat() expects parameter 1 to be resource, string given in %s on line %d
+bool(false)
+
+Warning: fstat() expects parameter 1 to be resource, null given in %s on line %d
+bool(false)
+
+Warning: fstat() expects parameter 1 to be resource, null given in %s on line %d
+bool(false)
+===DONE=== \ No newline at end of file
diff --git a/ext/standard/tests/file/fstat_variation4.phpt b/ext/standard/tests/file/fstat_variation4.phpt
new file mode 100644
index 0000000..1649776
--- /dev/null
+++ b/ext/standard/tests/file/fstat_variation4.phpt
@@ -0,0 +1,35 @@
+--TEST--
+Test function fstat() by substituting agument 1 with float values.
+--FILE--
+<?php
+$variation_array = array(
+ 'float 10.5' => 10.5,
+ 'float -10.5' => -10.5,
+ 'float 12.3456789000e10' => 12.3456789000e10,
+ 'float -12.3456789000e10' => -12.3456789000e10,
+ 'float .5' => .5,
+ );
+
+
+foreach ( $variation_array as $var ) {
+ var_dump(fstat( $var ) );
+}
+?>
+===DONE===
+--EXPECTF--
+
+Warning: fstat() expects parameter 1 to be resource, double given in %s on line %d
+bool(false)
+
+Warning: fstat() expects parameter 1 to be resource, double given in %s on line %d
+bool(false)
+
+Warning: fstat() expects parameter 1 to be resource, double given in %s on line %d
+bool(false)
+
+Warning: fstat() expects parameter 1 to be resource, double given in %s on line %d
+bool(false)
+
+Warning: fstat() expects parameter 1 to be resource, double given in %s on line %d
+bool(false)
+===DONE=== \ No newline at end of file
diff --git a/ext/standard/tests/file/fstat_variation5.phpt b/ext/standard/tests/file/fstat_variation5.phpt
new file mode 100644
index 0000000..ef4f4ea
--- /dev/null
+++ b/ext/standard/tests/file/fstat_variation5.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Test function fstat() by substituting agument 1 with int values.
+--FILE--
+<?php
+$variation_array = array (
+ 'int 0' => 0,
+ 'int 1' => 1,
+ 'int 12345' => 12345,
+ 'int -12345' => -2345,
+ );
+
+
+foreach ( $variation_array as $var ) {
+ var_dump(fstat( $var ) );
+}
+?>
+===DONE===
+--EXPECTF--
+
+Warning: fstat() expects parameter 1 to be resource, integer given in %s on line %d
+bool(false)
+
+Warning: fstat() expects parameter 1 to be resource, integer given in %s on line %d
+bool(false)
+
+Warning: fstat() expects parameter 1 to be resource, integer given in %s on line %d
+bool(false)
+
+Warning: fstat() expects parameter 1 to be resource, integer given in %s on line %d
+bool(false)
+===DONE=== \ No newline at end of file
diff --git a/ext/standard/tests/file/fstat_variation6.phpt b/ext/standard/tests/file/fstat_variation6.phpt
new file mode 100644
index 0000000..0789ff7
--- /dev/null
+++ b/ext/standard/tests/file/fstat_variation6.phpt
@@ -0,0 +1,46 @@
+--TEST--
+Test function fstat() by substituting agument 1 with object values.
+--FILE--
+<?php
+
+
+
+
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+
+
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+$variation_array = array(
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+ );
+
+
+foreach ( $variation_array as $var ) {
+ var_dump(fstat( $var ) );
+}
+?>
+===DONE===
+--EXPECTF--
+Error: 2 - fstat() expects parameter 1 to be resource, object given, %s(%d)
+bool(false)
+Error: 2 - fstat() expects parameter 1 to be resource, object given, %s(%d)
+bool(false)
+===DONE=== \ No newline at end of file
diff --git a/ext/standard/tests/file/fstat_variation7.phpt b/ext/standard/tests/file/fstat_variation7.phpt
new file mode 100644
index 0000000..1f3f001
--- /dev/null
+++ b/ext/standard/tests/file/fstat_variation7.phpt
@@ -0,0 +1,35 @@
+--TEST--
+Test function fstat() by substituting agument 1 with string values.
+--FILE--
+<?php
+$heredoc = <<<EOT
+hello world
+EOT;
+
+$variation_array = array(
+ 'string DQ' => "string",
+ 'string SQ' => 'string',
+ 'mixed case string' => "sTrInG",
+ 'heredoc' => $heredoc,
+ );
+
+
+foreach ( $variation_array as $var ) {
+ var_dump(fstat( $var ) );
+}
+?>
+===DONE===
+--EXPECTF--
+
+Warning: fstat() expects parameter 1 to be resource, string given in %s on line %d
+bool(false)
+
+Warning: fstat() expects parameter 1 to be resource, string given in %s on line %d
+bool(false)
+
+Warning: fstat() expects parameter 1 to be resource, string given in %s on line %d
+bool(false)
+
+Warning: fstat() expects parameter 1 to be resource, string given in %s on line %d
+bool(false)
+===DONE=== \ No newline at end of file
diff --git a/ext/standard/tests/file/fstat_variation8.phpt b/ext/standard/tests/file/fstat_variation8.phpt
new file mode 100644
index 0000000..b493d4e
--- /dev/null
+++ b/ext/standard/tests/file/fstat_variation8.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Test function fstat() by calling it with its expected arguments
+--FILE--
+<?php
+$stat_result = stat(__FILE__);
+clearstatcache();
+$fp = fopen (__FILE__, 'r');
+$fstat_result = fstat($fp);
+fclose($fp);
+
+$isWin = (substr(PHP_OS, 0, 3) == 'WIN');
+$failed = false;
+foreach($stat_result as $key =>$value) {
+ if ($isWin && ($key === 0 || $key === 6 || $key === 'dev' || $key === 'rdev')) {
+ // windows, dev and rdev will not match this is expected
+ }
+ else {
+ if ($fstat_result[$key] != $value) {
+ echo "FAIL: stat differs at '$key'. $fstat_result[$key] -- $value\n";
+ $failed = true;
+ }
+ }
+}
+if ($failed !== true) {
+ echo "PASSED: all elements are the same\n";
+}
+
+
+?>
+===DONE===
+--EXPECT--
+PASSED: all elements are the same
+===DONE=== \ No newline at end of file
diff --git a/ext/standard/tests/file/ftruncate.phpt b/ext/standard/tests/file/ftruncate.phpt
new file mode 100644
index 0000000..8954ef1
--- /dev/null
+++ b/ext/standard/tests/file/ftruncate.phpt
Binary files differ
diff --git a/ext/standard/tests/file/ftruncate_error.phpt b/ext/standard/tests/file/ftruncate_error.phpt
new file mode 100644
index 0000000..a28095b
--- /dev/null
+++ b/ext/standard/tests/file/ftruncate_error.phpt
@@ -0,0 +1,124 @@
+--TEST--
+Test ftruncate() function : error conditions
+--FILE--
+<?php
+/*
+ Prototype: bool ftruncate ( resource $handle, int $size );
+ Description: truncates a file to a given length
+*/
+
+echo "*** Testing ftruncate() : error conditions ***\n";
+
+$filename = dirname(__FILE__)."/ftruncate_error.tmp";
+$file_handle = fopen($filename, "w" );
+fwrite($file_handle, (binary)"Testing ftruncate error conditions \n");
+fflush($file_handle);
+echo "\n Initial file size = ".filesize($filename)."\n";
+
+echo "-- Testing ftruncate() with less than expected number of arguments --\n";
+
+// zero arguments
+var_dump( ftruncate() );
+
+// arguments less than expected numbers
+var_dump( ftruncate( $file_handle ) );
+// check the first size
+var_dump( filesize($filename) );
+
+echo "-- Testing ftruncate() with more than expected number of arguments --\n";
+// more than expected number of arguments
+var_dump( ftruncate($file_handle, 10, 20) );
+// check the first size
+var_dump( filesize($filename) );
+
+// test invalid arguments : non-resources
+echo "-- Testing ftruncate() with invalid file pointer --\n";
+$invalid_args = array (
+ "string",
+ 10,
+ 10.5,
+ true,
+ array(1,2,3),
+ new stdclass,
+);
+/* loop to test ftruncate() with different invalid type of args */
+for($loop_counter = 1; $loop_counter <= count($invalid_args); $loop_counter++) {
+ echo "-- Iteration $loop_counter --\n";
+ var_dump( ftruncate($invalid_args[$loop_counter - 1], 10) );
+}
+
+// ftruncate() on a file handle which is already closed/unset
+echo "-- Testing ftruncate() with closed/unset file handle --\n";
+
+// ftruncate on close file handle
+fclose($file_handle);
+var_dump( ftruncate($file_handle,10) );
+// check the first size
+var_dump( filesize($filename) );
+
+// ftruncate on a file handle which is unset
+$fp = fopen($filename, "w");
+unset($fp); //unset file handle
+var_dump( ftruncate(@$fp,10));
+// check the first size
+var_dump( filesize($filename) );
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+$filename = dirname(__FILE__)."/ftruncate_error.tmp";
+unlink( $filename );
+?>
+--EXPECTF--
+*** Testing ftruncate() : error conditions ***
+
+ Initial file size = 36
+-- Testing ftruncate() with less than expected number of arguments --
+
+Warning: ftruncate() expects exactly 2 parameters, 0 given in %s on line %d
+bool(false)
+
+Warning: ftruncate() expects exactly 2 parameters, 1 given in %s on line %d
+bool(false)
+int(36)
+-- Testing ftruncate() with more than expected number of arguments --
+
+Warning: ftruncate() expects exactly 2 parameters, 3 given in %s on line %d
+bool(false)
+int(36)
+-- Testing ftruncate() with invalid file pointer --
+-- Iteration 1 --
+
+Warning: ftruncate() expects parameter 1 to be resource, string given in %s on line %d
+bool(false)
+-- Iteration 2 --
+
+Warning: ftruncate() expects parameter 1 to be resource, integer given in %s on line %d
+bool(false)
+-- Iteration 3 --
+
+Warning: ftruncate() expects parameter 1 to be resource, double given in %s on line %d
+bool(false)
+-- Iteration 4 --
+
+Warning: ftruncate() expects parameter 1 to be resource, boolean given in %s on line %d
+bool(false)
+-- Iteration 5 --
+
+Warning: ftruncate() expects parameter 1 to be resource, array given in %s on line %d
+bool(false)
+-- Iteration 6 --
+
+Warning: ftruncate() expects parameter 1 to be resource, object given in %s on line %d
+bool(false)
+-- Testing ftruncate() with closed/unset file handle --
+
+Warning: ftruncate(): 5 is not a valid stream resource in %s on line %d
+bool(false)
+int(36)
+
+Warning: ftruncate() expects parameter 1 to be resource, null given in %s on line %d
+bool(false)
+int(36)
+Done
diff --git a/ext/standard/tests/file/ftruncate_variation1-win32.phpt b/ext/standard/tests/file/ftruncate_variation1-win32.phpt
new file mode 100644
index 0000000..dbf1896
--- /dev/null
+++ b/ext/standard/tests/file/ftruncate_variation1-win32.phpt
@@ -0,0 +1,461 @@
+--TEST--
+Test ftruncate() function : usage variations - truncate filesize to zero
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip.. only valid for Windows');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: bool ftruncate ( resource $handle, int $size );
+ Description: Truncates a file to a given length
+*/
+
+// include common file related test functions
+include ("file.inc");
+
+echo "*** Testing ftruncate() : usage variations ***\n";
+
+/* test ftruncate with file opened in different modes */
+$file_modes = array("r", "rb", "rt", "r+", "r+b", "r+t",
+ "w", "wb", "wt", "w+", "w+b", "w+t",
+ "x", "xb", "xt", "x+", "x+b", "x+t",
+ "a", "ab", "at", "a+", "a+b", "a+t");
+
+$file_content_types = array("numeric","text_with_new_line");
+
+foreach($file_content_types as $file_content_type) {
+ echo "\n-- Testing ftruncate() with file having data of type ". $file_content_type ." --\n";
+
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ echo "-- Testing ftruncate() with file opening using $file_modes[$mode_counter] mode --\n";
+
+ // create 1 file with some contents
+ $filename = dirname(__FILE__)."/ftruncate_variation1.tmp";
+ if( strstr($file_modes[$mode_counter], "x") || strstr($file_modes[$mode_counter], "w") ) {
+ // fopen the file using the $file_modes
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ fill_file($file_handle, $file_content_type, 1024);
+ } else {
+ create_files ( dirname(__FILE__), 1, $file_content_type, 0755, 1, "w", "ftruncate_variation");
+ // fopen the file using the $file_modes
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ }
+ if (!$file_handle) {
+ echo "Error: failed to open file $filename!\n";
+ exit();
+ }
+
+ rewind($file_handle); // file pointer to 0
+
+ /* truncate it to size 0 */
+ echo "-- Testing ftruncate(): truncate file to size = 0 --\n";
+ $new_size = 0;
+ var_dump( filesize($filename) ); // check the current file size
+ var_dump( ftell($file_handle) );
+ var_dump( ftruncate($file_handle, $new_size) ); // truncate it
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+ fclose($file_handle);
+ clearstatcache(); // clear previous size value in cache
+ var_dump( filesize($filename) ); // check the file size, should be 0
+
+ //delete all files created
+ delete_file($filename);
+ } //end of inner for loop
+}//end of outer foreach loop
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing ftruncate() : usage variations ***
+
+-- Testing ftruncate() with file having data of type numeric --
+-- Testing ftruncate() with file opening using r mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rb mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rt mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using r+ mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using r+b mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using r+t mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using w mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using wb mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using wt mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using w+ mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using w+b mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using w+t mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using x mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using xb mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using xt mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using x+ mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using x+b mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using x+t mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using a mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using ab mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using at mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using a+ mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using a+b mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using a+t mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+
+-- Testing ftruncate() with file having data of type text_with_new_line --
+-- Testing ftruncate() with file opening using r mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rb mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rt mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using r+ mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using r+b mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using r+t mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using w mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using wb mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using wt mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1137)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using w+ mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using w+b mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using w+t mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1137)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using x mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using xb mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using xt mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1137)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using x+ mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using x+b mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using x+t mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1137)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using a mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using ab mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using at mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using a+ mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using a+b mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using a+t mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+Done
diff --git a/ext/standard/tests/file/ftruncate_variation1.phpt b/ext/standard/tests/file/ftruncate_variation1.phpt
new file mode 100644
index 0000000..cf51e20
--- /dev/null
+++ b/ext/standard/tests/file/ftruncate_variation1.phpt
@@ -0,0 +1,461 @@
+--TEST--
+Test ftruncate() function : usage variations - truncate filesize to zero
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip Not valid for Windows');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: bool ftruncate ( resource $handle, int $size );
+ Description: Truncates a file to a given length
+*/
+
+// include common file related test functions
+include ("file.inc");
+
+echo "*** Testing ftruncate() : usage variations ***\n";
+
+/* test ftruncate with file opened in different modes */
+$file_modes = array("r", "rb", "rt", "r+", "r+b", "r+t",
+ "w", "wb", "wt", "w+", "w+b", "w+t",
+ "x", "xb", "xt", "x+", "x+b", "x+t",
+ "a", "ab", "at", "a+", "a+b", "a+t");
+
+$file_content_types = array("numeric","text_with_new_line");
+
+foreach($file_content_types as $file_content_type) {
+ echo "\n-- Testing ftruncate() with file having data of type ". $file_content_type ." --\n";
+
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ echo "-- Testing ftruncate() with file opening using $file_modes[$mode_counter] mode --\n";
+
+ // create 1 file with some contents
+ $filename = dirname(__FILE__)."/ftruncate_variation1.tmp";
+ if( strstr($file_modes[$mode_counter], "x") || strstr($file_modes[$mode_counter], "w") ) {
+ // fopen the file using the $file_modes
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ fill_file($file_handle, $file_content_type, 1024);
+ } else {
+ create_files ( dirname(__FILE__), 1, $file_content_type, 0755, 1, "w", "ftruncate_variation");
+ // fopen the file using the $file_modes
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ }
+ if (!$file_handle) {
+ echo "Error: failed to open file $filename!\n";
+ exit();
+ }
+
+ rewind($file_handle); // file pointer to 0
+
+ /* truncate it to size 0 */
+ echo "-- Testing ftruncate(): truncate file to size = 0 --\n";
+ $new_size = 0;
+ var_dump( filesize($filename) ); // check the current file size
+ var_dump( ftell($file_handle) );
+ var_dump( ftruncate($file_handle, $new_size) ); // truncate it
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+ fclose($file_handle);
+ clearstatcache(); // clear previous size value in cache
+ var_dump( filesize($filename) ); // check the file size, should be 0
+
+ //delete all files created
+ delete_file($filename);
+ } //end of inner for loop
+}//end of outer foreach loop
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing ftruncate() : usage variations ***
+
+-- Testing ftruncate() with file having data of type numeric --
+-- Testing ftruncate() with file opening using r mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rb mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rt mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using r+ mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using r+b mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using r+t mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using w mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using wb mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using wt mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using w+ mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using w+b mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using w+t mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using x mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using xb mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using xt mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using x+ mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using x+b mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using x+t mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using a mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using ab mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using at mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using a+ mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using a+b mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using a+t mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+
+-- Testing ftruncate() with file having data of type text_with_new_line --
+-- Testing ftruncate() with file opening using r mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rb mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rt mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using r+ mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using r+b mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using r+t mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using w mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using wb mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using wt mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using w+ mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using w+b mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using w+t mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using x mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using xb mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using xt mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using x+ mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using x+b mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using x+t mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using a mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using ab mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using at mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using a+ mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using a+b mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+-- Testing ftruncate() with file opening using a+t mode --
+-- Testing ftruncate(): truncate file to size = 0 --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(0)
+Done
diff --git a/ext/standard/tests/file/ftruncate_variation2-win32.phpt b/ext/standard/tests/file/ftruncate_variation2-win32.phpt
new file mode 100644
index 0000000..7b2e0b4
--- /dev/null
+++ b/ext/standard/tests/file/ftruncate_variation2-win32.phpt
@@ -0,0 +1,462 @@
+--TEST--
+Test ftruncate() function : usage variations - truncate file to current size
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip.. only valid for Windows');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: bool ftruncate ( resource $handle, int $size );
+ Description: Truncates a file to a given length
+*/
+
+// include common file related test functions
+include ("file.inc");
+
+echo "*** Testing ftruncate() : usage variations ***\n";
+
+/* test ftruncate with file opened in different modes */
+$file_modes = array("r", "rb", "rt", "r+", "r+b", "r+t",
+ "w", "wb", "wt", "w+", "w+b", "w+t",
+ "x", "xb", "xt", "x+", "x+b", "x+t",
+ "a", "ab", "at", "a+", "a+b", "a+t");
+
+$file_content_types = array("numeric","text_with_new_line");
+
+foreach($file_content_types as $file_content_type) {
+ echo "\n-- Testing ftruncate() with file having data of type ". $file_content_type ." --\n";
+
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ echo "-- Testing ftruncate() with file opening using $file_modes[$mode_counter] mode --\n";
+
+ // create 1 file with some contents
+ $filename = dirname(__FILE__)."/ftruncate_variation2.tmp";
+ if( strstr($file_modes[$mode_counter], "x") || strstr($file_modes[$mode_counter], "w") ) {
+ // fopen the file using the $file_modes
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ fill_file($file_handle, $file_content_type, 1024);
+ } else {
+ create_files ( dirname(__FILE__), 1, $file_content_type, 0755, 1, "w", "ftruncate_variation", 2);
+ // fopen the file using the $file_modes
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ }
+ if (!$file_handle) {
+ echo "Error: failed to open file $filename!\n";
+ exit();
+ }
+
+ rewind($file_handle); // file pointer to 0
+
+ echo "-- Testing ftruncate(): truncate file to size = current size --\n";
+ /* truncate the file to its current filesize, size should not change*/
+
+ $new_size = filesize($filename);
+ var_dump( filesize($filename) ); // current filesize
+ var_dump( ftell($file_handle) );
+ var_dump( ftruncate($file_handle, $new_size) ); // truncate it
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+ fclose($file_handle);
+ clearstatcache(); // clear previous size value in cache
+ var_dump( filesize($filename) ); // new file size, should be same as before truncating
+
+ //delete all files created
+ delete_file($filename);
+ }//end of inner for loop
+}//end of outer foreach loop
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing ftruncate() : usage variations ***
+
+-- Testing ftruncate() with file having data of type numeric --
+-- Testing ftruncate() with file opening using r mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rb mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rt mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using r+ mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using r+b mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using r+t mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using w mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using wb mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using wt mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using w+ mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using w+b mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using w+t mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using x mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using xb mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using xt mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using x+ mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using x+b mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using x+t mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using a mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using ab mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using at mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using a+ mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using a+b mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using a+t mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+
+-- Testing ftruncate() with file having data of type text_with_new_line --
+-- Testing ftruncate() with file opening using r mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rb mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rt mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using r+ mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using r+b mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using r+t mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using w mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using wb mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using wt mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1137)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1137)
+-- Testing ftruncate() with file opening using w+ mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using w+b mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using w+t mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1137)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1137)
+-- Testing ftruncate() with file opening using x mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using xb mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using xt mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1137)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1137)
+-- Testing ftruncate() with file opening using x+ mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using x+b mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using x+t mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1137)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1137)
+-- Testing ftruncate() with file opening using a mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using ab mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using at mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using a+ mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using a+b mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using a+t mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+Done
diff --git a/ext/standard/tests/file/ftruncate_variation2.phpt b/ext/standard/tests/file/ftruncate_variation2.phpt
new file mode 100644
index 0000000..e01a167
--- /dev/null
+++ b/ext/standard/tests/file/ftruncate_variation2.phpt
@@ -0,0 +1,462 @@
+--TEST--
+Test ftruncate() function : usage variations - truncate file to current size
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. Not valid for Windows');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: bool ftruncate ( resource $handle, int $size );
+ Description: Truncates a file to a given length
+*/
+
+// include common file related test functions
+include ("file.inc");
+
+echo "*** Testing ftruncate() : usage variations ***\n";
+
+/* test ftruncate with file opened in different modes */
+$file_modes = array("r", "rb", "rt", "r+", "r+b", "r+t",
+ "w", "wb", "wt", "w+", "w+b", "w+t",
+ "x", "xb", "xt", "x+", "x+b", "x+t",
+ "a", "ab", "at", "a+", "a+b", "a+t");
+
+$file_content_types = array("numeric","text_with_new_line");
+
+foreach($file_content_types as $file_content_type) {
+ echo "\n-- Testing ftruncate() with file having data of type ". $file_content_type ." --\n";
+
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ echo "-- Testing ftruncate() with file opening using $file_modes[$mode_counter] mode --\n";
+
+ // create 1 file with some contents
+ $filename = dirname(__FILE__)."/ftruncate_variation2.tmp";
+ if( strstr($file_modes[$mode_counter], "x") || strstr($file_modes[$mode_counter], "w") ) {
+ // fopen the file using the $file_modes
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ fill_file($file_handle, $file_content_type, 1024);
+ } else {
+ create_files ( dirname(__FILE__), 1, $file_content_type, 0755, 1, "w", "ftruncate_variation", 2);
+ // fopen the file using the $file_modes
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ }
+ if (!$file_handle) {
+ echo "Error: failed to open file $filename!\n";
+ exit();
+ }
+
+ rewind($file_handle); // file pointer to 0
+
+ echo "-- Testing ftruncate(): truncate file to size = current size --\n";
+ /* truncate the file to its current filesize, size should not change*/
+
+ $new_size = filesize($filename);
+ var_dump( filesize($filename) ); // current filesize
+ var_dump( ftell($file_handle) );
+ var_dump( ftruncate($file_handle, $new_size) ); // truncate it
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+ fclose($file_handle);
+ clearstatcache(); // clear previous size value in cache
+ var_dump( filesize($filename) ); // new file size, should be same as before truncating
+
+ //delete all files created
+ delete_file($filename);
+ }//end of inner for loop
+}//end of outer foreach loop
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing ftruncate() : usage variations ***
+
+-- Testing ftruncate() with file having data of type numeric --
+-- Testing ftruncate() with file opening using r mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rb mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rt mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using r+ mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using r+b mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using r+t mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using w mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using wb mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using wt mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using w+ mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using w+b mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using w+t mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using x mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using xb mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using xt mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using x+ mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using x+b mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using x+t mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using a mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using ab mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using at mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using a+ mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using a+b mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using a+t mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+
+-- Testing ftruncate() with file having data of type text_with_new_line --
+-- Testing ftruncate() with file opening using r mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rb mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rt mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using r+ mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using r+b mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using r+t mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using w mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using wb mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using wt mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using w+ mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using w+b mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using w+t mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using x mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using xb mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using xt mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using x+ mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using x+b mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using x+t mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using a mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using ab mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using at mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using a+ mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using a+b mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using a+t mode --
+-- Testing ftruncate(): truncate file to size = current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1024)
+Done
diff --git a/ext/standard/tests/file/ftruncate_variation3-win32.phpt b/ext/standard/tests/file/ftruncate_variation3-win32.phpt
new file mode 100644
index 0000000..d9aa40e
--- /dev/null
+++ b/ext/standard/tests/file/ftruncate_variation3-win32.phpt
@@ -0,0 +1,461 @@
+--TEST--
+Test ftruncate() function : usage variations - truncate file to half size
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip.. only valid for Windows');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: bool ftruncate ( resource $handle, int $size );
+ Description: Truncates a file to a given length
+*/
+
+// include common file related test functions
+include ("file.inc");
+
+echo "*** Testing ftruncate() : usage variations ***\n";
+
+/* test ftruncate with file opened in different modes */
+$file_modes = array("r", "rb", "rt", "r+", "r+b", "r+t",
+ "w", "wb", "wt", "w+", "w+b", "w+t",
+ "x", "xb", "xt", "x+", "x+b", "x+t",
+ "a", "ab", "at", "a+", "a+b", "a+t");
+
+$file_content_types = array("numeric","text_with_new_line");
+
+foreach($file_content_types as $file_content_type) {
+ echo "\n-- Testing ftruncate() with file having data of type ". $file_content_type ." --\n";
+
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ echo "-- Testing ftruncate() with file opening using $file_modes[$mode_counter] mode --\n";
+
+ // create 1 file with some contents
+ $filename = dirname(__FILE__)."/ftruncate_variation3.tmp";
+ if( strstr($file_modes[$mode_counter], "x") || strstr($file_modes[$mode_counter], "w") ) {
+ // fopen the file using the $file_modes
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ fill_file($file_handle, $file_content_type, 1024);
+ } else {
+ create_files ( dirname(__FILE__), 1, $file_content_type, 0755, 1, "w", "ftruncate_variation", 3);
+ // fopen the file using the $file_modes
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ }
+ if (!$file_handle) {
+ echo "Error: failed to open file $filename!\n";
+ exit();
+ }
+
+ rewind($file_handle); // file pointer to 0
+
+ echo "-- Testing ftruncate(): truncate file to half of its current size --\n";
+ /* truncate it to half of its current size */
+ $new_size = filesize($filename)/2;
+ var_dump( filesize($filename) ); // current filesize
+ var_dump( ftell($file_handle) );
+ var_dump( ftruncate($file_handle, $new_size) ); // truncate it
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+ fclose($file_handle);
+ clearstatcache(); // clear previous size value in cache
+ var_dump( filesize($filename) ); // new file size = $new_size
+
+ // delete file
+ delete_file($filename);
+ }//end of inner for loop
+}//end of outer foreach loop
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing ftruncate() : usage variations ***
+
+-- Testing ftruncate() with file having data of type numeric --
+-- Testing ftruncate() with file opening using r mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rb mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rt mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using r+ mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using r+b mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using r+t mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using w mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using wb mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using wt mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using w+ mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using w+b mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using w+t mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using x mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using xb mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using xt mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using x+ mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using x+b mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using x+t mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using a mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using ab mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using at mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using a+ mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using a+b mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using a+t mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+
+-- Testing ftruncate() with file having data of type text_with_new_line --
+-- Testing ftruncate() with file opening using r mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rb mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rt mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using r+ mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using r+b mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using r+t mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using w mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using wb mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using wt mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1137)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(568)
+-- Testing ftruncate() with file opening using w+ mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using w+b mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using w+t mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1137)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(568)
+-- Testing ftruncate() with file opening using x mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using xb mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using xt mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1137)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(568)
+-- Testing ftruncate() with file opening using x+ mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using x+b mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using x+t mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1137)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(568)
+-- Testing ftruncate() with file opening using a mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using ab mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using at mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using a+ mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using a+b mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using a+t mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+Done
diff --git a/ext/standard/tests/file/ftruncate_variation3.phpt b/ext/standard/tests/file/ftruncate_variation3.phpt
new file mode 100644
index 0000000..cdbeb8e
--- /dev/null
+++ b/ext/standard/tests/file/ftruncate_variation3.phpt
@@ -0,0 +1,461 @@
+--TEST--
+Test ftruncate() function : usage variations - truncate file to half size
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. Not valid for Windows');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: bool ftruncate ( resource $handle, int $size );
+ Description: Truncates a file to a given length
+*/
+
+// include common file related test functions
+include ("file.inc");
+
+echo "*** Testing ftruncate() : usage variations ***\n";
+
+/* test ftruncate with file opened in different modes */
+$file_modes = array("r", "rb", "rt", "r+", "r+b", "r+t",
+ "w", "wb", "wt", "w+", "w+b", "w+t",
+ "x", "xb", "xt", "x+", "x+b", "x+t",
+ "a", "ab", "at", "a+", "a+b", "a+t");
+
+$file_content_types = array("numeric","text_with_new_line");
+
+foreach($file_content_types as $file_content_type) {
+ echo "\n-- Testing ftruncate() with file having data of type ". $file_content_type ." --\n";
+
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ echo "-- Testing ftruncate() with file opening using $file_modes[$mode_counter] mode --\n";
+
+ // create 1 file with some contents
+ $filename = dirname(__FILE__)."/ftruncate_variation3.tmp";
+ if( strstr($file_modes[$mode_counter], "x") || strstr($file_modes[$mode_counter], "w") ) {
+ // fopen the file using the $file_modes
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ fill_file($file_handle, $file_content_type, 1024);
+ } else {
+ create_files ( dirname(__FILE__), 1, $file_content_type, 0755, 1, "w", "ftruncate_variation", 3);
+ // fopen the file using the $file_modes
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ }
+ if (!$file_handle) {
+ echo "Error: failed to open file $filename!\n";
+ exit();
+ }
+
+ rewind($file_handle); // file pointer to 0
+
+ echo "-- Testing ftruncate(): truncate file to half of its current size --\n";
+ /* truncate it to half of its current size */
+ $new_size = filesize($filename)/2;
+ var_dump( filesize($filename) ); // current filesize
+ var_dump( ftell($file_handle) );
+ var_dump( ftruncate($file_handle, $new_size) ); // truncate it
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+ fclose($file_handle);
+ clearstatcache(); // clear previous size value in cache
+ var_dump( filesize($filename) ); // new file size = $new_size
+
+ // delete file
+ delete_file($filename);
+ }//end of inner for loop
+}//end of outer foreach loop
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing ftruncate() : usage variations ***
+
+-- Testing ftruncate() with file having data of type numeric --
+-- Testing ftruncate() with file opening using r mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rb mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rt mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using r+ mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using r+b mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using r+t mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using w mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using wb mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using wt mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using w+ mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using w+b mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using w+t mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using x mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using xb mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using xt mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using x+ mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using x+b mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using x+t mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using a mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using ab mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using at mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using a+ mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using a+b mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using a+t mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+
+-- Testing ftruncate() with file having data of type text_with_new_line --
+-- Testing ftruncate() with file opening using r mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rb mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rt mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using r+ mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using r+b mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using r+t mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using w mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using wb mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using wt mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using w+ mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using w+b mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using w+t mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using x mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using xb mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using xt mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using x+ mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using x+b mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using x+t mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using a mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using ab mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using at mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using a+ mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using a+b mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+-- Testing ftruncate() with file opening using a+t mode --
+-- Testing ftruncate(): truncate file to half of its current size --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(512)
+Done
diff --git a/ext/standard/tests/file/ftruncate_variation4-win32.phpt b/ext/standard/tests/file/ftruncate_variation4-win32.phpt
new file mode 100644
index 0000000..ae9e5a4
--- /dev/null
+++ b/ext/standard/tests/file/ftruncate_variation4-win32.phpt
@@ -0,0 +1,462 @@
+--TEST--
+Test ftruncate() function : usage variations - truncate file to negative size
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip.. only valid for Windows');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: bool ftruncate ( resource $handle, int $size );
+ Description: Truncates a file to a given length
+*/
+
+// include common file related test functions
+include ("file.inc");
+
+echo "*** Testing ftruncate() : usage variations ***\n";
+
+/* test ftruncate with file opened in different modes */
+$file_modes = array("r", "rb", "rt", "r+", "r+b", "r+t",
+ "w", "wb", "wt", "w+", "w+b", "w+t",
+ "x", "xb", "xt", "x+", "x+b", "x+t",
+ "a", "ab", "at", "a+", "a+b", "a+t");
+
+$file_content_types = array("numeric","text_with_new_line");
+
+foreach($file_content_types as $file_content_type) {
+ echo "\n-- Testing ftruncate() with file having data of type ". $file_content_type ." --\n";
+
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ echo "-- Testing ftruncate() with file opening using $file_modes[$mode_counter] mode --\n";
+
+ // create 1 file with some contents
+ $filename = dirname(__FILE__)."/ftruncate_variation4.tmp";
+ if( strstr($file_modes[$mode_counter], "x") || strstr($file_modes[$mode_counter], "w") ) {
+ // fopen the file using the $file_modes
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ fill_file($file_handle, $file_content_type, 1024);
+ } else {
+ create_files ( dirname(__FILE__), 1, $file_content_type, 0755, 1, "w", "ftruncate_variation", 4);
+ // fopen the file using the $file_modes
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ }
+ if (!$file_handle) {
+ echo "Error: failed to open file $filename!\n";
+ exit();
+ }
+
+ rewind($file_handle); // file pointer to 0
+
+ echo "-- Testing ftruncate(): try truncating file to a negative size --\n";
+ /* try to truncate it to a negative size, size should not change*/
+
+ $new_size = -1000;
+ var_dump( filesize($filename) ); // current filesize
+ var_dump( ftell($file_handle) );
+ var_dump( ftruncate($file_handle, $new_size) ); // truncate it
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+ fclose($file_handle);
+ clearstatcache(); // clear previous size value in cache
+ var_dump( filesize($filename) ); // new file size = actual size, no change
+
+ //delete all files created
+ delete_file( $filename );
+ }//end of inner for loop
+}//end of outer foreach loop
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing ftruncate() : usage variations ***
+
+-- Testing ftruncate() with file having data of type numeric --
+-- Testing ftruncate() with file opening using r mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rb mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rt mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using r+ mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using r+b mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using r+t mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using w mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using wb mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using wt mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using w+ mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using w+b mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using w+t mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using x mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using xb mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using xt mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using x+ mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using x+b mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using x+t mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using a mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using ab mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using at mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using a+ mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using a+b mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using a+t mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+
+-- Testing ftruncate() with file having data of type text_with_new_line --
+-- Testing ftruncate() with file opening using r mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rb mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rt mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using r+ mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using r+b mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using r+t mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using w mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using wb mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using wt mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1137)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1137)
+-- Testing ftruncate() with file opening using w+ mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using w+b mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using w+t mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1137)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1137)
+-- Testing ftruncate() with file opening using x mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using xb mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using xt mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1137)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1137)
+-- Testing ftruncate() with file opening using x+ mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using x+b mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using x+t mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1137)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1137)
+-- Testing ftruncate() with file opening using a mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using ab mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using at mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using a+ mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using a+b mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using a+t mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+Done
diff --git a/ext/standard/tests/file/ftruncate_variation4.phpt b/ext/standard/tests/file/ftruncate_variation4.phpt
new file mode 100644
index 0000000..4a5a362
--- /dev/null
+++ b/ext/standard/tests/file/ftruncate_variation4.phpt
@@ -0,0 +1,462 @@
+--TEST--
+Test ftruncate() function : usage variations - truncate file to negative size
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. Not valid for Windows');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: bool ftruncate ( resource $handle, int $size );
+ Description: Truncates a file to a given length
+*/
+
+// include common file related test functions
+include ("file.inc");
+
+echo "*** Testing ftruncate() : usage variations ***\n";
+
+/* test ftruncate with file opened in different modes */
+$file_modes = array("r", "rb", "rt", "r+", "r+b", "r+t",
+ "w", "wb", "wt", "w+", "w+b", "w+t",
+ "x", "xb", "xt", "x+", "x+b", "x+t",
+ "a", "ab", "at", "a+", "a+b", "a+t");
+
+$file_content_types = array("numeric","text_with_new_line");
+
+foreach($file_content_types as $file_content_type) {
+ echo "\n-- Testing ftruncate() with file having data of type ". $file_content_type ." --\n";
+
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ echo "-- Testing ftruncate() with file opening using $file_modes[$mode_counter] mode --\n";
+
+ // create 1 file with some contents
+ $filename = dirname(__FILE__)."/ftruncate_variation4.tmp";
+ if( strstr($file_modes[$mode_counter], "x") || strstr($file_modes[$mode_counter], "w") ) {
+ // fopen the file using the $file_modes
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ fill_file($file_handle, $file_content_type, 1024);
+ } else {
+ create_files ( dirname(__FILE__), 1, $file_content_type, 0755, 1, "w", "ftruncate_variation", 4);
+ // fopen the file using the $file_modes
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ }
+ if (!$file_handle) {
+ echo "Error: failed to open file $filename!\n";
+ exit();
+ }
+
+ rewind($file_handle); // file pointer to 0
+
+ echo "-- Testing ftruncate(): try truncating file to a negative size --\n";
+ /* try to truncate it to a negative size, size should not change*/
+
+ $new_size = -1000;
+ var_dump( filesize($filename) ); // current filesize
+ var_dump( ftell($file_handle) );
+ var_dump( ftruncate($file_handle, $new_size) ); // truncate it
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+ fclose($file_handle);
+ clearstatcache(); // clear previous size value in cache
+ var_dump( filesize($filename) ); // new file size = actual size, no change
+
+ //delete all files created
+ delete_file( $filename );
+ }//end of inner for loop
+}//end of outer foreach loop
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing ftruncate() : usage variations ***
+
+-- Testing ftruncate() with file having data of type numeric --
+-- Testing ftruncate() with file opening using r mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rb mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rt mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using r+ mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using r+b mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using r+t mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using w mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using wb mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using wt mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using w+ mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using w+b mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using w+t mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using x mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using xb mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using xt mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using x+ mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using x+b mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using x+t mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using a mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using ab mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using at mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using a+ mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using a+b mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using a+t mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+
+-- Testing ftruncate() with file having data of type text_with_new_line --
+-- Testing ftruncate() with file opening using r mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rb mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rt mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using r+ mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using r+b mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using r+t mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using w mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using wb mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using wt mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using w+ mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using w+b mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using w+t mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using x mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using xb mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using xt mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using x+ mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using x+b mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using x+t mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using a mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using ab mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using at mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using a+ mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using a+b mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using a+t mode --
+-- Testing ftruncate(): try truncating file to a negative size --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+Done
diff --git a/ext/standard/tests/file/ftruncate_variation5-win32.phpt b/ext/standard/tests/file/ftruncate_variation5-win32.phpt
new file mode 100644
index 0000000..eb45ffc
--- /dev/null
+++ b/ext/standard/tests/file/ftruncate_variation5-win32.phpt
@@ -0,0 +1,463 @@
+--TEST--
+Test ftruncate() function : usage variations - truncate file to bigger size
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip.. only valid for Windows');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: bool ftruncate ( resource $handle, int $size );
+ Description: Truncates a file to a given length
+*/
+
+// include common file related test functions
+include ("file.inc");
+
+echo "*** Testing ftruncate() : usage variations ***\n";
+
+/* test ftruncate with file opened in different modes */
+$file_modes = array("r", "rb", "rt", "r+", "r+b", "r+t",
+ "w", "wb", "wt", "w+", "w+b", "w+t",
+ "x", "xb", "xt", "x+", "x+b", "x+t",
+ "a", "ab", "at", "a+", "a+b", "a+t");
+
+$file_content_types = array("numeric","text_with_new_line");
+
+foreach($file_content_types as $file_content_type) {
+ echo "\n-- Testing ftruncate() with file having data of type ". $file_content_type ." --\n";
+
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ echo "-- Testing ftruncate() with file opening using $file_modes[$mode_counter] mode --\n";
+
+ // create 1 file with some contents
+ $filename = dirname(__FILE__)."/ftruncate_variation5.tmp";
+ if( strstr($file_modes[$mode_counter], "x") || strstr($file_modes[$mode_counter], "w") ) {
+ // fopen the file using the $file_modes
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ fill_file($file_handle, $file_content_type, 1024);
+ } else {
+ create_files ( dirname(__FILE__), 1, $file_content_type, 0755, 1, "w", "ftruncate_variation", 5);
+ // fopen the file using the $file_modes
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ }
+ if (!$file_handle) {
+ echo "Error: failed to open file $filename!\n";
+ exit();
+ }
+
+ rewind($file_handle); // file pointer to 0
+
+ echo "-- Testing ftruncate(): try truncating file to size, bigger than existing --\n";
+ /* try to truncate it to size bigger then current */
+
+ $new_size = filesize($filename) + 100;
+ var_dump( filesize($filename) ); // current filesize
+ var_dump( ftell($file_handle) );
+ var_dump( ftruncate($file_handle, $new_size) ); // truncate it
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+ fclose($file_handle);
+ clearstatcache(); // clear previous size value in cache
+ var_dump( filesize($filename) ); // new file size = actual size, no change
+
+ //delete all files created
+ delete_file($filename);
+ }//end of inner for loop
+
+}//end of outer foreach loop
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing ftruncate() : usage variations ***
+
+-- Testing ftruncate() with file having data of type numeric --
+-- Testing ftruncate() with file opening using r mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rb mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rt mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using r+ mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using r+b mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using r+t mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using w mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using wb mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using wt mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using w+ mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using w+b mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using w+t mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using x mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using xb mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using xt mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using x+ mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using x+b mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using x+t mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using a mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using ab mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using at mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using a+ mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using a+b mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using a+t mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+
+-- Testing ftruncate() with file having data of type text_with_new_line --
+-- Testing ftruncate() with file opening using r mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rb mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rt mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using r+ mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using r+b mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using r+t mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using w mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using wb mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using wt mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1137)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1237)
+-- Testing ftruncate() with file opening using w+ mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using w+b mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using w+t mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1137)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1237)
+-- Testing ftruncate() with file opening using x mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using xb mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using xt mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1137)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1237)
+-- Testing ftruncate() with file opening using x+ mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using x+b mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using x+t mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1137)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1237)
+-- Testing ftruncate() with file opening using a mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using ab mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using at mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using a+ mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using a+b mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using a+t mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+Done
diff --git a/ext/standard/tests/file/ftruncate_variation5.phpt b/ext/standard/tests/file/ftruncate_variation5.phpt
new file mode 100644
index 0000000..5d282d1
--- /dev/null
+++ b/ext/standard/tests/file/ftruncate_variation5.phpt
@@ -0,0 +1,463 @@
+--TEST--
+Test ftruncate() function : usage variations - truncate file to bigger size
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. Not valid for Windows');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: bool ftruncate ( resource $handle, int $size );
+ Description: Truncates a file to a given length
+*/
+
+// include common file related test functions
+include ("file.inc");
+
+echo "*** Testing ftruncate() : usage variations ***\n";
+
+/* test ftruncate with file opened in different modes */
+$file_modes = array("r", "rb", "rt", "r+", "r+b", "r+t",
+ "w", "wb", "wt", "w+", "w+b", "w+t",
+ "x", "xb", "xt", "x+", "x+b", "x+t",
+ "a", "ab", "at", "a+", "a+b", "a+t");
+
+$file_content_types = array("numeric","text_with_new_line");
+
+foreach($file_content_types as $file_content_type) {
+ echo "\n-- Testing ftruncate() with file having data of type ". $file_content_type ." --\n";
+
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ echo "-- Testing ftruncate() with file opening using $file_modes[$mode_counter] mode --\n";
+
+ // create 1 file with some contents
+ $filename = dirname(__FILE__)."/ftruncate_variation5.tmp";
+ if( strstr($file_modes[$mode_counter], "x") || strstr($file_modes[$mode_counter], "w") ) {
+ // fopen the file using the $file_modes
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ fill_file($file_handle, $file_content_type, 1024);
+ } else {
+ create_files ( dirname(__FILE__), 1, $file_content_type, 0755, 1, "w", "ftruncate_variation", 5);
+ // fopen the file using the $file_modes
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ }
+ if (!$file_handle) {
+ echo "Error: failed to open file $filename!\n";
+ exit();
+ }
+
+ rewind($file_handle); // file pointer to 0
+
+ echo "-- Testing ftruncate(): try truncating file to size, bigger than existing --\n";
+ /* try to truncate it to size bigger then current */
+
+ $new_size = filesize($filename) + 100;
+ var_dump( filesize($filename) ); // current filesize
+ var_dump( ftell($file_handle) );
+ var_dump( ftruncate($file_handle, $new_size) ); // truncate it
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+ fclose($file_handle);
+ clearstatcache(); // clear previous size value in cache
+ var_dump( filesize($filename) ); // new file size = actual size, no change
+
+ //delete all files created
+ delete_file($filename);
+ }//end of inner for loop
+
+}//end of outer foreach loop
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing ftruncate() : usage variations ***
+
+-- Testing ftruncate() with file having data of type numeric --
+-- Testing ftruncate() with file opening using r mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rb mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rt mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using r+ mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using r+b mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using r+t mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using w mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using wb mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using wt mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using w+ mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using w+b mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using w+t mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using x mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using xb mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using xt mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using x+ mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using x+b mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using x+t mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using a mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using ab mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using at mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using a+ mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using a+b mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using a+t mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+
+-- Testing ftruncate() with file having data of type text_with_new_line --
+-- Testing ftruncate() with file opening using r mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rb mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rt mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(false)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using r+ mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using r+b mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using r+t mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using w mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using wb mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using wt mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using w+ mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using w+b mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using w+t mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using x mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using xb mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using xt mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using x+ mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using x+b mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using x+t mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using a mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using ab mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using at mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using a+ mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using a+b mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+-- Testing ftruncate() with file opening using a+t mode --
+-- Testing ftruncate(): try truncating file to size, bigger than existing --
+int(1024)
+int(0)
+bool(true)
+int(0)
+bool(false)
+int(1124)
+Done
diff --git a/ext/standard/tests/file/ftruncate_variation6-win32.phpt b/ext/standard/tests/file/ftruncate_variation6-win32.phpt
new file mode 100644
index 0000000..0815092
--- /dev/null
+++ b/ext/standard/tests/file/ftruncate_variation6-win32.phpt
@@ -0,0 +1,482 @@
+--TEST--
+Test ftruncate() function : usage variations - truncate file to smaller size
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip.. only valid for Windows');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: bool ftruncate ( resource $handle, int $size );
+ Description: Truncates a file to a given length
+*/
+
+/* truncate the file to smaller size and display the content */
+
+// include common file related test functions
+include ("file.inc");
+
+echo "*** Testing ftruncate() : usage variations ***\n";
+
+/* test ftruncate with file opened in different modes */
+$file_modes = array("r", "rb", "rt", "r+", "r+b", "r+t",
+ "w", "wb", "wt", "w+", "w+b", "w+t",
+ "x", "xb", "xt", "x+", "x+b", "x+t",
+ "a", "ab", "at", "a+", "a+b", "a+t");
+
+$file_content_types = array("numeric","text_with_new_line");
+
+foreach($file_content_types as $file_content_type) {
+ echo "\n-- Testing ftruncate() with file having data of type ". $file_content_type ." --\n";
+
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ echo "-- Testing ftruncate() with file opening using $file_modes[$mode_counter] mode --\n";
+
+ // create 1 file with some contents
+ $filename = dirname(__FILE__)."/ftruncate_variation6.tmp";
+ if( strstr($file_modes[$mode_counter], "x") || strstr($file_modes[$mode_counter], "w") ) {
+ // fopen the file using the $file_modes
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ fill_file($file_handle, $file_content_type, 1024);
+ } else {
+ create_files ( dirname(__FILE__), 1, $file_content_type, 0755, 1, "w", "ftruncate_variation", 6);
+ // fopen the file using the $file_modes
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ }
+ if (!$file_handle) {
+ echo "Error: failed to open file $filename!\n";
+ exit();
+ }
+
+ rewind($file_handle); // file pointer to 0
+
+ echo "-- Testing ftruncate(): truncate to smaller size and display the file content --\n";
+ /* try to truncate it and display the file content */
+
+ $new_size = 15;
+ var_dump( filesize($filename) ); // current filesize
+ var_dump( ftell($file_handle) );
+ if(ftruncate($file_handle, $new_size) ){// truncate it
+ echo "File content after truncating file to $new_size size : ";
+ var_dump( file_get_contents($filename) );
+ }
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+ fclose($file_handle);
+ clearstatcache(); // clear previous size value in cache
+ var_dump( filesize($filename) );
+
+ //delete all files created
+ delete_file( $filename );
+ }//end of inner for loop
+}//end of outer foreach loop
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing ftruncate() : usage variations ***
+
+-- Testing ftruncate() with file having data of type numeric --
+-- Testing ftruncate() with file opening using r mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rb mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rt mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using r+ mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "222222222222222"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using r+b mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "222222222222222"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using r+t mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "222222222222222"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using w mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "222222222222222"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using wb mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "222222222222222"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using wt mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "222222222222222"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using w+ mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "222222222222222"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using w+b mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "222222222222222"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using w+t mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "222222222222222"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using x mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "222222222222222"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using xb mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "222222222222222"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using xt mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "222222222222222"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using x+ mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "222222222222222"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using x+b mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "222222222222222"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using x+t mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "222222222222222"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using a mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "222222222222222"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using ab mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "222222222222222"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using at mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "222222222222222"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using a+ mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "222222222222222"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using a+b mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "222222222222222"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using a+t mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "222222222222222"
+int(0)
+bool(false)
+int(15)
+
+-- Testing ftruncate() with file having data of type text_with_new_line --
+-- Testing ftruncate() with file opening using r mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rb mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rt mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using r+ mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "line
+line of te"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using r+b mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "line
+line of te"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using r+t mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "line
+line of te"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using w mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "line
+line of te"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using wb mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "line
+line of te"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using wt mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1137)
+int(0)
+File content after truncating file to 15 size : string(15) "line
+line of t"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using w+ mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "line
+line of te"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using w+b mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "line
+line of te"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using w+t mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1137)
+int(0)
+File content after truncating file to 15 size : string(15) "line
+line of t"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using x mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "line
+line of te"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using xb mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "line
+line of te"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using xt mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1137)
+int(0)
+File content after truncating file to 15 size : string(15) "line
+line of t"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using x+ mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "line
+line of te"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using x+b mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "line
+line of te"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using x+t mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1137)
+int(0)
+File content after truncating file to 15 size : string(15) "line
+line of t"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using a mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "line
+line of te"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using ab mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "line
+line of te"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using at mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "line
+line of te"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using a+ mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "line
+line of te"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using a+b mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "line
+line of te"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using a+t mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "line
+line of te"
+int(0)
+bool(false)
+int(15)
+Done
diff --git a/ext/standard/tests/file/ftruncate_variation6.phpt b/ext/standard/tests/file/ftruncate_variation6.phpt
new file mode 100644
index 0000000..e9d5eb3
--- /dev/null
+++ b/ext/standard/tests/file/ftruncate_variation6.phpt
@@ -0,0 +1,482 @@
+--TEST--
+Test ftruncate() function : usage variations - truncate file to smaller size
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. Not valid for Windows');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: bool ftruncate ( resource $handle, int $size );
+ Description: Truncates a file to a given length
+*/
+
+/* truncate the file to smaller size and display the content */
+
+// include common file related test functions
+include ("file.inc");
+
+echo "*** Testing ftruncate() : usage variations ***\n";
+
+/* test ftruncate with file opened in different modes */
+$file_modes = array("r", "rb", "rt", "r+", "r+b", "r+t",
+ "w", "wb", "wt", "w+", "w+b", "w+t",
+ "x", "xb", "xt", "x+", "x+b", "x+t",
+ "a", "ab", "at", "a+", "a+b", "a+t");
+
+$file_content_types = array("numeric","text_with_new_line");
+
+foreach($file_content_types as $file_content_type) {
+ echo "\n-- Testing ftruncate() with file having data of type ". $file_content_type ." --\n";
+
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ echo "-- Testing ftruncate() with file opening using $file_modes[$mode_counter] mode --\n";
+
+ // create 1 file with some contents
+ $filename = dirname(__FILE__)."/ftruncate_variation6.tmp";
+ if( strstr($file_modes[$mode_counter], "x") || strstr($file_modes[$mode_counter], "w") ) {
+ // fopen the file using the $file_modes
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ fill_file($file_handle, $file_content_type, 1024);
+ } else {
+ create_files ( dirname(__FILE__), 1, $file_content_type, 0755, 1, "w", "ftruncate_variation", 6);
+ // fopen the file using the $file_modes
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ }
+ if (!$file_handle) {
+ echo "Error: failed to open file $filename!\n";
+ exit();
+ }
+
+ rewind($file_handle); // file pointer to 0
+
+ echo "-- Testing ftruncate(): truncate to smaller size and display the file content --\n";
+ /* try to truncate it and display the file content */
+
+ $new_size = 15;
+ var_dump( filesize($filename) ); // current filesize
+ var_dump( ftell($file_handle) );
+ if(ftruncate($file_handle, $new_size) ){// truncate it
+ echo "File content after truncating file to $new_size size : ";
+ var_dump( file_get_contents($filename) );
+ }
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+ fclose($file_handle);
+ clearstatcache(); // clear previous size value in cache
+ var_dump( filesize($filename) );
+
+ //delete all files created
+ delete_file( $filename );
+ }//end of inner for loop
+}//end of outer foreach loop
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing ftruncate() : usage variations ***
+
+-- Testing ftruncate() with file having data of type numeric --
+-- Testing ftruncate() with file opening using r mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rb mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rt mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using r+ mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "222222222222222"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using r+b mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "222222222222222"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using r+t mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "222222222222222"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using w mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "222222222222222"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using wb mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "222222222222222"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using wt mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "222222222222222"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using w+ mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "222222222222222"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using w+b mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "222222222222222"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using w+t mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "222222222222222"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using x mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "222222222222222"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using xb mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "222222222222222"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using xt mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "222222222222222"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using x+ mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "222222222222222"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using x+b mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "222222222222222"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using x+t mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "222222222222222"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using a mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "222222222222222"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using ab mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "222222222222222"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using at mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "222222222222222"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using a+ mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "222222222222222"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using a+b mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "222222222222222"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using a+t mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "222222222222222"
+int(0)
+bool(false)
+int(15)
+
+-- Testing ftruncate() with file having data of type text_with_new_line --
+-- Testing ftruncate() with file opening using r mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rb mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rt mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+int(0)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using r+ mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "line
+line of te"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using r+b mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "line
+line of te"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using r+t mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "line
+line of te"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using w mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "line
+line of te"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using wb mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "line
+line of te"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using wt mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "line
+line of te"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using w+ mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "line
+line of te"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using w+b mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "line
+line of te"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using w+t mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "line
+line of te"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using x mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "line
+line of te"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using xb mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "line
+line of te"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using xt mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "line
+line of te"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using x+ mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "line
+line of te"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using x+b mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "line
+line of te"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using x+t mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "line
+line of te"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using a mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "line
+line of te"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using ab mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "line
+line of te"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using at mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "line
+line of te"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using a+ mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "line
+line of te"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using a+b mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "line
+line of te"
+int(0)
+bool(false)
+int(15)
+-- Testing ftruncate() with file opening using a+t mode --
+-- Testing ftruncate(): truncate to smaller size and display the file content --
+int(1024)
+int(0)
+File content after truncating file to 15 size : string(15) "line
+line of te"
+int(0)
+bool(false)
+int(15)
+Done
diff --git a/ext/standard/tests/file/ftruncate_variation7-win32.phpt b/ext/standard/tests/file/ftruncate_variation7-win32.phpt
new file mode 100644
index 0000000..dc3a4cc
--- /dev/null
+++ b/ext/standard/tests/file/ftruncate_variation7-win32.phpt
@@ -0,0 +1,463 @@
+--TEST--
+Test ftruncate() function : usage variations - truncate when file pointer at EOF
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip.. only valid for Windows');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: bool ftruncate ( resource $handle, int $size );
+ Description: Truncates a file to a given length
+*/
+
+/* truncate the file when file pointer is positioned at end of the file */
+// include common file related test functions
+include ("file.inc");
+
+echo "*** Testing ftruncate() : usage variations ***\n";
+
+/* test ftruncate with file opened in different modes */
+$file_modes = array("r", "rb", "rt", "r+", "r+b", "r+t",
+ "w", "wb", "wt", "w+", "w+b", "w+t",
+ "x", "xb", "xt", "x+", "x+b", "x+t",
+ "a", "ab", "at", "a+", "a+b", "a+t");
+
+$file_content_types = array("numeric","text_with_new_line");
+
+foreach($file_content_types as $file_content_type) {
+ echo "\n-- Testing ftruncate() with file having data of type ". $file_content_type ." --\n";
+
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ echo "-- Testing ftruncate() with file opening using $file_modes[$mode_counter] mode --\n";
+
+ // create 1 file with some contents
+ $filename = dirname(__FILE__)."/ftruncate_variation7.tmp";
+ if( strstr($file_modes[$mode_counter], "x") || strstr($file_modes[$mode_counter], "w") ) {
+ // fopen the file using the $file_modes
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ fill_file($file_handle, $file_content_type, 1024);
+ } else {
+ create_files ( dirname(__FILE__), 1, $file_content_type, 0755, 1, "w", "ftruncate_variation", 7);
+ // fopen the file using the $file_modes
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ }
+ if (!$file_handle) {
+ echo "Error: failed to open file $filename!\n";
+ exit();
+ }
+
+ rewind($file_handle); // file pointer to 0
+
+ echo "-- Testing ftruncate(): File pointer at the end --\n";
+ /* try to truncate it to while file pointer at the end */
+ fseek($file_handle, 0, SEEK_END);
+ $new_size = 200;
+ var_dump( filesize($filename) ); // current filesize
+ var_dump( ftell($file_handle) );
+ var_dump( ftruncate($file_handle, $new_size) ); // truncate it
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+ fclose($file_handle);
+ clearstatcache(); // clear previous size value in cache
+ var_dump( filesize($filename) );
+
+ //delete all files created
+ delete_file($filename);
+ }//end of inner for loop
+}//end of outer foreach loop
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing ftruncate() : usage variations ***
+
+-- Testing ftruncate() with file having data of type numeric --
+-- Testing ftruncate() with file opening using r mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(false)
+int(1024)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rb mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(false)
+int(1024)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rt mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(false)
+int(1024)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using r+ mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using r+b mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using r+t mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using w mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using wb mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using wt mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using w+ mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using w+b mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using w+t mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using x mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using xb mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using xt mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using x+ mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using x+b mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using x+t mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using a mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using ab mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using at mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using a+ mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using a+b mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using a+t mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+
+-- Testing ftruncate() with file having data of type text_with_new_line --
+-- Testing ftruncate() with file opening using r mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(false)
+int(1024)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rb mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(false)
+int(1024)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rt mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(false)
+int(1024)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using r+ mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using r+b mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using r+t mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using w mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using wb mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using wt mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1137)
+int(1137)
+bool(true)
+int(1137)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using w+ mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using w+b mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using w+t mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1137)
+int(1137)
+bool(true)
+int(1137)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using x mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using xb mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using xt mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1137)
+int(1137)
+bool(true)
+int(1137)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using x+ mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using x+b mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using x+t mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1137)
+int(1137)
+bool(true)
+int(1137)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using a mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using ab mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using at mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using a+ mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using a+b mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using a+t mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+Done
diff --git a/ext/standard/tests/file/ftruncate_variation7.phpt b/ext/standard/tests/file/ftruncate_variation7.phpt
new file mode 100644
index 0000000..5b38adf
--- /dev/null
+++ b/ext/standard/tests/file/ftruncate_variation7.phpt
@@ -0,0 +1,463 @@
+--TEST--
+Test ftruncate() function : usage variations - truncate when file pointer at EOF
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. Not valid for Windows');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: bool ftruncate ( resource $handle, int $size );
+ Description: Truncates a file to a given length
+*/
+
+/* truncate the file when file pointer is positioned at end of the file */
+// include common file related test functions
+include ("file.inc");
+
+echo "*** Testing ftruncate() : usage variations ***\n";
+
+/* test ftruncate with file opened in different modes */
+$file_modes = array("r", "rb", "rt", "r+", "r+b", "r+t",
+ "w", "wb", "wt", "w+", "w+b", "w+t",
+ "x", "xb", "xt", "x+", "x+b", "x+t",
+ "a", "ab", "at", "a+", "a+b", "a+t");
+
+$file_content_types = array("numeric","text_with_new_line");
+
+foreach($file_content_types as $file_content_type) {
+ echo "\n-- Testing ftruncate() with file having data of type ". $file_content_type ." --\n";
+
+ for($mode_counter = 0; $mode_counter < count($file_modes); $mode_counter++) {
+ echo "-- Testing ftruncate() with file opening using $file_modes[$mode_counter] mode --\n";
+
+ // create 1 file with some contents
+ $filename = dirname(__FILE__)."/ftruncate_variation7.tmp";
+ if( strstr($file_modes[$mode_counter], "x") || strstr($file_modes[$mode_counter], "w") ) {
+ // fopen the file using the $file_modes
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ fill_file($file_handle, $file_content_type, 1024);
+ } else {
+ create_files ( dirname(__FILE__), 1, $file_content_type, 0755, 1, "w", "ftruncate_variation", 7);
+ // fopen the file using the $file_modes
+ $file_handle = fopen($filename, $file_modes[$mode_counter]);
+ }
+ if (!$file_handle) {
+ echo "Error: failed to open file $filename!\n";
+ exit();
+ }
+
+ rewind($file_handle); // file pointer to 0
+
+ echo "-- Testing ftruncate(): File pointer at the end --\n";
+ /* try to truncate it to while file pointer at the end */
+ fseek($file_handle, 0, SEEK_END);
+ $new_size = 200;
+ var_dump( filesize($filename) ); // current filesize
+ var_dump( ftell($file_handle) );
+ var_dump( ftruncate($file_handle, $new_size) ); // truncate it
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) );
+ fclose($file_handle);
+ clearstatcache(); // clear previous size value in cache
+ var_dump( filesize($filename) );
+
+ //delete all files created
+ delete_file($filename);
+ }//end of inner for loop
+}//end of outer foreach loop
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing ftruncate() : usage variations ***
+
+-- Testing ftruncate() with file having data of type numeric --
+-- Testing ftruncate() with file opening using r mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(false)
+int(1024)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rb mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(false)
+int(1024)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rt mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(false)
+int(1024)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using r+ mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using r+b mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using r+t mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using w mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using wb mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using wt mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using w+ mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using w+b mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using w+t mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using x mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using xb mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using xt mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using x+ mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using x+b mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using x+t mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using a mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using ab mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using at mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using a+ mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using a+b mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using a+t mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+
+-- Testing ftruncate() with file having data of type text_with_new_line --
+-- Testing ftruncate() with file opening using r mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(false)
+int(1024)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rb mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(false)
+int(1024)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using rt mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(false)
+int(1024)
+bool(false)
+int(1024)
+-- Testing ftruncate() with file opening using r+ mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using r+b mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using r+t mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using w mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using wb mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using wt mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using w+ mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using w+b mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using w+t mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using x mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using xb mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using xt mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using x+ mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using x+b mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using x+t mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using a mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using ab mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using at mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using a+ mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using a+b mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+-- Testing ftruncate() with file opening using a+t mode --
+-- Testing ftruncate(): File pointer at the end --
+int(1024)
+int(1024)
+bool(true)
+int(1024)
+bool(false)
+int(200)
+Done
diff --git a/ext/standard/tests/file/fwrite.phpt b/ext/standard/tests/file/fwrite.phpt
new file mode 100644
index 0000000..7f12ebb
--- /dev/null
+++ b/ext/standard/tests/file/fwrite.phpt
@@ -0,0 +1,52 @@
+--TEST--
+fwrite() tests
+--FILE--
+<?php
+
+$filename = dirname(__FILE__)."/fwrite.dat";
+
+$fp = fopen($filename, "w");
+var_dump(fwrite($fp));
+var_dump(fwrite($fp, array()));
+fclose($fp);
+
+$fp = fopen($filename, "r");
+var_dump(fwrite($fp, "data"));
+
+$fp = fopen($filename, "w");
+var_dump(fwrite($fp, "data", -1));
+var_dump(fwrite($fp, "data", 100000));
+fclose($fp);
+
+var_dump(fwrite($fp, "data", -1));
+
+var_dump(fwrite(array(), "data", -1));
+var_dump(fwrite(array(), "data"));
+var_dump(fwrite(array()));
+
+var_dump(file_get_contents($filename));
+
+@unlink($filename);
+echo "Done\n";
+?>
+--EXPECTF--
+Warning: fwrite() expects at least 2 parameters, 1 given in %s on line %d
+bool(false)
+
+Warning: fwrite() expects parameter 2 to be string, array given in %s on line %d
+bool(false)
+int(0)
+int(0)
+int(4)
+int(0)
+
+Warning: fwrite() expects parameter 1 to be resource, array given in %s on line %d
+bool(false)
+
+Warning: fwrite() expects parameter 1 to be resource, array given in %s on line %d
+bool(false)
+
+Warning: fwrite() expects at least 2 parameters, 1 given in %s on line %d
+bool(false)
+string(4) "data"
+Done
diff --git a/ext/standard/tests/file/fwrite_basic-win32.phpt b/ext/standard/tests/file/fwrite_basic-win32.phpt
new file mode 100644
index 0000000..81d9360
--- /dev/null
+++ b/ext/standard/tests/file/fwrite_basic-win32.phpt
@@ -0,0 +1,424 @@
+--TEST--
+Test fwrite() function : basic functionality
+--SKIPIF--
+<?php
+if( substr(PHP_OS, 0, 3) != 'WIN' ) {
+ die('skip...Valid for Windows only');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: int fwrite ( resource $handle,string string, [, int $length] );
+ Description: fwrite() writes the contents of string to the file stream pointed to by handle.
+ If the length arquement is given,writing will stop after length bytes have been
+ written or the end of string reached, whichever comes first.
+ fwrite() returns the number of bytes written or FALSE on error
+*/
+
+// include the file.inc for Function: function delete_file($filename)
+include ("file.inc");
+
+echo "*** Testing fwrite() basic operations ***\n";
+/*
+ test fwrite with file opened in mode : w,wb,wt,w+,w+b,w+t
+ File containing data of type, numeric, text, text_with_new_line, alphanumeric
+*/
+$file_modes = array( "w", "wb", "wt", "w+", "w+b", "w+t");
+$file_content_types = array("numeric","text","text_with_new_line","alphanumeric");
+
+foreach($file_content_types as $file_content_type) {
+ echo "\n-- Testing fwrite() with file having data of type ". $file_content_type ." --\n";
+ $filename = dirname(__FILE__)."/fwrite_basic-win32.tmp"; // this is name of the file
+
+ for($inner_loop_counter = 0;
+ $inner_loop_counter < count($file_modes);
+ $inner_loop_counter++) {
+ echo "-- File opened in mode : " . $file_modes[$inner_loop_counter]. " --\n";
+ /* open the file using $files_modes and perform fwrite() on it */
+ $file_handle = fopen($filename, $file_modes[$inner_loop_counter]);
+ if (!$file_handle) {
+ echo "Error: failed to fopen() file: $filename!";
+ exit();
+ }
+ $data_to_be_written="";
+ fill_buffer($data_to_be_written, $file_content_type, 1024); //get the data of size 1024
+
+ /* Write the data in to the file, verify the write by checking file pointer position,
+ eof position, and data. */
+ // writing 100 bytes
+ var_dump( ftell($file_handle) ); // Expecting 0
+ var_dump( fwrite($file_handle, $data_to_be_written, 100)); //int(100)
+ var_dump( feof($file_handle) ); // expected : false
+ var_dump( ftell($file_handle) ); //expected: 100
+
+ // trying to write more than the available data, available 1024 bytes but trying 2048
+ var_dump( fwrite($file_handle, $data_to_be_written, 2048)); //int(1024)
+ var_dump( feof($file_handle) ); // expected : false
+ var_dump( ftell($file_handle) ); // expected: 1124
+
+ // fwrite() without length parameter
+ var_dump( fwrite($file_handle, $data_to_be_written)); //int(1024)
+ var_dump( ftell($file_handle) ); // expected: 2148
+ var_dump( feof($file_handle) ); // expected: false
+
+ // close the file, get the size and content of the file.
+ var_dump( fclose($file_handle) ); //expected : true
+ clearstatcache();//clears file status cache
+ var_dump( filesize($filename) ); // expected: 2148
+ var_dump(md5(file_get_contents($filename))); // hash the output
+
+ } // end of inner for loop
+
+ // delete the file created : fwrite_basic.tmp
+ delete_file($filename);
+} // end of outer foreach loop
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fwrite() basic operations ***
+
+-- Testing fwrite() with file having data of type numeric --
+-- File opened in mode : w --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "04db34906fe2c56dcfbd649b7d916974"
+-- File opened in mode : wb --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "04db34906fe2c56dcfbd649b7d916974"
+-- File opened in mode : wt --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "04db34906fe2c56dcfbd649b7d916974"
+-- File opened in mode : w+ --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "04db34906fe2c56dcfbd649b7d916974"
+-- File opened in mode : w+b --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "04db34906fe2c56dcfbd649b7d916974"
+-- File opened in mode : w+t --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "04db34906fe2c56dcfbd649b7d916974"
+
+-- Testing fwrite() with file having data of type text --
+-- File opened in mode : w --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "9c08ac77b7a93a84dd0b055900165e84"
+-- File opened in mode : wb --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "9c08ac77b7a93a84dd0b055900165e84"
+-- File opened in mode : wt --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "9c08ac77b7a93a84dd0b055900165e84"
+-- File opened in mode : w+ --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "9c08ac77b7a93a84dd0b055900165e84"
+-- File opened in mode : w+b --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "9c08ac77b7a93a84dd0b055900165e84"
+-- File opened in mode : w+t --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "9c08ac77b7a93a84dd0b055900165e84"
+
+-- Testing fwrite() with file having data of type text_with_new_line --
+-- File opened in mode : w --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "56a1963cc292d7f8245219116d9eca40"
+-- File opened in mode : wb --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "56a1963cc292d7f8245219116d9eca40"
+-- File opened in mode : wt --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2385)
+string(32) "62b09dac6d598bf54de7b02e0e68e5c7"
+-- File opened in mode : w+ --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "56a1963cc292d7f8245219116d9eca40"
+-- File opened in mode : w+b --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "56a1963cc292d7f8245219116d9eca40"
+-- File opened in mode : w+t --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2385)
+string(32) "62b09dac6d598bf54de7b02e0e68e5c7"
+
+-- Testing fwrite() with file having data of type alphanumeric --
+-- File opened in mode : w --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "719e3329c19218c12d232f2ee81e100f"
+-- File opened in mode : wb --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "719e3329c19218c12d232f2ee81e100f"
+-- File opened in mode : wt --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "719e3329c19218c12d232f2ee81e100f"
+-- File opened in mode : w+ --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "719e3329c19218c12d232f2ee81e100f"
+-- File opened in mode : w+b --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "719e3329c19218c12d232f2ee81e100f"
+-- File opened in mode : w+t --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "719e3329c19218c12d232f2ee81e100f"
+Done \ No newline at end of file
diff --git a/ext/standard/tests/file/fwrite_basic.phpt b/ext/standard/tests/file/fwrite_basic.phpt
new file mode 100644
index 0000000..c568b7c
--- /dev/null
+++ b/ext/standard/tests/file/fwrite_basic.phpt
@@ -0,0 +1,424 @@
+--TEST--
+Test fwrite() function : basic functionality
+--SKIPIF--
+<?php
+if( substr(PHP_OS, 0, 3) == 'WIN' ) {
+ die('skip...Not valid for Windows');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: int fwrite ( resource $handle,string string, [, int $length] );
+ Description: fwrite() writes the contents of string to the file stream pointed to by handle.
+ If the length arquement is given,writing will stop after length bytes have been
+ written or the end of string reached, whichever comes first.
+ fwrite() returns the number of bytes written or FALSE on error
+*/
+
+// include the file.inc for Function: function delete_file($filename)
+include ("file.inc");
+
+echo "*** Testing fwrite() basic operations ***\n";
+/*
+ test fwrite with file opened in mode : w,wb,wt,w+,w+b,w+t
+ File containing data of type, numeric, text, text_with_new_line, alphanumeric
+*/
+$file_modes = array( "w", "wb", "wt", "w+", "w+b", "w+t");
+$file_content_types = array("numeric","text","text_with_new_line","alphanumeric");
+
+foreach($file_content_types as $file_content_type) {
+ echo "\n-- Testing fwrite() with file having data of type ". $file_content_type ." --\n";
+ $filename = dirname(__FILE__)."/fwrite_basic.tmp"; // this is name of the file
+
+ for($inner_loop_counter = 0;
+ $inner_loop_counter < count($file_modes);
+ $inner_loop_counter++) {
+ echo "-- File opened in mode : " . $file_modes[$inner_loop_counter]. " --\n";
+ /* open the file using $files_modes and perform fwrite() on it */
+ $file_handle = fopen($filename, $file_modes[$inner_loop_counter]);
+ if (!$file_handle) {
+ echo "Error: failed to fopen() file: $filename!";
+ exit();
+ }
+ $data_to_be_written="";
+ fill_buffer($data_to_be_written, $file_content_type, 1024); //get the data of size 1024
+
+ /* Write the data in to the file, verify the write by checking file pointer position,
+ eof position, and data. */
+ // writing 100 bytes
+ var_dump( ftell($file_handle) ); // Expecting 0
+ var_dump( fwrite($file_handle, $data_to_be_written, 100)); //int(100)
+ var_dump( feof($file_handle) ); // expected : false
+ var_dump( ftell($file_handle) ); //expected: 100
+
+ // trying to write more than the available data, available 1024 bytes but trying 2048
+ var_dump( fwrite($file_handle, $data_to_be_written, 2048)); //int(1024)
+ var_dump( feof($file_handle) ); // expected : false
+ var_dump( ftell($file_handle) ); // expected: 1124
+
+ // fwrite() without length parameter
+ var_dump( fwrite($file_handle, $data_to_be_written)); //int(1024)
+ var_dump( ftell($file_handle) ); // expected: 2148
+ var_dump( feof($file_handle) ); // expected: false
+
+ // close the file, get the size and content of the file.
+ var_dump( fclose($file_handle) ); //expected : true
+ clearstatcache();//clears file status cache
+ var_dump( filesize($filename) ); // expected: 2148
+ var_dump(md5(file_get_contents($filename))); // hash the output
+
+ } // end of inner for loop
+
+ // delete the file created : fwrite_basic.tmp
+ delete_file($filename);
+} // end of outer foreach loop
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fwrite() basic operations ***
+
+-- Testing fwrite() with file having data of type numeric --
+-- File opened in mode : w --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "04db34906fe2c56dcfbd649b7d916974"
+-- File opened in mode : wb --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "04db34906fe2c56dcfbd649b7d916974"
+-- File opened in mode : wt --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "04db34906fe2c56dcfbd649b7d916974"
+-- File opened in mode : w+ --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "04db34906fe2c56dcfbd649b7d916974"
+-- File opened in mode : w+b --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "04db34906fe2c56dcfbd649b7d916974"
+-- File opened in mode : w+t --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "04db34906fe2c56dcfbd649b7d916974"
+
+-- Testing fwrite() with file having data of type text --
+-- File opened in mode : w --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "9c08ac77b7a93a84dd0b055900165e84"
+-- File opened in mode : wb --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "9c08ac77b7a93a84dd0b055900165e84"
+-- File opened in mode : wt --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "9c08ac77b7a93a84dd0b055900165e84"
+-- File opened in mode : w+ --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "9c08ac77b7a93a84dd0b055900165e84"
+-- File opened in mode : w+b --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "9c08ac77b7a93a84dd0b055900165e84"
+-- File opened in mode : w+t --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "9c08ac77b7a93a84dd0b055900165e84"
+
+-- Testing fwrite() with file having data of type text_with_new_line --
+-- File opened in mode : w --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "56a1963cc292d7f8245219116d9eca40"
+-- File opened in mode : wb --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "56a1963cc292d7f8245219116d9eca40"
+-- File opened in mode : wt --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "56a1963cc292d7f8245219116d9eca40"
+-- File opened in mode : w+ --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "56a1963cc292d7f8245219116d9eca40"
+-- File opened in mode : w+b --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "56a1963cc292d7f8245219116d9eca40"
+-- File opened in mode : w+t --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "56a1963cc292d7f8245219116d9eca40"
+
+-- Testing fwrite() with file having data of type alphanumeric --
+-- File opened in mode : w --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "719e3329c19218c12d232f2ee81e100f"
+-- File opened in mode : wb --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "719e3329c19218c12d232f2ee81e100f"
+-- File opened in mode : wt --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "719e3329c19218c12d232f2ee81e100f"
+-- File opened in mode : w+ --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "719e3329c19218c12d232f2ee81e100f"
+-- File opened in mode : w+b --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "719e3329c19218c12d232f2ee81e100f"
+-- File opened in mode : w+t --
+int(0)
+int(100)
+bool(false)
+int(100)
+int(1024)
+bool(false)
+int(1124)
+int(1024)
+int(2148)
+bool(false)
+bool(true)
+int(2148)
+string(32) "719e3329c19218c12d232f2ee81e100f"
+Done \ No newline at end of file
diff --git a/ext/standard/tests/file/fwrite_error.phpt b/ext/standard/tests/file/fwrite_error.phpt
new file mode 100644
index 0000000..988d618
--- /dev/null
+++ b/ext/standard/tests/file/fwrite_error.phpt
@@ -0,0 +1,121 @@
+--TEST--
+Test fwrite() function : error conditions
+--FILE--
+<?php
+/*
+ Prototype: int fwrite ( resource $handle,string string, [, int $length] );
+ Description: fwrite() writes the contents of string to the file stream pointed to by handle.
+ If the length arquement is given,writing will stop after length bytes have been
+ written or the end of string reached, whichever comes first.
+ fwrite() returns the number of bytes written or FALSE on error
+*/
+
+// include the file.inc for Function: function delete_file($filename)
+include ("file.inc");
+
+echo "*** Testing fwrite() : error conditions ***\n";
+
+$filename = dirname(__FILE__)."/fwrite_error.tmp";
+
+echo "-- Testing fwrite() with less than expected number of arguments --\n";
+// zero argument
+var_dump( fwrite() );
+// less than expected, 1 arg
+$file_handle = fopen ( $filename, "w");
+var_dump( fwrite($file_handle) );
+
+// more than expected no. of args
+echo "-- Testing fwrite() with more than expected number of arguments --\n";
+$data = "data";
+var_dump( fwrite($file_handle, $data, strlen($data), 10) );
+
+// invalid length argument
+echo "-- Testing fwrite() with invalid length arguments --\n";
+$len = 0;
+var_dump( fwrite($file_handle, $data, $len) );
+$len = -10;
+var_dump( fwrite($file_handle, $data, $len) );
+
+// test invalid arguments : non-resources
+echo "-- Testing fwrite() with invalid arguments --\n";
+$invalid_args = array (
+ "string",
+ 10,
+ 10.5,
+ true,
+ array(1,2,3),
+ new stdclass,
+);
+/* loop to test fwrite() with different invalid type of args */
+for($loop_counter = 1; $loop_counter <= count($invalid_args); $loop_counter++) {
+ echo "-- Iteration $loop_counter --\n";
+ var_dump( fwrite($invalid_args[$loop_counter - 1], 10) );
+}
+
+// fwrite() on a file handle which is already closed
+echo "-- Testing fwrite() with closed/unset file handle --\n";
+fclose($file_handle);
+var_dump(fwrite($file_handle,"data"));
+
+// fwrite on a file handle which is unset
+$fp = fopen($filename, "w");
+unset($fp); //unset file handle
+var_dump( fwrite(@$fp,"data"));
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+$filename = dirname(__FILE__)."/fwrite_error.tmp";
+unlink( $filename );
+?>
+--EXPECTF--
+*** Testing fwrite() : error conditions ***
+-- Testing fwrite() with less than expected number of arguments --
+
+Warning: fwrite() expects at least 2 parameters, 0 given in %s on line %d
+bool(false)
+
+Warning: fwrite() expects at least 2 parameters, 1 given in %s on line %d
+bool(false)
+-- Testing fwrite() with more than expected number of arguments --
+
+Warning: fwrite() expects at most 3 parameters, 4 given in %s on line %d
+bool(false)
+-- Testing fwrite() with invalid length arguments --
+int(0)
+int(0)
+-- Testing fwrite() with invalid arguments --
+-- Iteration 1 --
+
+Warning: fwrite() expects parameter 1 to be resource, string given in %s on line %d
+bool(false)
+-- Iteration 2 --
+
+Warning: fwrite() expects parameter 1 to be resource, integer given in %s on line %d
+bool(false)
+-- Iteration 3 --
+
+Warning: fwrite() expects parameter 1 to be resource, double given in %s on line %d
+bool(false)
+-- Iteration 4 --
+
+Warning: fwrite() expects parameter 1 to be resource, boolean given in %s on line %d
+bool(false)
+-- Iteration 5 --
+
+Warning: fwrite() expects parameter 1 to be resource, array given in %s on line %d
+bool(false)
+-- Iteration 6 --
+
+Warning: fwrite() expects parameter 1 to be resource, object given in %s on line %d
+bool(false)
+-- Testing fwrite() with closed/unset file handle --
+
+Warning: fwrite(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: fwrite() expects parameter 1 to be resource, null given in %s on line %d
+bool(false)
+Done
+
diff --git a/ext/standard/tests/file/fwrite_variation1-win32.phpt b/ext/standard/tests/file/fwrite_variation1-win32.phpt
new file mode 100644
index 0000000..1091aeb
--- /dev/null
+++ b/ext/standard/tests/file/fwrite_variation1-win32.phpt
@@ -0,0 +1,235 @@
+--TEST--
+Test fwrite() function : usage variations - r, rb & rt modes
+--SKIPIF--
+<?php
+if( substr(PHP_OS, 0, 3) != 'WIN' ) {
+ die('skip...Not valid for Linux');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: int fwrite ( resource $handle,string string, [, int $length] );
+ Description: fwrite() writes the contents of string to the file stream pointed to by handle.
+ If the length arquement is given,writing will stop after length bytes have been
+ written or the end of string reached, whichever comes first.
+ fwrite() returns the number of bytes written or FALSE on error
+*/
+
+
+echo "*** Testing fwrite() various operations ***\n";
+
+// include the file.inc for Function: function delete_file($filename)
+include ("file.inc");
+
+/*
+ Test fwrite with file opened in mode : r,rb,rt
+ File having content of type numeric, text,text_with_new_line & alphanumeric
+*/
+
+$file_modes = array("r","rb","rt");
+$file_content_types = array("numeric","text","text_with_new_line","alphanumeric");
+
+
+foreach($file_content_types as $file_content_type) {
+ echo "\n-- Testing fwrite() with file having content of type ". $file_content_type ." --\n";
+
+ /* open the file using $files_modes and perform fwrite() on it */
+ foreach($file_modes as $file_mode) {
+ echo "-- Opening file in $file_mode --\n";
+
+ // create the temp file with content of type $file_content_type
+ $filename = dirname(__FILE__)."/fwrite_variation1.tmp"; // this is name of the file
+ create_files ( dirname(__FILE__), 1, $file_content_type, 0755, 1, "w", "fwrite_variation");
+
+ $file_handle = fopen($filename, $file_mode);
+ if(!$file_handle) {
+ echo "Error: failed to fopen() file: $filename!";
+ exit();
+ }
+
+ $data_to_be_written="";
+ fill_buffer($data_to_be_written,$file_content_type,1024); //get the data of size 1024
+
+ /* Write the data into the file, verify it by checking the file pointer position, eof position,
+ filesize & by displaying the content */
+
+ var_dump( ftell($file_handle) ); // expected: 0
+ var_dump( fwrite($file_handle, $data_to_be_written ));
+ var_dump( ftell($file_handle) ); // expected: 0
+ var_dump( feof($file_handle) ); // expected: false
+
+ // move the file pointer to end of the file and try fwrite()
+ fseek($file_handle, SEEK_END, 0);
+ var_dump( ftell($file_handle) ); // expecting 1024
+ var_dump( fwrite($file_handle, $data_to_be_written) ); // fwrite to fail
+ var_dump( ftell($file_handle) ); //check that file pointer points at eof, expected: 1024
+ var_dump( feof($file_handle) ); // ensure that feof() points to eof, expected: true
+
+ // ensure that file content/size didn't change.
+ var_dump( fclose($file_handle) );
+ clearstatcache();//clears file status cache
+ var_dump( filesize($filename) ); // expected: 1024
+ var_dump(md5(file_get_contents($filename))); // hash the output
+ delete_file($filename); // delete file with name fwrite_variation1.tmp
+
+ } // end of inner foreach loop
+} // end of outer foreach loop
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fwrite() various operations ***
+
+-- Testing fwrite() with file having content of type numeric --
+-- Opening file in r --
+int(0)
+int(0)
+int(0)
+bool(false)
+int(2)
+int(0)
+int(2)
+bool(false)
+bool(true)
+int(1024)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+-- Opening file in rb --
+int(0)
+int(0)
+int(0)
+bool(false)
+int(2)
+int(0)
+int(2)
+bool(false)
+bool(true)
+int(1024)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+-- Opening file in rt --
+int(0)
+int(0)
+int(0)
+bool(false)
+int(2)
+int(0)
+int(2)
+bool(false)
+bool(true)
+int(1024)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+
+-- Testing fwrite() with file having content of type text --
+-- Opening file in r --
+int(0)
+int(0)
+int(0)
+bool(false)
+int(2)
+int(0)
+int(2)
+bool(false)
+bool(true)
+int(1024)
+string(32) "e486000c4c8452774f746a27658d87fa"
+-- Opening file in rb --
+int(0)
+int(0)
+int(0)
+bool(false)
+int(2)
+int(0)
+int(2)
+bool(false)
+bool(true)
+int(1024)
+string(32) "e486000c4c8452774f746a27658d87fa"
+-- Opening file in rt --
+int(0)
+int(0)
+int(0)
+bool(false)
+int(2)
+int(0)
+int(2)
+bool(false)
+bool(true)
+int(1024)
+string(32) "e486000c4c8452774f746a27658d87fa"
+
+-- Testing fwrite() with file having content of type text_with_new_line --
+-- Opening file in r --
+int(0)
+int(0)
+int(0)
+bool(false)
+int(2)
+int(0)
+int(2)
+bool(false)
+bool(true)
+int(1024)
+string(32) "b09c8026a64a88d36d4c2f17983964bb"
+-- Opening file in rb --
+int(0)
+int(0)
+int(0)
+bool(false)
+int(2)
+int(0)
+int(2)
+bool(false)
+bool(true)
+int(1024)
+string(32) "b09c8026a64a88d36d4c2f17983964bb"
+-- Opening file in rt --
+int(0)
+int(0)
+int(0)
+bool(false)
+int(2)
+int(0)
+int(2)
+bool(false)
+bool(true)
+int(1024)
+string(32) "b09c8026a64a88d36d4c2f17983964bb"
+
+-- Testing fwrite() with file having content of type alphanumeric --
+-- Opening file in r --
+int(0)
+int(0)
+int(0)
+bool(false)
+int(2)
+int(0)
+int(2)
+bool(false)
+bool(true)
+int(1024)
+string(32) "3fabd48d8eaa65c14e0d93d6880c560c"
+-- Opening file in rb --
+int(0)
+int(0)
+int(0)
+bool(false)
+int(2)
+int(0)
+int(2)
+bool(false)
+bool(true)
+int(1024)
+string(32) "3fabd48d8eaa65c14e0d93d6880c560c"
+-- Opening file in rt --
+int(0)
+int(0)
+int(0)
+bool(false)
+int(2)
+int(0)
+int(2)
+bool(false)
+bool(true)
+int(1024)
+string(32) "3fabd48d8eaa65c14e0d93d6880c560c"
+Done
diff --git a/ext/standard/tests/file/fwrite_variation1.phpt b/ext/standard/tests/file/fwrite_variation1.phpt
new file mode 100644
index 0000000..44f6939
--- /dev/null
+++ b/ext/standard/tests/file/fwrite_variation1.phpt
@@ -0,0 +1,233 @@
+--TEST--
+Test fwrite() function : usage variations - r, rb & rt modes
+--SKIPIF--
+<?php
+if( substr(PHP_OS, 0, 3) == 'WIN' ) {
+ die('skip...Not valid for Windows');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: int fwrite ( resource $handle,string string, [, int $length] );
+ Description: fwrite() writes the contents of string to the file stream pointed to by handle.
+ If the length arquement is given,writing will stop after length bytes have been
+ written or the end of string reached, whichever comes first.
+ fwrite() returns the number of bytes written or FALSE on error
+*/
+
+
+echo "*** Testing fwrite() various operations ***\n";
+
+// include the file.inc for Function: function delete_file($filename)
+include ("file.inc");
+
+/*
+ Test fwrite with file opened in mode : r,rb,rt
+ File having content of type numeric, text,text_with_new_line & alphanumeric
+*/
+
+$file_modes = array("r","rb","rt");
+$file_content_types = array("numeric","text","text_with_new_line","alphanumeric");
+
+foreach($file_content_types as $file_content_type) {
+ echo "\n-- Testing fwrite() with file having content of type ". $file_content_type ." --\n";
+
+ /* open the file using $files_modes and perform fwrite() on it */
+ foreach($file_modes as $file_mode) {
+ echo "-- Opening file in $file_mode --\n";
+
+ // create the temp file with content of type $file_content_type
+ $filename = dirname(__FILE__)."/fwrite_variation1.tmp"; // this is name of the file
+ create_files ( dirname(__FILE__), 1, $file_content_type, 0755, 1, "w", "fwrite_variation");
+
+ $file_handle = fopen($filename, $file_mode);
+ if(!$file_handle) {
+ echo "Error: failed to fopen() file: $filename!";
+ exit();
+ }
+
+ $data_to_be_written="";
+ fill_buffer($data_to_be_written,$file_content_type,1024); //get the data of size 1024
+
+ /* Write the data into the file, verify it by checking the file pointer position, eof position,
+ filesize & by displaying the content */
+
+ var_dump( ftell($file_handle) ); // expected: 0
+ var_dump( fwrite($file_handle, $data_to_be_written ));
+ var_dump( ftell($file_handle) ); // expected: 0
+ var_dump( feof($file_handle) ); // expected: false
+
+ // move the file pointer to end of the file and try fwrite()
+ fseek($file_handle, SEEK_END, 0);
+ var_dump( ftell($file_handle) ); // expecting 1024
+ var_dump( fwrite($file_handle, $data_to_be_written) ); // fwrite to fail
+ var_dump( ftell($file_handle) ); //check that file pointer points at eof, expected: 1024
+ var_dump( feof($file_handle) ); // ensure that feof() points to eof, expected: true
+
+ // ensure that file content/size didn't change.
+ var_dump( fclose($file_handle) );
+ clearstatcache();//clears file status cache
+ var_dump( filesize($filename) ); // expected: 1024
+ var_dump(md5(file_get_contents($filename))); // hash the output
+ delete_file($filename); // delete file with name fwrite_variation1.tmp
+ } // end of inner foreach loop
+} // end of outer foreach loop
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fwrite() various operations ***
+
+-- Testing fwrite() with file having content of type numeric --
+-- Opening file in r --
+int(0)
+int(0)
+int(0)
+bool(false)
+int(2)
+int(0)
+int(2)
+bool(false)
+bool(true)
+int(1024)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+-- Opening file in rb --
+int(0)
+int(0)
+int(0)
+bool(false)
+int(2)
+int(0)
+int(2)
+bool(false)
+bool(true)
+int(1024)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+-- Opening file in rt --
+int(0)
+int(0)
+int(0)
+bool(false)
+int(2)
+int(0)
+int(2)
+bool(false)
+bool(true)
+int(1024)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+
+-- Testing fwrite() with file having content of type text --
+-- Opening file in r --
+int(0)
+int(0)
+int(0)
+bool(false)
+int(2)
+int(0)
+int(2)
+bool(false)
+bool(true)
+int(1024)
+string(32) "e486000c4c8452774f746a27658d87fa"
+-- Opening file in rb --
+int(0)
+int(0)
+int(0)
+bool(false)
+int(2)
+int(0)
+int(2)
+bool(false)
+bool(true)
+int(1024)
+string(32) "e486000c4c8452774f746a27658d87fa"
+-- Opening file in rt --
+int(0)
+int(0)
+int(0)
+bool(false)
+int(2)
+int(0)
+int(2)
+bool(false)
+bool(true)
+int(1024)
+string(32) "e486000c4c8452774f746a27658d87fa"
+
+-- Testing fwrite() with file having content of type text_with_new_line --
+-- Opening file in r --
+int(0)
+int(0)
+int(0)
+bool(false)
+int(2)
+int(0)
+int(2)
+bool(false)
+bool(true)
+int(1024)
+string(32) "b09c8026a64a88d36d4c2f17983964bb"
+-- Opening file in rb --
+int(0)
+int(0)
+int(0)
+bool(false)
+int(2)
+int(0)
+int(2)
+bool(false)
+bool(true)
+int(1024)
+string(32) "b09c8026a64a88d36d4c2f17983964bb"
+-- Opening file in rt --
+int(0)
+int(0)
+int(0)
+bool(false)
+int(2)
+int(0)
+int(2)
+bool(false)
+bool(true)
+int(1024)
+string(32) "b09c8026a64a88d36d4c2f17983964bb"
+
+-- Testing fwrite() with file having content of type alphanumeric --
+-- Opening file in r --
+int(0)
+int(0)
+int(0)
+bool(false)
+int(2)
+int(0)
+int(2)
+bool(false)
+bool(true)
+int(1024)
+string(32) "3fabd48d8eaa65c14e0d93d6880c560c"
+-- Opening file in rb --
+int(0)
+int(0)
+int(0)
+bool(false)
+int(2)
+int(0)
+int(2)
+bool(false)
+bool(true)
+int(1024)
+string(32) "3fabd48d8eaa65c14e0d93d6880c560c"
+-- Opening file in rt --
+int(0)
+int(0)
+int(0)
+bool(false)
+int(2)
+int(0)
+int(2)
+bool(false)
+bool(true)
+int(1024)
+string(32) "3fabd48d8eaa65c14e0d93d6880c560c"
+Done
diff --git a/ext/standard/tests/file/fwrite_variation2-win32.phpt b/ext/standard/tests/file/fwrite_variation2-win32.phpt
new file mode 100644
index 0000000..8545db9
--- /dev/null
+++ b/ext/standard/tests/file/fwrite_variation2-win32.phpt
@@ -0,0 +1,304 @@
+--TEST--
+Test fwrite() function : usage variations - r+, r+b & r+t modes
+--SKIPIF--
+<?php
+if( substr(PHP_OS, 0, 3) != 'WIN' ) {
+ die('skip...Not valid for Linux');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: int fwrite ( resource $handle,string string, [, int $length] );
+ Description: fwrite() writes the contents of string to the file stream pointed to by handle.
+ If the length arquement is given,writing will stop after length bytes have been
+ written or the end of string reached, whichever comes first.
+ fwrite() returns the number of bytes written or FALSE on error
+*/
+
+
+echo "*** Testing fwrite() various operations ***\n";
+
+// include the file.inc for Function: function delete_file($filename)
+include ("file.inc");
+
+/*
+ Test fwrite with file opened in mode : r+,r+b,r+t
+ File having content of type numeric, text,text_with_new_line & alphanumeric
+*/
+
+$file_modes = array("r+", "r+b", "r+t");
+$file_content_types = array("numeric","text","text_with_new_line","alphanumeric");
+
+
+foreach($file_content_types as $file_content_type) {
+ echo "\n-- Testing fwrite() with file having content of type ". $file_content_type ." --\n";
+
+ /* open the file using $files_modes and perform fwrite() on it */
+ foreach($file_modes as $file_mode) {
+ echo "-- Opening file in $file_mode --\n";
+
+ // create temp file and fill the data of type $file_content_type
+ $filename = dirname(__FILE__)."/fwrite_variation2.tmp"; // this is name of the file
+ create_files ( dirname(__FILE__), 1, $file_content_type, 0755, 1, "w", "fwrite_variation", 2);
+
+ $file_handle = fopen($filename, $file_mode);
+ if(!$file_handle) {
+ echo "Error: failed to fopen() file: $filename!";
+ exit();
+ }
+
+ $data_to_be_written="";
+ fill_buffer($data_to_be_written,$file_content_type,1024); //get the data of size 1024
+
+ /* Write the data into the file, verify it by checking the file pointer position, eof position,
+ filesize & by displaying the content */
+
+ /*overwrite first 400 bytes in the file*/
+ var_dump( ftell($file_handle) ); // expected : 0
+ var_dump( fwrite($file_handle, $data_to_be_written, 400));
+ var_dump( ftell($file_handle) ); // expected: 400
+ var_dump( feof($file_handle) ); //Expecting bool(false)
+
+ /*overwrite data in middle of the file*/
+ fseek($file_handle, SEEK_SET, 1024/2 );
+ var_dump( ftell($file_handle)); // expected: 1024/2
+ var_dump( fwrite($file_handle, $data_to_be_written, 200) );
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) ); //Expecting bool(false)
+
+ /* write at the end of the file */
+ fseek($file_handle, SEEK_END, 0);
+ var_dump( ftell($file_handle) ); // expected: 1024
+ var_dump( feof($file_handle) );
+ var_dump( fwrite($file_handle, $data_to_be_written, 200) );
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) ); //Expecting bool(false)
+
+ /* display the file content, check the file size */
+ var_dump( fclose($file_handle) );
+ clearstatcache();//clears file status cache
+ var_dump( filesize($filename) );
+ var_dump(md5(file_get_contents($filename)));
+ delete_file($filename); // delete file with name fwrite_variation2.tmp
+
+ } // end of inner foreach loop
+} // end of outer foreach loop
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fwrite() various operations ***
+
+-- Testing fwrite() with file having content of type numeric --
+-- Opening file in r+ --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+int(2)
+bool(false)
+int(200)
+int(202)
+bool(false)
+bool(true)
+int(1024)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+-- Opening file in r+b --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+int(2)
+bool(false)
+int(200)
+int(202)
+bool(false)
+bool(true)
+int(1024)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+-- Opening file in r+t --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+int(2)
+bool(false)
+int(200)
+int(202)
+bool(false)
+bool(true)
+int(1024)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+
+-- Testing fwrite() with file having content of type text --
+-- Opening file in r+ --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+int(2)
+bool(false)
+int(200)
+int(202)
+bool(false)
+bool(true)
+int(1024)
+string(32) "3bdaf80dae28bc24bb304daa5ffee16c"
+-- Opening file in r+b --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+int(2)
+bool(false)
+int(200)
+int(202)
+bool(false)
+bool(true)
+int(1024)
+string(32) "3bdaf80dae28bc24bb304daa5ffee16c"
+-- Opening file in r+t --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+int(2)
+bool(false)
+int(200)
+int(202)
+bool(false)
+bool(true)
+int(1024)
+string(32) "3bdaf80dae28bc24bb304daa5ffee16c"
+
+-- Testing fwrite() with file having content of type text_with_new_line --
+-- Opening file in r+ --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+int(2)
+bool(false)
+int(200)
+int(202)
+bool(false)
+bool(true)
+int(1024)
+string(32) "b188d7c8aa229cbef067e5970f2daba9"
+-- Opening file in r+b --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+int(2)
+bool(false)
+int(200)
+int(202)
+bool(false)
+bool(true)
+int(1024)
+string(32) "b188d7c8aa229cbef067e5970f2daba9"
+-- Opening file in r+t --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+int(2)
+bool(false)
+int(200)
+int(202)
+bool(false)
+bool(true)
+int(1024)
+string(32) "991652c76db8d17c790c702ac0a6dc5f"
+
+-- Testing fwrite() with file having content of type alphanumeric --
+-- Opening file in r+ --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+int(2)
+bool(false)
+int(200)
+int(202)
+bool(false)
+bool(true)
+int(1024)
+string(32) "5d4ec23a3d9dd447e2f702d9e0e114d9"
+-- Opening file in r+b --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+int(2)
+bool(false)
+int(200)
+int(202)
+bool(false)
+bool(true)
+int(1024)
+string(32) "5d4ec23a3d9dd447e2f702d9e0e114d9"
+-- Opening file in r+t --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+int(2)
+bool(false)
+int(200)
+int(202)
+bool(false)
+bool(true)
+int(1024)
+string(32) "5d4ec23a3d9dd447e2f702d9e0e114d9"
+Done
diff --git a/ext/standard/tests/file/fwrite_variation2.phpt b/ext/standard/tests/file/fwrite_variation2.phpt
new file mode 100644
index 0000000..34804b6
--- /dev/null
+++ b/ext/standard/tests/file/fwrite_variation2.phpt
@@ -0,0 +1,303 @@
+--TEST--
+Test fwrite() function : usage variations - r+, r+b & r+t modes
+--SKIPIF--
+<?php
+if( substr(PHP_OS, 0, 3) == 'WIN' ) {
+ die('skip...Not valid for Windows');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: int fwrite ( resource $handle,string string, [, int $length] );
+ Description: fwrite() writes the contents of string to the file stream pointed to by handle.
+ If the length arquement is given,writing will stop after length bytes have been
+ written or the end of string reached, whichever comes first.
+ fwrite() returns the number of bytes written or FALSE on error
+*/
+
+
+echo "*** Testing fwrite() various operations ***\n";
+
+// include the file.inc for Function: function delete_file($filename)
+include ("file.inc");
+
+/*
+ Test fwrite with file opened in mode : r+,r+b,r+t
+ File having content of type numeric, text,text_with_new_line & alphanumeric
+*/
+
+$file_modes = array("r+", "r+b", "r+t");
+$file_content_types = array("numeric","text","text_with_new_line","alphanumeric");
+
+
+foreach($file_content_types as $file_content_type) {
+ echo "\n-- Testing fwrite() with file having content of type ". $file_content_type ." --\n";
+
+ /* open the file using $files_modes and perform fwrite() on it */
+ foreach($file_modes as $file_mode) {
+ echo "-- Opening file in $file_mode --\n";
+
+ // create temp file and fill the data of type $file_content_type
+ $filename = dirname(__FILE__)."/fwrite_variation2.tmp"; // this is name of the file
+ create_files ( dirname(__FILE__), 1, $file_content_type, 0755, 1, "w", "fwrite_variation", 2);
+
+ $file_handle = fopen($filename, $file_mode);
+ if(!$file_handle) {
+ echo "Error: failed to fopen() file: $filename!";
+ exit();
+ }
+
+ $data_to_be_written="";
+ fill_buffer($data_to_be_written,$file_content_type,1024); //get the data of size 1024
+
+ /* Write the data into the file, verify it by checking the file pointer position, eof position,
+ filesize & by displaying the content */
+
+ /*overwrite first 400 bytes in the file*/
+ var_dump( ftell($file_handle) ); // expected : 0
+ var_dump( fwrite($file_handle, $data_to_be_written, 400));
+ var_dump( ftell($file_handle) ); // expected: 400
+ var_dump( feof($file_handle) ); //Expecting bool(false)
+
+ /*overwrite data in middle of the file*/
+ fseek($file_handle, SEEK_SET, 1024/2 );
+ var_dump( ftell($file_handle)); // expected: 1024/2
+ var_dump( fwrite($file_handle, $data_to_be_written, 200) );
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) ); //Expecting bool(false)
+
+ /* write at the end of the file */
+ fseek($file_handle, SEEK_END, 0);
+ var_dump( ftell($file_handle) ); // expected: 1024
+ var_dump( feof($file_handle) );
+ var_dump( fwrite($file_handle, $data_to_be_written, 200) );
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) ); //Expecting bool(false)
+
+ /* display the file content, check the file size */
+ var_dump( fclose($file_handle) );
+ clearstatcache();//clears file status cache
+ var_dump( filesize($filename) );
+ var_dump(md5(file_get_contents($filename)));
+ delete_file($filename); // delete file with name fwrite_variation2.tmp
+ } // end of inner foreach loop
+} // end of outer foreach loop
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fwrite() various operations ***
+
+-- Testing fwrite() with file having content of type numeric --
+-- Opening file in r+ --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+int(2)
+bool(false)
+int(200)
+int(202)
+bool(false)
+bool(true)
+int(1024)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+-- Opening file in r+b --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+int(2)
+bool(false)
+int(200)
+int(202)
+bool(false)
+bool(true)
+int(1024)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+-- Opening file in r+t --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+int(2)
+bool(false)
+int(200)
+int(202)
+bool(false)
+bool(true)
+int(1024)
+string(32) "950b7457d1deb6332f2fc5d42f3129d6"
+
+-- Testing fwrite() with file having content of type text --
+-- Opening file in r+ --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+int(2)
+bool(false)
+int(200)
+int(202)
+bool(false)
+bool(true)
+int(1024)
+string(32) "3bdaf80dae28bc24bb304daa5ffee16c"
+-- Opening file in r+b --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+int(2)
+bool(false)
+int(200)
+int(202)
+bool(false)
+bool(true)
+int(1024)
+string(32) "3bdaf80dae28bc24bb304daa5ffee16c"
+-- Opening file in r+t --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+int(2)
+bool(false)
+int(200)
+int(202)
+bool(false)
+bool(true)
+int(1024)
+string(32) "3bdaf80dae28bc24bb304daa5ffee16c"
+
+-- Testing fwrite() with file having content of type text_with_new_line --
+-- Opening file in r+ --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+int(2)
+bool(false)
+int(200)
+int(202)
+bool(false)
+bool(true)
+int(1024)
+string(32) "b188d7c8aa229cbef067e5970f2daba9"
+-- Opening file in r+b --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+int(2)
+bool(false)
+int(200)
+int(202)
+bool(false)
+bool(true)
+int(1024)
+string(32) "b188d7c8aa229cbef067e5970f2daba9"
+-- Opening file in r+t --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+int(2)
+bool(false)
+int(200)
+int(202)
+bool(false)
+bool(true)
+int(1024)
+string(32) "b188d7c8aa229cbef067e5970f2daba9"
+
+-- Testing fwrite() with file having content of type alphanumeric --
+-- Opening file in r+ --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+int(2)
+bool(false)
+int(200)
+int(202)
+bool(false)
+bool(true)
+int(1024)
+string(32) "5d4ec23a3d9dd447e2f702d9e0e114d9"
+-- Opening file in r+b --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+int(2)
+bool(false)
+int(200)
+int(202)
+bool(false)
+bool(true)
+int(1024)
+string(32) "5d4ec23a3d9dd447e2f702d9e0e114d9"
+-- Opening file in r+t --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+int(2)
+bool(false)
+int(200)
+int(202)
+bool(false)
+bool(true)
+int(1024)
+string(32) "5d4ec23a3d9dd447e2f702d9e0e114d9"
+Done
diff --git a/ext/standard/tests/file/fwrite_variation3-win32.phpt b/ext/standard/tests/file/fwrite_variation3-win32.phpt
new file mode 100644
index 0000000..125f88d
--- /dev/null
+++ b/ext/standard/tests/file/fwrite_variation3-win32.phpt
@@ -0,0 +1,380 @@
+--TEST--
+Test fwrite() function : usage variations - a, ab, at, a+, a+b & a+t mode
+--SKIPIF--
+<?php
+if( substr(PHP_OS, 0, 3) != 'WIN' ) {
+ die('skip...Not valid for Linux');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: int fwrite ( resource $handle,string string, [, int $length] );
+ Description: fwrite() writes the contents of string to the file stream pointed to by handle.
+ If the length arquement is given,writing will stop after length bytes have been
+ written or the end of string reached, whichever comes first.
+ fwrite() returns the number of bytes written or FALSE on error
+*/
+
+
+echo "*** Testing fwrite() various operations ***\n";
+
+// include the file.inc for Function: function delete_file($filename)
+include ("file.inc");
+
+/*
+ Test fwrite with file opened in mode : a,ab,at,a+,a+b,a+
+ File having content of type numeric, text,text_with_new_line & alphanumeric
+*/
+
+$file_modes = array("a","ab","at","a+","a+b","a+t");
+$file_content_types = array("numeric","text","text_with_new_line","alphanumeric");
+
+
+foreach($file_content_types as $file_content_type) {
+ echo "\n-- Testing fwrite() with file having content of type ". $file_content_type ." --\n";
+
+ /* open the file using $files_modes and perform fwrite() on it */
+ foreach($file_modes as $file_mode) {
+ echo "-- Opening file in $file_mode --\n";
+
+ // create temp file and fill it content of type $file_content_type
+ $filename = dirname(__FILE__)."/fwrite_variation3.tmp"; // this is name of the file
+ create_files ( dirname(__FILE__), 1, $file_content_type, 0755, 1, "w", "fwrite_variation", 3);
+
+ $file_handle = fopen($filename, $file_mode);
+ if(!$file_handle) {
+ echo "Error: failed to fopen() file: $filename!";
+ exit();
+ }
+
+ $data_to_be_written="";
+ fill_buffer($data_to_be_written,$file_content_type,1024); //get the data of size 1024
+
+ /* Write the data into the file, verify it by checking the file pointer position, eof position,
+ filesize & by displaying the content */
+ // append the data to the file, starting from current position of the file pointer
+ var_dump( ftell($file_handle) ); // expected: 1024
+ var_dump( fwrite($file_handle,$data_to_be_written,400) );
+ var_dump( ftell($file_handle) ); // expected: 1024 + 400
+ var_dump( feof($file_handle) ); // expected : true
+
+ /*overwrite data in middle of the file*/
+ fseek($file_handle, SEEK_SET, (1024 + 400)/2 );
+ var_dump( ftell($file_handle)); // expected: (1024 + 400)/2
+ var_dump( fwrite($file_handle, $data_to_be_written, 200) );
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) ); //Expecting bool(false)
+
+ /* check the filesize and display file content */
+ // close the file, get the size and content of the file.
+ var_dump( fclose($file_handle) );
+ clearstatcache();//clears file status cache
+ var_dump( filesize($filename) );
+ var_dump(md5(file_get_contents($filename)));
+ // delete the file created
+ delete_file($filename); // delete file with name fwrite_variation3.tmp
+ } // end of inner foreach loop
+} // end of outer foreach loop
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fwrite() various operations ***
+
+-- Testing fwrite() with file having content of type numeric --
+-- Opening file in a --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "59ce5bf03b69069d00d6354bdc969ff6"
+-- Opening file in ab --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "59ce5bf03b69069d00d6354bdc969ff6"
+-- Opening file in at --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "59ce5bf03b69069d00d6354bdc969ff6"
+-- Opening file in a+ --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "59ce5bf03b69069d00d6354bdc969ff6"
+-- Opening file in a+b --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "59ce5bf03b69069d00d6354bdc969ff6"
+-- Opening file in a+t --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "59ce5bf03b69069d00d6354bdc969ff6"
+
+-- Testing fwrite() with file having content of type text --
+-- Opening file in a --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "dbd9dffd809d82e299bc1e5c55087f3b"
+-- Opening file in ab --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "dbd9dffd809d82e299bc1e5c55087f3b"
+-- Opening file in at --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "dbd9dffd809d82e299bc1e5c55087f3b"
+-- Opening file in a+ --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "dbd9dffd809d82e299bc1e5c55087f3b"
+-- Opening file in a+b --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "dbd9dffd809d82e299bc1e5c55087f3b"
+-- Opening file in a+t --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "dbd9dffd809d82e299bc1e5c55087f3b"
+
+-- Testing fwrite() with file having content of type text_with_new_line --
+-- Opening file in a --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "3f0a483fe8a2f405677844e0b1af6cf4"
+-- Opening file in ab --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "3f0a483fe8a2f405677844e0b1af6cf4"
+-- Opening file in at --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1690)
+string(32) "656648355b64df6fded53b12fb355ab8"
+-- Opening file in a+ --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "3f0a483fe8a2f405677844e0b1af6cf4"
+-- Opening file in a+b --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "3f0a483fe8a2f405677844e0b1af6cf4"
+-- Opening file in a+t --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1690)
+string(32) "656648355b64df6fded53b12fb355ab8"
+
+-- Testing fwrite() with file having content of type alphanumeric --
+-- Opening file in a --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "ea0c0bfa0b10aa8e614fd33ffe295cb9"
+-- Opening file in ab --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "ea0c0bfa0b10aa8e614fd33ffe295cb9"
+-- Opening file in at --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "ea0c0bfa0b10aa8e614fd33ffe295cb9"
+-- Opening file in a+ --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "ea0c0bfa0b10aa8e614fd33ffe295cb9"
+-- Opening file in a+b --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "ea0c0bfa0b10aa8e614fd33ffe295cb9"
+-- Opening file in a+t --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "ea0c0bfa0b10aa8e614fd33ffe295cb9"
+Done
diff --git a/ext/standard/tests/file/fwrite_variation3.phpt b/ext/standard/tests/file/fwrite_variation3.phpt
new file mode 100644
index 0000000..7d635fd
--- /dev/null
+++ b/ext/standard/tests/file/fwrite_variation3.phpt
@@ -0,0 +1,381 @@
+--TEST--
+Test fwrite() function : usage variations - a, ab, at, a+, a+b & a+t modes
+--SKIPIF--
+<?php
+if( substr(PHP_OS, 0, 3) == 'WIN' ) {
+ die('skip...Not valid for Windows');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: int fwrite ( resource $handle,string string, [, int $length] );
+ Description: fwrite() writes the contents of string to the file stream pointed to by handle.
+ If the length arquement is given,writing will stop after length bytes have been
+ written or the end of string reached, whichever comes first.
+ fwrite() returns the number of bytes written or FALSE on error
+*/
+
+
+echo "*** Testing fwrite() various operations ***\n";
+
+// include the file.inc for Function: function delete_file($filename)
+include ("file.inc");
+
+/*
+ Test fwrite with file opened in mode : a,ab,at,a+,a+b,a+t
+ File having content of type numeric, text,text_with_new_line & alphanumeric
+*/
+
+$file_modes = array("a","ab","at","a+","a+b","a+t");
+$file_content_types = array("numeric","text","text_with_new_line","alphanumeric");
+
+
+foreach($file_content_types as $file_content_type) {
+ echo "\n-- Testing fwrite() with file having content of type ". $file_content_type ." --\n";
+
+ /* open the file using $files_modes and perform fwrite() on it */
+ foreach($file_modes as $file_mode) {
+ echo "-- Opening file in $file_mode --\n";
+
+ // create temp file and fill it content of type $file_content_type
+ $filename = dirname(__FILE__)."/fwrite_variation3.tmp"; // this is name of the file
+ create_files ( dirname(__FILE__), 1, $file_content_type, 0755, 1, "w", "fwrite_variation", 3);
+
+ $file_handle = fopen($filename, $file_mode);
+ if(!$file_handle) {
+ echo "Error: failed to fopen() file: $filename!";
+ exit();
+ }
+
+ $data_to_be_written="";
+ fill_buffer($data_to_be_written,$file_content_type,1024); //get the data of size 1024
+
+ /* Write the data into the file, verify it by checking the file pointer position, eof position,
+ filesize & by displaying the content */
+
+ // append the data to the file, starting from current position of the file pointer
+ var_dump( ftell($file_handle) ); // expected: 1024
+ var_dump( fwrite($file_handle,$data_to_be_written,400) );
+ var_dump( ftell($file_handle) ); // expected: 1024 + 400
+ var_dump( feof($file_handle) ); // expected : true
+
+ /*overwrite data in middle of the file*/
+ fseek($file_handle, SEEK_SET, (1024 + 400)/2 );
+ var_dump( ftell($file_handle)); // expected: (1024 + 400)/2
+ var_dump( fwrite($file_handle, $data_to_be_written, 200) );
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) ); //Expecting bool(false)
+
+ /* check the filesize and display file content */
+ // close the file, get the size and content of the file.
+ var_dump( fclose($file_handle) );
+ clearstatcache();//clears file status cache
+ var_dump( filesize($filename) );
+ var_dump(md5(file_get_contents($filename)));
+ // delete the file created
+ delete_file($filename); // delete file with name fwrite_variation3.tmp
+ } // end of inner foreach loop
+} // end of outer foreach loop
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fwrite() various operations ***
+
+-- Testing fwrite() with file having content of type numeric --
+-- Opening file in a --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "59ce5bf03b69069d00d6354bdc969ff6"
+-- Opening file in ab --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "59ce5bf03b69069d00d6354bdc969ff6"
+-- Opening file in at --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "59ce5bf03b69069d00d6354bdc969ff6"
+-- Opening file in a+ --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "59ce5bf03b69069d00d6354bdc969ff6"
+-- Opening file in a+b --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "59ce5bf03b69069d00d6354bdc969ff6"
+-- Opening file in a+t --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "59ce5bf03b69069d00d6354bdc969ff6"
+
+-- Testing fwrite() with file having content of type text --
+-- Opening file in a --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "dbd9dffd809d82e299bc1e5c55087f3b"
+-- Opening file in ab --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "dbd9dffd809d82e299bc1e5c55087f3b"
+-- Opening file in at --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "dbd9dffd809d82e299bc1e5c55087f3b"
+-- Opening file in a+ --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "dbd9dffd809d82e299bc1e5c55087f3b"
+-- Opening file in a+b --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "dbd9dffd809d82e299bc1e5c55087f3b"
+-- Opening file in a+t --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "dbd9dffd809d82e299bc1e5c55087f3b"
+
+-- Testing fwrite() with file having content of type text_with_new_line --
+-- Opening file in a --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "3f0a483fe8a2f405677844e0b1af6cf4"
+-- Opening file in ab --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "3f0a483fe8a2f405677844e0b1af6cf4"
+-- Opening file in at --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "3f0a483fe8a2f405677844e0b1af6cf4"
+-- Opening file in a+ --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "3f0a483fe8a2f405677844e0b1af6cf4"
+-- Opening file in a+b --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "3f0a483fe8a2f405677844e0b1af6cf4"
+-- Opening file in a+t --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "3f0a483fe8a2f405677844e0b1af6cf4"
+
+-- Testing fwrite() with file having content of type alphanumeric --
+-- Opening file in a --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "ea0c0bfa0b10aa8e614fd33ffe295cb9"
+-- Opening file in ab --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "ea0c0bfa0b10aa8e614fd33ffe295cb9"
+-- Opening file in at --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "ea0c0bfa0b10aa8e614fd33ffe295cb9"
+-- Opening file in a+ --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "ea0c0bfa0b10aa8e614fd33ffe295cb9"
+-- Opening file in a+b --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "ea0c0bfa0b10aa8e614fd33ffe295cb9"
+-- Opening file in a+t --
+int(0)
+int(400)
+int(400)
+bool(false)
+int(400)
+int(200)
+int(600)
+bool(false)
+bool(true)
+int(1624)
+string(32) "ea0c0bfa0b10aa8e614fd33ffe295cb9"
+Done
diff --git a/ext/standard/tests/file/fwrite_variation4-win32.phpt b/ext/standard/tests/file/fwrite_variation4-win32.phpt
new file mode 100644
index 0000000..ed2114e
--- /dev/null
+++ b/ext/standard/tests/file/fwrite_variation4-win32.phpt
@@ -0,0 +1,275 @@
+--TEST--
+Test fwrite() function : usage variations - x, xb, xt, x+, x+b & x+t modes
+--SKIPIF--
+<?php
+if( substr(PHP_OS, 0, 3) != 'WIN' ) {
+ die('skip...Not valid for Linux');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: int fwrite ( resource $handle,string string, [, int $length] );
+ Description: fwrite() writes the contents of string to the file stream pointed to by handle.
+ If the length arquement is given,writing will stop after length bytes have been
+ written or the end of string reached, whichever comes first.
+ fwrite() returns the number of bytes written or FALSE on error
+*/
+
+
+echo "*** Testing fwrite() various operations ***\n";
+
+// include the file.inc for Function: function delete_file($filename)
+include ("file.inc");
+
+/*
+ Test fwrite with file opened in mode : x, xb, xt, x+, x+b, x+t
+ File having content of type numeric, text,text_with_new_line & alphanumeric
+*/
+
+$file_modes = array("x","xb","xt","x+","x+b","x+t");
+$file_content_types = array("numeric","text","text_with_new_line","alphanumeric");
+
+
+foreach($file_content_types as $file_content_type) {
+ echo "\n-- Testing fwrite() with file having content of type ". $file_content_type ." --\n";
+
+ /* open the file using $files_modes and perform fwrite() on it */
+ foreach($file_modes as $file_mode) {
+ echo "-- Opening file in $file_mode --\n";
+
+ $filename = dirname(__FILE__)."/fwrite_variation4.tmp"; // this is name of the file
+
+ $file_handle = fopen($filename, $file_mode);
+ if(!$file_handle) {
+ echo "Error: failed to fopen() file: $filename!";
+ exit();
+ }
+
+ $data_to_be_written="";
+ fill_buffer($data_to_be_written,$file_content_type,1024); //get the data of size 1024
+
+ /* Write the data into the file, verify it by checking the file pointer position, eof position,
+ filesize & by displaying the content */
+ // write data to the file
+ var_dump( ftell($file_handle) );
+ var_dump( fwrite($file_handle,$data_to_be_written,400));
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) ); // expected: true
+
+ //check the filesize and content
+ // close the file, get the size and content of the file.
+ var_dump( fclose($file_handle) );
+ clearstatcache();//clears file status cache
+ var_dump( filesize($filename) );
+ var_dump(md5(file_get_contents($filename)));
+ // delete the file created
+ delete_file($filename); // delete file with name fwrite_variation4.tmp
+ } // end of inner foreach loop
+} // end of outer foreach loop
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fwrite() various operations ***
+
+-- Testing fwrite() with file having content of type numeric --
+-- Opening file in x --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "f255efe87ebdf755e515868cea9ad24b"
+-- Opening file in xb --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "f255efe87ebdf755e515868cea9ad24b"
+-- Opening file in xt --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "f255efe87ebdf755e515868cea9ad24b"
+-- Opening file in x+ --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "f255efe87ebdf755e515868cea9ad24b"
+-- Opening file in x+b --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "f255efe87ebdf755e515868cea9ad24b"
+-- Opening file in x+t --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "f255efe87ebdf755e515868cea9ad24b"
+
+-- Testing fwrite() with file having content of type text --
+-- Opening file in x --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "c2244282eeca7c2d32d0dacf21e19432"
+-- Opening file in xb --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "c2244282eeca7c2d32d0dacf21e19432"
+-- Opening file in xt --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "c2244282eeca7c2d32d0dacf21e19432"
+-- Opening file in x+ --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "c2244282eeca7c2d32d0dacf21e19432"
+-- Opening file in x+b --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "c2244282eeca7c2d32d0dacf21e19432"
+-- Opening file in x+t --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "c2244282eeca7c2d32d0dacf21e19432"
+
+-- Testing fwrite() with file having content of type text_with_new_line --
+-- Opening file in x --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "fa6c79b925c2fc754b9d063c6de1d8df"
+-- Opening file in xb --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "fa6c79b925c2fc754b9d063c6de1d8df"
+-- Opening file in xt --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(444)
+string(32) "c96531f6b4c8d9e829c25b87f96ea86e"
+-- Opening file in x+ --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "fa6c79b925c2fc754b9d063c6de1d8df"
+-- Opening file in x+b --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "fa6c79b925c2fc754b9d063c6de1d8df"
+-- Opening file in x+t --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(444)
+string(32) "c96531f6b4c8d9e829c25b87f96ea86e"
+
+-- Testing fwrite() with file having content of type alphanumeric --
+-- Opening file in x --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "b2a123e1d84e6a03c8520aff7689219e"
+-- Opening file in xb --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "b2a123e1d84e6a03c8520aff7689219e"
+-- Opening file in xt --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "b2a123e1d84e6a03c8520aff7689219e"
+-- Opening file in x+ --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "b2a123e1d84e6a03c8520aff7689219e"
+-- Opening file in x+b --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "b2a123e1d84e6a03c8520aff7689219e"
+-- Opening file in x+t --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "b2a123e1d84e6a03c8520aff7689219e"
+Done
diff --git a/ext/standard/tests/file/fwrite_variation4.phpt b/ext/standard/tests/file/fwrite_variation4.phpt
new file mode 100644
index 0000000..eefc2f8
--- /dev/null
+++ b/ext/standard/tests/file/fwrite_variation4.phpt
@@ -0,0 +1,275 @@
+--TEST--
+Test fwrite() function : usage variations - x, xb, xt, x+, x+b & x+t modes
+--SKIPIF--
+<?php
+if( substr(PHP_OS, 0, 3) == 'WIN' ) {
+ die('skip...Not valid for Windows');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: int fwrite ( resource $handle,string string, [, int $length] );
+ Description: fwrite() writes the contents of string to the file stream pointed to by handle.
+ If the length arquement is given,writing will stop after length bytes have been
+ written or the end of string reached, whichever comes first.
+ fwrite() returns the number of bytes written or FALSE on error
+*/
+
+
+echo "*** Testing fwrite() various operations ***\n";
+
+// include the file.inc for Function: function delete_file($filename)
+include ("file.inc");
+
+/*
+ Test fwrite with file opened in mode : x, xb, xt, x+, x+b, x+t
+ File having content of type numeric, text,text_with_new_line & alphanumeric
+*/
+
+$file_modes = array("x","xb","xt","x+","x+b","x+t");
+$file_content_types = array("numeric","text","text_with_new_line","alphanumeric");
+
+
+foreach($file_content_types as $file_content_type) {
+ echo "\n-- Testing fwrite() with file having content of type ". $file_content_type ." --\n";
+
+ /* open the file using $files_modes and perform fwrite() on it */
+ foreach($file_modes as $file_mode) {
+ echo "-- Opening file in $file_mode --\n";
+
+ $filename = dirname(__FILE__)."/fwrite_variation4.tmp"; // this is name of the file
+
+ $file_handle = fopen($filename, $file_mode);
+ if(!$file_handle) {
+ echo "Error: failed to fopen() file: $filename!";
+ exit();
+ }
+
+ $data_to_be_written="";
+ fill_buffer($data_to_be_written,$file_content_type,1024); //get the data of size 1024
+
+ /* Write the data into the file, verify it by checking the file pointer position, eof position,
+ filesize & by displaying the content */
+ // write data to the file
+ var_dump( ftell($file_handle) );
+ var_dump( fwrite($file_handle,$data_to_be_written,400));
+ var_dump( ftell($file_handle) );
+ var_dump( feof($file_handle) ); // expected: true
+
+ //check the filesize and content
+ // close the file, get the size and content of the file.
+ var_dump( fclose($file_handle) );
+ clearstatcache();//clears file status cache
+ var_dump( filesize($filename) );
+ var_dump(md5(file_get_contents($filename)));
+ // delete the file created
+ delete_file($filename); // delete file with name fwrite_variation4.tmp
+ } // end of inner foreach loop
+} // end of outer foreach loop
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing fwrite() various operations ***
+
+-- Testing fwrite() with file having content of type numeric --
+-- Opening file in x --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "f255efe87ebdf755e515868cea9ad24b"
+-- Opening file in xb --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "f255efe87ebdf755e515868cea9ad24b"
+-- Opening file in xt --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "f255efe87ebdf755e515868cea9ad24b"
+-- Opening file in x+ --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "f255efe87ebdf755e515868cea9ad24b"
+-- Opening file in x+b --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "f255efe87ebdf755e515868cea9ad24b"
+-- Opening file in x+t --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "f255efe87ebdf755e515868cea9ad24b"
+
+-- Testing fwrite() with file having content of type text --
+-- Opening file in x --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "c2244282eeca7c2d32d0dacf21e19432"
+-- Opening file in xb --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "c2244282eeca7c2d32d0dacf21e19432"
+-- Opening file in xt --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "c2244282eeca7c2d32d0dacf21e19432"
+-- Opening file in x+ --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "c2244282eeca7c2d32d0dacf21e19432"
+-- Opening file in x+b --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "c2244282eeca7c2d32d0dacf21e19432"
+-- Opening file in x+t --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "c2244282eeca7c2d32d0dacf21e19432"
+
+-- Testing fwrite() with file having content of type text_with_new_line --
+-- Opening file in x --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "fa6c79b925c2fc754b9d063c6de1d8df"
+-- Opening file in xb --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "fa6c79b925c2fc754b9d063c6de1d8df"
+-- Opening file in xt --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "fa6c79b925c2fc754b9d063c6de1d8df"
+-- Opening file in x+ --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "fa6c79b925c2fc754b9d063c6de1d8df"
+-- Opening file in x+b --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "fa6c79b925c2fc754b9d063c6de1d8df"
+-- Opening file in x+t --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "fa6c79b925c2fc754b9d063c6de1d8df"
+
+-- Testing fwrite() with file having content of type alphanumeric --
+-- Opening file in x --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "b2a123e1d84e6a03c8520aff7689219e"
+-- Opening file in xb --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "b2a123e1d84e6a03c8520aff7689219e"
+-- Opening file in xt --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "b2a123e1d84e6a03c8520aff7689219e"
+-- Opening file in x+ --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "b2a123e1d84e6a03c8520aff7689219e"
+-- Opening file in x+b --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "b2a123e1d84e6a03c8520aff7689219e"
+-- Opening file in x+t --
+int(0)
+int(400)
+int(400)
+bool(false)
+bool(true)
+int(400)
+string(32) "b2a123e1d84e6a03c8520aff7689219e"
+Done
diff --git a/ext/standard/tests/file/fwrite_variation5.phpt b/ext/standard/tests/file/fwrite_variation5.phpt
new file mode 100644
index 0000000..b12af31
--- /dev/null
+++ b/ext/standard/tests/file/fwrite_variation5.phpt
@@ -0,0 +1,173 @@
+--TEST--
+Test fwrite() function : usage variation
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : int fwrite(resource fp, string str [, int length])
+ * Description: Binary-safe file write
+ * Source code: ext/standard/file.c
+ * Alias to functions: bzwrite fputs gzwrite
+ */
+
+echo "*** Testing fwrite() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+
+$filename = __DIR__ . '/fwriteVar5.tmp';
+
+
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+ // int data
+ 'int 0' => 0,
+ 'int 1' => 1,
+ 'int 12345' => 12345,
+ 'int -12345' => -2345,
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float -10.5' => -10.5,
+ 'float 12.3456789000e10' => 12.3456789000e10,
+ 'float -12.3456789000e10' => -12.3456789000e10,
+ 'float .5' => .5,
+
+ // array data
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for str
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ $fp = fopen($filename,'w');
+ fwrite($fp, $value);
+ fclose($fp);
+ readfile($filename);
+};
+unlink($filename);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing fwrite() : usage variation ***
+
+--int 0--
+0
+--int 1--
+1
+--int 12345--
+12345
+--int -12345--
+-2345
+--float 10.5--
+10.5
+--float -10.5--
+-10.5
+--float 12.3456789000e10--
+123456789000
+--float -12.3456789000e10--
+-123456789000
+--float .5--
+0.5
+--empty array--
+Error: 2 - fwrite() expects parameter 2 to be string, array given, %s(%d)
+
+--int indexed array--
+Error: 2 - fwrite() expects parameter 2 to be string, array given, %s(%d)
+
+--associative array--
+Error: 2 - fwrite() expects parameter 2 to be string, array given, %s(%d)
+
+--nested arrays--
+Error: 2 - fwrite() expects parameter 2 to be string, array given, %s(%d)
+
+--uppercase NULL--
+
+--lowercase null--
+
+--lowercase true--
+1
+--lowercase false--
+
+--uppercase TRUE--
+1
+--uppercase FALSE--
+
+--empty string DQ--
+
+--empty string SQ--
+
+--instance of classWithToString--
+Class A object
+--instance of classWithoutToString--
+Error: 2 - fwrite() expects parameter 2 to be string, object given, %s(%d)
+
+--undefined var--
+
+--unset var--
+===DONE===
+
diff --git a/ext/standard/tests/file/get_current_user.phpt b/ext/standard/tests/file/get_current_user.phpt
new file mode 100644
index 0000000..b67195b
--- /dev/null
+++ b/ext/standard/tests/file/get_current_user.phpt
@@ -0,0 +1,15 @@
+--TEST--
+get_current_user() tests
+--FILE--
+<?php
+
+var_dump(get_current_user("blah"));
+var_dump(get_current_user());
+
+echo "Done\n";
+?>
+--EXPECTF--
+Warning: get_current_user() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+string(%d) %s
+Done
diff --git a/ext/standard/tests/file/glob_basic.phpt b/ext/standard/tests/file/glob_basic.phpt
new file mode 100644
index 0000000..fc269c4
--- /dev/null
+++ b/ext/standard/tests/file/glob_basic.phpt
@@ -0,0 +1,82 @@
+--TEST--
+Test glob() function: basic functions
+--FILE--
+<?php
+/* Prototype: array glob ( string $pattern [, int $flags] );
+ Description: Find pathnames matching a pattern
+*/
+
+echo "*** Testing glob() : basic functions ***\n";
+
+$file_path = dirname(__FILE__);
+
+// temp dirname used here
+$dirname = "$file_path/glob_basic";
+
+// temp dir created
+mkdir($dirname);
+
+// temp files created
+$fp = fopen("$dirname/wonder12345", "w");
+fclose($fp);
+$fp = fopen("$dirname/wonder.txt", "w");
+fclose($fp);
+$fp = fopen("$dirname/file.text", "w");
+fclose($fp);
+
+// glob() with default arguments
+sort_var_dump( glob($dirname."/*") );
+sort_var_dump( glob($dirname."/*.txt") );
+sort_var_dump( glob($dirname."/*.t?t") );
+sort_var_dump( glob($dirname."/*.t*t") );
+sort_var_dump( glob($dirname."/*.?") );
+sort_var_dump( glob($dirname."/*.*") );
+
+echo "Done\n";
+
+function sort_var_dump($results) {
+ sort($results);
+ var_dump($results);
+}
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink("$file_path/glob_basic/wonder12345");
+unlink("$file_path/glob_basic/wonder.txt");
+unlink("$file_path/glob_basic/file.text");
+rmdir("$file_path/glob_basic/");
+?>
+--EXPECTF--
+*** Testing glob() : basic functions ***
+array(3) {
+ [0]=>
+ string(%d) "%s/glob_basic/file.text"
+ [1]=>
+ string(%d) "%s/glob_basic/wonder.txt"
+ [2]=>
+ string(%d) "%s/glob_basic/wonder12345"
+}
+array(1) {
+ [0]=>
+ string(%d) "%s/glob_basic/wonder.txt"
+}
+array(1) {
+ [0]=>
+ string(%d) "%s/glob_basic/wonder.txt"
+}
+array(2) {
+ [0]=>
+ string(%d) "%s/glob_basic/file.text"
+ [1]=>
+ string(%d) "%s/glob_basic/wonder.txt"
+}
+array(0) {
+}
+array(2) {
+ [0]=>
+ string(%d) "%s/glob_basic/file.text"
+ [1]=>
+ string(%d) "%s/glob_basic/wonder.txt"
+}
+Done
diff --git a/ext/standard/tests/file/glob_error.phpt b/ext/standard/tests/file/glob_error.phpt
new file mode 100644
index 0000000..546b40d
--- /dev/null
+++ b/ext/standard/tests/file/glob_error.phpt
@@ -0,0 +1,53 @@
+--TEST--
+Test glob() function: error conditions
+--FILE--
+<?php
+/* Prototype: array glob ( string $pattern [, int $flags] );
+ Description: Find pathnames matching a pattern
+*/
+
+$file_path = dirname(__FILE__);
+
+// temp dir created
+mkdir("$file_path/glob_error");
+// temp file created
+$fp = fopen("$file_path/glob_error/wonder12345", "w");
+fclose($fp);
+
+echo "*** Testing glob() : error conditions ***\n";
+
+echo "-- Testing glob() with unexpected no. of arguments --\n";
+var_dump( glob() ); // args < expected
+var_dump( glob(dirname(__FILE__)."/glob_error/wonder12345", GLOB_ERR, 3) ); // args > expected
+
+echo "\n-- Testing glob() with invalid arguments --\n";
+var_dump( glob(dirname(__FILE__)."/glob_error/wonder12345", '') );
+var_dump( glob(dirname(__FILE__)."/glob_error/wonder12345", "string") );
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+// temp file deleted
+unlink(dirname(__FILE__)."/glob_error/wonder12345");
+// temp dir deleted
+rmdir(dirname(__FILE__)."/glob_error");
+?>
+--EXPECTF--
+*** Testing glob() : error conditions ***
+-- Testing glob() with unexpected no. of arguments --
+
+Warning: glob() expects at least 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: glob() expects at most 2 parameters, 3 given in %s on line %d
+NULL
+
+-- Testing glob() with invalid arguments --
+
+Warning: glob() expects parameter 2 to be long, string given in %s on line %d
+NULL
+
+Warning: glob() expects parameter 2 to be long, string given in %s on line %d
+NULL
+Done
diff --git a/ext/standard/tests/file/glob_error_002-win32.phpt b/ext/standard/tests/file/glob_error_002-win32.phpt
new file mode 100644
index 0000000..a61efd1
--- /dev/null
+++ b/ext/standard/tests/file/glob_error_002-win32.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Test glob() function: error condition - pattern too long.
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+ die("skip Only valid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype: array glob ( string $pattern [, int $flags] );
+ Description: Find pathnames matching a pattern
+*/
+
+echo "*** Testing glob() : error condition - pattern too long. ***\n";
+
+var_dump(glob(str_repeat('x', 3000)));
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing glob() : error condition - pattern too long. ***
+
+Warning: glob(): Pattern exceeds the maximum allowed length of %d characters in %s on line %d
+bool(false)
+Done
diff --git a/ext/standard/tests/file/glob_variation-win32.phpt b/ext/standard/tests/file/glob_variation-win32.phpt
new file mode 100644
index 0000000..5027ac0
--- /dev/null
+++ b/ext/standard/tests/file/glob_variation-win32.phpt
@@ -0,0 +1,465 @@
+--TEST--
+Test glob() function: usage variations
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip.. only for Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: array glob ( string $pattern [, int $flags] );
+ Description: Find pathnames matching a pattern
+*/
+
+echo "*** Testing glob() : usage variations ***\n";
+
+$file_path = dirname(__FILE__);
+
+// temp dir created
+mkdir("$file_path/glob_variation");
+mkdir("$file_path/glob_variation/wonder");
+
+// temp files created
+$fp = fopen("$file_path/glob_variation/wonder12345", "w");
+fclose($fp);
+$fp = fopen("$file_path/glob_variation/wonder;123456", "w");
+fclose($fp);
+
+$patterns = array (
+ "$file_path/glob_variation/*der*",
+ "$file_path/glob_variation/?onder*",
+ "$file_path/glob_variation/w*der?*",
+ "$file_path/glob_variation/*der5",
+ "$file_path/glob_variation/??onder*",
+ "$file_path/glob_variation/***der***",
+ "$file_path/glob_variation/++onder*",
+ "$file_path/glob_variation/WONDER5\0",
+ '$file_path/glob_variation/wonder5',
+ "$file_path/glob_variation/?wonder?",
+ "$file_path/glob_variation/wonder?",
+ TRUE // boolean true
+);
+$counter = 1;
+/* loop through $patterns to match each $pattern with the files created
+ using glob() */
+foreach($patterns as $pattern) {
+ echo "\n-- Iteration $counter --\n";
+ var_dump( glob($pattern) ); // default arguments
+ var_dump( glob($pattern, GLOB_MARK) );
+ var_dump( glob($pattern, GLOB_NOSORT) );
+ var_dump( glob($pattern, GLOB_NOCHECK) );
+ var_dump( glob($pattern, GLOB_NOESCAPE) );
+ var_dump( glob($pattern, GLOB_ERR) );
+ $counter++;
+}
+
+echo "\n*** Testing glob() with pattern within braces ***\n";
+var_dump( glob("$file_path/glob_variation/*{5}", GLOB_BRACE) );
+
+// delete temp files and dir
+unlink("$file_path/glob_variation/wonder12345");
+unlink("$file_path/glob_variation/wonder;123456");
+rmdir("$file_path/glob_variation/wonder");
+rmdir("$file_path/glob_variation");
+
+echo "\n*** Testing glob() on directories ***\n";
+// temp dir created to check for pattern matching the sub dir created in it
+mkdir("$file_path/glob_variation/wonder1/wonder2", 0777, true);
+
+$counter = 1;
+/* loop through $patterns to match each $pattern with the directories created
+ using glob() */
+foreach($patterns as $pattern) {
+ echo "-- Iteration $counter --\n";
+ var_dump( glob($pattern, GLOB_ONLYDIR) );
+ $counter++;
+}
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+rmdir("$file_path/glob_variation/wonder1/wonder2");
+rmdir("$file_path/glob_variation/wonder1/");
+rmdir("$file_path/glob_variation/");
+?>
+--EXPECTF--
+*** Testing glob() : usage variations ***
+
+-- Iteration 1 --
+array(3) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder"
+ [1]=>
+ string(%d) "%s/glob_variation/wonder12345"
+ [2]=>
+ string(%d) "%s/glob_variation/wonder;123456"
+}
+array(3) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder12345"
+ [1]=>
+ string(%d) "%s/glob_variation/wonder;123456"
+ [2]=>
+ string(%d) "%s/glob_variation/wonder\"
+}
+array(3) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder"
+ [1]=>
+ string(%d) "%s/glob_variation/wonder12345"
+ [2]=>
+ string(%d) "%s/glob_variation/wonder;123456"
+}
+array(3) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder"
+ [1]=>
+ string(%d) "%s/glob_variation/wonder12345"
+ [2]=>
+ string(%d) "%s/glob_variation/wonder;123456"
+}
+array(3) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder"
+ [1]=>
+ string(%d) "%s/glob_variation/wonder12345"
+ [2]=>
+ string(%d) "%s/glob_variation/wonder;123456"
+}
+array(3) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder"
+ [1]=>
+ string(%d) "%s/glob_variation/wonder12345"
+ [2]=>
+ string(%d) "%s/glob_variation/wonder;123456"
+}
+
+-- Iteration 2 --
+array(3) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder"
+ [1]=>
+ string(%d) "%s/glob_variation/wonder12345"
+ [2]=>
+ string(%d) "%s/glob_variation/wonder;123456"
+}
+array(3) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder12345"
+ [1]=>
+ string(%d) "%s/glob_variation/wonder;123456"
+ [2]=>
+ string(%d) "%s/glob_variation/wonder\"
+}
+array(3) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder"
+ [1]=>
+ string(%d) "%s/glob_variation/wonder12345"
+ [2]=>
+ string(%d) "%s/glob_variation/wonder;123456"
+}
+array(3) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder"
+ [1]=>
+ string(%d) "%s/glob_variation/wonder12345"
+ [2]=>
+ string(%d) "%s/glob_variation/wonder;123456"
+}
+array(3) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder"
+ [1]=>
+ string(%d) "%s/glob_variation/wonder12345"
+ [2]=>
+ string(%d) "%s/glob_variation/wonder;123456"
+}
+array(3) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder"
+ [1]=>
+ string(%d) "%s/glob_variation/wonder12345"
+ [2]=>
+ string(%d) "%s/glob_variation/wonder;123456"
+}
+
+-- Iteration 3 --
+array(2) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder12345"
+ [1]=>
+ string(%d) "%s/glob_variation/wonder;123456"
+}
+array(2) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder12345"
+ [1]=>
+ string(%d) "%s/glob_variation/wonder;123456"
+}
+array(2) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder12345"
+ [1]=>
+ string(%d) "%s/glob_variation/wonder;123456"
+}
+array(2) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder12345"
+ [1]=>
+ string(%d) "%s/glob_variation/wonder;123456"
+}
+array(2) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder12345"
+ [1]=>
+ string(%d) "%s/glob_variation/wonder;123456"
+}
+array(2) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder12345"
+ [1]=>
+ string(%d) "%s/glob_variation/wonder;123456"
+}
+
+-- Iteration 4 --
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(1) {
+ [0]=>
+ string(%d) "%s/glob_variation/*der5"
+}
+array(0) {
+}
+array(0) {
+}
+
+-- Iteration 5 --
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(1) {
+ [0]=>
+ string(%d) "%s/glob_variation/??onder*"
+}
+array(0) {
+}
+array(0) {
+}
+
+-- Iteration 6 --
+array(3) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder"
+ [1]=>
+ string(%d) "%s/glob_variation/wonder12345"
+ [2]=>
+ string(%d) "%s/glob_variation/wonder;123456"
+}
+array(3) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder12345"
+ [1]=>
+ string(%d) "%s/glob_variation/wonder;123456"
+ [2]=>
+ string(%d) "%s/glob_variation/wonder\"
+}
+array(3) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder"
+ [1]=>
+ string(%d) "%s/glob_variation/wonder12345"
+ [2]=>
+ string(%d) "%s/glob_variation/wonder;123456"
+}
+array(3) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder"
+ [1]=>
+ string(%d) "%s/glob_variation/wonder12345"
+ [2]=>
+ string(%d) "%s/glob_variation/wonder;123456"
+}
+array(3) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder"
+ [1]=>
+ string(%d) "%s/glob_variation/wonder12345"
+ [2]=>
+ string(%d) "%s/glob_variation/wonder;123456"
+}
+array(3) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder"
+ [1]=>
+ string(%d) "%s/glob_variation/wonder12345"
+ [2]=>
+ string(%d) "%s/glob_variation/wonder;123456"
+}
+
+-- Iteration 7 --
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(1) {
+ [0]=>
+ string(%d) "%s/glob_variation/++onder*"
+}
+array(0) {
+}
+array(0) {
+}
+
+-- Iteration 8 --
+
+Warning: glob() expects parameter 1 to be a valid path, string given %sglob_variation-win32.php on line %d
+NULL
+
+Warning: glob() expects parameter 1 to be a valid path, string given %sglob_variation-win32.php on line %d
+NULL
+
+Warning: glob() expects parameter 1 to be a valid path, string given %sglob_variation-win32.php on line %d
+NULL
+
+Warning: glob() expects parameter 1 to be a valid path, string given %sglob_variation-win32.php on line %d
+NULL
+
+Warning: glob() expects parameter 1 to be a valid path, string given %sglob_variation-win32.php on line %d
+NULL
+
+Warning: glob() expects parameter 1 to be a valid path, string given %sglob_variation-win32.php on line %d
+NULL
+
+-- Iteration 9 --
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(1) {
+ [0]=>
+ string(%d) "$file_path/glob_variation/wonder5"
+}
+array(0) {
+}
+array(0) {
+}
+
+-- Iteration 10 --
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(1) {
+ [0]=>
+ string(%d) "%s/glob_variation/?wonder?"
+}
+array(0) {
+}
+array(0) {
+}
+
+-- Iteration 11 --
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(1) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder?"
+}
+array(0) {
+}
+array(0) {
+}
+
+-- Iteration 12 --
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(1) {
+ [0]=>
+ string(%d) "1"
+}
+array(0) {
+}
+array(0) {
+}
+
+*** Testing glob() with pattern within braces ***
+array(1) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder12345"
+}
+
+*** Testing glob() on directories ***
+-- Iteration 1 --
+array(1) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder1"
+}
+-- Iteration 2 --
+array(1) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder1"
+}
+-- Iteration 3 --
+array(1) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder1"
+}
+-- Iteration 4 --
+array(0) {
+}
+-- Iteration 5 --
+array(0) {
+}
+-- Iteration 6 --
+array(1) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder1"
+}
+-- Iteration 7 --
+array(0) {
+}
+-- Iteration 8 --
+
+Warning: glob() expects parameter 1 to be a valid path, string given in %sglob_variation-win32.php on line %d
+NULL
+-- Iteration 9 --
+array(0) {
+}
+-- Iteration 10 --
+array(0) {
+}
+-- Iteration 11 --
+array(1) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder1"
+}
+-- Iteration 12 --
+array(0) {
+}
+Done
diff --git a/ext/standard/tests/file/glob_variation.phpt b/ext/standard/tests/file/glob_variation.phpt
new file mode 100644
index 0000000..00fd6ff
--- /dev/null
+++ b/ext/standard/tests/file/glob_variation.phpt
@@ -0,0 +1,465 @@
+--TEST--
+Test glob() function: usage variations
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. Not valid for Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: array glob ( string $pattern [, int $flags] );
+ Description: Find pathnames matching a pattern
+*/
+
+echo "*** Testing glob() : usage variations ***\n";
+
+$file_path = dirname(__FILE__);
+
+// temp dir created
+mkdir("$file_path/glob_variation");
+mkdir("$file_path/glob_variation/wonder");
+
+// temp files created
+$fp = fopen("$file_path/glob_variation/wonder12345", "w");
+fclose($fp);
+$fp = fopen("$file_path/glob_variation/wonder;123456", "w");
+fclose($fp);
+
+$patterns = array (
+ "$file_path/glob_variation/*der*",
+ "$file_path/glob_variation/?onder*",
+ "$file_path/glob_variation/w*der?*",
+ "$file_path/glob_variation/*der5",
+ "$file_path/glob_variation/??onder*",
+ "$file_path/glob_variation/***der***",
+ "$file_path/glob_variation/++onder*",
+ "$file_path/glob_variation/WONDER5\0",
+ '$file_path/glob_variation/wonder5',
+ "$file_path/glob_variation/?wonder?",
+ "$file_path/glob_variation/wonder?",
+ TRUE // boolean true
+);
+$counter = 1;
+/* loop through $patterns to match each $pattern with the files created
+ using glob() */
+foreach($patterns as $pattern) {
+ echo "\n-- Iteration $counter --\n";
+ var_dump( glob($pattern) ); // default arguments
+ var_dump( glob($pattern, GLOB_MARK) );
+ var_dump( glob($pattern, GLOB_NOSORT) );
+ var_dump( glob($pattern, GLOB_NOCHECK) );
+ var_dump( glob($pattern, GLOB_NOESCAPE) );
+ var_dump( glob($pattern, GLOB_ERR) );
+ $counter++;
+}
+
+echo "\n*** Testing glob() with pattern within braces ***\n";
+var_dump( glob("$file_path/glob_variation/*{5}", GLOB_BRACE) );
+
+// delete temp files and dir
+unlink("$file_path/glob_variation/wonder12345");
+unlink("$file_path/glob_variation/wonder;123456");
+rmdir("$file_path/glob_variation/wonder");
+rmdir("$file_path/glob_variation");
+
+echo "\n*** Testing glob() on directories ***\n";
+// temp dir created to check for pattern matching the sub dir created in it
+mkdir("$file_path/glob_variation/wonder1/wonder2", 0777, true);
+
+$counter = 1;
+/* loop through $patterns to match each $pattern with the directories created
+ using glob() */
+foreach($patterns as $pattern) {
+ echo "-- Iteration $counter --\n";
+ var_dump( glob($pattern, GLOB_ONLYDIR) );
+ $counter++;
+}
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+rmdir("$file_path/glob_variation/wonder1/wonder2");
+rmdir("$file_path/glob_variation/wonder1/");
+rmdir("$file_path/glob_variation/");
+?>
+--EXPECTF--
+*** Testing glob() : usage variations ***
+
+-- Iteration 1 --
+array(3) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder"
+ [1]=>
+ string(%d) "%s/glob_variation/wonder12345"
+ [2]=>
+ string(%d) "%s/glob_variation/wonder;123456"
+}
+array(3) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder/"
+ [1]=>
+ string(%d) "%s/glob_variation/wonder12345"
+ [2]=>
+ string(%d) "%s/glob_variation/wonder;123456"
+}
+array(3) {
+ [0]=>
+ string(%d) "%s"
+ [1]=>
+ string(%d) "%s"
+ [2]=>
+ string(%d) "%s"
+}
+array(3) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder"
+ [1]=>
+ string(%d) "%s/glob_variation/wonder12345"
+ [2]=>
+ string(%d) "%s/glob_variation/wonder;123456"
+}
+array(3) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder"
+ [1]=>
+ string(%d) "%s/glob_variation/wonder12345"
+ [2]=>
+ string(%d) "%s/glob_variation/wonder;123456"
+}
+array(3) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder"
+ [1]=>
+ string(%d) "%s/glob_variation/wonder12345"
+ [2]=>
+ string(%d) "%s/glob_variation/wonder;123456"
+}
+
+-- Iteration 2 --
+array(3) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder"
+ [1]=>
+ string(%d) "%s/glob_variation/wonder12345"
+ [2]=>
+ string(%d) "%s/glob_variation/wonder;123456"
+}
+array(3) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder/"
+ [1]=>
+ string(%d) "%s/glob_variation/wonder12345"
+ [2]=>
+ string(%d) "%s/glob_variation/wonder;123456"
+}
+array(3) {
+ [0]=>
+ string(%d) "%s"
+ [1]=>
+ string(%d) "%s"
+ [2]=>
+ string(%d) "%s"
+}
+array(3) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder"
+ [1]=>
+ string(%d) "%s/glob_variation/wonder12345"
+ [2]=>
+ string(%d) "%s/glob_variation/wonder;123456"
+}
+array(3) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder"
+ [1]=>
+ string(%d) "%s/glob_variation/wonder12345"
+ [2]=>
+ string(%d) "%s/glob_variation/wonder;123456"
+}
+array(3) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder"
+ [1]=>
+ string(%d) "%s/glob_variation/wonder12345"
+ [2]=>
+ string(%d) "%s/glob_variation/wonder;123456"
+}
+
+-- Iteration 3 --
+array(2) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder12345"
+ [1]=>
+ string(%d) "%s/glob_variation/wonder;123456"
+}
+array(2) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder12345"
+ [1]=>
+ string(%d) "%s/glob_variation/wonder;123456"
+}
+array(2) {
+ [0]=>
+ string(%d) "%s"
+ [1]=>
+ string(%d) "%s"
+}
+array(2) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder12345"
+ [1]=>
+ string(%d) "%s/glob_variation/wonder;123456"
+}
+array(2) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder12345"
+ [1]=>
+ string(%d) "%s/glob_variation/wonder;123456"
+}
+array(2) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder12345"
+ [1]=>
+ string(%d) "%s/glob_variation/wonder;123456"
+}
+
+-- Iteration 4 --
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(1) {
+ [0]=>
+ string(%d) "%s/glob_variation/*der5"
+}
+array(0) {
+}
+array(0) {
+}
+
+-- Iteration 5 --
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(1) {
+ [0]=>
+ string(%d) "%s/glob_variation/??onder*"
+}
+array(0) {
+}
+array(0) {
+}
+
+-- Iteration 6 --
+array(3) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder"
+ [1]=>
+ string(%d) "%s/glob_variation/wonder12345"
+ [2]=>
+ string(%d) "%s/glob_variation/wonder;123456"
+}
+array(3) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder/"
+ [1]=>
+ string(%d) "%s/glob_variation/wonder12345"
+ [2]=>
+ string(%d) "%s/glob_variation/wonder;123456"
+}
+array(3) {
+ [0]=>
+ string(%d) "%s"
+ [1]=>
+ string(%d) "%s"
+ [2]=>
+ string(%d) "%s"
+}
+array(3) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder"
+ [1]=>
+ string(%d) "%s/glob_variation/wonder12345"
+ [2]=>
+ string(%d) "%s/glob_variation/wonder;123456"
+}
+array(3) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder"
+ [1]=>
+ string(%d) "%s/glob_variation/wonder12345"
+ [2]=>
+ string(%d) "%s/glob_variation/wonder;123456"
+}
+array(3) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder"
+ [1]=>
+ string(%d) "%s/glob_variation/wonder12345"
+ [2]=>
+ string(%d) "%s/glob_variation/wonder;123456"
+}
+
+-- Iteration 7 --
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(1) {
+ [0]=>
+ string(%d) "%s/glob_variation/++onder*"
+}
+array(0) {
+}
+array(0) {
+}
+
+-- Iteration 8 --
+
+Warning: glob() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+
+Warning: glob() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+
+Warning: glob() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+
+Warning: glob() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+
+Warning: glob() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+
+Warning: glob() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+
+-- Iteration 9 --
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(1) {
+ [0]=>
+ string(%d) "$file_path/glob_variation/wonder5"
+}
+array(0) {
+}
+array(0) {
+}
+
+-- Iteration 10 --
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(1) {
+ [0]=>
+ string(%d) "%s/glob_variation/?wonder?"
+}
+array(0) {
+}
+array(0) {
+}
+
+-- Iteration 11 --
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(1) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder?"
+}
+array(0) {
+}
+array(0) {
+}
+
+-- Iteration 12 --
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(1) {
+ [0]=>
+ string(%d) "1"
+}
+array(0) {
+}
+array(0) {
+}
+
+*** Testing glob() with pattern within braces ***
+array(1) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder12345"
+}
+
+*** Testing glob() on directories ***
+-- Iteration 1 --
+array(1) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder1"
+}
+-- Iteration 2 --
+array(1) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder1"
+}
+-- Iteration 3 --
+array(1) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder1"
+}
+-- Iteration 4 --
+array(0) {
+}
+-- Iteration 5 --
+array(0) {
+}
+-- Iteration 6 --
+array(1) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder1"
+}
+-- Iteration 7 --
+array(0) {
+}
+-- Iteration 8 --
+
+Warning: glob() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+-- Iteration 9 --
+array(0) {
+}
+-- Iteration 10 --
+array(0) {
+}
+-- Iteration 11 --
+array(1) {
+ [0]=>
+ string(%d) "%s/glob_variation/wonder1"
+}
+-- Iteration 12 --
+array(0) {
+}
+Done
diff --git a/ext/standard/tests/file/glob_variation2.phpt b/ext/standard/tests/file/glob_variation2.phpt
new file mode 100644
index 0000000..f95fd17
--- /dev/null
+++ b/ext/standard/tests/file/glob_variation2.phpt
@@ -0,0 +1,57 @@
+--TEST--
+Test glob() function with relative path
+--FILE--
+<?php
+/* Prototype: array glob ( string $pattern [, int $flags] );
+ Description: Find pathnames matching a pattern
+*/
+
+$file_path = dirname(__FILE__);
+
+// temp dirname used here
+$dir_name = 'glob_test';
+
+// create temp directory
+mkdir("$file_path/$dir_name");
+
+// create temp file
+$fp = fopen("$file_path/$dir_name/file.text", "w");
+fclose($fp);
+
+echo "Testing glob() with relative paths:\n";
+
+chdir("$file_path/$dir_name");
+var_dump( glob("./*") );
+var_dump( glob("../$dir_name/*"));
+
+chdir("$file_path");
+var_dump( glob("$dir_name/*"));
+var_dump( glob("$dir_name"));
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink("$file_path/glob_test/file.text");
+rmdir("$file_path/glob_test/");
+?>
+--EXPECT--
+Testing glob() with relative paths:
+array(1) {
+ [0]=>
+ string(11) "./file.text"
+}
+array(1) {
+ [0]=>
+ string(22) "../glob_test/file.text"
+}
+array(1) {
+ [0]=>
+ string(19) "glob_test/file.text"
+}
+array(1) {
+ [0]=>
+ string(9) "glob_test"
+}
+Done
diff --git a/ext/standard/tests/file/include_streams.phpt b/ext/standard/tests/file/include_streams.phpt
new file mode 100644
index 0000000..e459c6a
--- /dev/null
+++ b/ext/standard/tests/file/include_streams.phpt
@@ -0,0 +1,130 @@
+--TEST--
+Stream wrappers in include_path
+--FILE--
+<?php
+$data1 = $data2 = $data3 = $data4 = $data5 = $data6 = <<<'EOD'
+<?php echo __FILE__ . "\n";?>
+
+EOD;
+/*<?*/
+
+class mystream
+{
+ public $path;
+ public $mode;
+ public $options;
+
+ public $position;
+ public $varname;
+
+ function url_stat($path, $flags) {
+ return array();
+ }
+
+ function stream_stat() {
+ return array();
+ }
+
+ function stream_open($path, $mode, $options, &$opened_path)
+ {
+ $this->path = $path;
+ $this->mode = $mode;
+ $this->options = $options;
+
+ $split = parse_url($path);
+ if ($split["host"] !== b"GLOBALS" ||
+ empty($split["path"]) ||
+ empty($GLOBALS[substr($split["path"],1)])) {
+ return false;
+ }
+ $this->varname = substr($split["path"],1);
+
+ if (strchr($mode, 'a'))
+ $this->position = strlen($GLOBALS[$this->varname]);
+ else
+ $this->position = 0;
+
+ return true;
+ }
+
+ function stream_read($count)
+ {
+ $ret = substr($GLOBALS[$this->varname], $this->position, $count);
+ $this->position += strlen($ret);
+ return $ret;
+ }
+
+ function stream_tell()
+ {
+ return $this->position;
+ }
+
+ function stream_eof()
+ {
+ return $this->position >= strlen($GLOBALS[$this->varname]);
+ }
+
+ function stream_seek($offset, $whence)
+ {
+ switch($whence) {
+ case SEEK_SET:
+ if ($offset < strlen($GLOBALS[$this->varname]) && $offset >= 0) {
+ $this->position = $offset;
+ return true;
+ } else {
+ return false;
+ }
+ break;
+ case SEEK_CUR:
+ if ($offset >= 0) {
+ $this->position += $offset;
+ return true;
+ } else {
+ return false;
+ }
+ break;
+ case SEEK_END:
+ if (strlen($GLOBALS[$this->varname]) + $offset >= 0) {
+ $this->position = strlen($GLOBALS[$this->varname]) + $offset;
+ return true;
+ } else {
+ return false;
+ }
+ break;
+ default:
+ return false;
+ }
+ }
+
+}
+
+if (!stream_wrapper_register("test", "mystream")) {
+ die("test wrapper registration failed");
+}
+
+echo file_get_contents("test://GLOBALS/data1");
+include("test://GLOBALS/data1");
+include_once("test://GLOBALS/data2");
+include_once("test://GLOBALS/data2");
+$include_path = get_include_path();
+set_include_path($include_path . PATH_SEPARATOR . "test://GLOBALS");
+echo file_get_contents("data3", true);
+include("data3");
+include_once("data4");
+include_once("data4");
+set_include_path("test://GLOBALS" . PATH_SEPARATOR . $include_path);
+echo file_get_contents("data5", true);
+include("data5");
+include_once("data6");
+include_once("data6");
+?>
+--EXPECT--
+<?php echo __FILE__ . "\n";?>
+test://GLOBALS/data1
+test://GLOBALS/data2
+<?php echo __FILE__ . "\n";?>
+test://GLOBALS/data3
+test://GLOBALS/data4
+<?php echo __FILE__ . "\n";?>
+test://GLOBALS/data5
+test://GLOBALS/data6
diff --git a/ext/standard/tests/file/include_userstream_001.phpt b/ext/standard/tests/file/include_userstream_001.phpt
new file mode 100644
index 0000000..d805afd
--- /dev/null
+++ b/ext/standard/tests/file/include_userstream_001.phpt
@@ -0,0 +1,82 @@
+--TEST--
+User streams and include()
+--INI--
+allow_url_fopen=1
+allow_url_include=0
+--FILE--
+<?php
+class test {
+ private $data = '<?php echo "Hello World\n";?>';
+ private $pos;
+
+ function stream_open($path, $mode, $options, &$opened_path)
+ {
+ if (strchr($mode, 'a'))
+ $this->pos = strlen($this->data);
+ else
+ $this->po = 0;
+
+ return true;
+ }
+
+ function stream_read($count)
+ {
+ $ret = substr($this->data, $this->pos, $count);
+ $this->pos += strlen($ret);
+ return $ret;
+ }
+
+ function stream_tell()
+ {
+ return $this->pos;
+ }
+
+ function stream_eof()
+ {
+ return $this->pos >= strlen($this->data);
+ }
+
+ function stream_seek($offset, $whence)
+ {
+ switch($whence) {
+ case SEEK_SET:
+ if ($offset < $this->data && $offset >= 0) {
+ $this->pos = $offset;
+ return true;
+ } else {
+ return false;
+ }
+ break;
+ case SEEK_CUR:
+ if ($offset >= 0) {
+ $this->pos += $offset;
+ return true;
+ } else {
+ return false;
+ }
+ break;
+ case SEEK_END:
+ if (strlen($this->data) + $offset >= 0) {
+ $this->pos = strlen($this->data) + $offset;
+ return true;
+ } else {
+ return false;
+ }
+ break;
+ default:
+ return false;
+ }
+ }
+
+}
+
+stream_register_wrapper("test1", "test", STREAM_IS_URL);
+stream_register_wrapper("test2", "test");
+echo @file_get_contents("test1://hello"),"\n";
+@include "test1://hello";
+echo @file_get_contents("test2://hello"),"\n";
+@include "test2://hello";
+--EXPECT--
+<?php echo "Hello World\n";?>
+<?php echo "Hello World\n";?>
+Hello World
diff --git a/ext/standard/tests/file/include_userstream_002.phpt b/ext/standard/tests/file/include_userstream_002.phpt
new file mode 100644
index 0000000..4841d39
--- /dev/null
+++ b/ext/standard/tests/file/include_userstream_002.phpt
@@ -0,0 +1,106 @@
+--TEST--
+local user streams must not be able to open() url's
+--INI--
+allow_url_fopen=1
+allow_url_include=0
+--FILE--
+<?php
+class test {
+ private $data = '<?php echo "Hello World\n";?>';
+ private $pos;
+ private $stream = null;
+
+ function stream_open($path, $mode, $options, &$opened_path)
+ {
+ if (strpos($path, "test2://") === 0) {
+ $this->stream = fopen("test1://".substr($path, 8), $mode);
+ return !empty($this->stream);
+ }
+ if (strchr($mode, 'a'))
+ $this->pos = strlen($this->data);
+ else
+ $this->po = 0;
+
+ return true;
+ }
+
+ function stream_read($count)
+ {
+ if (!empty($this->stream)) {
+ return fread($this->stream, $count);
+ }
+ $ret = substr($this->data, $this->pos, $count);
+ $this->pos += strlen($ret);
+ return $ret;
+ }
+
+ function stream_tell()
+ {
+ if (!empty($this->stream)) {
+ return ftell($this->stream);
+ }
+ return $this->pos;
+ }
+
+ function stream_eof()
+ {
+ if (!empty($this->stream)) {
+ return feof($this->stream);
+ }
+ return $this->pos >= strlen($this->data);
+ }
+
+ function stream_seek($offset, $whence)
+ {
+ if (!empty($this->stream)) {
+ return fseek($this->stream, $offset, $whence);
+ }
+ switch($whence) {
+ case SEEK_SET:
+ if ($offset < $this->data && $offset >= 0) {
+ $this->pos = $offset;
+ return true;
+ } else {
+ return false;
+ }
+ break;
+ case SEEK_CUR:
+ if ($offset >= 0) {
+ $this->pos += $offset;
+ return true;
+ } else {
+ return false;
+ }
+ break;
+ case SEEK_END:
+ if (strlen($this->data) + $offset >= 0) {
+ $this->pos = strlen($this->data) + $offset;
+ return true;
+ } else {
+ return false;
+ }
+ break;
+ default:
+ return false;
+ }
+ }
+
+}
+
+stream_register_wrapper("test1", "test", STREAM_IS_URL);
+stream_register_wrapper("test2", "test");
+echo @file_get_contents("test1://hello"),"\n";
+@include "test1://hello";
+echo @file_get_contents("test2://hello"),"\n";
+include "test2://hello";
+--EXPECTF--
+<?php echo "Hello World\n";?>
+<?php echo "Hello World\n";?>
+
+Warning: fopen(): test1:// wrapper is disabled in the server configuration by allow_url_include=0 in %sinclude_userstream_002.php on line 10
+
+Warning: fopen(test1://hello): failed to open stream: no suitable wrapper could be found in %sinclude_userstream_002.php on line 10
+
+Warning: include(test2://hello): failed to open stream: "test::stream_open" call failed in %sinclude_userstream_002.php on line 89
+
+Warning: include(): Failed opening 'test2://hello' for inclusion (include_path='%s') in %sinclude_userstream_002.php on line 89
diff --git a/ext/standard/tests/file/include_userstream_003.phpt b/ext/standard/tests/file/include_userstream_003.phpt
new file mode 100644
index 0000000..2b439cf
--- /dev/null
+++ b/ext/standard/tests/file/include_userstream_003.phpt
@@ -0,0 +1,121 @@
+--TEST--
+allow_url_fopen disabled
+--INI--
+allow_url_fopen=0
+allow_url_include=1
+--FILE--
+<?php
+class test {
+ private $data = '<?php echo "Hello World\n";?>';
+ private $pos;
+ private $stream = null;
+
+ function stream_open($path, $mode, $options, &$opened_path)
+ {
+ if (strpos($path, "test2://") === 0) {
+ $this->stream = fopen("test1://".substr($path, 8), $mode);
+ return !empty($this->stream);
+ }
+ if (strchr($mode, 'a'))
+ $this->pos = strlen($this->data);
+ else
+ $this->po = 0;
+
+ return true;
+ }
+
+ function stream_read($count)
+ {
+ if (!empty($this->stream)) {
+ return fread($this->stream, $count);
+ }
+ $ret = substr($this->data, $this->pos, $count);
+ $this->pos += strlen($ret);
+ return $ret;
+ }
+
+ function stream_tell()
+ {
+ if (!empty($this->stream)) {
+ return ftell($this->stream);
+ }
+ return $this->pos;
+ }
+
+ function stream_eof()
+ {
+ if (!empty($this->stream)) {
+ return feof($this->stream);
+ }
+ return $this->pos >= strlen($this->data);
+ }
+
+ function stream_seek($offset, $whence)
+ {
+ if (!empty($this->stream)) {
+ return fseek($this->stream, $offset, $whence);
+ }
+ switch($whence) {
+ case SEEK_SET:
+ if ($offset < $this->data && $offset >= 0) {
+ $this->pos = $offset;
+ return true;
+ } else {
+ return false;
+ }
+ break;
+ case SEEK_CUR:
+ if ($offset >= 0) {
+ $this->pos += $offset;
+ return true;
+ } else {
+ return false;
+ }
+ break;
+ case SEEK_END:
+ if (strlen($this->data) + $offset >= 0) {
+ $this->pos = strlen($this->data) + $offset;
+ return true;
+ } else {
+ return false;
+ }
+ break;
+ default:
+ return false;
+ }
+ }
+
+}
+
+stream_register_wrapper("test1", "test", STREAM_IS_URL);
+stream_register_wrapper("test2", "test");
+echo file_get_contents("test1://hello"),"\n";
+include "test1://hello";
+echo file_get_contents("test2://hello"),"\n";
+include "test2://hello";
+--EXPECTF--
+Warning: file_get_contents(): test1:// wrapper is disabled in the server configuration by allow_url_fopen=0 in %sinclude_userstream_003.php on line 86
+
+Warning: file_get_contents(test1://hello): failed to open stream: no suitable wrapper could be found in %sinclude_userstream_003.php on line 86
+
+
+Warning: include(): test1:// wrapper is disabled in the server configuration by allow_url_fopen=0 in %sinclude_userstream_003.php on line 87
+
+Warning: include(test1://hello): failed to open stream: no suitable wrapper could be found in %sinclude_userstream_003.php on line 87
+
+Warning: include(): Failed opening 'test1://hello' for inclusion (include_path='%s') in %sinclude_userstream_003.php on line 87
+
+Warning: fopen(): test1:// wrapper is disabled in the server configuration by allow_url_fopen=0 in %sinclude_userstream_003.php on line 10
+
+Warning: fopen(test1://hello): failed to open stream: no suitable wrapper could be found in %sinclude_userstream_003.php on line 10
+
+Warning: file_get_contents(test2://hello): failed to open stream: "test::stream_open" call failed in %sinclude_userstream_003.php on line 88
+
+
+Warning: fopen(): test1:// wrapper is disabled in the server configuration by allow_url_fopen=0 in %sinclude_userstream_003.php on line 10
+
+Warning: fopen(test1://hello): failed to open stream: no suitable wrapper could be found in %sinclude_userstream_003.php on line 10
+
+Warning: include(test2://hello): failed to open stream: "test::stream_open" call failed in %sinclude_userstream_003.php on line 89
+
+Warning: include(): Failed opening 'test2://hello' for inclusion (include_path='%s') in %sinclude_userstream_003.php on line 89 \ No newline at end of file
diff --git a/ext/standard/tests/file/is_dir_basic.phpt b/ext/standard/tests/file/is_dir_basic.phpt
new file mode 100644
index 0000000..7265d50
--- /dev/null
+++ b/ext/standard/tests/file/is_dir_basic.phpt
@@ -0,0 +1,43 @@
+--TEST--
+Test is_dir() function: basic functionality
+--FILE--
+<?php
+/* Prototype: bool is_dir ( string $filename );
+ Description: Tells whether the filename is a regular file
+ Returns TRUE if the filename exists and is a regular file
+*/
+
+echo "*** Testing is_dir(): basic functionality ***\n";
+$file_path = dirname(__FILE__);
+var_dump( is_dir($file_path) );
+clearstatcache();
+var_dump( is_dir(".") );
+var_dump( is_dir(__FILE__) ); // expected: bool(false)
+
+$dir_name = $file_path."/is_dir_basic";
+mkdir($dir_name);
+var_dump( is_dir($dir_name) );
+
+echo "*** Testing is_dir() for its return value type ***\n";
+var_dump( is_bool( is_dir($file_path) ) );
+var_dump( is_bool( is_dir("/no/such/dir") ) );
+
+echo "*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$dir_name = $file_path."/is_dir_basic";
+rmdir($dir_name);
+?>
+
+--EXPECTF--
+*** Testing is_dir(): basic functionality ***
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+*** Testing is_dir() for its return value type ***
+bool(true)
+bool(true)
+*** Done ***
diff --git a/ext/standard/tests/file/is_dir_error.phpt b/ext/standard/tests/file/is_dir_error.phpt
new file mode 100644
index 0000000..6040767
--- /dev/null
+++ b/ext/standard/tests/file/is_dir_error.phpt
@@ -0,0 +1,35 @@
+--TEST--
+Test is_dir() function: error conditions
+--FILE--
+<?php
+/* Prototype: bool is_dir ( string $filename );
+ * Description: Tells whether the filename is a regular file
+ * Returns TRUE if the filename exists and is a regular file
+ */
+
+echo "*** Testing is_dir() error conditions ***";
+var_dump( is_dir() ); // Zero No. of args
+
+$dir_name = dirname(__FILE__)."/is_dir_error";
+mkdir($dir_name);
+var_dump( is_dir($dir_name, "is_dir_error1") ); // args > expected no.of args
+
+/* Non-existing dir */
+var_dump( is_dir("/no/such/dir") );
+
+echo "*** Done ***";
+?>
+
+--CLEAN--
+<?php
+rmdir(dirname(__FILE__)."/is_dir_error");
+?>
+--EXPECTF--
+*** Testing is_dir() error conditions ***
+Warning: is_dir() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: is_dir() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+bool(false)
+*** Done ***
diff --git a/ext/standard/tests/file/is_dir_variation1.phpt b/ext/standard/tests/file/is_dir_variation1.phpt
new file mode 100644
index 0000000..1a0b556
--- /dev/null
+++ b/ext/standard/tests/file/is_dir_variation1.phpt
@@ -0,0 +1,42 @@
+--TEST--
+Test is_dir() function: usage variations - dir/subdir
+--FILE--
+<?php
+/* Prototype: bool is_dir ( string $dirname );
+ Description: Tells whether the dirname is a directory
+ Returns TRUE if the dirname exists and is a directory, FALSE otherwise.
+*/
+
+/* Testing is_dir() with base and sub dirs */
+
+$file_path = dirname(__FILE__);
+
+echo "-- Testing is_dir() with an empty dir --\n";
+$dirname = $file_path."/is_dir_variation1";
+mkdir($dirname);
+var_dump( is_dir($dirname) );
+clearstatcache();
+
+echo "-- Testing is_dir() with a subdir in base dir --\n";
+$subdirname = $dirname."/is_dir_variation1_sub";
+mkdir($subdirname);
+var_dump( is_dir($subdirname) );
+var_dump( is_dir($dirname) );
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$dir_name = $file_path."/is_dir_variation1";
+rmdir($dir_name."/is_dir_variation1_sub");
+rmdir($dir_name);
+?>
+--EXPECTF--
+-- Testing is_dir() with an empty dir --
+bool(true)
+-- Testing is_dir() with a subdir in base dir --
+bool(true)
+bool(true)
+
+*** Done ***
diff --git a/ext/standard/tests/file/is_dir_variation2.phpt b/ext/standard/tests/file/is_dir_variation2.phpt
new file mode 100644
index 0000000..65efeab
--- /dev/null
+++ b/ext/standard/tests/file/is_dir_variation2.phpt
@@ -0,0 +1,96 @@
+--TEST--
+Test is_dir() function: usage variations - links
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip Do not run on Windows');
+}
+--FILE--
+<?php
+/* Prototype: bool is_dir ( string $dirname );
+ Description: Tells whether the dirname is a directory
+ Returns TRUE if the dirname exists and is a directory, FALSE otherwise.
+*/
+
+/* Testing is_dir() with dir, soft & hard link to dir,
+ and with file, soft & hard link to file */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Testing is_dir() with dir and links to dir ***\n";
+echo "-- With dir --\n";
+$dirname = $file_path."/is_dir_variation2";
+mkdir($dirname);
+var_dump( is_dir($dirname) );
+clearstatcache();
+
+echo "-- With symlink --\n";
+symlink($file_path."/is_dir_variation2", $file_path."/is_dir_variation2_symlink");
+var_dump( is_dir($file_path."/is_dir_variation2_symlink") ); //is_dir() resolves symlinks
+clearstatcache();
+
+echo "-- With hardlink --";
+link($file_path."/is_dir_variation2", $file_path."/is_dir_variation2_link"); //Not permitted to create hard-link to a dir
+var_dump( is_dir($file_path."/is_dir_variation2_link") );
+clearstatcache();
+
+echo "\n*** Testing is_dir() with file and links to a file ***\n";
+echo "-- With file --\n";
+$filename = $file_path."/is_dir_variation2.tmp";
+fclose( fopen($filename, "w") );
+var_dump( is_dir($filename) );
+clearstatcache();
+
+echo "-- With symlink --\n";
+symlink($file_path."/is_dir_variation2.tmp", $file_path."/is_dir_variation2_symlink.tmp");
+var_dump( is_dir($file_path."/is_dir_variation2_symlink.tmp") );
+clearstatcache();
+
+echo "-- With hardlink --\n";
+link($file_path."/is_dir_variation2.tmp", $file_path."/is_dir_variation2_link.tmp");
+var_dump( is_dir($file_path."/is_dir_variation2_link.tmp") );
+clearstatcache();
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+if(file_exists($file_path."/is_dir_variation2_symlink")) {
+ unlink($file_path."/is_dir_variation2_symlink");
+}
+if(file_exists($file_path."/is_dir_variation2_symlink")) {
+ unlink($file_path."/is_dir_variation2_symlink");
+}
+if(file_exists($file_path."/is_dir_variation2_symlink.tmp")) {
+ unlink($file_path."/is_dir_variation2_symlink.tmp");
+}
+if(file_exists($file_path."/is_dir_variation2_link.tmp")) {
+ unlink($file_path."/is_dir_variation2_link.tmp");
+}
+if(file_exists($file_path."/is_dir_variation2.tmp")) {
+ unlink($file_path."/is_dir_variation2.tmp");
+}
+if(file_exists($file_path."/is_dir_variation2")) {
+ rmdir($file_path."/is_dir_variation2");
+}
+?>
+--EXPECTF--
+*** Testing is_dir() with dir and links to dir ***
+-- With dir --
+bool(true)
+-- With symlink --
+bool(true)
+-- With hardlink --
+Warning: link(): %s in %s on line %d
+bool(false)
+
+*** Testing is_dir() with file and links to a file ***
+-- With file --
+bool(false)
+-- With symlink --
+bool(false)
+-- With hardlink --
+bool(false)
+
+*** Done ***
diff --git a/ext/standard/tests/file/is_dir_variation3.phpt b/ext/standard/tests/file/is_dir_variation3.phpt
new file mode 100644
index 0000000..41826ad
--- /dev/null
+++ b/ext/standard/tests/file/is_dir_variation3.phpt
@@ -0,0 +1,51 @@
+--TEST--
+Test is_dir() function: usage variations - invalid arguments
+--FILE--
+<?php
+/* Prototype: bool is_dir ( string $dirname );
+ Description: Tells whether the dirname is a directory
+ Returns TRUE if the dirname exists and is a directory, FALSE otherwise.
+*/
+
+/* Passing invalid arguments to is_dir() */
+
+$dir_handle = opendir( dirname(__FILE__) );
+
+echo "*** Testing is_dir() with Invalid arguments: expected bool(false) ***\n";
+$dirnames = array(
+ /* Invalid dirnames */
+ -2.34555,
+ TRUE,
+ FALSE,
+ NULL,
+ " ",
+ $dir_handle,
+
+ /* scalars */
+ 0,
+ 1234
+);
+
+/* loop through to test each element the above array */
+foreach($dirnames as $dirname) {
+ var_dump( is_dir($dirname) );
+}
+closedir($dir_handle);
+
+echo "\n*** Done ***";
+?>
+--EXPECTF--
+*** Testing is_dir() with Invalid arguments: expected bool(false) ***
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+Warning: is_dir() expects parameter 1 to be a valid path, resource given in %s on line %d
+NULL
+bool(false)
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/is_dir_variation4.phpt b/ext/standard/tests/file/is_dir_variation4.phpt
new file mode 100644
index 0000000..5c0be48
--- /dev/null
+++ b/ext/standard/tests/file/is_dir_variation4.phpt
@@ -0,0 +1,89 @@
+--TEST--
+Test is_dir() function: usage variations - diff. path notations
+--FILE--
+<?php
+/* Prototype: bool is_dir ( string $dirname );
+ Description: Tells whether the dirname is a directory
+ Returns TRUE if the dirname exists and is a directory, FALSE otherwise.
+*/
+
+/* Passing dir names with different notations, using slashes, wild-card chars */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Testing is_dir() with different notations of dir names ***";
+$dir_name = "/is_dir_variation4";
+mkdir($file_path.$dir_name);
+
+$dirs_arr = array(
+ "is_dir_variation4",
+ "./is_dir_variation4",
+
+ /* Testing a file trailing slash */
+ "is_dir_variation4/",
+ "./is_dir_variation4/",
+
+ /* Testing file with double trailing slashes */
+ "is_dir_variation4//",
+ "./is_dir_variation4//",
+ ".//is_dir_variation4//",
+ "is_dir_vari*",
+
+ /* Testing Binary safe */
+ "./is_dir_variation4/".chr(0),
+ "is_dir_variation4\0"
+);
+
+$count = 1;
+/* loop through to test each element the above array */
+foreach($dirs_arr as $dir) {
+ echo "\n-- Iteration $count --\n";
+ var_dump( is_dir($file_path."/".$dir ) );
+ $count++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$dir_name = $file_path."/is_dir_variation4";
+rmdir($dir_name);
+?>
+--EXPECTF--
+*** Testing is_dir() with different notations of dir names ***
+-- Iteration 1 --
+bool(true)
+
+-- Iteration 2 --
+bool(true)
+
+-- Iteration 3 --
+bool(true)
+
+-- Iteration 4 --
+bool(true)
+
+-- Iteration 5 --
+bool(true)
+
+-- Iteration 6 --
+bool(true)
+
+-- Iteration 7 --
+bool(true)
+
+-- Iteration 8 --
+bool(false)
+
+-- Iteration 9 --
+
+Warning: is_dir() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+
+-- Iteration 10 --
+
+Warning: is_dir() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+
+*** Done ***
diff --git a/ext/standard/tests/file/is_executable_basic-win32.phpt b/ext/standard/tests/file/is_executable_basic-win32.phpt
new file mode 100644
index 0000000..1462368
--- /dev/null
+++ b/ext/standard/tests/file/is_executable_basic-win32.phpt
@@ -0,0 +1,1064 @@
+--TEST--
+Test is_executable() function: basic functionality
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip.. only for Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: bool is_executable ( string $filename );
+ Description: Tells whether the filename is executable
+*/
+require dirname(__FILE__).'/file.inc';
+
+echo "*** Testing is_executable(): basic functionality ***\n";
+
+// create a file
+$filename = dirname(__FILE__)."/is_executable.tmp";
+create_file($filename);
+
+$counter = 1;
+/* loop to check if the file with new mode is executable
+ using is_executable() */
+for($mode = 0000; $mode <= 0777; $mode++) {
+ echo "-- Changing mode of file to $mode --\n";
+ chmod($filename, $mode); // change mode of file
+ var_dump( is_executable($filename) );
+ $counter++;
+ clearstatcache();
+}
+
+// delete the temp file
+delete_file($filename);
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing is_executable(): basic functionality ***
+-- Changing mode of file to 0 --
+bool(false)
+-- Changing mode of file to 1 --
+bool(false)
+-- Changing mode of file to 2 --
+bool(false)
+-- Changing mode of file to 3 --
+bool(false)
+-- Changing mode of file to 4 --
+bool(false)
+-- Changing mode of file to 5 --
+bool(false)
+-- Changing mode of file to 6 --
+bool(false)
+-- Changing mode of file to 7 --
+bool(false)
+-- Changing mode of file to 8 --
+bool(false)
+-- Changing mode of file to 9 --
+bool(false)
+-- Changing mode of file to 10 --
+bool(false)
+-- Changing mode of file to 11 --
+bool(false)
+-- Changing mode of file to 12 --
+bool(false)
+-- Changing mode of file to 13 --
+bool(false)
+-- Changing mode of file to 14 --
+bool(false)
+-- Changing mode of file to 15 --
+bool(false)
+-- Changing mode of file to 16 --
+bool(false)
+-- Changing mode of file to 17 --
+bool(false)
+-- Changing mode of file to 18 --
+bool(false)
+-- Changing mode of file to 19 --
+bool(false)
+-- Changing mode of file to 20 --
+bool(false)
+-- Changing mode of file to 21 --
+bool(false)
+-- Changing mode of file to 22 --
+bool(false)
+-- Changing mode of file to 23 --
+bool(false)
+-- Changing mode of file to 24 --
+bool(false)
+-- Changing mode of file to 25 --
+bool(false)
+-- Changing mode of file to 26 --
+bool(false)
+-- Changing mode of file to 27 --
+bool(false)
+-- Changing mode of file to 28 --
+bool(false)
+-- Changing mode of file to 29 --
+bool(false)
+-- Changing mode of file to 30 --
+bool(false)
+-- Changing mode of file to 31 --
+bool(false)
+-- Changing mode of file to 32 --
+bool(false)
+-- Changing mode of file to 33 --
+bool(false)
+-- Changing mode of file to 34 --
+bool(false)
+-- Changing mode of file to 35 --
+bool(false)
+-- Changing mode of file to 36 --
+bool(false)
+-- Changing mode of file to 37 --
+bool(false)
+-- Changing mode of file to 38 --
+bool(false)
+-- Changing mode of file to 39 --
+bool(false)
+-- Changing mode of file to 40 --
+bool(false)
+-- Changing mode of file to 41 --
+bool(false)
+-- Changing mode of file to 42 --
+bool(false)
+-- Changing mode of file to 43 --
+bool(false)
+-- Changing mode of file to 44 --
+bool(false)
+-- Changing mode of file to 45 --
+bool(false)
+-- Changing mode of file to 46 --
+bool(false)
+-- Changing mode of file to 47 --
+bool(false)
+-- Changing mode of file to 48 --
+bool(false)
+-- Changing mode of file to 49 --
+bool(false)
+-- Changing mode of file to 50 --
+bool(false)
+-- Changing mode of file to 51 --
+bool(false)
+-- Changing mode of file to 52 --
+bool(false)
+-- Changing mode of file to 53 --
+bool(false)
+-- Changing mode of file to 54 --
+bool(false)
+-- Changing mode of file to 55 --
+bool(false)
+-- Changing mode of file to 56 --
+bool(false)
+-- Changing mode of file to 57 --
+bool(false)
+-- Changing mode of file to 58 --
+bool(false)
+-- Changing mode of file to 59 --
+bool(false)
+-- Changing mode of file to 60 --
+bool(false)
+-- Changing mode of file to 61 --
+bool(false)
+-- Changing mode of file to 62 --
+bool(false)
+-- Changing mode of file to 63 --
+bool(false)
+-- Changing mode of file to 64 --
+bool(false)
+-- Changing mode of file to 65 --
+bool(false)
+-- Changing mode of file to 66 --
+bool(false)
+-- Changing mode of file to 67 --
+bool(false)
+-- Changing mode of file to 68 --
+bool(false)
+-- Changing mode of file to 69 --
+bool(false)
+-- Changing mode of file to 70 --
+bool(false)
+-- Changing mode of file to 71 --
+bool(false)
+-- Changing mode of file to 72 --
+bool(false)
+-- Changing mode of file to 73 --
+bool(false)
+-- Changing mode of file to 74 --
+bool(false)
+-- Changing mode of file to 75 --
+bool(false)
+-- Changing mode of file to 76 --
+bool(false)
+-- Changing mode of file to 77 --
+bool(false)
+-- Changing mode of file to 78 --
+bool(false)
+-- Changing mode of file to 79 --
+bool(false)
+-- Changing mode of file to 80 --
+bool(false)
+-- Changing mode of file to 81 --
+bool(false)
+-- Changing mode of file to 82 --
+bool(false)
+-- Changing mode of file to 83 --
+bool(false)
+-- Changing mode of file to 84 --
+bool(false)
+-- Changing mode of file to 85 --
+bool(false)
+-- Changing mode of file to 86 --
+bool(false)
+-- Changing mode of file to 87 --
+bool(false)
+-- Changing mode of file to 88 --
+bool(false)
+-- Changing mode of file to 89 --
+bool(false)
+-- Changing mode of file to 90 --
+bool(false)
+-- Changing mode of file to 91 --
+bool(false)
+-- Changing mode of file to 92 --
+bool(false)
+-- Changing mode of file to 93 --
+bool(false)
+-- Changing mode of file to 94 --
+bool(false)
+-- Changing mode of file to 95 --
+bool(false)
+-- Changing mode of file to 96 --
+bool(false)
+-- Changing mode of file to 97 --
+bool(false)
+-- Changing mode of file to 98 --
+bool(false)
+-- Changing mode of file to 99 --
+bool(false)
+-- Changing mode of file to 100 --
+bool(false)
+-- Changing mode of file to 101 --
+bool(false)
+-- Changing mode of file to 102 --
+bool(false)
+-- Changing mode of file to 103 --
+bool(false)
+-- Changing mode of file to 104 --
+bool(false)
+-- Changing mode of file to 105 --
+bool(false)
+-- Changing mode of file to 106 --
+bool(false)
+-- Changing mode of file to 107 --
+bool(false)
+-- Changing mode of file to 108 --
+bool(false)
+-- Changing mode of file to 109 --
+bool(false)
+-- Changing mode of file to 110 --
+bool(false)
+-- Changing mode of file to 111 --
+bool(false)
+-- Changing mode of file to 112 --
+bool(false)
+-- Changing mode of file to 113 --
+bool(false)
+-- Changing mode of file to 114 --
+bool(false)
+-- Changing mode of file to 115 --
+bool(false)
+-- Changing mode of file to 116 --
+bool(false)
+-- Changing mode of file to 117 --
+bool(false)
+-- Changing mode of file to 118 --
+bool(false)
+-- Changing mode of file to 119 --
+bool(false)
+-- Changing mode of file to 120 --
+bool(false)
+-- Changing mode of file to 121 --
+bool(false)
+-- Changing mode of file to 122 --
+bool(false)
+-- Changing mode of file to 123 --
+bool(false)
+-- Changing mode of file to 124 --
+bool(false)
+-- Changing mode of file to 125 --
+bool(false)
+-- Changing mode of file to 126 --
+bool(false)
+-- Changing mode of file to 127 --
+bool(false)
+-- Changing mode of file to 128 --
+bool(false)
+-- Changing mode of file to 129 --
+bool(false)
+-- Changing mode of file to 130 --
+bool(false)
+-- Changing mode of file to 131 --
+bool(false)
+-- Changing mode of file to 132 --
+bool(false)
+-- Changing mode of file to 133 --
+bool(false)
+-- Changing mode of file to 134 --
+bool(false)
+-- Changing mode of file to 135 --
+bool(false)
+-- Changing mode of file to 136 --
+bool(false)
+-- Changing mode of file to 137 --
+bool(false)
+-- Changing mode of file to 138 --
+bool(false)
+-- Changing mode of file to 139 --
+bool(false)
+-- Changing mode of file to 140 --
+bool(false)
+-- Changing mode of file to 141 --
+bool(false)
+-- Changing mode of file to 142 --
+bool(false)
+-- Changing mode of file to 143 --
+bool(false)
+-- Changing mode of file to 144 --
+bool(false)
+-- Changing mode of file to 145 --
+bool(false)
+-- Changing mode of file to 146 --
+bool(false)
+-- Changing mode of file to 147 --
+bool(false)
+-- Changing mode of file to 148 --
+bool(false)
+-- Changing mode of file to 149 --
+bool(false)
+-- Changing mode of file to 150 --
+bool(false)
+-- Changing mode of file to 151 --
+bool(false)
+-- Changing mode of file to 152 --
+bool(false)
+-- Changing mode of file to 153 --
+bool(false)
+-- Changing mode of file to 154 --
+bool(false)
+-- Changing mode of file to 155 --
+bool(false)
+-- Changing mode of file to 156 --
+bool(false)
+-- Changing mode of file to 157 --
+bool(false)
+-- Changing mode of file to 158 --
+bool(false)
+-- Changing mode of file to 159 --
+bool(false)
+-- Changing mode of file to 160 --
+bool(false)
+-- Changing mode of file to 161 --
+bool(false)
+-- Changing mode of file to 162 --
+bool(false)
+-- Changing mode of file to 163 --
+bool(false)
+-- Changing mode of file to 164 --
+bool(false)
+-- Changing mode of file to 165 --
+bool(false)
+-- Changing mode of file to 166 --
+bool(false)
+-- Changing mode of file to 167 --
+bool(false)
+-- Changing mode of file to 168 --
+bool(false)
+-- Changing mode of file to 169 --
+bool(false)
+-- Changing mode of file to 170 --
+bool(false)
+-- Changing mode of file to 171 --
+bool(false)
+-- Changing mode of file to 172 --
+bool(false)
+-- Changing mode of file to 173 --
+bool(false)
+-- Changing mode of file to 174 --
+bool(false)
+-- Changing mode of file to 175 --
+bool(false)
+-- Changing mode of file to 176 --
+bool(false)
+-- Changing mode of file to 177 --
+bool(false)
+-- Changing mode of file to 178 --
+bool(false)
+-- Changing mode of file to 179 --
+bool(false)
+-- Changing mode of file to 180 --
+bool(false)
+-- Changing mode of file to 181 --
+bool(false)
+-- Changing mode of file to 182 --
+bool(false)
+-- Changing mode of file to 183 --
+bool(false)
+-- Changing mode of file to 184 --
+bool(false)
+-- Changing mode of file to 185 --
+bool(false)
+-- Changing mode of file to 186 --
+bool(false)
+-- Changing mode of file to 187 --
+bool(false)
+-- Changing mode of file to 188 --
+bool(false)
+-- Changing mode of file to 189 --
+bool(false)
+-- Changing mode of file to 190 --
+bool(false)
+-- Changing mode of file to 191 --
+bool(false)
+-- Changing mode of file to 192 --
+bool(false)
+-- Changing mode of file to 193 --
+bool(false)
+-- Changing mode of file to 194 --
+bool(false)
+-- Changing mode of file to 195 --
+bool(false)
+-- Changing mode of file to 196 --
+bool(false)
+-- Changing mode of file to 197 --
+bool(false)
+-- Changing mode of file to 198 --
+bool(false)
+-- Changing mode of file to 199 --
+bool(false)
+-- Changing mode of file to 200 --
+bool(false)
+-- Changing mode of file to 201 --
+bool(false)
+-- Changing mode of file to 202 --
+bool(false)
+-- Changing mode of file to 203 --
+bool(false)
+-- Changing mode of file to 204 --
+bool(false)
+-- Changing mode of file to 205 --
+bool(false)
+-- Changing mode of file to 206 --
+bool(false)
+-- Changing mode of file to 207 --
+bool(false)
+-- Changing mode of file to 208 --
+bool(false)
+-- Changing mode of file to 209 --
+bool(false)
+-- Changing mode of file to 210 --
+bool(false)
+-- Changing mode of file to 211 --
+bool(false)
+-- Changing mode of file to 212 --
+bool(false)
+-- Changing mode of file to 213 --
+bool(false)
+-- Changing mode of file to 214 --
+bool(false)
+-- Changing mode of file to 215 --
+bool(false)
+-- Changing mode of file to 216 --
+bool(false)
+-- Changing mode of file to 217 --
+bool(false)
+-- Changing mode of file to 218 --
+bool(false)
+-- Changing mode of file to 219 --
+bool(false)
+-- Changing mode of file to 220 --
+bool(false)
+-- Changing mode of file to 221 --
+bool(false)
+-- Changing mode of file to 222 --
+bool(false)
+-- Changing mode of file to 223 --
+bool(false)
+-- Changing mode of file to 224 --
+bool(false)
+-- Changing mode of file to 225 --
+bool(false)
+-- Changing mode of file to 226 --
+bool(false)
+-- Changing mode of file to 227 --
+bool(false)
+-- Changing mode of file to 228 --
+bool(false)
+-- Changing mode of file to 229 --
+bool(false)
+-- Changing mode of file to 230 --
+bool(false)
+-- Changing mode of file to 231 --
+bool(false)
+-- Changing mode of file to 232 --
+bool(false)
+-- Changing mode of file to 233 --
+bool(false)
+-- Changing mode of file to 234 --
+bool(false)
+-- Changing mode of file to 235 --
+bool(false)
+-- Changing mode of file to 236 --
+bool(false)
+-- Changing mode of file to 237 --
+bool(false)
+-- Changing mode of file to 238 --
+bool(false)
+-- Changing mode of file to 239 --
+bool(false)
+-- Changing mode of file to 240 --
+bool(false)
+-- Changing mode of file to 241 --
+bool(false)
+-- Changing mode of file to 242 --
+bool(false)
+-- Changing mode of file to 243 --
+bool(false)
+-- Changing mode of file to 244 --
+bool(false)
+-- Changing mode of file to 245 --
+bool(false)
+-- Changing mode of file to 246 --
+bool(false)
+-- Changing mode of file to 247 --
+bool(false)
+-- Changing mode of file to 248 --
+bool(false)
+-- Changing mode of file to 249 --
+bool(false)
+-- Changing mode of file to 250 --
+bool(false)
+-- Changing mode of file to 251 --
+bool(false)
+-- Changing mode of file to 252 --
+bool(false)
+-- Changing mode of file to 253 --
+bool(false)
+-- Changing mode of file to 254 --
+bool(false)
+-- Changing mode of file to 255 --
+bool(false)
+-- Changing mode of file to 256 --
+bool(false)
+-- Changing mode of file to 257 --
+bool(false)
+-- Changing mode of file to 258 --
+bool(false)
+-- Changing mode of file to 259 --
+bool(false)
+-- Changing mode of file to 260 --
+bool(false)
+-- Changing mode of file to 261 --
+bool(false)
+-- Changing mode of file to 262 --
+bool(false)
+-- Changing mode of file to 263 --
+bool(false)
+-- Changing mode of file to 264 --
+bool(false)
+-- Changing mode of file to 265 --
+bool(false)
+-- Changing mode of file to 266 --
+bool(false)
+-- Changing mode of file to 267 --
+bool(false)
+-- Changing mode of file to 268 --
+bool(false)
+-- Changing mode of file to 269 --
+bool(false)
+-- Changing mode of file to 270 --
+bool(false)
+-- Changing mode of file to 271 --
+bool(false)
+-- Changing mode of file to 272 --
+bool(false)
+-- Changing mode of file to 273 --
+bool(false)
+-- Changing mode of file to 274 --
+bool(false)
+-- Changing mode of file to 275 --
+bool(false)
+-- Changing mode of file to 276 --
+bool(false)
+-- Changing mode of file to 277 --
+bool(false)
+-- Changing mode of file to 278 --
+bool(false)
+-- Changing mode of file to 279 --
+bool(false)
+-- Changing mode of file to 280 --
+bool(false)
+-- Changing mode of file to 281 --
+bool(false)
+-- Changing mode of file to 282 --
+bool(false)
+-- Changing mode of file to 283 --
+bool(false)
+-- Changing mode of file to 284 --
+bool(false)
+-- Changing mode of file to 285 --
+bool(false)
+-- Changing mode of file to 286 --
+bool(false)
+-- Changing mode of file to 287 --
+bool(false)
+-- Changing mode of file to 288 --
+bool(false)
+-- Changing mode of file to 289 --
+bool(false)
+-- Changing mode of file to 290 --
+bool(false)
+-- Changing mode of file to 291 --
+bool(false)
+-- Changing mode of file to 292 --
+bool(false)
+-- Changing mode of file to 293 --
+bool(false)
+-- Changing mode of file to 294 --
+bool(false)
+-- Changing mode of file to 295 --
+bool(false)
+-- Changing mode of file to 296 --
+bool(false)
+-- Changing mode of file to 297 --
+bool(false)
+-- Changing mode of file to 298 --
+bool(false)
+-- Changing mode of file to 299 --
+bool(false)
+-- Changing mode of file to 300 --
+bool(false)
+-- Changing mode of file to 301 --
+bool(false)
+-- Changing mode of file to 302 --
+bool(false)
+-- Changing mode of file to 303 --
+bool(false)
+-- Changing mode of file to 304 --
+bool(false)
+-- Changing mode of file to 305 --
+bool(false)
+-- Changing mode of file to 306 --
+bool(false)
+-- Changing mode of file to 307 --
+bool(false)
+-- Changing mode of file to 308 --
+bool(false)
+-- Changing mode of file to 309 --
+bool(false)
+-- Changing mode of file to 310 --
+bool(false)
+-- Changing mode of file to 311 --
+bool(false)
+-- Changing mode of file to 312 --
+bool(false)
+-- Changing mode of file to 313 --
+bool(false)
+-- Changing mode of file to 314 --
+bool(false)
+-- Changing mode of file to 315 --
+bool(false)
+-- Changing mode of file to 316 --
+bool(false)
+-- Changing mode of file to 317 --
+bool(false)
+-- Changing mode of file to 318 --
+bool(false)
+-- Changing mode of file to 319 --
+bool(false)
+-- Changing mode of file to 320 --
+bool(false)
+-- Changing mode of file to 321 --
+bool(false)
+-- Changing mode of file to 322 --
+bool(false)
+-- Changing mode of file to 323 --
+bool(false)
+-- Changing mode of file to 324 --
+bool(false)
+-- Changing mode of file to 325 --
+bool(false)
+-- Changing mode of file to 326 --
+bool(false)
+-- Changing mode of file to 327 --
+bool(false)
+-- Changing mode of file to 328 --
+bool(false)
+-- Changing mode of file to 329 --
+bool(false)
+-- Changing mode of file to 330 --
+bool(false)
+-- Changing mode of file to 331 --
+bool(false)
+-- Changing mode of file to 332 --
+bool(false)
+-- Changing mode of file to 333 --
+bool(false)
+-- Changing mode of file to 334 --
+bool(false)
+-- Changing mode of file to 335 --
+bool(false)
+-- Changing mode of file to 336 --
+bool(false)
+-- Changing mode of file to 337 --
+bool(false)
+-- Changing mode of file to 338 --
+bool(false)
+-- Changing mode of file to 339 --
+bool(false)
+-- Changing mode of file to 340 --
+bool(false)
+-- Changing mode of file to 341 --
+bool(false)
+-- Changing mode of file to 342 --
+bool(false)
+-- Changing mode of file to 343 --
+bool(false)
+-- Changing mode of file to 344 --
+bool(false)
+-- Changing mode of file to 345 --
+bool(false)
+-- Changing mode of file to 346 --
+bool(false)
+-- Changing mode of file to 347 --
+bool(false)
+-- Changing mode of file to 348 --
+bool(false)
+-- Changing mode of file to 349 --
+bool(false)
+-- Changing mode of file to 350 --
+bool(false)
+-- Changing mode of file to 351 --
+bool(false)
+-- Changing mode of file to 352 --
+bool(false)
+-- Changing mode of file to 353 --
+bool(false)
+-- Changing mode of file to 354 --
+bool(false)
+-- Changing mode of file to 355 --
+bool(false)
+-- Changing mode of file to 356 --
+bool(false)
+-- Changing mode of file to 357 --
+bool(false)
+-- Changing mode of file to 358 --
+bool(false)
+-- Changing mode of file to 359 --
+bool(false)
+-- Changing mode of file to 360 --
+bool(false)
+-- Changing mode of file to 361 --
+bool(false)
+-- Changing mode of file to 362 --
+bool(false)
+-- Changing mode of file to 363 --
+bool(false)
+-- Changing mode of file to 364 --
+bool(false)
+-- Changing mode of file to 365 --
+bool(false)
+-- Changing mode of file to 366 --
+bool(false)
+-- Changing mode of file to 367 --
+bool(false)
+-- Changing mode of file to 368 --
+bool(false)
+-- Changing mode of file to 369 --
+bool(false)
+-- Changing mode of file to 370 --
+bool(false)
+-- Changing mode of file to 371 --
+bool(false)
+-- Changing mode of file to 372 --
+bool(false)
+-- Changing mode of file to 373 --
+bool(false)
+-- Changing mode of file to 374 --
+bool(false)
+-- Changing mode of file to 375 --
+bool(false)
+-- Changing mode of file to 376 --
+bool(false)
+-- Changing mode of file to 377 --
+bool(false)
+-- Changing mode of file to 378 --
+bool(false)
+-- Changing mode of file to 379 --
+bool(false)
+-- Changing mode of file to 380 --
+bool(false)
+-- Changing mode of file to 381 --
+bool(false)
+-- Changing mode of file to 382 --
+bool(false)
+-- Changing mode of file to 383 --
+bool(false)
+-- Changing mode of file to 384 --
+bool(false)
+-- Changing mode of file to 385 --
+bool(false)
+-- Changing mode of file to 386 --
+bool(false)
+-- Changing mode of file to 387 --
+bool(false)
+-- Changing mode of file to 388 --
+bool(false)
+-- Changing mode of file to 389 --
+bool(false)
+-- Changing mode of file to 390 --
+bool(false)
+-- Changing mode of file to 391 --
+bool(false)
+-- Changing mode of file to 392 --
+bool(false)
+-- Changing mode of file to 393 --
+bool(false)
+-- Changing mode of file to 394 --
+bool(false)
+-- Changing mode of file to 395 --
+bool(false)
+-- Changing mode of file to 396 --
+bool(false)
+-- Changing mode of file to 397 --
+bool(false)
+-- Changing mode of file to 398 --
+bool(false)
+-- Changing mode of file to 399 --
+bool(false)
+-- Changing mode of file to 400 --
+bool(false)
+-- Changing mode of file to 401 --
+bool(false)
+-- Changing mode of file to 402 --
+bool(false)
+-- Changing mode of file to 403 --
+bool(false)
+-- Changing mode of file to 404 --
+bool(false)
+-- Changing mode of file to 405 --
+bool(false)
+-- Changing mode of file to 406 --
+bool(false)
+-- Changing mode of file to 407 --
+bool(false)
+-- Changing mode of file to 408 --
+bool(false)
+-- Changing mode of file to 409 --
+bool(false)
+-- Changing mode of file to 410 --
+bool(false)
+-- Changing mode of file to 411 --
+bool(false)
+-- Changing mode of file to 412 --
+bool(false)
+-- Changing mode of file to 413 --
+bool(false)
+-- Changing mode of file to 414 --
+bool(false)
+-- Changing mode of file to 415 --
+bool(false)
+-- Changing mode of file to 416 --
+bool(false)
+-- Changing mode of file to 417 --
+bool(false)
+-- Changing mode of file to 418 --
+bool(false)
+-- Changing mode of file to 419 --
+bool(false)
+-- Changing mode of file to 420 --
+bool(false)
+-- Changing mode of file to 421 --
+bool(false)
+-- Changing mode of file to 422 --
+bool(false)
+-- Changing mode of file to 423 --
+bool(false)
+-- Changing mode of file to 424 --
+bool(false)
+-- Changing mode of file to 425 --
+bool(false)
+-- Changing mode of file to 426 --
+bool(false)
+-- Changing mode of file to 427 --
+bool(false)
+-- Changing mode of file to 428 --
+bool(false)
+-- Changing mode of file to 429 --
+bool(false)
+-- Changing mode of file to 430 --
+bool(false)
+-- Changing mode of file to 431 --
+bool(false)
+-- Changing mode of file to 432 --
+bool(false)
+-- Changing mode of file to 433 --
+bool(false)
+-- Changing mode of file to 434 --
+bool(false)
+-- Changing mode of file to 435 --
+bool(false)
+-- Changing mode of file to 436 --
+bool(false)
+-- Changing mode of file to 437 --
+bool(false)
+-- Changing mode of file to 438 --
+bool(false)
+-- Changing mode of file to 439 --
+bool(false)
+-- Changing mode of file to 440 --
+bool(false)
+-- Changing mode of file to 441 --
+bool(false)
+-- Changing mode of file to 442 --
+bool(false)
+-- Changing mode of file to 443 --
+bool(false)
+-- Changing mode of file to 444 --
+bool(false)
+-- Changing mode of file to 445 --
+bool(false)
+-- Changing mode of file to 446 --
+bool(false)
+-- Changing mode of file to 447 --
+bool(false)
+-- Changing mode of file to 448 --
+bool(false)
+-- Changing mode of file to 449 --
+bool(false)
+-- Changing mode of file to 450 --
+bool(false)
+-- Changing mode of file to 451 --
+bool(false)
+-- Changing mode of file to 452 --
+bool(false)
+-- Changing mode of file to 453 --
+bool(false)
+-- Changing mode of file to 454 --
+bool(false)
+-- Changing mode of file to 455 --
+bool(false)
+-- Changing mode of file to 456 --
+bool(false)
+-- Changing mode of file to 457 --
+bool(false)
+-- Changing mode of file to 458 --
+bool(false)
+-- Changing mode of file to 459 --
+bool(false)
+-- Changing mode of file to 460 --
+bool(false)
+-- Changing mode of file to 461 --
+bool(false)
+-- Changing mode of file to 462 --
+bool(false)
+-- Changing mode of file to 463 --
+bool(false)
+-- Changing mode of file to 464 --
+bool(false)
+-- Changing mode of file to 465 --
+bool(false)
+-- Changing mode of file to 466 --
+bool(false)
+-- Changing mode of file to 467 --
+bool(false)
+-- Changing mode of file to 468 --
+bool(false)
+-- Changing mode of file to 469 --
+bool(false)
+-- Changing mode of file to 470 --
+bool(false)
+-- Changing mode of file to 471 --
+bool(false)
+-- Changing mode of file to 472 --
+bool(false)
+-- Changing mode of file to 473 --
+bool(false)
+-- Changing mode of file to 474 --
+bool(false)
+-- Changing mode of file to 475 --
+bool(false)
+-- Changing mode of file to 476 --
+bool(false)
+-- Changing mode of file to 477 --
+bool(false)
+-- Changing mode of file to 478 --
+bool(false)
+-- Changing mode of file to 479 --
+bool(false)
+-- Changing mode of file to 480 --
+bool(false)
+-- Changing mode of file to 481 --
+bool(false)
+-- Changing mode of file to 482 --
+bool(false)
+-- Changing mode of file to 483 --
+bool(false)
+-- Changing mode of file to 484 --
+bool(false)
+-- Changing mode of file to 485 --
+bool(false)
+-- Changing mode of file to 486 --
+bool(false)
+-- Changing mode of file to 487 --
+bool(false)
+-- Changing mode of file to 488 --
+bool(false)
+-- Changing mode of file to 489 --
+bool(false)
+-- Changing mode of file to 490 --
+bool(false)
+-- Changing mode of file to 491 --
+bool(false)
+-- Changing mode of file to 492 --
+bool(false)
+-- Changing mode of file to 493 --
+bool(false)
+-- Changing mode of file to 494 --
+bool(false)
+-- Changing mode of file to 495 --
+bool(false)
+-- Changing mode of file to 496 --
+bool(false)
+-- Changing mode of file to 497 --
+bool(false)
+-- Changing mode of file to 498 --
+bool(false)
+-- Changing mode of file to 499 --
+bool(false)
+-- Changing mode of file to 500 --
+bool(false)
+-- Changing mode of file to 501 --
+bool(false)
+-- Changing mode of file to 502 --
+bool(false)
+-- Changing mode of file to 503 --
+bool(false)
+-- Changing mode of file to 504 --
+bool(false)
+-- Changing mode of file to 505 --
+bool(false)
+-- Changing mode of file to 506 --
+bool(false)
+-- Changing mode of file to 507 --
+bool(false)
+-- Changing mode of file to 508 --
+bool(false)
+-- Changing mode of file to 509 --
+bool(false)
+-- Changing mode of file to 510 --
+bool(false)
+-- Changing mode of file to 511 --
+bool(false)
+Done
diff --git a/ext/standard/tests/file/is_executable_basic.phpt b/ext/standard/tests/file/is_executable_basic.phpt
new file mode 100644
index 0000000..c0a04e6
--- /dev/null
+++ b/ext/standard/tests/file/is_executable_basic.phpt
@@ -0,0 +1,1076 @@
+--TEST--
+Test is_executable() function: basic functionality
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip not for windows');
+}
+// Skip if being run by root (files are always readable, writeable and executable)
+$filename = dirname(__FILE__)."/is_readable_root_check.tmp";
+$fp = fopen($filename, 'w');
+fclose($fp);
+if(fileowner($filename) == 0) {
+ unlink ($filename);
+ die('skip cannot be run as root');
+}
+
+unlink($filename);
+?>
+--FILE--
+<?php
+/* Prototype: bool is_executable ( string $filename );
+ Description: Tells whether the filename is executable
+*/
+
+// include common file test functions
+require dirname(__FILE__).'/file.inc';
+
+echo "*** Testing is_executable(): basic functionality ***\n";
+
+// create a file
+$filename = dirname(__FILE__)."/is_executable.tmp";
+create_file($filename);
+
+$counter = 1;
+/* loop to check if the file with new mode is executable
+ using is_executable() */
+for($mode = 0000; $mode <= 0777; $mode++) {
+ echo "-- Changing mode of file to $mode --\n";
+ chmod($filename, $mode); // change mode of file
+ var_dump( is_executable($filename) );
+ $counter++;
+ clearstatcache();
+}
+
+// delete the temp file
+delete_file($filename);
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing is_executable(): basic functionality ***
+-- Changing mode of file to 0 --
+bool(false)
+-- Changing mode of file to 1 --
+bool(false)
+-- Changing mode of file to 2 --
+bool(false)
+-- Changing mode of file to 3 --
+bool(false)
+-- Changing mode of file to 4 --
+bool(false)
+-- Changing mode of file to 5 --
+bool(false)
+-- Changing mode of file to 6 --
+bool(false)
+-- Changing mode of file to 7 --
+bool(false)
+-- Changing mode of file to 8 --
+bool(false)
+-- Changing mode of file to 9 --
+bool(false)
+-- Changing mode of file to 10 --
+bool(false)
+-- Changing mode of file to 11 --
+bool(false)
+-- Changing mode of file to 12 --
+bool(false)
+-- Changing mode of file to 13 --
+bool(false)
+-- Changing mode of file to 14 --
+bool(false)
+-- Changing mode of file to 15 --
+bool(false)
+-- Changing mode of file to 16 --
+bool(false)
+-- Changing mode of file to 17 --
+bool(false)
+-- Changing mode of file to 18 --
+bool(false)
+-- Changing mode of file to 19 --
+bool(false)
+-- Changing mode of file to 20 --
+bool(false)
+-- Changing mode of file to 21 --
+bool(false)
+-- Changing mode of file to 22 --
+bool(false)
+-- Changing mode of file to 23 --
+bool(false)
+-- Changing mode of file to 24 --
+bool(false)
+-- Changing mode of file to 25 --
+bool(false)
+-- Changing mode of file to 26 --
+bool(false)
+-- Changing mode of file to 27 --
+bool(false)
+-- Changing mode of file to 28 --
+bool(false)
+-- Changing mode of file to 29 --
+bool(false)
+-- Changing mode of file to 30 --
+bool(false)
+-- Changing mode of file to 31 --
+bool(false)
+-- Changing mode of file to 32 --
+bool(false)
+-- Changing mode of file to 33 --
+bool(false)
+-- Changing mode of file to 34 --
+bool(false)
+-- Changing mode of file to 35 --
+bool(false)
+-- Changing mode of file to 36 --
+bool(false)
+-- Changing mode of file to 37 --
+bool(false)
+-- Changing mode of file to 38 --
+bool(false)
+-- Changing mode of file to 39 --
+bool(false)
+-- Changing mode of file to 40 --
+bool(false)
+-- Changing mode of file to 41 --
+bool(false)
+-- Changing mode of file to 42 --
+bool(false)
+-- Changing mode of file to 43 --
+bool(false)
+-- Changing mode of file to 44 --
+bool(false)
+-- Changing mode of file to 45 --
+bool(false)
+-- Changing mode of file to 46 --
+bool(false)
+-- Changing mode of file to 47 --
+bool(false)
+-- Changing mode of file to 48 --
+bool(false)
+-- Changing mode of file to 49 --
+bool(false)
+-- Changing mode of file to 50 --
+bool(false)
+-- Changing mode of file to 51 --
+bool(false)
+-- Changing mode of file to 52 --
+bool(false)
+-- Changing mode of file to 53 --
+bool(false)
+-- Changing mode of file to 54 --
+bool(false)
+-- Changing mode of file to 55 --
+bool(false)
+-- Changing mode of file to 56 --
+bool(false)
+-- Changing mode of file to 57 --
+bool(false)
+-- Changing mode of file to 58 --
+bool(false)
+-- Changing mode of file to 59 --
+bool(false)
+-- Changing mode of file to 60 --
+bool(false)
+-- Changing mode of file to 61 --
+bool(false)
+-- Changing mode of file to 62 --
+bool(false)
+-- Changing mode of file to 63 --
+bool(false)
+-- Changing mode of file to 64 --
+bool(true)
+-- Changing mode of file to 65 --
+bool(true)
+-- Changing mode of file to 66 --
+bool(true)
+-- Changing mode of file to 67 --
+bool(true)
+-- Changing mode of file to 68 --
+bool(true)
+-- Changing mode of file to 69 --
+bool(true)
+-- Changing mode of file to 70 --
+bool(true)
+-- Changing mode of file to 71 --
+bool(true)
+-- Changing mode of file to 72 --
+bool(true)
+-- Changing mode of file to 73 --
+bool(true)
+-- Changing mode of file to 74 --
+bool(true)
+-- Changing mode of file to 75 --
+bool(true)
+-- Changing mode of file to 76 --
+bool(true)
+-- Changing mode of file to 77 --
+bool(true)
+-- Changing mode of file to 78 --
+bool(true)
+-- Changing mode of file to 79 --
+bool(true)
+-- Changing mode of file to 80 --
+bool(true)
+-- Changing mode of file to 81 --
+bool(true)
+-- Changing mode of file to 82 --
+bool(true)
+-- Changing mode of file to 83 --
+bool(true)
+-- Changing mode of file to 84 --
+bool(true)
+-- Changing mode of file to 85 --
+bool(true)
+-- Changing mode of file to 86 --
+bool(true)
+-- Changing mode of file to 87 --
+bool(true)
+-- Changing mode of file to 88 --
+bool(true)
+-- Changing mode of file to 89 --
+bool(true)
+-- Changing mode of file to 90 --
+bool(true)
+-- Changing mode of file to 91 --
+bool(true)
+-- Changing mode of file to 92 --
+bool(true)
+-- Changing mode of file to 93 --
+bool(true)
+-- Changing mode of file to 94 --
+bool(true)
+-- Changing mode of file to 95 --
+bool(true)
+-- Changing mode of file to 96 --
+bool(true)
+-- Changing mode of file to 97 --
+bool(true)
+-- Changing mode of file to 98 --
+bool(true)
+-- Changing mode of file to 99 --
+bool(true)
+-- Changing mode of file to 100 --
+bool(true)
+-- Changing mode of file to 101 --
+bool(true)
+-- Changing mode of file to 102 --
+bool(true)
+-- Changing mode of file to 103 --
+bool(true)
+-- Changing mode of file to 104 --
+bool(true)
+-- Changing mode of file to 105 --
+bool(true)
+-- Changing mode of file to 106 --
+bool(true)
+-- Changing mode of file to 107 --
+bool(true)
+-- Changing mode of file to 108 --
+bool(true)
+-- Changing mode of file to 109 --
+bool(true)
+-- Changing mode of file to 110 --
+bool(true)
+-- Changing mode of file to 111 --
+bool(true)
+-- Changing mode of file to 112 --
+bool(true)
+-- Changing mode of file to 113 --
+bool(true)
+-- Changing mode of file to 114 --
+bool(true)
+-- Changing mode of file to 115 --
+bool(true)
+-- Changing mode of file to 116 --
+bool(true)
+-- Changing mode of file to 117 --
+bool(true)
+-- Changing mode of file to 118 --
+bool(true)
+-- Changing mode of file to 119 --
+bool(true)
+-- Changing mode of file to 120 --
+bool(true)
+-- Changing mode of file to 121 --
+bool(true)
+-- Changing mode of file to 122 --
+bool(true)
+-- Changing mode of file to 123 --
+bool(true)
+-- Changing mode of file to 124 --
+bool(true)
+-- Changing mode of file to 125 --
+bool(true)
+-- Changing mode of file to 126 --
+bool(true)
+-- Changing mode of file to 127 --
+bool(true)
+-- Changing mode of file to 128 --
+bool(false)
+-- Changing mode of file to 129 --
+bool(false)
+-- Changing mode of file to 130 --
+bool(false)
+-- Changing mode of file to 131 --
+bool(false)
+-- Changing mode of file to 132 --
+bool(false)
+-- Changing mode of file to 133 --
+bool(false)
+-- Changing mode of file to 134 --
+bool(false)
+-- Changing mode of file to 135 --
+bool(false)
+-- Changing mode of file to 136 --
+bool(false)
+-- Changing mode of file to 137 --
+bool(false)
+-- Changing mode of file to 138 --
+bool(false)
+-- Changing mode of file to 139 --
+bool(false)
+-- Changing mode of file to 140 --
+bool(false)
+-- Changing mode of file to 141 --
+bool(false)
+-- Changing mode of file to 142 --
+bool(false)
+-- Changing mode of file to 143 --
+bool(false)
+-- Changing mode of file to 144 --
+bool(false)
+-- Changing mode of file to 145 --
+bool(false)
+-- Changing mode of file to 146 --
+bool(false)
+-- Changing mode of file to 147 --
+bool(false)
+-- Changing mode of file to 148 --
+bool(false)
+-- Changing mode of file to 149 --
+bool(false)
+-- Changing mode of file to 150 --
+bool(false)
+-- Changing mode of file to 151 --
+bool(false)
+-- Changing mode of file to 152 --
+bool(false)
+-- Changing mode of file to 153 --
+bool(false)
+-- Changing mode of file to 154 --
+bool(false)
+-- Changing mode of file to 155 --
+bool(false)
+-- Changing mode of file to 156 --
+bool(false)
+-- Changing mode of file to 157 --
+bool(false)
+-- Changing mode of file to 158 --
+bool(false)
+-- Changing mode of file to 159 --
+bool(false)
+-- Changing mode of file to 160 --
+bool(false)
+-- Changing mode of file to 161 --
+bool(false)
+-- Changing mode of file to 162 --
+bool(false)
+-- Changing mode of file to 163 --
+bool(false)
+-- Changing mode of file to 164 --
+bool(false)
+-- Changing mode of file to 165 --
+bool(false)
+-- Changing mode of file to 166 --
+bool(false)
+-- Changing mode of file to 167 --
+bool(false)
+-- Changing mode of file to 168 --
+bool(false)
+-- Changing mode of file to 169 --
+bool(false)
+-- Changing mode of file to 170 --
+bool(false)
+-- Changing mode of file to 171 --
+bool(false)
+-- Changing mode of file to 172 --
+bool(false)
+-- Changing mode of file to 173 --
+bool(false)
+-- Changing mode of file to 174 --
+bool(false)
+-- Changing mode of file to 175 --
+bool(false)
+-- Changing mode of file to 176 --
+bool(false)
+-- Changing mode of file to 177 --
+bool(false)
+-- Changing mode of file to 178 --
+bool(false)
+-- Changing mode of file to 179 --
+bool(false)
+-- Changing mode of file to 180 --
+bool(false)
+-- Changing mode of file to 181 --
+bool(false)
+-- Changing mode of file to 182 --
+bool(false)
+-- Changing mode of file to 183 --
+bool(false)
+-- Changing mode of file to 184 --
+bool(false)
+-- Changing mode of file to 185 --
+bool(false)
+-- Changing mode of file to 186 --
+bool(false)
+-- Changing mode of file to 187 --
+bool(false)
+-- Changing mode of file to 188 --
+bool(false)
+-- Changing mode of file to 189 --
+bool(false)
+-- Changing mode of file to 190 --
+bool(false)
+-- Changing mode of file to 191 --
+bool(false)
+-- Changing mode of file to 192 --
+bool(true)
+-- Changing mode of file to 193 --
+bool(true)
+-- Changing mode of file to 194 --
+bool(true)
+-- Changing mode of file to 195 --
+bool(true)
+-- Changing mode of file to 196 --
+bool(true)
+-- Changing mode of file to 197 --
+bool(true)
+-- Changing mode of file to 198 --
+bool(true)
+-- Changing mode of file to 199 --
+bool(true)
+-- Changing mode of file to 200 --
+bool(true)
+-- Changing mode of file to 201 --
+bool(true)
+-- Changing mode of file to 202 --
+bool(true)
+-- Changing mode of file to 203 --
+bool(true)
+-- Changing mode of file to 204 --
+bool(true)
+-- Changing mode of file to 205 --
+bool(true)
+-- Changing mode of file to 206 --
+bool(true)
+-- Changing mode of file to 207 --
+bool(true)
+-- Changing mode of file to 208 --
+bool(true)
+-- Changing mode of file to 209 --
+bool(true)
+-- Changing mode of file to 210 --
+bool(true)
+-- Changing mode of file to 211 --
+bool(true)
+-- Changing mode of file to 212 --
+bool(true)
+-- Changing mode of file to 213 --
+bool(true)
+-- Changing mode of file to 214 --
+bool(true)
+-- Changing mode of file to 215 --
+bool(true)
+-- Changing mode of file to 216 --
+bool(true)
+-- Changing mode of file to 217 --
+bool(true)
+-- Changing mode of file to 218 --
+bool(true)
+-- Changing mode of file to 219 --
+bool(true)
+-- Changing mode of file to 220 --
+bool(true)
+-- Changing mode of file to 221 --
+bool(true)
+-- Changing mode of file to 222 --
+bool(true)
+-- Changing mode of file to 223 --
+bool(true)
+-- Changing mode of file to 224 --
+bool(true)
+-- Changing mode of file to 225 --
+bool(true)
+-- Changing mode of file to 226 --
+bool(true)
+-- Changing mode of file to 227 --
+bool(true)
+-- Changing mode of file to 228 --
+bool(true)
+-- Changing mode of file to 229 --
+bool(true)
+-- Changing mode of file to 230 --
+bool(true)
+-- Changing mode of file to 231 --
+bool(true)
+-- Changing mode of file to 232 --
+bool(true)
+-- Changing mode of file to 233 --
+bool(true)
+-- Changing mode of file to 234 --
+bool(true)
+-- Changing mode of file to 235 --
+bool(true)
+-- Changing mode of file to 236 --
+bool(true)
+-- Changing mode of file to 237 --
+bool(true)
+-- Changing mode of file to 238 --
+bool(true)
+-- Changing mode of file to 239 --
+bool(true)
+-- Changing mode of file to 240 --
+bool(true)
+-- Changing mode of file to 241 --
+bool(true)
+-- Changing mode of file to 242 --
+bool(true)
+-- Changing mode of file to 243 --
+bool(true)
+-- Changing mode of file to 244 --
+bool(true)
+-- Changing mode of file to 245 --
+bool(true)
+-- Changing mode of file to 246 --
+bool(true)
+-- Changing mode of file to 247 --
+bool(true)
+-- Changing mode of file to 248 --
+bool(true)
+-- Changing mode of file to 249 --
+bool(true)
+-- Changing mode of file to 250 --
+bool(true)
+-- Changing mode of file to 251 --
+bool(true)
+-- Changing mode of file to 252 --
+bool(true)
+-- Changing mode of file to 253 --
+bool(true)
+-- Changing mode of file to 254 --
+bool(true)
+-- Changing mode of file to 255 --
+bool(true)
+-- Changing mode of file to 256 --
+bool(false)
+-- Changing mode of file to 257 --
+bool(false)
+-- Changing mode of file to 258 --
+bool(false)
+-- Changing mode of file to 259 --
+bool(false)
+-- Changing mode of file to 260 --
+bool(false)
+-- Changing mode of file to 261 --
+bool(false)
+-- Changing mode of file to 262 --
+bool(false)
+-- Changing mode of file to 263 --
+bool(false)
+-- Changing mode of file to 264 --
+bool(false)
+-- Changing mode of file to 265 --
+bool(false)
+-- Changing mode of file to 266 --
+bool(false)
+-- Changing mode of file to 267 --
+bool(false)
+-- Changing mode of file to 268 --
+bool(false)
+-- Changing mode of file to 269 --
+bool(false)
+-- Changing mode of file to 270 --
+bool(false)
+-- Changing mode of file to 271 --
+bool(false)
+-- Changing mode of file to 272 --
+bool(false)
+-- Changing mode of file to 273 --
+bool(false)
+-- Changing mode of file to 274 --
+bool(false)
+-- Changing mode of file to 275 --
+bool(false)
+-- Changing mode of file to 276 --
+bool(false)
+-- Changing mode of file to 277 --
+bool(false)
+-- Changing mode of file to 278 --
+bool(false)
+-- Changing mode of file to 279 --
+bool(false)
+-- Changing mode of file to 280 --
+bool(false)
+-- Changing mode of file to 281 --
+bool(false)
+-- Changing mode of file to 282 --
+bool(false)
+-- Changing mode of file to 283 --
+bool(false)
+-- Changing mode of file to 284 --
+bool(false)
+-- Changing mode of file to 285 --
+bool(false)
+-- Changing mode of file to 286 --
+bool(false)
+-- Changing mode of file to 287 --
+bool(false)
+-- Changing mode of file to 288 --
+bool(false)
+-- Changing mode of file to 289 --
+bool(false)
+-- Changing mode of file to 290 --
+bool(false)
+-- Changing mode of file to 291 --
+bool(false)
+-- Changing mode of file to 292 --
+bool(false)
+-- Changing mode of file to 293 --
+bool(false)
+-- Changing mode of file to 294 --
+bool(false)
+-- Changing mode of file to 295 --
+bool(false)
+-- Changing mode of file to 296 --
+bool(false)
+-- Changing mode of file to 297 --
+bool(false)
+-- Changing mode of file to 298 --
+bool(false)
+-- Changing mode of file to 299 --
+bool(false)
+-- Changing mode of file to 300 --
+bool(false)
+-- Changing mode of file to 301 --
+bool(false)
+-- Changing mode of file to 302 --
+bool(false)
+-- Changing mode of file to 303 --
+bool(false)
+-- Changing mode of file to 304 --
+bool(false)
+-- Changing mode of file to 305 --
+bool(false)
+-- Changing mode of file to 306 --
+bool(false)
+-- Changing mode of file to 307 --
+bool(false)
+-- Changing mode of file to 308 --
+bool(false)
+-- Changing mode of file to 309 --
+bool(false)
+-- Changing mode of file to 310 --
+bool(false)
+-- Changing mode of file to 311 --
+bool(false)
+-- Changing mode of file to 312 --
+bool(false)
+-- Changing mode of file to 313 --
+bool(false)
+-- Changing mode of file to 314 --
+bool(false)
+-- Changing mode of file to 315 --
+bool(false)
+-- Changing mode of file to 316 --
+bool(false)
+-- Changing mode of file to 317 --
+bool(false)
+-- Changing mode of file to 318 --
+bool(false)
+-- Changing mode of file to 319 --
+bool(false)
+-- Changing mode of file to 320 --
+bool(true)
+-- Changing mode of file to 321 --
+bool(true)
+-- Changing mode of file to 322 --
+bool(true)
+-- Changing mode of file to 323 --
+bool(true)
+-- Changing mode of file to 324 --
+bool(true)
+-- Changing mode of file to 325 --
+bool(true)
+-- Changing mode of file to 326 --
+bool(true)
+-- Changing mode of file to 327 --
+bool(true)
+-- Changing mode of file to 328 --
+bool(true)
+-- Changing mode of file to 329 --
+bool(true)
+-- Changing mode of file to 330 --
+bool(true)
+-- Changing mode of file to 331 --
+bool(true)
+-- Changing mode of file to 332 --
+bool(true)
+-- Changing mode of file to 333 --
+bool(true)
+-- Changing mode of file to 334 --
+bool(true)
+-- Changing mode of file to 335 --
+bool(true)
+-- Changing mode of file to 336 --
+bool(true)
+-- Changing mode of file to 337 --
+bool(true)
+-- Changing mode of file to 338 --
+bool(true)
+-- Changing mode of file to 339 --
+bool(true)
+-- Changing mode of file to 340 --
+bool(true)
+-- Changing mode of file to 341 --
+bool(true)
+-- Changing mode of file to 342 --
+bool(true)
+-- Changing mode of file to 343 --
+bool(true)
+-- Changing mode of file to 344 --
+bool(true)
+-- Changing mode of file to 345 --
+bool(true)
+-- Changing mode of file to 346 --
+bool(true)
+-- Changing mode of file to 347 --
+bool(true)
+-- Changing mode of file to 348 --
+bool(true)
+-- Changing mode of file to 349 --
+bool(true)
+-- Changing mode of file to 350 --
+bool(true)
+-- Changing mode of file to 351 --
+bool(true)
+-- Changing mode of file to 352 --
+bool(true)
+-- Changing mode of file to 353 --
+bool(true)
+-- Changing mode of file to 354 --
+bool(true)
+-- Changing mode of file to 355 --
+bool(true)
+-- Changing mode of file to 356 --
+bool(true)
+-- Changing mode of file to 357 --
+bool(true)
+-- Changing mode of file to 358 --
+bool(true)
+-- Changing mode of file to 359 --
+bool(true)
+-- Changing mode of file to 360 --
+bool(true)
+-- Changing mode of file to 361 --
+bool(true)
+-- Changing mode of file to 362 --
+bool(true)
+-- Changing mode of file to 363 --
+bool(true)
+-- Changing mode of file to 364 --
+bool(true)
+-- Changing mode of file to 365 --
+bool(true)
+-- Changing mode of file to 366 --
+bool(true)
+-- Changing mode of file to 367 --
+bool(true)
+-- Changing mode of file to 368 --
+bool(true)
+-- Changing mode of file to 369 --
+bool(true)
+-- Changing mode of file to 370 --
+bool(true)
+-- Changing mode of file to 371 --
+bool(true)
+-- Changing mode of file to 372 --
+bool(true)
+-- Changing mode of file to 373 --
+bool(true)
+-- Changing mode of file to 374 --
+bool(true)
+-- Changing mode of file to 375 --
+bool(true)
+-- Changing mode of file to 376 --
+bool(true)
+-- Changing mode of file to 377 --
+bool(true)
+-- Changing mode of file to 378 --
+bool(true)
+-- Changing mode of file to 379 --
+bool(true)
+-- Changing mode of file to 380 --
+bool(true)
+-- Changing mode of file to 381 --
+bool(true)
+-- Changing mode of file to 382 --
+bool(true)
+-- Changing mode of file to 383 --
+bool(true)
+-- Changing mode of file to 384 --
+bool(false)
+-- Changing mode of file to 385 --
+bool(false)
+-- Changing mode of file to 386 --
+bool(false)
+-- Changing mode of file to 387 --
+bool(false)
+-- Changing mode of file to 388 --
+bool(false)
+-- Changing mode of file to 389 --
+bool(false)
+-- Changing mode of file to 390 --
+bool(false)
+-- Changing mode of file to 391 --
+bool(false)
+-- Changing mode of file to 392 --
+bool(false)
+-- Changing mode of file to 393 --
+bool(false)
+-- Changing mode of file to 394 --
+bool(false)
+-- Changing mode of file to 395 --
+bool(false)
+-- Changing mode of file to 396 --
+bool(false)
+-- Changing mode of file to 397 --
+bool(false)
+-- Changing mode of file to 398 --
+bool(false)
+-- Changing mode of file to 399 --
+bool(false)
+-- Changing mode of file to 400 --
+bool(false)
+-- Changing mode of file to 401 --
+bool(false)
+-- Changing mode of file to 402 --
+bool(false)
+-- Changing mode of file to 403 --
+bool(false)
+-- Changing mode of file to 404 --
+bool(false)
+-- Changing mode of file to 405 --
+bool(false)
+-- Changing mode of file to 406 --
+bool(false)
+-- Changing mode of file to 407 --
+bool(false)
+-- Changing mode of file to 408 --
+bool(false)
+-- Changing mode of file to 409 --
+bool(false)
+-- Changing mode of file to 410 --
+bool(false)
+-- Changing mode of file to 411 --
+bool(false)
+-- Changing mode of file to 412 --
+bool(false)
+-- Changing mode of file to 413 --
+bool(false)
+-- Changing mode of file to 414 --
+bool(false)
+-- Changing mode of file to 415 --
+bool(false)
+-- Changing mode of file to 416 --
+bool(false)
+-- Changing mode of file to 417 --
+bool(false)
+-- Changing mode of file to 418 --
+bool(false)
+-- Changing mode of file to 419 --
+bool(false)
+-- Changing mode of file to 420 --
+bool(false)
+-- Changing mode of file to 421 --
+bool(false)
+-- Changing mode of file to 422 --
+bool(false)
+-- Changing mode of file to 423 --
+bool(false)
+-- Changing mode of file to 424 --
+bool(false)
+-- Changing mode of file to 425 --
+bool(false)
+-- Changing mode of file to 426 --
+bool(false)
+-- Changing mode of file to 427 --
+bool(false)
+-- Changing mode of file to 428 --
+bool(false)
+-- Changing mode of file to 429 --
+bool(false)
+-- Changing mode of file to 430 --
+bool(false)
+-- Changing mode of file to 431 --
+bool(false)
+-- Changing mode of file to 432 --
+bool(false)
+-- Changing mode of file to 433 --
+bool(false)
+-- Changing mode of file to 434 --
+bool(false)
+-- Changing mode of file to 435 --
+bool(false)
+-- Changing mode of file to 436 --
+bool(false)
+-- Changing mode of file to 437 --
+bool(false)
+-- Changing mode of file to 438 --
+bool(false)
+-- Changing mode of file to 439 --
+bool(false)
+-- Changing mode of file to 440 --
+bool(false)
+-- Changing mode of file to 441 --
+bool(false)
+-- Changing mode of file to 442 --
+bool(false)
+-- Changing mode of file to 443 --
+bool(false)
+-- Changing mode of file to 444 --
+bool(false)
+-- Changing mode of file to 445 --
+bool(false)
+-- Changing mode of file to 446 --
+bool(false)
+-- Changing mode of file to 447 --
+bool(false)
+-- Changing mode of file to 448 --
+bool(true)
+-- Changing mode of file to 449 --
+bool(true)
+-- Changing mode of file to 450 --
+bool(true)
+-- Changing mode of file to 451 --
+bool(true)
+-- Changing mode of file to 452 --
+bool(true)
+-- Changing mode of file to 453 --
+bool(true)
+-- Changing mode of file to 454 --
+bool(true)
+-- Changing mode of file to 455 --
+bool(true)
+-- Changing mode of file to 456 --
+bool(true)
+-- Changing mode of file to 457 --
+bool(true)
+-- Changing mode of file to 458 --
+bool(true)
+-- Changing mode of file to 459 --
+bool(true)
+-- Changing mode of file to 460 --
+bool(true)
+-- Changing mode of file to 461 --
+bool(true)
+-- Changing mode of file to 462 --
+bool(true)
+-- Changing mode of file to 463 --
+bool(true)
+-- Changing mode of file to 464 --
+bool(true)
+-- Changing mode of file to 465 --
+bool(true)
+-- Changing mode of file to 466 --
+bool(true)
+-- Changing mode of file to 467 --
+bool(true)
+-- Changing mode of file to 468 --
+bool(true)
+-- Changing mode of file to 469 --
+bool(true)
+-- Changing mode of file to 470 --
+bool(true)
+-- Changing mode of file to 471 --
+bool(true)
+-- Changing mode of file to 472 --
+bool(true)
+-- Changing mode of file to 473 --
+bool(true)
+-- Changing mode of file to 474 --
+bool(true)
+-- Changing mode of file to 475 --
+bool(true)
+-- Changing mode of file to 476 --
+bool(true)
+-- Changing mode of file to 477 --
+bool(true)
+-- Changing mode of file to 478 --
+bool(true)
+-- Changing mode of file to 479 --
+bool(true)
+-- Changing mode of file to 480 --
+bool(true)
+-- Changing mode of file to 481 --
+bool(true)
+-- Changing mode of file to 482 --
+bool(true)
+-- Changing mode of file to 483 --
+bool(true)
+-- Changing mode of file to 484 --
+bool(true)
+-- Changing mode of file to 485 --
+bool(true)
+-- Changing mode of file to 486 --
+bool(true)
+-- Changing mode of file to 487 --
+bool(true)
+-- Changing mode of file to 488 --
+bool(true)
+-- Changing mode of file to 489 --
+bool(true)
+-- Changing mode of file to 490 --
+bool(true)
+-- Changing mode of file to 491 --
+bool(true)
+-- Changing mode of file to 492 --
+bool(true)
+-- Changing mode of file to 493 --
+bool(true)
+-- Changing mode of file to 494 --
+bool(true)
+-- Changing mode of file to 495 --
+bool(true)
+-- Changing mode of file to 496 --
+bool(true)
+-- Changing mode of file to 497 --
+bool(true)
+-- Changing mode of file to 498 --
+bool(true)
+-- Changing mode of file to 499 --
+bool(true)
+-- Changing mode of file to 500 --
+bool(true)
+-- Changing mode of file to 501 --
+bool(true)
+-- Changing mode of file to 502 --
+bool(true)
+-- Changing mode of file to 503 --
+bool(true)
+-- Changing mode of file to 504 --
+bool(true)
+-- Changing mode of file to 505 --
+bool(true)
+-- Changing mode of file to 506 --
+bool(true)
+-- Changing mode of file to 507 --
+bool(true)
+-- Changing mode of file to 508 --
+bool(true)
+-- Changing mode of file to 509 --
+bool(true)
+-- Changing mode of file to 510 --
+bool(true)
+-- Changing mode of file to 511 --
+bool(true)
+Done
diff --git a/ext/standard/tests/file/is_executable_error.phpt b/ext/standard/tests/file/is_executable_error.phpt
new file mode 100644
index 0000000..4fb3dba
--- /dev/null
+++ b/ext/standard/tests/file/is_executable_error.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Test is_executable() function: error conditions
+--FILE--
+<?php
+/* Prototype: bool is_executable ( string $filename );
+ Description: Tells whether the filename is executable
+*/
+
+echo "*** Testing is_executable(): error conditions ***\n";
+var_dump( is_executable() ); // args < expected no of arguments
+
+var_dump( is_executable(1, 2) ); // args > expected no. of arguments
+
+echo "\n*** Testing is_exceutable() on non-existent directory ***\n";
+var_dump( is_executable(dirname(__FILE__)."/is_executable") );
+
+echo "Done\n";
+--EXPECTF--
+*** Testing is_executable(): error conditions ***
+
+Warning: is_executable() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: is_executable() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+
+*** Testing is_exceutable() on non-existent directory ***
+bool(false)
+Done
diff --git a/ext/standard/tests/file/is_executable_variation1.phpt b/ext/standard/tests/file/is_executable_variation1.phpt
new file mode 100644
index 0000000..231f1bf
--- /dev/null
+++ b/ext/standard/tests/file/is_executable_variation1.phpt
@@ -0,0 +1,92 @@
+--TEST--
+Test is_executable() function: usage variations - diff. path notations
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip not for windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: bool is_executable ( string $filename );
+ Description: Tells whether the filename is executable
+*/
+
+/* test is_executable() with file having different filepath notation */
+
+require dirname(__FILE__).'/file.inc';
+echo "*** Testing is_executable(): usage variations ***\n";
+
+$file_path = dirname(__FILE__);
+mkdir("$file_path/is_executable_variation1");
+
+// create a new temporary file
+$fp = fopen("$file_path/is_executable_variation1/bar.tmp", "w");
+fclose($fp);
+
+/* array of files checked to see if they are executable files
+ using is_executable() function */
+$files_arr = array(
+ "$file_path/is_executable_variation1/bar.tmp",
+
+ /* Testing a file with trailing slash */
+ "$file_path/is_executable_variation1/bar.tmp/",
+
+ /* Testing file with double slashes */
+ "$file_path/is_executable_variation1//bar.tmp",
+ "$file_path/is_executable_variation1/*.tmp",
+ "$file_path/is_executable_variation1/b*.tmp",
+
+ /* Testing Binary safe */
+ "$file_path/is_executable_variation1".chr(0)."bar.temp",
+ "$file_path".chr(0)."is_executable_variation1/bar.temp",
+ "$file_path/is_executable_variation1x000/",
+
+ /* Testing directories */
+ ".", // current directory, exp: bool(true)
+ "$file_path/is_executable_variation1" // temp directory, exp: bool(true)
+);
+$counter = 1;
+/* loop through to test each element in the above array
+ is an executable file */
+foreach($files_arr as $file) {
+ echo "-- Iteration $counter --\n";
+ var_dump( is_executable($file) );
+ $counter++;
+ clearstatcache();
+}
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/is_executable_variation1/bar.tmp");
+rmdir(dirname(__FILE__)."/is_executable_variation1/");
+?>
+--EXPECTF--
+*** Testing is_executable(): usage variations ***
+-- Iteration 1 --
+bool(false)
+-- Iteration 2 --
+bool(false)
+-- Iteration 3 --
+bool(false)
+-- Iteration 4 --
+bool(false)
+-- Iteration 5 --
+bool(false)
+-- Iteration 6 --
+
+Warning: is_executable() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+-- Iteration 7 --
+
+Warning: is_executable() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+-- Iteration 8 --
+bool(false)
+-- Iteration 9 --
+bool(true)
+-- Iteration 10 --
+bool(true)
+Done
diff --git a/ext/standard/tests/file/is_executable_variation2.phpt b/ext/standard/tests/file/is_executable_variation2.phpt
new file mode 100644
index 0000000..fc804d6
--- /dev/null
+++ b/ext/standard/tests/file/is_executable_variation2.phpt
@@ -0,0 +1,110 @@
+--TEST--
+Test is_executable() function: usage variations - file/dir with diff. perms
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip not for windows');
+}
+// Skip if being run by root
+$filename = dirname(__FILE__)."/is_readable_root_check.tmp";
+$fp = fopen($filename, 'w');
+fclose($fp);
+if(fileowner($filename) == 0) {
+ unlink ($filename);
+ die('skip cannot be run as root');
+}
+
+unlink($filename);
+?>
+--FILE--
+<?php
+/* Prototype: bool is_executable ( string $filename );
+ Description: Tells whether the filename is executable
+*/
+
+/* test is_executable() with file/dir having different permissions */
+
+require dirname(__FILE__).'/file.inc';
+echo "*** Testing is_executable(): usage variations ***\n";
+
+$file_path = dirname(__FILE__);
+mkdir("$file_path/is_executable_variation2");
+
+echo "\n*** Testing is_executable() on directory without execute permission ***\n";
+chmod("$file_path/is_executable_variation2", 0444);
+var_dump( is_executable("$file_path/is_executable_variation2") ); // exp: bool(false)
+chmod("$file_path/is_executable_variation2", 0777); // chmod to enable deletion of directory
+
+echo "\n*** Testing miscelleneous input for is_executable() function ***\n";
+$name_prefix = "is_executable_variation2";
+create_files(dirname(__FILE__), 1, "numeric", 0755, 1, "w", $name_prefix, 1);
+create_files(dirname(__FILE__), 1, "text", 0755, 1, "w", $name_prefix, 2);
+create_files(dirname(__FILE__), 1, "empty", 0755, 1, "w", $name_prefix, 3);
+create_files(dirname(__FILE__), 1, "numeric", 0755, 1, "w", $name_prefix, 4);
+create_files(dirname(__FILE__), 1, "text", 0222, 1, "w", $name_prefix, 5);
+create_files(dirname(__FILE__), 1, "numeric", 0711, 1, "w", $name_prefix, 6);
+create_files(dirname(__FILE__), 1, "text", 0714, 1, "w", $name_prefix, 7);
+create_files(dirname(__FILE__), 1, "numeric", 0744, 1, "w", $name_prefix, 8);
+create_files(dirname(__FILE__), 1, "text", 0421, 1, "w", $name_prefix, 9);
+create_files(dirname(__FILE__), 1, "text", 0712, 1, "w", $name_prefix, 10);
+
+$files = array (
+ "$file_path/is_executable_variation21.tmp",
+ "$file_path/is_executable_variation22.tmp",
+ "$file_path/is_executable_variation23.tmp",
+ "$file_path/is_executable_variation24.tmp",
+ "$file_path/is_executable_variation25.tmp",
+ "$file_path/is_executable_variation26.tmp",
+ "$file_path/is_executable_variation27.tmp",
+ "$file_path/is_executable_variation28.tmp",
+ "$file_path/is_executable_variation29.tmp",
+ "$file_path/is_executable_variation210.tmp",
+);
+$counter = 1;
+/* loop through to test each element in the above array
+ is an executable file */
+foreach($files as $file) {
+ echo "-- Iteration $counter --\n";
+ var_dump( is_executable($file) );
+ $counter++;
+ clearstatcache();
+}
+
+// change all file's permissions to 777 before deleting
+change_file_perms($file_path, 10, 0777, $name_prefix);
+delete_files($file_path, 10, $name_prefix);
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+rmdir(dirname(__FILE__)."/is_executable_variation2/");
+?>
+--EXPECTF--
+*** Testing is_executable(): usage variations ***
+
+*** Testing is_executable() on directory without execute permission ***
+bool(false)
+
+*** Testing miscelleneous input for is_executable() function ***
+-- Iteration 1 --
+bool(true)
+-- Iteration 2 --
+bool(true)
+-- Iteration 3 --
+bool(true)
+-- Iteration 4 --
+bool(true)
+-- Iteration 5 --
+bool(false)
+-- Iteration 6 --
+bool(true)
+-- Iteration 7 --
+bool(true)
+-- Iteration 8 --
+bool(true)
+-- Iteration 9 --
+bool(false)
+-- Iteration 10 --
+bool(true)
+Done
diff --git a/ext/standard/tests/file/is_executable_variation3.phpt b/ext/standard/tests/file/is_executable_variation3.phpt
new file mode 100644
index 0000000..925f996
--- /dev/null
+++ b/ext/standard/tests/file/is_executable_variation3.phpt
@@ -0,0 +1,69 @@
+--TEST--
+Test is_executable() function: usage variations - invalid file names
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip not for windows');
+}
+// Skip if being run by root (files are always readable, writeable and executable)
+$filename = dirname(__FILE__)."/is_executable_root_check.tmp";
+$fp = fopen($filename, 'w');
+fclose($fp);
+if(fileowner($filename) == 0) {
+ unlink ($filename);
+ die('skip cannot be run as root');
+}
+
+unlink($filename);
+?>
+--FILE--
+<?php
+/* Prototype: bool is_executable ( string $filename );
+ Description: Tells whether the filename is executable
+*/
+
+/* test is_executable() with invalid arguments */
+
+echo "*** Testing is_executable(): usage variations ***\n";
+
+$file_handle = fopen(__FILE__, "r");
+unset($file_handle);
+
+echo "\n*** Testing is_executable() on invalid files ***\n";
+$invalid_files = array(
+ 0,
+ 1234,
+ -2.34555,
+ TRUE,
+ FALSE,
+ NULL,
+ " ",
+ @array(),
+ @$file_handle
+);
+/* loop through to test each element in the above array
+ is an executable file */
+foreach( $invalid_files as $invalid_file ) {
+ var_dump( is_executable($invalid_file) );
+ clearstatcache();
+}
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing is_executable(): usage variations ***
+
+*** Testing is_executable() on invalid files ***
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+Warning: is_executable() expects parameter 1 to be a valid path, array given in %s on line %d
+NULL
+bool(false)
+Done
+
diff --git a/ext/standard/tests/file/is_file_basic.phpt b/ext/standard/tests/file/is_file_basic.phpt
new file mode 100644
index 0000000..f8c06a0
--- /dev/null
+++ b/ext/standard/tests/file/is_file_basic.phpt
@@ -0,0 +1,48 @@
+--TEST--
+Test is_file() function: basic functionality
+--FILE--
+<?php
+/* Prototype: bool is_file ( string $filename );
+ Description: Tells whether the filename is a regular file
+ Returns TRUE if the filename exists and is a regular file
+*/
+
+echo "*** Testing is_file(): basic functionality ***\n";
+
+/* Checking with current file */
+var_dump( is_file(__FILE__) );
+
+/* Checking with (current) dir */
+var_dump( is_file(dirname(__FILE__)) );
+
+$file_path = dirname(__FILE__);
+$file_name = $file_path."/is_file_basic.tmp";
+/* With non-existing file */
+var_dump( is_file($file_name) );
+/* With existing file */
+fclose( fopen($file_name, "w") );
+var_dump( is_file($file_name) );
+
+echo "*** Testing is_file() for its return value type ***\n";
+var_dump( is_bool( is_file(__FILE__) ) );
+var_dump( is_bool( is_file("/no/such/file") ) );
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$file_name = $file_path."/is_file_basic.tmp";
+unlink($file_name);
+?>
+--EXPECTF--
+*** Testing is_file(): basic functionality ***
+bool(true)
+bool(false)
+bool(false)
+bool(true)
+*** Testing is_file() for its return value type ***
+bool(true)
+bool(true)
+
+*** Done ***
diff --git a/ext/standard/tests/file/is_file_error.phpt b/ext/standard/tests/file/is_file_error.phpt
new file mode 100644
index 0000000..abccb72
--- /dev/null
+++ b/ext/standard/tests/file/is_file_error.phpt
@@ -0,0 +1,51 @@
+--TEST--
+Test is_file() function: error conditions
+--FILE--
+<?php
+/* Prototype: bool is_file ( string $filename );
+ Description: Tells whether the filename is a regular file
+ Returns TRUE if the filename exists and is a regular file
+*/
+
+echo "*** Testing is_file() error conditions ***";
+$file_path = dirname(__FILE__);
+var_dump( is_file() ); // Zero No. of args
+
+/* no of args > expected */
+$file_handle = fopen($file_path."/is_file_error.tmp", "w");
+var_dump( is_file( $file_path."/is_file_error.tmp", $file_path."/is_file_error1.tmp") );
+
+/* Non-existing file */
+var_dump( is_file($file_path."/is_file_error1.tmp") );
+
+/* Passing resource as an argument */
+var_dump( is_file($file_handle) );
+
+fclose($file_handle);
+
+echo "\n*** Done ***";
+?>
+
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+if(file_exists($file_path."/is_file_error.tmp")) {
+ unlink($file_path."/is_file_error.tmp");
+}
+if(file_exists($file_path."/is_file_error1.tmp")) {
+ unlink($file_path."/is_file_error1.tmp");
+}
+?>
+--EXPECTF--
+*** Testing is_file() error conditions ***
+Warning: is_file() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: is_file() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+bool(false)
+
+Warning: is_file() expects parameter 1 to be a valid path, resource given in %s on line %d
+NULL
+
+*** Done ***
diff --git a/ext/standard/tests/file/is_file_variation1.phpt b/ext/standard/tests/file/is_file_variation1.phpt
new file mode 100644
index 0000000..92bff95
--- /dev/null
+++ b/ext/standard/tests/file/is_file_variation1.phpt
@@ -0,0 +1,57 @@
+--TEST--
+Test is_file() function: usage variations - diff. files
+--FILE--
+<?php
+/* Prototype: bool is_file ( string $filename );
+ Description: Tells whether the filename is a regular file
+ Returns TRUE if the filename exists and is a regular file
+*/
+
+/* Testing is_file() with file containing data, truncating its size
+ and the file created by touch() */
+
+$file_path = dirname(__FILE__);
+
+echo "-- Testing is_file() with file containing data --\n";
+$filename = $file_path."/is_file_variation1.tmp";
+$file_handle = fopen($filename, "w" );
+fwrite( $file_handle, "Hello, world....." ); // exptected true
+fclose($file_handle);
+var_dump( is_file($filename) );
+clearstatcache();
+
+echo "\n-- Testing is_file() after truncating filesize to zero bytes --\n";
+$file_handle = fopen( $file_path."/is_file_variation1.tmp", "r");
+ftruncate($file_handle, 0);
+fclose($file_handle);
+var_dump( is_file($file_path."/is_file_variation1.tmp") ); // expected true
+clearstatcache();
+unlink($file_path."/is_file_variation1.tmp");
+
+echo "\n-- Testing is_file() with an empty file --\n";
+/* created by fopen() */
+fclose( fopen($file_path."/is_file_variation1.tmp", "w") );
+var_dump( is_file($file_path."/is_file_variation1.tmp") ); //expected true
+clearstatcache();
+unlink($file_path."/is_file_variation1.tmp");
+
+/* created by touch() */
+touch($file_path."/is_file_variation1.tmp");
+var_dump( is_file($file_path."/is_file_variation1.tmp") ); // expected true
+clearstatcache();
+unlink($file_path."/is_file_variation1.tmp");
+
+echo "\n*** Done ***";
+?>
+--EXPECTF--
+-- Testing is_file() with file containing data --
+bool(true)
+
+-- Testing is_file() after truncating filesize to zero bytes --
+bool(true)
+
+-- Testing is_file() with an empty file --
+bool(true)
+bool(true)
+
+*** Done ***
diff --git a/ext/standard/tests/file/is_file_variation2.phpt b/ext/standard/tests/file/is_file_variation2.phpt
new file mode 100644
index 0000000..dbe74da
--- /dev/null
+++ b/ext/standard/tests/file/is_file_variation2.phpt
@@ -0,0 +1,46 @@
+--TEST--
+Test is_file() function: usage variations - links
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip Do not run on Windows');
+}
+--FILE--
+<?php
+/* Prototype: bool is_file ( string $filename );
+ Description: Tells whether the filename is a regular file
+ Returns TRUE if the filename exists and is a regular file
+*/
+
+/* Creating soft and hard links to a file and applying is_file() on links */
+
+$file_path = dirname(__FILE__);
+fclose( fopen($file_path."/is_file_variation2.tmp", "w") );
+
+echo "*** Testing is_file() with links ***\n";
+/* With symlink */
+symlink($file_path."/is_file_variation2.tmp", $file_path."/is_file_variation2_symlink.tmp");
+var_dump( is_file($file_path."/is_file_variation2_symlink.tmp") ); //expected true
+clearstatcache();
+
+/* With hardlink */
+link($file_path."/is_file_variation2.tmp", $file_path."/is_file_variation2_link.tmp");
+var_dump( is_file($file_path."/is_file_variation2_link.tmp") ); // expected: true
+clearstatcache();
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/is_file_variation2_symlink.tmp");
+unlink($file_path."/is_file_variation2_link.tmp");
+unlink($file_path."/is_file_variation2.tmp");
+?>
+
+--EXPECTF--
+*** Testing is_file() with links ***
+bool(true)
+bool(true)
+
+*** Done ***
diff --git a/ext/standard/tests/file/is_file_variation3.phpt b/ext/standard/tests/file/is_file_variation3.phpt
new file mode 100644
index 0000000..2a13e46
--- /dev/null
+++ b/ext/standard/tests/file/is_file_variation3.phpt
@@ -0,0 +1,60 @@
+--TEST--
+Test is_file() function: usage variations - invalid filenames
+--FILE--
+<?php
+/* Prototype: bool is_file ( string $filename );
+ Description: Tells whether the filename is a regular file
+ Returns TRUE if the filename exists and is a regular file
+*/
+
+/* Testing is_file() with invalid arguments -int, float, bool, NULL, resource */
+
+$file_path = dirname(__FILE__);
+$file_handle = fopen($file_path."/is_file_variation3.tmp", "w");
+
+echo "*** Testing Invalid file types ***\n";
+$filenames = array(
+ /* Invalid filenames */
+ -2.34555,
+ " ",
+ "",
+ TRUE,
+ FALSE,
+ NULL,
+ $file_handle,
+
+ /* scalars */
+ 1234,
+ 0
+);
+
+/* loop through to test each element the above array */
+foreach( $filenames as $filename ) {
+ var_dump( is_file($filename) );
+ clearstatcache();
+}
+fclose($file_handle);
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/is_file_variation3.tmp");
+?>
+--EXPECTF--
+*** Testing Invalid file types ***
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+Warning: is_file() expects parameter 1 to be a valid path, resource given in %s on line %d
+NULL
+bool(false)
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/is_file_variation4.phpt b/ext/standard/tests/file/is_file_variation4.phpt
new file mode 100644
index 0000000..b927446
--- /dev/null
+++ b/ext/standard/tests/file/is_file_variation4.phpt
@@ -0,0 +1,78 @@
+--TEST--
+Test is_file() function: usage variations - diff. path notations (Bug #42027)
+--FILE--
+<?php
+/* Prototype: bool is_file ( string $filename );
+ Description: Tells whether the filename is a regular file
+ Returns TRUE if the filename exists and is a regular file
+*/
+
+/* Passing file names with different notations, using slashes, wild-card chars */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Testing is_file() with different notations of file names ***\n";
+$dir_name = $file_path."/is_file_variation4";
+mkdir($dir_name);
+$file_handle = fopen($dir_name."/is_file_variation4.tmp", "w");
+fclose($file_handle);
+
+$files_arr = array(
+ "/is_file_variation4/is_file_variation4.tmp",
+
+ /* Testing a file trailing slash */
+ "/is_file_variation4/is_file_variation4.tmp/",
+
+ /* Testing file with double slashes */
+ "/is_file_variation4//is_file_variation4.tmp",
+ "//is_file_variation4//is_file_variation4.tmp",
+ "/is_file_variation4/*.tmp",
+ "is_file_variation4/is_file*.tmp",
+
+ /* Testing Binary safe */
+ "/is_file_variation4/is_file_variation4.tmp".chr(0),
+ "/is_file_variation4/is_file_variation4.tmp\0"
+);
+
+$count = 1;
+/* loop through to test each element in the above array */
+foreach($files_arr as $file) {
+ echo "- Iteration $count -\n";
+ var_dump( is_file( $file_path."/".$file ) );
+ clearstatcache();
+ $count++;
+}
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$dir_name = $file_path."/is_file_variation4";
+unlink($dir_name."/is_file_variation4.tmp");
+rmdir($dir_name);
+?>
+--EXPECTF--
+*** Testing is_file() with different notations of file names ***
+- Iteration 1 -
+bool(true)
+- Iteration 2 -
+bool(false)
+- Iteration 3 -
+bool(true)
+- Iteration 4 -
+bool(true)
+- Iteration 5 -
+bool(false)
+- Iteration 6 -
+bool(false)
+- Iteration 7 -
+
+Warning: is_file() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+- Iteration 8 -
+
+Warning: is_file() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+
+*** Done ***
diff --git a/ext/standard/tests/file/is_readable_basic-win32.phpt b/ext/standard/tests/file/is_readable_basic-win32.phpt
new file mode 100644
index 0000000..67f5768
--- /dev/null
+++ b/ext/standard/tests/file/is_readable_basic-win32.phpt
@@ -0,0 +1,1066 @@
+--TEST--
+Test is_readable() function: basic functionality
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip only for Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: bool is_readable ( string $filename );
+ Description: Tells whether the filename is readable
+*/
+
+// include common file test functions
+require dirname(__FILE__).'/file.inc';
+
+echo "*** Testing is_readable(): basic functionality ***\n";
+
+// create a file
+$filename = dirname(__FILE__)."/is_readable.tmp";
+create_file($filename);
+
+$counter = 1;
+/* loop to check if the file with new mode is readable
+ using is_readable() */
+for($mode = 0000; $mode <= 0777; $mode++) {
+ echo "-- Changing mode of file to $mode --\n";
+ chmod($filename, $mode); // change mode of file
+ var_dump( is_readable($filename) );
+ $counter++;
+ clearstatcache();
+}
+
+// delete the temp file
+delete_file($filename);
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing is_readable(): basic functionality ***
+-- Changing mode of file to 0 --
+bool(true)
+-- Changing mode of file to 1 --
+bool(true)
+-- Changing mode of file to 2 --
+bool(true)
+-- Changing mode of file to 3 --
+bool(true)
+-- Changing mode of file to 4 --
+bool(true)
+-- Changing mode of file to 5 --
+bool(true)
+-- Changing mode of file to 6 --
+bool(true)
+-- Changing mode of file to 7 --
+bool(true)
+-- Changing mode of file to 8 --
+bool(true)
+-- Changing mode of file to 9 --
+bool(true)
+-- Changing mode of file to 10 --
+bool(true)
+-- Changing mode of file to 11 --
+bool(true)
+-- Changing mode of file to 12 --
+bool(true)
+-- Changing mode of file to 13 --
+bool(true)
+-- Changing mode of file to 14 --
+bool(true)
+-- Changing mode of file to 15 --
+bool(true)
+-- Changing mode of file to 16 --
+bool(true)
+-- Changing mode of file to 17 --
+bool(true)
+-- Changing mode of file to 18 --
+bool(true)
+-- Changing mode of file to 19 --
+bool(true)
+-- Changing mode of file to 20 --
+bool(true)
+-- Changing mode of file to 21 --
+bool(true)
+-- Changing mode of file to 22 --
+bool(true)
+-- Changing mode of file to 23 --
+bool(true)
+-- Changing mode of file to 24 --
+bool(true)
+-- Changing mode of file to 25 --
+bool(true)
+-- Changing mode of file to 26 --
+bool(true)
+-- Changing mode of file to 27 --
+bool(true)
+-- Changing mode of file to 28 --
+bool(true)
+-- Changing mode of file to 29 --
+bool(true)
+-- Changing mode of file to 30 --
+bool(true)
+-- Changing mode of file to 31 --
+bool(true)
+-- Changing mode of file to 32 --
+bool(true)
+-- Changing mode of file to 33 --
+bool(true)
+-- Changing mode of file to 34 --
+bool(true)
+-- Changing mode of file to 35 --
+bool(true)
+-- Changing mode of file to 36 --
+bool(true)
+-- Changing mode of file to 37 --
+bool(true)
+-- Changing mode of file to 38 --
+bool(true)
+-- Changing mode of file to 39 --
+bool(true)
+-- Changing mode of file to 40 --
+bool(true)
+-- Changing mode of file to 41 --
+bool(true)
+-- Changing mode of file to 42 --
+bool(true)
+-- Changing mode of file to 43 --
+bool(true)
+-- Changing mode of file to 44 --
+bool(true)
+-- Changing mode of file to 45 --
+bool(true)
+-- Changing mode of file to 46 --
+bool(true)
+-- Changing mode of file to 47 --
+bool(true)
+-- Changing mode of file to 48 --
+bool(true)
+-- Changing mode of file to 49 --
+bool(true)
+-- Changing mode of file to 50 --
+bool(true)
+-- Changing mode of file to 51 --
+bool(true)
+-- Changing mode of file to 52 --
+bool(true)
+-- Changing mode of file to 53 --
+bool(true)
+-- Changing mode of file to 54 --
+bool(true)
+-- Changing mode of file to 55 --
+bool(true)
+-- Changing mode of file to 56 --
+bool(true)
+-- Changing mode of file to 57 --
+bool(true)
+-- Changing mode of file to 58 --
+bool(true)
+-- Changing mode of file to 59 --
+bool(true)
+-- Changing mode of file to 60 --
+bool(true)
+-- Changing mode of file to 61 --
+bool(true)
+-- Changing mode of file to 62 --
+bool(true)
+-- Changing mode of file to 63 --
+bool(true)
+-- Changing mode of file to 64 --
+bool(true)
+-- Changing mode of file to 65 --
+bool(true)
+-- Changing mode of file to 66 --
+bool(true)
+-- Changing mode of file to 67 --
+bool(true)
+-- Changing mode of file to 68 --
+bool(true)
+-- Changing mode of file to 69 --
+bool(true)
+-- Changing mode of file to 70 --
+bool(true)
+-- Changing mode of file to 71 --
+bool(true)
+-- Changing mode of file to 72 --
+bool(true)
+-- Changing mode of file to 73 --
+bool(true)
+-- Changing mode of file to 74 --
+bool(true)
+-- Changing mode of file to 75 --
+bool(true)
+-- Changing mode of file to 76 --
+bool(true)
+-- Changing mode of file to 77 --
+bool(true)
+-- Changing mode of file to 78 --
+bool(true)
+-- Changing mode of file to 79 --
+bool(true)
+-- Changing mode of file to 80 --
+bool(true)
+-- Changing mode of file to 81 --
+bool(true)
+-- Changing mode of file to 82 --
+bool(true)
+-- Changing mode of file to 83 --
+bool(true)
+-- Changing mode of file to 84 --
+bool(true)
+-- Changing mode of file to 85 --
+bool(true)
+-- Changing mode of file to 86 --
+bool(true)
+-- Changing mode of file to 87 --
+bool(true)
+-- Changing mode of file to 88 --
+bool(true)
+-- Changing mode of file to 89 --
+bool(true)
+-- Changing mode of file to 90 --
+bool(true)
+-- Changing mode of file to 91 --
+bool(true)
+-- Changing mode of file to 92 --
+bool(true)
+-- Changing mode of file to 93 --
+bool(true)
+-- Changing mode of file to 94 --
+bool(true)
+-- Changing mode of file to 95 --
+bool(true)
+-- Changing mode of file to 96 --
+bool(true)
+-- Changing mode of file to 97 --
+bool(true)
+-- Changing mode of file to 98 --
+bool(true)
+-- Changing mode of file to 99 --
+bool(true)
+-- Changing mode of file to 100 --
+bool(true)
+-- Changing mode of file to 101 --
+bool(true)
+-- Changing mode of file to 102 --
+bool(true)
+-- Changing mode of file to 103 --
+bool(true)
+-- Changing mode of file to 104 --
+bool(true)
+-- Changing mode of file to 105 --
+bool(true)
+-- Changing mode of file to 106 --
+bool(true)
+-- Changing mode of file to 107 --
+bool(true)
+-- Changing mode of file to 108 --
+bool(true)
+-- Changing mode of file to 109 --
+bool(true)
+-- Changing mode of file to 110 --
+bool(true)
+-- Changing mode of file to 111 --
+bool(true)
+-- Changing mode of file to 112 --
+bool(true)
+-- Changing mode of file to 113 --
+bool(true)
+-- Changing mode of file to 114 --
+bool(true)
+-- Changing mode of file to 115 --
+bool(true)
+-- Changing mode of file to 116 --
+bool(true)
+-- Changing mode of file to 117 --
+bool(true)
+-- Changing mode of file to 118 --
+bool(true)
+-- Changing mode of file to 119 --
+bool(true)
+-- Changing mode of file to 120 --
+bool(true)
+-- Changing mode of file to 121 --
+bool(true)
+-- Changing mode of file to 122 --
+bool(true)
+-- Changing mode of file to 123 --
+bool(true)
+-- Changing mode of file to 124 --
+bool(true)
+-- Changing mode of file to 125 --
+bool(true)
+-- Changing mode of file to 126 --
+bool(true)
+-- Changing mode of file to 127 --
+bool(true)
+-- Changing mode of file to 128 --
+bool(true)
+-- Changing mode of file to 129 --
+bool(true)
+-- Changing mode of file to 130 --
+bool(true)
+-- Changing mode of file to 131 --
+bool(true)
+-- Changing mode of file to 132 --
+bool(true)
+-- Changing mode of file to 133 --
+bool(true)
+-- Changing mode of file to 134 --
+bool(true)
+-- Changing mode of file to 135 --
+bool(true)
+-- Changing mode of file to 136 --
+bool(true)
+-- Changing mode of file to 137 --
+bool(true)
+-- Changing mode of file to 138 --
+bool(true)
+-- Changing mode of file to 139 --
+bool(true)
+-- Changing mode of file to 140 --
+bool(true)
+-- Changing mode of file to 141 --
+bool(true)
+-- Changing mode of file to 142 --
+bool(true)
+-- Changing mode of file to 143 --
+bool(true)
+-- Changing mode of file to 144 --
+bool(true)
+-- Changing mode of file to 145 --
+bool(true)
+-- Changing mode of file to 146 --
+bool(true)
+-- Changing mode of file to 147 --
+bool(true)
+-- Changing mode of file to 148 --
+bool(true)
+-- Changing mode of file to 149 --
+bool(true)
+-- Changing mode of file to 150 --
+bool(true)
+-- Changing mode of file to 151 --
+bool(true)
+-- Changing mode of file to 152 --
+bool(true)
+-- Changing mode of file to 153 --
+bool(true)
+-- Changing mode of file to 154 --
+bool(true)
+-- Changing mode of file to 155 --
+bool(true)
+-- Changing mode of file to 156 --
+bool(true)
+-- Changing mode of file to 157 --
+bool(true)
+-- Changing mode of file to 158 --
+bool(true)
+-- Changing mode of file to 159 --
+bool(true)
+-- Changing mode of file to 160 --
+bool(true)
+-- Changing mode of file to 161 --
+bool(true)
+-- Changing mode of file to 162 --
+bool(true)
+-- Changing mode of file to 163 --
+bool(true)
+-- Changing mode of file to 164 --
+bool(true)
+-- Changing mode of file to 165 --
+bool(true)
+-- Changing mode of file to 166 --
+bool(true)
+-- Changing mode of file to 167 --
+bool(true)
+-- Changing mode of file to 168 --
+bool(true)
+-- Changing mode of file to 169 --
+bool(true)
+-- Changing mode of file to 170 --
+bool(true)
+-- Changing mode of file to 171 --
+bool(true)
+-- Changing mode of file to 172 --
+bool(true)
+-- Changing mode of file to 173 --
+bool(true)
+-- Changing mode of file to 174 --
+bool(true)
+-- Changing mode of file to 175 --
+bool(true)
+-- Changing mode of file to 176 --
+bool(true)
+-- Changing mode of file to 177 --
+bool(true)
+-- Changing mode of file to 178 --
+bool(true)
+-- Changing mode of file to 179 --
+bool(true)
+-- Changing mode of file to 180 --
+bool(true)
+-- Changing mode of file to 181 --
+bool(true)
+-- Changing mode of file to 182 --
+bool(true)
+-- Changing mode of file to 183 --
+bool(true)
+-- Changing mode of file to 184 --
+bool(true)
+-- Changing mode of file to 185 --
+bool(true)
+-- Changing mode of file to 186 --
+bool(true)
+-- Changing mode of file to 187 --
+bool(true)
+-- Changing mode of file to 188 --
+bool(true)
+-- Changing mode of file to 189 --
+bool(true)
+-- Changing mode of file to 190 --
+bool(true)
+-- Changing mode of file to 191 --
+bool(true)
+-- Changing mode of file to 192 --
+bool(true)
+-- Changing mode of file to 193 --
+bool(true)
+-- Changing mode of file to 194 --
+bool(true)
+-- Changing mode of file to 195 --
+bool(true)
+-- Changing mode of file to 196 --
+bool(true)
+-- Changing mode of file to 197 --
+bool(true)
+-- Changing mode of file to 198 --
+bool(true)
+-- Changing mode of file to 199 --
+bool(true)
+-- Changing mode of file to 200 --
+bool(true)
+-- Changing mode of file to 201 --
+bool(true)
+-- Changing mode of file to 202 --
+bool(true)
+-- Changing mode of file to 203 --
+bool(true)
+-- Changing mode of file to 204 --
+bool(true)
+-- Changing mode of file to 205 --
+bool(true)
+-- Changing mode of file to 206 --
+bool(true)
+-- Changing mode of file to 207 --
+bool(true)
+-- Changing mode of file to 208 --
+bool(true)
+-- Changing mode of file to 209 --
+bool(true)
+-- Changing mode of file to 210 --
+bool(true)
+-- Changing mode of file to 211 --
+bool(true)
+-- Changing mode of file to 212 --
+bool(true)
+-- Changing mode of file to 213 --
+bool(true)
+-- Changing mode of file to 214 --
+bool(true)
+-- Changing mode of file to 215 --
+bool(true)
+-- Changing mode of file to 216 --
+bool(true)
+-- Changing mode of file to 217 --
+bool(true)
+-- Changing mode of file to 218 --
+bool(true)
+-- Changing mode of file to 219 --
+bool(true)
+-- Changing mode of file to 220 --
+bool(true)
+-- Changing mode of file to 221 --
+bool(true)
+-- Changing mode of file to 222 --
+bool(true)
+-- Changing mode of file to 223 --
+bool(true)
+-- Changing mode of file to 224 --
+bool(true)
+-- Changing mode of file to 225 --
+bool(true)
+-- Changing mode of file to 226 --
+bool(true)
+-- Changing mode of file to 227 --
+bool(true)
+-- Changing mode of file to 228 --
+bool(true)
+-- Changing mode of file to 229 --
+bool(true)
+-- Changing mode of file to 230 --
+bool(true)
+-- Changing mode of file to 231 --
+bool(true)
+-- Changing mode of file to 232 --
+bool(true)
+-- Changing mode of file to 233 --
+bool(true)
+-- Changing mode of file to 234 --
+bool(true)
+-- Changing mode of file to 235 --
+bool(true)
+-- Changing mode of file to 236 --
+bool(true)
+-- Changing mode of file to 237 --
+bool(true)
+-- Changing mode of file to 238 --
+bool(true)
+-- Changing mode of file to 239 --
+bool(true)
+-- Changing mode of file to 240 --
+bool(true)
+-- Changing mode of file to 241 --
+bool(true)
+-- Changing mode of file to 242 --
+bool(true)
+-- Changing mode of file to 243 --
+bool(true)
+-- Changing mode of file to 244 --
+bool(true)
+-- Changing mode of file to 245 --
+bool(true)
+-- Changing mode of file to 246 --
+bool(true)
+-- Changing mode of file to 247 --
+bool(true)
+-- Changing mode of file to 248 --
+bool(true)
+-- Changing mode of file to 249 --
+bool(true)
+-- Changing mode of file to 250 --
+bool(true)
+-- Changing mode of file to 251 --
+bool(true)
+-- Changing mode of file to 252 --
+bool(true)
+-- Changing mode of file to 253 --
+bool(true)
+-- Changing mode of file to 254 --
+bool(true)
+-- Changing mode of file to 255 --
+bool(true)
+-- Changing mode of file to 256 --
+bool(true)
+-- Changing mode of file to 257 --
+bool(true)
+-- Changing mode of file to 258 --
+bool(true)
+-- Changing mode of file to 259 --
+bool(true)
+-- Changing mode of file to 260 --
+bool(true)
+-- Changing mode of file to 261 --
+bool(true)
+-- Changing mode of file to 262 --
+bool(true)
+-- Changing mode of file to 263 --
+bool(true)
+-- Changing mode of file to 264 --
+bool(true)
+-- Changing mode of file to 265 --
+bool(true)
+-- Changing mode of file to 266 --
+bool(true)
+-- Changing mode of file to 267 --
+bool(true)
+-- Changing mode of file to 268 --
+bool(true)
+-- Changing mode of file to 269 --
+bool(true)
+-- Changing mode of file to 270 --
+bool(true)
+-- Changing mode of file to 271 --
+bool(true)
+-- Changing mode of file to 272 --
+bool(true)
+-- Changing mode of file to 273 --
+bool(true)
+-- Changing mode of file to 274 --
+bool(true)
+-- Changing mode of file to 275 --
+bool(true)
+-- Changing mode of file to 276 --
+bool(true)
+-- Changing mode of file to 277 --
+bool(true)
+-- Changing mode of file to 278 --
+bool(true)
+-- Changing mode of file to 279 --
+bool(true)
+-- Changing mode of file to 280 --
+bool(true)
+-- Changing mode of file to 281 --
+bool(true)
+-- Changing mode of file to 282 --
+bool(true)
+-- Changing mode of file to 283 --
+bool(true)
+-- Changing mode of file to 284 --
+bool(true)
+-- Changing mode of file to 285 --
+bool(true)
+-- Changing mode of file to 286 --
+bool(true)
+-- Changing mode of file to 287 --
+bool(true)
+-- Changing mode of file to 288 --
+bool(true)
+-- Changing mode of file to 289 --
+bool(true)
+-- Changing mode of file to 290 --
+bool(true)
+-- Changing mode of file to 291 --
+bool(true)
+-- Changing mode of file to 292 --
+bool(true)
+-- Changing mode of file to 293 --
+bool(true)
+-- Changing mode of file to 294 --
+bool(true)
+-- Changing mode of file to 295 --
+bool(true)
+-- Changing mode of file to 296 --
+bool(true)
+-- Changing mode of file to 297 --
+bool(true)
+-- Changing mode of file to 298 --
+bool(true)
+-- Changing mode of file to 299 --
+bool(true)
+-- Changing mode of file to 300 --
+bool(true)
+-- Changing mode of file to 301 --
+bool(true)
+-- Changing mode of file to 302 --
+bool(true)
+-- Changing mode of file to 303 --
+bool(true)
+-- Changing mode of file to 304 --
+bool(true)
+-- Changing mode of file to 305 --
+bool(true)
+-- Changing mode of file to 306 --
+bool(true)
+-- Changing mode of file to 307 --
+bool(true)
+-- Changing mode of file to 308 --
+bool(true)
+-- Changing mode of file to 309 --
+bool(true)
+-- Changing mode of file to 310 --
+bool(true)
+-- Changing mode of file to 311 --
+bool(true)
+-- Changing mode of file to 312 --
+bool(true)
+-- Changing mode of file to 313 --
+bool(true)
+-- Changing mode of file to 314 --
+bool(true)
+-- Changing mode of file to 315 --
+bool(true)
+-- Changing mode of file to 316 --
+bool(true)
+-- Changing mode of file to 317 --
+bool(true)
+-- Changing mode of file to 318 --
+bool(true)
+-- Changing mode of file to 319 --
+bool(true)
+-- Changing mode of file to 320 --
+bool(true)
+-- Changing mode of file to 321 --
+bool(true)
+-- Changing mode of file to 322 --
+bool(true)
+-- Changing mode of file to 323 --
+bool(true)
+-- Changing mode of file to 324 --
+bool(true)
+-- Changing mode of file to 325 --
+bool(true)
+-- Changing mode of file to 326 --
+bool(true)
+-- Changing mode of file to 327 --
+bool(true)
+-- Changing mode of file to 328 --
+bool(true)
+-- Changing mode of file to 329 --
+bool(true)
+-- Changing mode of file to 330 --
+bool(true)
+-- Changing mode of file to 331 --
+bool(true)
+-- Changing mode of file to 332 --
+bool(true)
+-- Changing mode of file to 333 --
+bool(true)
+-- Changing mode of file to 334 --
+bool(true)
+-- Changing mode of file to 335 --
+bool(true)
+-- Changing mode of file to 336 --
+bool(true)
+-- Changing mode of file to 337 --
+bool(true)
+-- Changing mode of file to 338 --
+bool(true)
+-- Changing mode of file to 339 --
+bool(true)
+-- Changing mode of file to 340 --
+bool(true)
+-- Changing mode of file to 341 --
+bool(true)
+-- Changing mode of file to 342 --
+bool(true)
+-- Changing mode of file to 343 --
+bool(true)
+-- Changing mode of file to 344 --
+bool(true)
+-- Changing mode of file to 345 --
+bool(true)
+-- Changing mode of file to 346 --
+bool(true)
+-- Changing mode of file to 347 --
+bool(true)
+-- Changing mode of file to 348 --
+bool(true)
+-- Changing mode of file to 349 --
+bool(true)
+-- Changing mode of file to 350 --
+bool(true)
+-- Changing mode of file to 351 --
+bool(true)
+-- Changing mode of file to 352 --
+bool(true)
+-- Changing mode of file to 353 --
+bool(true)
+-- Changing mode of file to 354 --
+bool(true)
+-- Changing mode of file to 355 --
+bool(true)
+-- Changing mode of file to 356 --
+bool(true)
+-- Changing mode of file to 357 --
+bool(true)
+-- Changing mode of file to 358 --
+bool(true)
+-- Changing mode of file to 359 --
+bool(true)
+-- Changing mode of file to 360 --
+bool(true)
+-- Changing mode of file to 361 --
+bool(true)
+-- Changing mode of file to 362 --
+bool(true)
+-- Changing mode of file to 363 --
+bool(true)
+-- Changing mode of file to 364 --
+bool(true)
+-- Changing mode of file to 365 --
+bool(true)
+-- Changing mode of file to 366 --
+bool(true)
+-- Changing mode of file to 367 --
+bool(true)
+-- Changing mode of file to 368 --
+bool(true)
+-- Changing mode of file to 369 --
+bool(true)
+-- Changing mode of file to 370 --
+bool(true)
+-- Changing mode of file to 371 --
+bool(true)
+-- Changing mode of file to 372 --
+bool(true)
+-- Changing mode of file to 373 --
+bool(true)
+-- Changing mode of file to 374 --
+bool(true)
+-- Changing mode of file to 375 --
+bool(true)
+-- Changing mode of file to 376 --
+bool(true)
+-- Changing mode of file to 377 --
+bool(true)
+-- Changing mode of file to 378 --
+bool(true)
+-- Changing mode of file to 379 --
+bool(true)
+-- Changing mode of file to 380 --
+bool(true)
+-- Changing mode of file to 381 --
+bool(true)
+-- Changing mode of file to 382 --
+bool(true)
+-- Changing mode of file to 383 --
+bool(true)
+-- Changing mode of file to 384 --
+bool(true)
+-- Changing mode of file to 385 --
+bool(true)
+-- Changing mode of file to 386 --
+bool(true)
+-- Changing mode of file to 387 --
+bool(true)
+-- Changing mode of file to 388 --
+bool(true)
+-- Changing mode of file to 389 --
+bool(true)
+-- Changing mode of file to 390 --
+bool(true)
+-- Changing mode of file to 391 --
+bool(true)
+-- Changing mode of file to 392 --
+bool(true)
+-- Changing mode of file to 393 --
+bool(true)
+-- Changing mode of file to 394 --
+bool(true)
+-- Changing mode of file to 395 --
+bool(true)
+-- Changing mode of file to 396 --
+bool(true)
+-- Changing mode of file to 397 --
+bool(true)
+-- Changing mode of file to 398 --
+bool(true)
+-- Changing mode of file to 399 --
+bool(true)
+-- Changing mode of file to 400 --
+bool(true)
+-- Changing mode of file to 401 --
+bool(true)
+-- Changing mode of file to 402 --
+bool(true)
+-- Changing mode of file to 403 --
+bool(true)
+-- Changing mode of file to 404 --
+bool(true)
+-- Changing mode of file to 405 --
+bool(true)
+-- Changing mode of file to 406 --
+bool(true)
+-- Changing mode of file to 407 --
+bool(true)
+-- Changing mode of file to 408 --
+bool(true)
+-- Changing mode of file to 409 --
+bool(true)
+-- Changing mode of file to 410 --
+bool(true)
+-- Changing mode of file to 411 --
+bool(true)
+-- Changing mode of file to 412 --
+bool(true)
+-- Changing mode of file to 413 --
+bool(true)
+-- Changing mode of file to 414 --
+bool(true)
+-- Changing mode of file to 415 --
+bool(true)
+-- Changing mode of file to 416 --
+bool(true)
+-- Changing mode of file to 417 --
+bool(true)
+-- Changing mode of file to 418 --
+bool(true)
+-- Changing mode of file to 419 --
+bool(true)
+-- Changing mode of file to 420 --
+bool(true)
+-- Changing mode of file to 421 --
+bool(true)
+-- Changing mode of file to 422 --
+bool(true)
+-- Changing mode of file to 423 --
+bool(true)
+-- Changing mode of file to 424 --
+bool(true)
+-- Changing mode of file to 425 --
+bool(true)
+-- Changing mode of file to 426 --
+bool(true)
+-- Changing mode of file to 427 --
+bool(true)
+-- Changing mode of file to 428 --
+bool(true)
+-- Changing mode of file to 429 --
+bool(true)
+-- Changing mode of file to 430 --
+bool(true)
+-- Changing mode of file to 431 --
+bool(true)
+-- Changing mode of file to 432 --
+bool(true)
+-- Changing mode of file to 433 --
+bool(true)
+-- Changing mode of file to 434 --
+bool(true)
+-- Changing mode of file to 435 --
+bool(true)
+-- Changing mode of file to 436 --
+bool(true)
+-- Changing mode of file to 437 --
+bool(true)
+-- Changing mode of file to 438 --
+bool(true)
+-- Changing mode of file to 439 --
+bool(true)
+-- Changing mode of file to 440 --
+bool(true)
+-- Changing mode of file to 441 --
+bool(true)
+-- Changing mode of file to 442 --
+bool(true)
+-- Changing mode of file to 443 --
+bool(true)
+-- Changing mode of file to 444 --
+bool(true)
+-- Changing mode of file to 445 --
+bool(true)
+-- Changing mode of file to 446 --
+bool(true)
+-- Changing mode of file to 447 --
+bool(true)
+-- Changing mode of file to 448 --
+bool(true)
+-- Changing mode of file to 449 --
+bool(true)
+-- Changing mode of file to 450 --
+bool(true)
+-- Changing mode of file to 451 --
+bool(true)
+-- Changing mode of file to 452 --
+bool(true)
+-- Changing mode of file to 453 --
+bool(true)
+-- Changing mode of file to 454 --
+bool(true)
+-- Changing mode of file to 455 --
+bool(true)
+-- Changing mode of file to 456 --
+bool(true)
+-- Changing mode of file to 457 --
+bool(true)
+-- Changing mode of file to 458 --
+bool(true)
+-- Changing mode of file to 459 --
+bool(true)
+-- Changing mode of file to 460 --
+bool(true)
+-- Changing mode of file to 461 --
+bool(true)
+-- Changing mode of file to 462 --
+bool(true)
+-- Changing mode of file to 463 --
+bool(true)
+-- Changing mode of file to 464 --
+bool(true)
+-- Changing mode of file to 465 --
+bool(true)
+-- Changing mode of file to 466 --
+bool(true)
+-- Changing mode of file to 467 --
+bool(true)
+-- Changing mode of file to 468 --
+bool(true)
+-- Changing mode of file to 469 --
+bool(true)
+-- Changing mode of file to 470 --
+bool(true)
+-- Changing mode of file to 471 --
+bool(true)
+-- Changing mode of file to 472 --
+bool(true)
+-- Changing mode of file to 473 --
+bool(true)
+-- Changing mode of file to 474 --
+bool(true)
+-- Changing mode of file to 475 --
+bool(true)
+-- Changing mode of file to 476 --
+bool(true)
+-- Changing mode of file to 477 --
+bool(true)
+-- Changing mode of file to 478 --
+bool(true)
+-- Changing mode of file to 479 --
+bool(true)
+-- Changing mode of file to 480 --
+bool(true)
+-- Changing mode of file to 481 --
+bool(true)
+-- Changing mode of file to 482 --
+bool(true)
+-- Changing mode of file to 483 --
+bool(true)
+-- Changing mode of file to 484 --
+bool(true)
+-- Changing mode of file to 485 --
+bool(true)
+-- Changing mode of file to 486 --
+bool(true)
+-- Changing mode of file to 487 --
+bool(true)
+-- Changing mode of file to 488 --
+bool(true)
+-- Changing mode of file to 489 --
+bool(true)
+-- Changing mode of file to 490 --
+bool(true)
+-- Changing mode of file to 491 --
+bool(true)
+-- Changing mode of file to 492 --
+bool(true)
+-- Changing mode of file to 493 --
+bool(true)
+-- Changing mode of file to 494 --
+bool(true)
+-- Changing mode of file to 495 --
+bool(true)
+-- Changing mode of file to 496 --
+bool(true)
+-- Changing mode of file to 497 --
+bool(true)
+-- Changing mode of file to 498 --
+bool(true)
+-- Changing mode of file to 499 --
+bool(true)
+-- Changing mode of file to 500 --
+bool(true)
+-- Changing mode of file to 501 --
+bool(true)
+-- Changing mode of file to 502 --
+bool(true)
+-- Changing mode of file to 503 --
+bool(true)
+-- Changing mode of file to 504 --
+bool(true)
+-- Changing mode of file to 505 --
+bool(true)
+-- Changing mode of file to 506 --
+bool(true)
+-- Changing mode of file to 507 --
+bool(true)
+-- Changing mode of file to 508 --
+bool(true)
+-- Changing mode of file to 509 --
+bool(true)
+-- Changing mode of file to 510 --
+bool(true)
+-- Changing mode of file to 511 --
+bool(true)
+Done
diff --git a/ext/standard/tests/file/is_readable_basic.phpt b/ext/standard/tests/file/is_readable_basic.phpt
new file mode 100644
index 0000000..4d5febf
--- /dev/null
+++ b/ext/standard/tests/file/is_readable_basic.phpt
@@ -0,0 +1,1076 @@
+--TEST--
+Test is_readable() function: basic functionality
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip not for windows');
+}
+// Skip if being run by root (files are always readable, writeable and executable)
+$filename = dirname(__FILE__)."/is_readable_root_check.tmp";
+$fp = fopen($filename, 'w');
+fclose($fp);
+if(fileowner($filename) == 0) {
+ unlink ($filename);
+ die('skip cannot be run as root');
+}
+
+unlink($filename);
+?>
+--FILE--
+<?php
+/* Prototype: bool is_readable ( string $filename );
+ Description: Tells whether the filename is readable
+*/
+
+// include common file test functions
+require dirname(__FILE__).'/file.inc';
+
+echo "*** Testing is_readable(): basic functionality ***\n";
+
+// create a file
+$filename = dirname(__FILE__)."/is_readable.tmp";
+create_file($filename);
+
+$counter = 1;
+/* loop to check if the file with new mode is readable
+ using is_readable() */
+for($mode = 0000; $mode <= 0777; $mode++) {
+ echo "-- Changing mode of file to $mode --\n";
+ chmod($filename, $mode); // change mode of file
+ var_dump( is_readable($filename) );
+ $counter++;
+ clearstatcache();
+}
+
+// delete the temp file
+delete_file($filename);
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing is_readable(): basic functionality ***
+-- Changing mode of file to 0 --
+bool(false)
+-- Changing mode of file to 1 --
+bool(false)
+-- Changing mode of file to 2 --
+bool(false)
+-- Changing mode of file to 3 --
+bool(false)
+-- Changing mode of file to 4 --
+bool(false)
+-- Changing mode of file to 5 --
+bool(false)
+-- Changing mode of file to 6 --
+bool(false)
+-- Changing mode of file to 7 --
+bool(false)
+-- Changing mode of file to 8 --
+bool(false)
+-- Changing mode of file to 9 --
+bool(false)
+-- Changing mode of file to 10 --
+bool(false)
+-- Changing mode of file to 11 --
+bool(false)
+-- Changing mode of file to 12 --
+bool(false)
+-- Changing mode of file to 13 --
+bool(false)
+-- Changing mode of file to 14 --
+bool(false)
+-- Changing mode of file to 15 --
+bool(false)
+-- Changing mode of file to 16 --
+bool(false)
+-- Changing mode of file to 17 --
+bool(false)
+-- Changing mode of file to 18 --
+bool(false)
+-- Changing mode of file to 19 --
+bool(false)
+-- Changing mode of file to 20 --
+bool(false)
+-- Changing mode of file to 21 --
+bool(false)
+-- Changing mode of file to 22 --
+bool(false)
+-- Changing mode of file to 23 --
+bool(false)
+-- Changing mode of file to 24 --
+bool(false)
+-- Changing mode of file to 25 --
+bool(false)
+-- Changing mode of file to 26 --
+bool(false)
+-- Changing mode of file to 27 --
+bool(false)
+-- Changing mode of file to 28 --
+bool(false)
+-- Changing mode of file to 29 --
+bool(false)
+-- Changing mode of file to 30 --
+bool(false)
+-- Changing mode of file to 31 --
+bool(false)
+-- Changing mode of file to 32 --
+bool(false)
+-- Changing mode of file to 33 --
+bool(false)
+-- Changing mode of file to 34 --
+bool(false)
+-- Changing mode of file to 35 --
+bool(false)
+-- Changing mode of file to 36 --
+bool(false)
+-- Changing mode of file to 37 --
+bool(false)
+-- Changing mode of file to 38 --
+bool(false)
+-- Changing mode of file to 39 --
+bool(false)
+-- Changing mode of file to 40 --
+bool(false)
+-- Changing mode of file to 41 --
+bool(false)
+-- Changing mode of file to 42 --
+bool(false)
+-- Changing mode of file to 43 --
+bool(false)
+-- Changing mode of file to 44 --
+bool(false)
+-- Changing mode of file to 45 --
+bool(false)
+-- Changing mode of file to 46 --
+bool(false)
+-- Changing mode of file to 47 --
+bool(false)
+-- Changing mode of file to 48 --
+bool(false)
+-- Changing mode of file to 49 --
+bool(false)
+-- Changing mode of file to 50 --
+bool(false)
+-- Changing mode of file to 51 --
+bool(false)
+-- Changing mode of file to 52 --
+bool(false)
+-- Changing mode of file to 53 --
+bool(false)
+-- Changing mode of file to 54 --
+bool(false)
+-- Changing mode of file to 55 --
+bool(false)
+-- Changing mode of file to 56 --
+bool(false)
+-- Changing mode of file to 57 --
+bool(false)
+-- Changing mode of file to 58 --
+bool(false)
+-- Changing mode of file to 59 --
+bool(false)
+-- Changing mode of file to 60 --
+bool(false)
+-- Changing mode of file to 61 --
+bool(false)
+-- Changing mode of file to 62 --
+bool(false)
+-- Changing mode of file to 63 --
+bool(false)
+-- Changing mode of file to 64 --
+bool(false)
+-- Changing mode of file to 65 --
+bool(false)
+-- Changing mode of file to 66 --
+bool(false)
+-- Changing mode of file to 67 --
+bool(false)
+-- Changing mode of file to 68 --
+bool(false)
+-- Changing mode of file to 69 --
+bool(false)
+-- Changing mode of file to 70 --
+bool(false)
+-- Changing mode of file to 71 --
+bool(false)
+-- Changing mode of file to 72 --
+bool(false)
+-- Changing mode of file to 73 --
+bool(false)
+-- Changing mode of file to 74 --
+bool(false)
+-- Changing mode of file to 75 --
+bool(false)
+-- Changing mode of file to 76 --
+bool(false)
+-- Changing mode of file to 77 --
+bool(false)
+-- Changing mode of file to 78 --
+bool(false)
+-- Changing mode of file to 79 --
+bool(false)
+-- Changing mode of file to 80 --
+bool(false)
+-- Changing mode of file to 81 --
+bool(false)
+-- Changing mode of file to 82 --
+bool(false)
+-- Changing mode of file to 83 --
+bool(false)
+-- Changing mode of file to 84 --
+bool(false)
+-- Changing mode of file to 85 --
+bool(false)
+-- Changing mode of file to 86 --
+bool(false)
+-- Changing mode of file to 87 --
+bool(false)
+-- Changing mode of file to 88 --
+bool(false)
+-- Changing mode of file to 89 --
+bool(false)
+-- Changing mode of file to 90 --
+bool(false)
+-- Changing mode of file to 91 --
+bool(false)
+-- Changing mode of file to 92 --
+bool(false)
+-- Changing mode of file to 93 --
+bool(false)
+-- Changing mode of file to 94 --
+bool(false)
+-- Changing mode of file to 95 --
+bool(false)
+-- Changing mode of file to 96 --
+bool(false)
+-- Changing mode of file to 97 --
+bool(false)
+-- Changing mode of file to 98 --
+bool(false)
+-- Changing mode of file to 99 --
+bool(false)
+-- Changing mode of file to 100 --
+bool(false)
+-- Changing mode of file to 101 --
+bool(false)
+-- Changing mode of file to 102 --
+bool(false)
+-- Changing mode of file to 103 --
+bool(false)
+-- Changing mode of file to 104 --
+bool(false)
+-- Changing mode of file to 105 --
+bool(false)
+-- Changing mode of file to 106 --
+bool(false)
+-- Changing mode of file to 107 --
+bool(false)
+-- Changing mode of file to 108 --
+bool(false)
+-- Changing mode of file to 109 --
+bool(false)
+-- Changing mode of file to 110 --
+bool(false)
+-- Changing mode of file to 111 --
+bool(false)
+-- Changing mode of file to 112 --
+bool(false)
+-- Changing mode of file to 113 --
+bool(false)
+-- Changing mode of file to 114 --
+bool(false)
+-- Changing mode of file to 115 --
+bool(false)
+-- Changing mode of file to 116 --
+bool(false)
+-- Changing mode of file to 117 --
+bool(false)
+-- Changing mode of file to 118 --
+bool(false)
+-- Changing mode of file to 119 --
+bool(false)
+-- Changing mode of file to 120 --
+bool(false)
+-- Changing mode of file to 121 --
+bool(false)
+-- Changing mode of file to 122 --
+bool(false)
+-- Changing mode of file to 123 --
+bool(false)
+-- Changing mode of file to 124 --
+bool(false)
+-- Changing mode of file to 125 --
+bool(false)
+-- Changing mode of file to 126 --
+bool(false)
+-- Changing mode of file to 127 --
+bool(false)
+-- Changing mode of file to 128 --
+bool(false)
+-- Changing mode of file to 129 --
+bool(false)
+-- Changing mode of file to 130 --
+bool(false)
+-- Changing mode of file to 131 --
+bool(false)
+-- Changing mode of file to 132 --
+bool(false)
+-- Changing mode of file to 133 --
+bool(false)
+-- Changing mode of file to 134 --
+bool(false)
+-- Changing mode of file to 135 --
+bool(false)
+-- Changing mode of file to 136 --
+bool(false)
+-- Changing mode of file to 137 --
+bool(false)
+-- Changing mode of file to 138 --
+bool(false)
+-- Changing mode of file to 139 --
+bool(false)
+-- Changing mode of file to 140 --
+bool(false)
+-- Changing mode of file to 141 --
+bool(false)
+-- Changing mode of file to 142 --
+bool(false)
+-- Changing mode of file to 143 --
+bool(false)
+-- Changing mode of file to 144 --
+bool(false)
+-- Changing mode of file to 145 --
+bool(false)
+-- Changing mode of file to 146 --
+bool(false)
+-- Changing mode of file to 147 --
+bool(false)
+-- Changing mode of file to 148 --
+bool(false)
+-- Changing mode of file to 149 --
+bool(false)
+-- Changing mode of file to 150 --
+bool(false)
+-- Changing mode of file to 151 --
+bool(false)
+-- Changing mode of file to 152 --
+bool(false)
+-- Changing mode of file to 153 --
+bool(false)
+-- Changing mode of file to 154 --
+bool(false)
+-- Changing mode of file to 155 --
+bool(false)
+-- Changing mode of file to 156 --
+bool(false)
+-- Changing mode of file to 157 --
+bool(false)
+-- Changing mode of file to 158 --
+bool(false)
+-- Changing mode of file to 159 --
+bool(false)
+-- Changing mode of file to 160 --
+bool(false)
+-- Changing mode of file to 161 --
+bool(false)
+-- Changing mode of file to 162 --
+bool(false)
+-- Changing mode of file to 163 --
+bool(false)
+-- Changing mode of file to 164 --
+bool(false)
+-- Changing mode of file to 165 --
+bool(false)
+-- Changing mode of file to 166 --
+bool(false)
+-- Changing mode of file to 167 --
+bool(false)
+-- Changing mode of file to 168 --
+bool(false)
+-- Changing mode of file to 169 --
+bool(false)
+-- Changing mode of file to 170 --
+bool(false)
+-- Changing mode of file to 171 --
+bool(false)
+-- Changing mode of file to 172 --
+bool(false)
+-- Changing mode of file to 173 --
+bool(false)
+-- Changing mode of file to 174 --
+bool(false)
+-- Changing mode of file to 175 --
+bool(false)
+-- Changing mode of file to 176 --
+bool(false)
+-- Changing mode of file to 177 --
+bool(false)
+-- Changing mode of file to 178 --
+bool(false)
+-- Changing mode of file to 179 --
+bool(false)
+-- Changing mode of file to 180 --
+bool(false)
+-- Changing mode of file to 181 --
+bool(false)
+-- Changing mode of file to 182 --
+bool(false)
+-- Changing mode of file to 183 --
+bool(false)
+-- Changing mode of file to 184 --
+bool(false)
+-- Changing mode of file to 185 --
+bool(false)
+-- Changing mode of file to 186 --
+bool(false)
+-- Changing mode of file to 187 --
+bool(false)
+-- Changing mode of file to 188 --
+bool(false)
+-- Changing mode of file to 189 --
+bool(false)
+-- Changing mode of file to 190 --
+bool(false)
+-- Changing mode of file to 191 --
+bool(false)
+-- Changing mode of file to 192 --
+bool(false)
+-- Changing mode of file to 193 --
+bool(false)
+-- Changing mode of file to 194 --
+bool(false)
+-- Changing mode of file to 195 --
+bool(false)
+-- Changing mode of file to 196 --
+bool(false)
+-- Changing mode of file to 197 --
+bool(false)
+-- Changing mode of file to 198 --
+bool(false)
+-- Changing mode of file to 199 --
+bool(false)
+-- Changing mode of file to 200 --
+bool(false)
+-- Changing mode of file to 201 --
+bool(false)
+-- Changing mode of file to 202 --
+bool(false)
+-- Changing mode of file to 203 --
+bool(false)
+-- Changing mode of file to 204 --
+bool(false)
+-- Changing mode of file to 205 --
+bool(false)
+-- Changing mode of file to 206 --
+bool(false)
+-- Changing mode of file to 207 --
+bool(false)
+-- Changing mode of file to 208 --
+bool(false)
+-- Changing mode of file to 209 --
+bool(false)
+-- Changing mode of file to 210 --
+bool(false)
+-- Changing mode of file to 211 --
+bool(false)
+-- Changing mode of file to 212 --
+bool(false)
+-- Changing mode of file to 213 --
+bool(false)
+-- Changing mode of file to 214 --
+bool(false)
+-- Changing mode of file to 215 --
+bool(false)
+-- Changing mode of file to 216 --
+bool(false)
+-- Changing mode of file to 217 --
+bool(false)
+-- Changing mode of file to 218 --
+bool(false)
+-- Changing mode of file to 219 --
+bool(false)
+-- Changing mode of file to 220 --
+bool(false)
+-- Changing mode of file to 221 --
+bool(false)
+-- Changing mode of file to 222 --
+bool(false)
+-- Changing mode of file to 223 --
+bool(false)
+-- Changing mode of file to 224 --
+bool(false)
+-- Changing mode of file to 225 --
+bool(false)
+-- Changing mode of file to 226 --
+bool(false)
+-- Changing mode of file to 227 --
+bool(false)
+-- Changing mode of file to 228 --
+bool(false)
+-- Changing mode of file to 229 --
+bool(false)
+-- Changing mode of file to 230 --
+bool(false)
+-- Changing mode of file to 231 --
+bool(false)
+-- Changing mode of file to 232 --
+bool(false)
+-- Changing mode of file to 233 --
+bool(false)
+-- Changing mode of file to 234 --
+bool(false)
+-- Changing mode of file to 235 --
+bool(false)
+-- Changing mode of file to 236 --
+bool(false)
+-- Changing mode of file to 237 --
+bool(false)
+-- Changing mode of file to 238 --
+bool(false)
+-- Changing mode of file to 239 --
+bool(false)
+-- Changing mode of file to 240 --
+bool(false)
+-- Changing mode of file to 241 --
+bool(false)
+-- Changing mode of file to 242 --
+bool(false)
+-- Changing mode of file to 243 --
+bool(false)
+-- Changing mode of file to 244 --
+bool(false)
+-- Changing mode of file to 245 --
+bool(false)
+-- Changing mode of file to 246 --
+bool(false)
+-- Changing mode of file to 247 --
+bool(false)
+-- Changing mode of file to 248 --
+bool(false)
+-- Changing mode of file to 249 --
+bool(false)
+-- Changing mode of file to 250 --
+bool(false)
+-- Changing mode of file to 251 --
+bool(false)
+-- Changing mode of file to 252 --
+bool(false)
+-- Changing mode of file to 253 --
+bool(false)
+-- Changing mode of file to 254 --
+bool(false)
+-- Changing mode of file to 255 --
+bool(false)
+-- Changing mode of file to 256 --
+bool(true)
+-- Changing mode of file to 257 --
+bool(true)
+-- Changing mode of file to 258 --
+bool(true)
+-- Changing mode of file to 259 --
+bool(true)
+-- Changing mode of file to 260 --
+bool(true)
+-- Changing mode of file to 261 --
+bool(true)
+-- Changing mode of file to 262 --
+bool(true)
+-- Changing mode of file to 263 --
+bool(true)
+-- Changing mode of file to 264 --
+bool(true)
+-- Changing mode of file to 265 --
+bool(true)
+-- Changing mode of file to 266 --
+bool(true)
+-- Changing mode of file to 267 --
+bool(true)
+-- Changing mode of file to 268 --
+bool(true)
+-- Changing mode of file to 269 --
+bool(true)
+-- Changing mode of file to 270 --
+bool(true)
+-- Changing mode of file to 271 --
+bool(true)
+-- Changing mode of file to 272 --
+bool(true)
+-- Changing mode of file to 273 --
+bool(true)
+-- Changing mode of file to 274 --
+bool(true)
+-- Changing mode of file to 275 --
+bool(true)
+-- Changing mode of file to 276 --
+bool(true)
+-- Changing mode of file to 277 --
+bool(true)
+-- Changing mode of file to 278 --
+bool(true)
+-- Changing mode of file to 279 --
+bool(true)
+-- Changing mode of file to 280 --
+bool(true)
+-- Changing mode of file to 281 --
+bool(true)
+-- Changing mode of file to 282 --
+bool(true)
+-- Changing mode of file to 283 --
+bool(true)
+-- Changing mode of file to 284 --
+bool(true)
+-- Changing mode of file to 285 --
+bool(true)
+-- Changing mode of file to 286 --
+bool(true)
+-- Changing mode of file to 287 --
+bool(true)
+-- Changing mode of file to 288 --
+bool(true)
+-- Changing mode of file to 289 --
+bool(true)
+-- Changing mode of file to 290 --
+bool(true)
+-- Changing mode of file to 291 --
+bool(true)
+-- Changing mode of file to 292 --
+bool(true)
+-- Changing mode of file to 293 --
+bool(true)
+-- Changing mode of file to 294 --
+bool(true)
+-- Changing mode of file to 295 --
+bool(true)
+-- Changing mode of file to 296 --
+bool(true)
+-- Changing mode of file to 297 --
+bool(true)
+-- Changing mode of file to 298 --
+bool(true)
+-- Changing mode of file to 299 --
+bool(true)
+-- Changing mode of file to 300 --
+bool(true)
+-- Changing mode of file to 301 --
+bool(true)
+-- Changing mode of file to 302 --
+bool(true)
+-- Changing mode of file to 303 --
+bool(true)
+-- Changing mode of file to 304 --
+bool(true)
+-- Changing mode of file to 305 --
+bool(true)
+-- Changing mode of file to 306 --
+bool(true)
+-- Changing mode of file to 307 --
+bool(true)
+-- Changing mode of file to 308 --
+bool(true)
+-- Changing mode of file to 309 --
+bool(true)
+-- Changing mode of file to 310 --
+bool(true)
+-- Changing mode of file to 311 --
+bool(true)
+-- Changing mode of file to 312 --
+bool(true)
+-- Changing mode of file to 313 --
+bool(true)
+-- Changing mode of file to 314 --
+bool(true)
+-- Changing mode of file to 315 --
+bool(true)
+-- Changing mode of file to 316 --
+bool(true)
+-- Changing mode of file to 317 --
+bool(true)
+-- Changing mode of file to 318 --
+bool(true)
+-- Changing mode of file to 319 --
+bool(true)
+-- Changing mode of file to 320 --
+bool(true)
+-- Changing mode of file to 321 --
+bool(true)
+-- Changing mode of file to 322 --
+bool(true)
+-- Changing mode of file to 323 --
+bool(true)
+-- Changing mode of file to 324 --
+bool(true)
+-- Changing mode of file to 325 --
+bool(true)
+-- Changing mode of file to 326 --
+bool(true)
+-- Changing mode of file to 327 --
+bool(true)
+-- Changing mode of file to 328 --
+bool(true)
+-- Changing mode of file to 329 --
+bool(true)
+-- Changing mode of file to 330 --
+bool(true)
+-- Changing mode of file to 331 --
+bool(true)
+-- Changing mode of file to 332 --
+bool(true)
+-- Changing mode of file to 333 --
+bool(true)
+-- Changing mode of file to 334 --
+bool(true)
+-- Changing mode of file to 335 --
+bool(true)
+-- Changing mode of file to 336 --
+bool(true)
+-- Changing mode of file to 337 --
+bool(true)
+-- Changing mode of file to 338 --
+bool(true)
+-- Changing mode of file to 339 --
+bool(true)
+-- Changing mode of file to 340 --
+bool(true)
+-- Changing mode of file to 341 --
+bool(true)
+-- Changing mode of file to 342 --
+bool(true)
+-- Changing mode of file to 343 --
+bool(true)
+-- Changing mode of file to 344 --
+bool(true)
+-- Changing mode of file to 345 --
+bool(true)
+-- Changing mode of file to 346 --
+bool(true)
+-- Changing mode of file to 347 --
+bool(true)
+-- Changing mode of file to 348 --
+bool(true)
+-- Changing mode of file to 349 --
+bool(true)
+-- Changing mode of file to 350 --
+bool(true)
+-- Changing mode of file to 351 --
+bool(true)
+-- Changing mode of file to 352 --
+bool(true)
+-- Changing mode of file to 353 --
+bool(true)
+-- Changing mode of file to 354 --
+bool(true)
+-- Changing mode of file to 355 --
+bool(true)
+-- Changing mode of file to 356 --
+bool(true)
+-- Changing mode of file to 357 --
+bool(true)
+-- Changing mode of file to 358 --
+bool(true)
+-- Changing mode of file to 359 --
+bool(true)
+-- Changing mode of file to 360 --
+bool(true)
+-- Changing mode of file to 361 --
+bool(true)
+-- Changing mode of file to 362 --
+bool(true)
+-- Changing mode of file to 363 --
+bool(true)
+-- Changing mode of file to 364 --
+bool(true)
+-- Changing mode of file to 365 --
+bool(true)
+-- Changing mode of file to 366 --
+bool(true)
+-- Changing mode of file to 367 --
+bool(true)
+-- Changing mode of file to 368 --
+bool(true)
+-- Changing mode of file to 369 --
+bool(true)
+-- Changing mode of file to 370 --
+bool(true)
+-- Changing mode of file to 371 --
+bool(true)
+-- Changing mode of file to 372 --
+bool(true)
+-- Changing mode of file to 373 --
+bool(true)
+-- Changing mode of file to 374 --
+bool(true)
+-- Changing mode of file to 375 --
+bool(true)
+-- Changing mode of file to 376 --
+bool(true)
+-- Changing mode of file to 377 --
+bool(true)
+-- Changing mode of file to 378 --
+bool(true)
+-- Changing mode of file to 379 --
+bool(true)
+-- Changing mode of file to 380 --
+bool(true)
+-- Changing mode of file to 381 --
+bool(true)
+-- Changing mode of file to 382 --
+bool(true)
+-- Changing mode of file to 383 --
+bool(true)
+-- Changing mode of file to 384 --
+bool(true)
+-- Changing mode of file to 385 --
+bool(true)
+-- Changing mode of file to 386 --
+bool(true)
+-- Changing mode of file to 387 --
+bool(true)
+-- Changing mode of file to 388 --
+bool(true)
+-- Changing mode of file to 389 --
+bool(true)
+-- Changing mode of file to 390 --
+bool(true)
+-- Changing mode of file to 391 --
+bool(true)
+-- Changing mode of file to 392 --
+bool(true)
+-- Changing mode of file to 393 --
+bool(true)
+-- Changing mode of file to 394 --
+bool(true)
+-- Changing mode of file to 395 --
+bool(true)
+-- Changing mode of file to 396 --
+bool(true)
+-- Changing mode of file to 397 --
+bool(true)
+-- Changing mode of file to 398 --
+bool(true)
+-- Changing mode of file to 399 --
+bool(true)
+-- Changing mode of file to 400 --
+bool(true)
+-- Changing mode of file to 401 --
+bool(true)
+-- Changing mode of file to 402 --
+bool(true)
+-- Changing mode of file to 403 --
+bool(true)
+-- Changing mode of file to 404 --
+bool(true)
+-- Changing mode of file to 405 --
+bool(true)
+-- Changing mode of file to 406 --
+bool(true)
+-- Changing mode of file to 407 --
+bool(true)
+-- Changing mode of file to 408 --
+bool(true)
+-- Changing mode of file to 409 --
+bool(true)
+-- Changing mode of file to 410 --
+bool(true)
+-- Changing mode of file to 411 --
+bool(true)
+-- Changing mode of file to 412 --
+bool(true)
+-- Changing mode of file to 413 --
+bool(true)
+-- Changing mode of file to 414 --
+bool(true)
+-- Changing mode of file to 415 --
+bool(true)
+-- Changing mode of file to 416 --
+bool(true)
+-- Changing mode of file to 417 --
+bool(true)
+-- Changing mode of file to 418 --
+bool(true)
+-- Changing mode of file to 419 --
+bool(true)
+-- Changing mode of file to 420 --
+bool(true)
+-- Changing mode of file to 421 --
+bool(true)
+-- Changing mode of file to 422 --
+bool(true)
+-- Changing mode of file to 423 --
+bool(true)
+-- Changing mode of file to 424 --
+bool(true)
+-- Changing mode of file to 425 --
+bool(true)
+-- Changing mode of file to 426 --
+bool(true)
+-- Changing mode of file to 427 --
+bool(true)
+-- Changing mode of file to 428 --
+bool(true)
+-- Changing mode of file to 429 --
+bool(true)
+-- Changing mode of file to 430 --
+bool(true)
+-- Changing mode of file to 431 --
+bool(true)
+-- Changing mode of file to 432 --
+bool(true)
+-- Changing mode of file to 433 --
+bool(true)
+-- Changing mode of file to 434 --
+bool(true)
+-- Changing mode of file to 435 --
+bool(true)
+-- Changing mode of file to 436 --
+bool(true)
+-- Changing mode of file to 437 --
+bool(true)
+-- Changing mode of file to 438 --
+bool(true)
+-- Changing mode of file to 439 --
+bool(true)
+-- Changing mode of file to 440 --
+bool(true)
+-- Changing mode of file to 441 --
+bool(true)
+-- Changing mode of file to 442 --
+bool(true)
+-- Changing mode of file to 443 --
+bool(true)
+-- Changing mode of file to 444 --
+bool(true)
+-- Changing mode of file to 445 --
+bool(true)
+-- Changing mode of file to 446 --
+bool(true)
+-- Changing mode of file to 447 --
+bool(true)
+-- Changing mode of file to 448 --
+bool(true)
+-- Changing mode of file to 449 --
+bool(true)
+-- Changing mode of file to 450 --
+bool(true)
+-- Changing mode of file to 451 --
+bool(true)
+-- Changing mode of file to 452 --
+bool(true)
+-- Changing mode of file to 453 --
+bool(true)
+-- Changing mode of file to 454 --
+bool(true)
+-- Changing mode of file to 455 --
+bool(true)
+-- Changing mode of file to 456 --
+bool(true)
+-- Changing mode of file to 457 --
+bool(true)
+-- Changing mode of file to 458 --
+bool(true)
+-- Changing mode of file to 459 --
+bool(true)
+-- Changing mode of file to 460 --
+bool(true)
+-- Changing mode of file to 461 --
+bool(true)
+-- Changing mode of file to 462 --
+bool(true)
+-- Changing mode of file to 463 --
+bool(true)
+-- Changing mode of file to 464 --
+bool(true)
+-- Changing mode of file to 465 --
+bool(true)
+-- Changing mode of file to 466 --
+bool(true)
+-- Changing mode of file to 467 --
+bool(true)
+-- Changing mode of file to 468 --
+bool(true)
+-- Changing mode of file to 469 --
+bool(true)
+-- Changing mode of file to 470 --
+bool(true)
+-- Changing mode of file to 471 --
+bool(true)
+-- Changing mode of file to 472 --
+bool(true)
+-- Changing mode of file to 473 --
+bool(true)
+-- Changing mode of file to 474 --
+bool(true)
+-- Changing mode of file to 475 --
+bool(true)
+-- Changing mode of file to 476 --
+bool(true)
+-- Changing mode of file to 477 --
+bool(true)
+-- Changing mode of file to 478 --
+bool(true)
+-- Changing mode of file to 479 --
+bool(true)
+-- Changing mode of file to 480 --
+bool(true)
+-- Changing mode of file to 481 --
+bool(true)
+-- Changing mode of file to 482 --
+bool(true)
+-- Changing mode of file to 483 --
+bool(true)
+-- Changing mode of file to 484 --
+bool(true)
+-- Changing mode of file to 485 --
+bool(true)
+-- Changing mode of file to 486 --
+bool(true)
+-- Changing mode of file to 487 --
+bool(true)
+-- Changing mode of file to 488 --
+bool(true)
+-- Changing mode of file to 489 --
+bool(true)
+-- Changing mode of file to 490 --
+bool(true)
+-- Changing mode of file to 491 --
+bool(true)
+-- Changing mode of file to 492 --
+bool(true)
+-- Changing mode of file to 493 --
+bool(true)
+-- Changing mode of file to 494 --
+bool(true)
+-- Changing mode of file to 495 --
+bool(true)
+-- Changing mode of file to 496 --
+bool(true)
+-- Changing mode of file to 497 --
+bool(true)
+-- Changing mode of file to 498 --
+bool(true)
+-- Changing mode of file to 499 --
+bool(true)
+-- Changing mode of file to 500 --
+bool(true)
+-- Changing mode of file to 501 --
+bool(true)
+-- Changing mode of file to 502 --
+bool(true)
+-- Changing mode of file to 503 --
+bool(true)
+-- Changing mode of file to 504 --
+bool(true)
+-- Changing mode of file to 505 --
+bool(true)
+-- Changing mode of file to 506 --
+bool(true)
+-- Changing mode of file to 507 --
+bool(true)
+-- Changing mode of file to 508 --
+bool(true)
+-- Changing mode of file to 509 --
+bool(true)
+-- Changing mode of file to 510 --
+bool(true)
+-- Changing mode of file to 511 --
+bool(true)
+Done
diff --git a/ext/standard/tests/file/is_readable_error.phpt b/ext/standard/tests/file/is_readable_error.phpt
new file mode 100644
index 0000000..9a734cd
--- /dev/null
+++ b/ext/standard/tests/file/is_readable_error.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Test is_readable() function: error conditions
+--FILE--
+<?php
+/* Prototype: bool is_readable ( string $filename );
+ Description: Tells whether the filename is readable
+*/
+
+echo "*** Testing is_readable(): error conditions ***\n";
+var_dump( is_readable() ); // args < expected
+var_dump( is_readable(1, 2) ); // args > expected
+
+echo "\n*** Testing is_readable() on non-existent file ***\n";
+var_dump( is_readable(dirname(__FILE__)."/is_readable.tmp") );
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing is_readable(): error conditions ***
+
+Warning: is_readable() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: is_readable() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+
+*** Testing is_readable() on non-existent file ***
+bool(false)
+Done
diff --git a/ext/standard/tests/file/is_readable_variation1.phpt b/ext/standard/tests/file/is_readable_variation1.phpt
new file mode 100644
index 0000000..5becac0
--- /dev/null
+++ b/ext/standard/tests/file/is_readable_variation1.phpt
@@ -0,0 +1,105 @@
+--TEST--
+Test is_readable() function: usage variations - diff. file notations
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ // Skip if being run by root (files are always readable, writeable and executable)
+ $filename = dirname(__FILE__)."/is_readable_root_check.tmp";
+ $fp = fopen($filename, 'w');
+ fclose($fp);
+ if(fileowner($filename) == 0) {
+ unlink ($filename);
+ die('skip cannot be run as root');
+ }
+ unlink($filename);
+}
+?>
+--FILE--
+<?php
+/* Prototype: bool is_readable ( string $filename );
+ Description: Tells whether the filename is readable.
+*/
+
+/* test is_readable() with file having different filepath notation */
+
+require dirname(__FILE__).'/file.inc';
+echo "*** Testing is_readable(): usage variations ***\n";
+
+$file_path = dirname(__FILE__);
+mkdir("$file_path/is_readable_variation1");
+
+// create a new temporary file
+$fp = fopen("$file_path/is_readable_variation1/bar.tmp", "w");
+fclose($fp);
+
+/* array of files to be tested if they are readable by using
+ is_readable() function */
+$files_arr = array(
+ "$file_path/is_readable_variation1/bar.tmp",
+
+ /* Testing a file trailing slash */
+ "$file_path/is_readable_variation1/bar.tmp/",
+
+ /* Testing file with double slashes */
+ "$file_path/is_readable_variation1//bar.tmp",
+ "$file_path//is_readable_variation1//bar.tmp",
+ "$file_path/is_readable_variation1/*.tmp",
+ "$file_path/is_readable_variation1/b*.tmp",
+
+ /* Testing Binary safe */
+ "$file_path/is_readable_variation1".chr(0)."bar.tmp",
+ "$file_path".chr(0)."is_readable_variation1/bar.tmp",
+ "$file_path".chr(0)."is_readable_variation1/bar.tmp",
+
+ /* Testing directories */
+ ".", // current directory, exp: bool(true)
+ "$file_path/is_readable_variation1" // temp directory, exp: bool(true)
+);
+$counter = 1;
+/* loop through to test each element in the above array
+ is a writable file */
+foreach($files_arr as $file) {
+ echo "-- Iteration $counter --\n";
+ var_dump( is_readable($file) );
+ $counter++;
+ clearstatcache();
+}
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/is_readable_variation1/bar.tmp");
+rmdir(dirname(__FILE__)."/is_readable_variation1/");
+?>
+--EXPECTF--
+*** Testing is_readable(): usage variations ***
+-- Iteration 1 --
+bool(true)
+-- Iteration 2 --
+bool(%s)
+-- Iteration 3 --
+bool(true)
+-- Iteration 4 --
+bool(true)
+-- Iteration 5 --
+bool(false)
+-- Iteration 6 --
+bool(false)
+-- Iteration 7 --
+
+Warning: is_readable() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+-- Iteration 8 --
+
+Warning: is_readable() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+-- Iteration 9 --
+
+Warning: is_readable() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+-- Iteration 10 --
+bool(true)
+-- Iteration 11 --
+bool(true)
+Done
diff --git a/ext/standard/tests/file/is_readable_variation2.phpt b/ext/standard/tests/file/is_readable_variation2.phpt
new file mode 100644
index 0000000..e1faf55
--- /dev/null
+++ b/ext/standard/tests/file/is_readable_variation2.phpt
@@ -0,0 +1,109 @@
+--TEST--
+Test is_readable() function: usage variations - file/dir with diff. perms
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip not for windows');
+}
+// Skip if being run by root
+$filename = dirname(__FILE__)."/is_readable_root_check.tmp";
+$fp = fopen($filename, 'w');
+fclose($fp);
+if(fileowner($filename) == 0) {
+ unlink ($filename);
+ die('skip cannot be run as root');
+}
+unlink($filename);
+?>
+--FILE--
+<?php
+/* Prototype: bool is_readable ( string $filename );
+ Description: Tells whether the filename is readable.
+*/
+
+/* test is_executable() with file/dir having different permissions */
+
+require dirname(__FILE__).'/file.inc';
+echo "*** Testing is_readable(): usage variations ***\n";
+
+$file_path = dirname(__FILE__);
+mkdir("$file_path/is_readable_variation2");
+
+echo "\n*** Testing is_readable() on directory without read permission ***\n";
+chmod("$file_path/is_readable_variation2", 0001);
+var_dump( is_readable("$file_path/is_readable_variation2") ); // exp: bool(false)
+chmod("$file_path/is_readable_variation2", 0777); // chmod to enable deletion of directory
+
+echo "\n*** Testing miscelleneous input for is_readable() function ***\n";
+$name_prefix = "is_readable_variation2";
+create_files(dirname(__FILE__), 1, "numeric", 0755, 1, "w", $name_prefix, 1);
+create_files(dirname(__FILE__), 1, "text", 0755, 1, "w", $name_prefix, 2);
+create_files(dirname(__FILE__), 1, "empty", 0755, 1, "w", $name_prefix, 3);
+create_files(dirname(__FILE__), 1, "numeric", 0555, 1, "w", $name_prefix, 4);
+create_files(dirname(__FILE__), 1, "text", 0222, 1, "w", $name_prefix, 5);
+create_files(dirname(__FILE__), 1, "numeric", 0711, 1, "w", $name_prefix, 6);
+create_files(dirname(__FILE__), 1, "text", 0411, 1, "w", $name_prefix, 7);
+create_files(dirname(__FILE__), 1, "numeric", 0444, 1, "w", $name_prefix, 8);
+create_files(dirname(__FILE__), 1, "text", 0421, 1, "w", $name_prefix, 9);
+create_files(dirname(__FILE__), 1, "text", 0422, 1, "w", $name_prefix, 10);
+
+$files = array (
+ "$file_path/is_readable_variation21.tmp",
+ "$file_path/is_readable_variation22.tmp",
+ "$file_path/is_readable_variation23.tmp",
+ "$file_path/is_readable_variation24.tmp",
+ "$file_path/is_readable_variation25.tmp",
+ "$file_path/is_readable_variation26.tmp",
+ "$file_path/is_readable_variation27.tmp",
+ "$file_path/is_readable_variation28.tmp",
+ "$file_path/is_readable_variation29.tmp",
+ "$file_path/is_readable_variation210.tmp"
+);
+$counter = 1;
+/* loop through to test each element in the above array
+ is a readable file */
+foreach($files as $file) {
+ echo "-- Iteration $counter --\n";
+ var_dump( is_readable($file) );
+ $counter++;
+ clearstatcache();
+}
+
+// change all file's permissions to 777 before deleting
+change_file_perms($file_path, 10, 0777, $name_prefix);
+delete_files($file_path, 10, $name_prefix);
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+rmdir(dirname(__FILE__)."/is_readable_variation2/");
+?>
+--EXPECTF--
+*** Testing is_readable(): usage variations ***
+
+*** Testing is_readable() on directory without read permission ***
+bool(false)
+
+*** Testing miscelleneous input for is_readable() function ***
+-- Iteration 1 --
+bool(true)
+-- Iteration 2 --
+bool(true)
+-- Iteration 3 --
+bool(true)
+-- Iteration 4 --
+bool(true)
+-- Iteration 5 --
+bool(false)
+-- Iteration 6 --
+bool(true)
+-- Iteration 7 --
+bool(true)
+-- Iteration 8 --
+bool(true)
+-- Iteration 9 --
+bool(true)
+-- Iteration 10 --
+bool(true)
+Done
diff --git a/ext/standard/tests/file/is_readable_variation3.phpt b/ext/standard/tests/file/is_readable_variation3.phpt
new file mode 100644
index 0000000..dc4d3b1
--- /dev/null
+++ b/ext/standard/tests/file/is_readable_variation3.phpt
@@ -0,0 +1,68 @@
+--TEST--
+Test is_readable() function: usage variations - invalid file names
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+
+ // Skip if being run by root (files are always readable, writeable and executable)
+ $filename = dirname(__FILE__)."/is_readable_root_check.tmp";
+ $fp = fopen($filename, 'w');
+ fclose($fp);
+ if(fileowner($filename) == 0) {
+ unlink ($filename);
+ die('skip cannot be run as root');
+ }
+ unlink($filename);
+}
+?>
+--FILE--
+<?php
+/* Prototype: bool is_readable ( string $filename );
+ Description: Tells whether the filename is readable.
+*/
+
+/* test is_executable() with invalid arguments */
+
+echo "*** Testing is_readable(): usage variations ***\n";
+
+$file_handle = fopen(__FILE__, "r");
+unset($file_handle);
+
+echo "\n*** Testing is_readable() on miscelleneous filenames ***\n";
+$misc_files = array(
+ 0,
+ 1234,
+ -2.34555,
+ TRUE,
+ FALSE,
+ NULL,
+ " ",
+ @array(),
+ @$file_handle
+);
+/* loop through to test each element in the above array
+ is a readable file */
+foreach( $misc_files as $misc_file ) {
+ var_dump( is_readable($misc_file) );
+ clearstatcache();
+}
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing is_readable(): usage variations ***
+
+*** Testing is_readable() on miscelleneous filenames ***
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+Warning: is_readable() expects parameter 1 to be a valid path, array given in %s on line %d
+NULL
+bool(false)
+Done
+
diff --git a/ext/standard/tests/file/is_uploaded_file_basic.phpt b/ext/standard/tests/file/is_uploaded_file_basic.phpt
new file mode 100644
index 0000000..1907d39
--- /dev/null
+++ b/ext/standard/tests/file/is_uploaded_file_basic.phpt
@@ -0,0 +1,48 @@
+--TEST--
+is_uploaded_file() function
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--POST_RAW--
+Content-type: multipart/form-data, boundary=AaB03x
+
+--AaB03x
+content-disposition: form-data; name="field1"
+
+Joe Blow
+--AaB03x
+content-disposition: form-data; name="pics"; filename="file1.txt"
+Content-Type: text/plain
+
+abcdef123456789
+--AaB03x--
+--FILE--
+<?php
+// uploaded file
+var_dump(is_uploaded_file($_FILES['pics']['tmp_name']));
+
+// not an uploaded file
+var_dump(is_uploaded_file($_FILES['pics']['name']));
+
+// not an uploaded file
+var_dump(is_uploaded_file('random_filename.txt'));
+
+// not an uploaded file
+var_dump(is_uploaded_file('__FILE__'));
+
+// Error cases
+var_dump(is_uploaded_file());
+var_dump(is_uploaded_file('a', 'b'));
+
+?>
+--EXPECTF--
+bool(true)
+bool(false)
+bool(false)
+bool(false)
+
+Warning: is_uploaded_file() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: is_uploaded_file() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+
diff --git a/ext/standard/tests/file/is_writable_basic.phpt b/ext/standard/tests/file/is_writable_basic.phpt
new file mode 100644
index 0000000..86599b4
--- /dev/null
+++ b/ext/standard/tests/file/is_writable_basic.phpt
@@ -0,0 +1,1588 @@
+--TEST--
+Test is_writable() and its alias is_writeable() function: basic functionality
+--SKIPIF--
+<?php
+// Skip if being run by root (files are always readable, writeable and executable)
+$filename = dirname(__FILE__)."/is_readable_root_check.tmp";
+$fp = fopen($filename, 'w');
+fclose($fp);
+if(fileowner($filename) == 0) {
+ unlink ($filename);
+ die('skip cannot be run as root');
+}
+
+unlink($filename);
+?>
+--FILE--
+<?php
+/* Prototype: bool is_writable ( string $filename );
+ Description: Tells whether the filename is writable.
+
+ is_writeable() is an alias of is_writable()
+*/
+
+// include common file test functions
+require dirname(__FILE__).'/file.inc';
+
+echo "*** Testing is_writable(): basic functionality ***\n";
+
+// create a file
+$filename = dirname(__FILE__)."/is_writable.tmp";
+create_file($filename);
+
+$counter = 1;
+/* loop to check if the file with new mode is writable
+ using is_writable() */
+for($mode = 0000; $mode <= 0777; $mode++) {
+ echo "-- Changing mode of file to $mode --\n";
+ chmod($filename, $mode); // change mode of file
+ var_dump( is_writeable($filename) );
+ var_dump( is_writable($filename) );
+ clearstatcache();
+ $counter++;
+}
+
+// delete the temp file
+delete_file($filename);
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing is_writable(): basic functionality ***
+-- Changing mode of file to 0 --
+bool(false)
+bool(false)
+-- Changing mode of file to 1 --
+bool(false)
+bool(false)
+-- Changing mode of file to 2 --
+bool(false)
+bool(false)
+-- Changing mode of file to 3 --
+bool(false)
+bool(false)
+-- Changing mode of file to 4 --
+bool(false)
+bool(false)
+-- Changing mode of file to 5 --
+bool(false)
+bool(false)
+-- Changing mode of file to 6 --
+bool(false)
+bool(false)
+-- Changing mode of file to 7 --
+bool(false)
+bool(false)
+-- Changing mode of file to 8 --
+bool(false)
+bool(false)
+-- Changing mode of file to 9 --
+bool(false)
+bool(false)
+-- Changing mode of file to 10 --
+bool(false)
+bool(false)
+-- Changing mode of file to 11 --
+bool(false)
+bool(false)
+-- Changing mode of file to 12 --
+bool(false)
+bool(false)
+-- Changing mode of file to 13 --
+bool(false)
+bool(false)
+-- Changing mode of file to 14 --
+bool(false)
+bool(false)
+-- Changing mode of file to 15 --
+bool(false)
+bool(false)
+-- Changing mode of file to 16 --
+bool(false)
+bool(false)
+-- Changing mode of file to 17 --
+bool(false)
+bool(false)
+-- Changing mode of file to 18 --
+bool(false)
+bool(false)
+-- Changing mode of file to 19 --
+bool(false)
+bool(false)
+-- Changing mode of file to 20 --
+bool(false)
+bool(false)
+-- Changing mode of file to 21 --
+bool(false)
+bool(false)
+-- Changing mode of file to 22 --
+bool(false)
+bool(false)
+-- Changing mode of file to 23 --
+bool(false)
+bool(false)
+-- Changing mode of file to 24 --
+bool(false)
+bool(false)
+-- Changing mode of file to 25 --
+bool(false)
+bool(false)
+-- Changing mode of file to 26 --
+bool(false)
+bool(false)
+-- Changing mode of file to 27 --
+bool(false)
+bool(false)
+-- Changing mode of file to 28 --
+bool(false)
+bool(false)
+-- Changing mode of file to 29 --
+bool(false)
+bool(false)
+-- Changing mode of file to 30 --
+bool(false)
+bool(false)
+-- Changing mode of file to 31 --
+bool(false)
+bool(false)
+-- Changing mode of file to 32 --
+bool(false)
+bool(false)
+-- Changing mode of file to 33 --
+bool(false)
+bool(false)
+-- Changing mode of file to 34 --
+bool(false)
+bool(false)
+-- Changing mode of file to 35 --
+bool(false)
+bool(false)
+-- Changing mode of file to 36 --
+bool(false)
+bool(false)
+-- Changing mode of file to 37 --
+bool(false)
+bool(false)
+-- Changing mode of file to 38 --
+bool(false)
+bool(false)
+-- Changing mode of file to 39 --
+bool(false)
+bool(false)
+-- Changing mode of file to 40 --
+bool(false)
+bool(false)
+-- Changing mode of file to 41 --
+bool(false)
+bool(false)
+-- Changing mode of file to 42 --
+bool(false)
+bool(false)
+-- Changing mode of file to 43 --
+bool(false)
+bool(false)
+-- Changing mode of file to 44 --
+bool(false)
+bool(false)
+-- Changing mode of file to 45 --
+bool(false)
+bool(false)
+-- Changing mode of file to 46 --
+bool(false)
+bool(false)
+-- Changing mode of file to 47 --
+bool(false)
+bool(false)
+-- Changing mode of file to 48 --
+bool(false)
+bool(false)
+-- Changing mode of file to 49 --
+bool(false)
+bool(false)
+-- Changing mode of file to 50 --
+bool(false)
+bool(false)
+-- Changing mode of file to 51 --
+bool(false)
+bool(false)
+-- Changing mode of file to 52 --
+bool(false)
+bool(false)
+-- Changing mode of file to 53 --
+bool(false)
+bool(false)
+-- Changing mode of file to 54 --
+bool(false)
+bool(false)
+-- Changing mode of file to 55 --
+bool(false)
+bool(false)
+-- Changing mode of file to 56 --
+bool(false)
+bool(false)
+-- Changing mode of file to 57 --
+bool(false)
+bool(false)
+-- Changing mode of file to 58 --
+bool(false)
+bool(false)
+-- Changing mode of file to 59 --
+bool(false)
+bool(false)
+-- Changing mode of file to 60 --
+bool(false)
+bool(false)
+-- Changing mode of file to 61 --
+bool(false)
+bool(false)
+-- Changing mode of file to 62 --
+bool(false)
+bool(false)
+-- Changing mode of file to 63 --
+bool(false)
+bool(false)
+-- Changing mode of file to 64 --
+bool(false)
+bool(false)
+-- Changing mode of file to 65 --
+bool(false)
+bool(false)
+-- Changing mode of file to 66 --
+bool(false)
+bool(false)
+-- Changing mode of file to 67 --
+bool(false)
+bool(false)
+-- Changing mode of file to 68 --
+bool(false)
+bool(false)
+-- Changing mode of file to 69 --
+bool(false)
+bool(false)
+-- Changing mode of file to 70 --
+bool(false)
+bool(false)
+-- Changing mode of file to 71 --
+bool(false)
+bool(false)
+-- Changing mode of file to 72 --
+bool(false)
+bool(false)
+-- Changing mode of file to 73 --
+bool(false)
+bool(false)
+-- Changing mode of file to 74 --
+bool(false)
+bool(false)
+-- Changing mode of file to 75 --
+bool(false)
+bool(false)
+-- Changing mode of file to 76 --
+bool(false)
+bool(false)
+-- Changing mode of file to 77 --
+bool(false)
+bool(false)
+-- Changing mode of file to 78 --
+bool(false)
+bool(false)
+-- Changing mode of file to 79 --
+bool(false)
+bool(false)
+-- Changing mode of file to 80 --
+bool(false)
+bool(false)
+-- Changing mode of file to 81 --
+bool(false)
+bool(false)
+-- Changing mode of file to 82 --
+bool(false)
+bool(false)
+-- Changing mode of file to 83 --
+bool(false)
+bool(false)
+-- Changing mode of file to 84 --
+bool(false)
+bool(false)
+-- Changing mode of file to 85 --
+bool(false)
+bool(false)
+-- Changing mode of file to 86 --
+bool(false)
+bool(false)
+-- Changing mode of file to 87 --
+bool(false)
+bool(false)
+-- Changing mode of file to 88 --
+bool(false)
+bool(false)
+-- Changing mode of file to 89 --
+bool(false)
+bool(false)
+-- Changing mode of file to 90 --
+bool(false)
+bool(false)
+-- Changing mode of file to 91 --
+bool(false)
+bool(false)
+-- Changing mode of file to 92 --
+bool(false)
+bool(false)
+-- Changing mode of file to 93 --
+bool(false)
+bool(false)
+-- Changing mode of file to 94 --
+bool(false)
+bool(false)
+-- Changing mode of file to 95 --
+bool(false)
+bool(false)
+-- Changing mode of file to 96 --
+bool(false)
+bool(false)
+-- Changing mode of file to 97 --
+bool(false)
+bool(false)
+-- Changing mode of file to 98 --
+bool(false)
+bool(false)
+-- Changing mode of file to 99 --
+bool(false)
+bool(false)
+-- Changing mode of file to 100 --
+bool(false)
+bool(false)
+-- Changing mode of file to 101 --
+bool(false)
+bool(false)
+-- Changing mode of file to 102 --
+bool(false)
+bool(false)
+-- Changing mode of file to 103 --
+bool(false)
+bool(false)
+-- Changing mode of file to 104 --
+bool(false)
+bool(false)
+-- Changing mode of file to 105 --
+bool(false)
+bool(false)
+-- Changing mode of file to 106 --
+bool(false)
+bool(false)
+-- Changing mode of file to 107 --
+bool(false)
+bool(false)
+-- Changing mode of file to 108 --
+bool(false)
+bool(false)
+-- Changing mode of file to 109 --
+bool(false)
+bool(false)
+-- Changing mode of file to 110 --
+bool(false)
+bool(false)
+-- Changing mode of file to 111 --
+bool(false)
+bool(false)
+-- Changing mode of file to 112 --
+bool(false)
+bool(false)
+-- Changing mode of file to 113 --
+bool(false)
+bool(false)
+-- Changing mode of file to 114 --
+bool(false)
+bool(false)
+-- Changing mode of file to 115 --
+bool(false)
+bool(false)
+-- Changing mode of file to 116 --
+bool(false)
+bool(false)
+-- Changing mode of file to 117 --
+bool(false)
+bool(false)
+-- Changing mode of file to 118 --
+bool(false)
+bool(false)
+-- Changing mode of file to 119 --
+bool(false)
+bool(false)
+-- Changing mode of file to 120 --
+bool(false)
+bool(false)
+-- Changing mode of file to 121 --
+bool(false)
+bool(false)
+-- Changing mode of file to 122 --
+bool(false)
+bool(false)
+-- Changing mode of file to 123 --
+bool(false)
+bool(false)
+-- Changing mode of file to 124 --
+bool(false)
+bool(false)
+-- Changing mode of file to 125 --
+bool(false)
+bool(false)
+-- Changing mode of file to 126 --
+bool(false)
+bool(false)
+-- Changing mode of file to 127 --
+bool(false)
+bool(false)
+-- Changing mode of file to 128 --
+bool(true)
+bool(true)
+-- Changing mode of file to 129 --
+bool(true)
+bool(true)
+-- Changing mode of file to 130 --
+bool(true)
+bool(true)
+-- Changing mode of file to 131 --
+bool(true)
+bool(true)
+-- Changing mode of file to 132 --
+bool(true)
+bool(true)
+-- Changing mode of file to 133 --
+bool(true)
+bool(true)
+-- Changing mode of file to 134 --
+bool(true)
+bool(true)
+-- Changing mode of file to 135 --
+bool(true)
+bool(true)
+-- Changing mode of file to 136 --
+bool(true)
+bool(true)
+-- Changing mode of file to 137 --
+bool(true)
+bool(true)
+-- Changing mode of file to 138 --
+bool(true)
+bool(true)
+-- Changing mode of file to 139 --
+bool(true)
+bool(true)
+-- Changing mode of file to 140 --
+bool(true)
+bool(true)
+-- Changing mode of file to 141 --
+bool(true)
+bool(true)
+-- Changing mode of file to 142 --
+bool(true)
+bool(true)
+-- Changing mode of file to 143 --
+bool(true)
+bool(true)
+-- Changing mode of file to 144 --
+bool(true)
+bool(true)
+-- Changing mode of file to 145 --
+bool(true)
+bool(true)
+-- Changing mode of file to 146 --
+bool(true)
+bool(true)
+-- Changing mode of file to 147 --
+bool(true)
+bool(true)
+-- Changing mode of file to 148 --
+bool(true)
+bool(true)
+-- Changing mode of file to 149 --
+bool(true)
+bool(true)
+-- Changing mode of file to 150 --
+bool(true)
+bool(true)
+-- Changing mode of file to 151 --
+bool(true)
+bool(true)
+-- Changing mode of file to 152 --
+bool(true)
+bool(true)
+-- Changing mode of file to 153 --
+bool(true)
+bool(true)
+-- Changing mode of file to 154 --
+bool(true)
+bool(true)
+-- Changing mode of file to 155 --
+bool(true)
+bool(true)
+-- Changing mode of file to 156 --
+bool(true)
+bool(true)
+-- Changing mode of file to 157 --
+bool(true)
+bool(true)
+-- Changing mode of file to 158 --
+bool(true)
+bool(true)
+-- Changing mode of file to 159 --
+bool(true)
+bool(true)
+-- Changing mode of file to 160 --
+bool(true)
+bool(true)
+-- Changing mode of file to 161 --
+bool(true)
+bool(true)
+-- Changing mode of file to 162 --
+bool(true)
+bool(true)
+-- Changing mode of file to 163 --
+bool(true)
+bool(true)
+-- Changing mode of file to 164 --
+bool(true)
+bool(true)
+-- Changing mode of file to 165 --
+bool(true)
+bool(true)
+-- Changing mode of file to 166 --
+bool(true)
+bool(true)
+-- Changing mode of file to 167 --
+bool(true)
+bool(true)
+-- Changing mode of file to 168 --
+bool(true)
+bool(true)
+-- Changing mode of file to 169 --
+bool(true)
+bool(true)
+-- Changing mode of file to 170 --
+bool(true)
+bool(true)
+-- Changing mode of file to 171 --
+bool(true)
+bool(true)
+-- Changing mode of file to 172 --
+bool(true)
+bool(true)
+-- Changing mode of file to 173 --
+bool(true)
+bool(true)
+-- Changing mode of file to 174 --
+bool(true)
+bool(true)
+-- Changing mode of file to 175 --
+bool(true)
+bool(true)
+-- Changing mode of file to 176 --
+bool(true)
+bool(true)
+-- Changing mode of file to 177 --
+bool(true)
+bool(true)
+-- Changing mode of file to 178 --
+bool(true)
+bool(true)
+-- Changing mode of file to 179 --
+bool(true)
+bool(true)
+-- Changing mode of file to 180 --
+bool(true)
+bool(true)
+-- Changing mode of file to 181 --
+bool(true)
+bool(true)
+-- Changing mode of file to 182 --
+bool(true)
+bool(true)
+-- Changing mode of file to 183 --
+bool(true)
+bool(true)
+-- Changing mode of file to 184 --
+bool(true)
+bool(true)
+-- Changing mode of file to 185 --
+bool(true)
+bool(true)
+-- Changing mode of file to 186 --
+bool(true)
+bool(true)
+-- Changing mode of file to 187 --
+bool(true)
+bool(true)
+-- Changing mode of file to 188 --
+bool(true)
+bool(true)
+-- Changing mode of file to 189 --
+bool(true)
+bool(true)
+-- Changing mode of file to 190 --
+bool(true)
+bool(true)
+-- Changing mode of file to 191 --
+bool(true)
+bool(true)
+-- Changing mode of file to 192 --
+bool(true)
+bool(true)
+-- Changing mode of file to 193 --
+bool(true)
+bool(true)
+-- Changing mode of file to 194 --
+bool(true)
+bool(true)
+-- Changing mode of file to 195 --
+bool(true)
+bool(true)
+-- Changing mode of file to 196 --
+bool(true)
+bool(true)
+-- Changing mode of file to 197 --
+bool(true)
+bool(true)
+-- Changing mode of file to 198 --
+bool(true)
+bool(true)
+-- Changing mode of file to 199 --
+bool(true)
+bool(true)
+-- Changing mode of file to 200 --
+bool(true)
+bool(true)
+-- Changing mode of file to 201 --
+bool(true)
+bool(true)
+-- Changing mode of file to 202 --
+bool(true)
+bool(true)
+-- Changing mode of file to 203 --
+bool(true)
+bool(true)
+-- Changing mode of file to 204 --
+bool(true)
+bool(true)
+-- Changing mode of file to 205 --
+bool(true)
+bool(true)
+-- Changing mode of file to 206 --
+bool(true)
+bool(true)
+-- Changing mode of file to 207 --
+bool(true)
+bool(true)
+-- Changing mode of file to 208 --
+bool(true)
+bool(true)
+-- Changing mode of file to 209 --
+bool(true)
+bool(true)
+-- Changing mode of file to 210 --
+bool(true)
+bool(true)
+-- Changing mode of file to 211 --
+bool(true)
+bool(true)
+-- Changing mode of file to 212 --
+bool(true)
+bool(true)
+-- Changing mode of file to 213 --
+bool(true)
+bool(true)
+-- Changing mode of file to 214 --
+bool(true)
+bool(true)
+-- Changing mode of file to 215 --
+bool(true)
+bool(true)
+-- Changing mode of file to 216 --
+bool(true)
+bool(true)
+-- Changing mode of file to 217 --
+bool(true)
+bool(true)
+-- Changing mode of file to 218 --
+bool(true)
+bool(true)
+-- Changing mode of file to 219 --
+bool(true)
+bool(true)
+-- Changing mode of file to 220 --
+bool(true)
+bool(true)
+-- Changing mode of file to 221 --
+bool(true)
+bool(true)
+-- Changing mode of file to 222 --
+bool(true)
+bool(true)
+-- Changing mode of file to 223 --
+bool(true)
+bool(true)
+-- Changing mode of file to 224 --
+bool(true)
+bool(true)
+-- Changing mode of file to 225 --
+bool(true)
+bool(true)
+-- Changing mode of file to 226 --
+bool(true)
+bool(true)
+-- Changing mode of file to 227 --
+bool(true)
+bool(true)
+-- Changing mode of file to 228 --
+bool(true)
+bool(true)
+-- Changing mode of file to 229 --
+bool(true)
+bool(true)
+-- Changing mode of file to 230 --
+bool(true)
+bool(true)
+-- Changing mode of file to 231 --
+bool(true)
+bool(true)
+-- Changing mode of file to 232 --
+bool(true)
+bool(true)
+-- Changing mode of file to 233 --
+bool(true)
+bool(true)
+-- Changing mode of file to 234 --
+bool(true)
+bool(true)
+-- Changing mode of file to 235 --
+bool(true)
+bool(true)
+-- Changing mode of file to 236 --
+bool(true)
+bool(true)
+-- Changing mode of file to 237 --
+bool(true)
+bool(true)
+-- Changing mode of file to 238 --
+bool(true)
+bool(true)
+-- Changing mode of file to 239 --
+bool(true)
+bool(true)
+-- Changing mode of file to 240 --
+bool(true)
+bool(true)
+-- Changing mode of file to 241 --
+bool(true)
+bool(true)
+-- Changing mode of file to 242 --
+bool(true)
+bool(true)
+-- Changing mode of file to 243 --
+bool(true)
+bool(true)
+-- Changing mode of file to 244 --
+bool(true)
+bool(true)
+-- Changing mode of file to 245 --
+bool(true)
+bool(true)
+-- Changing mode of file to 246 --
+bool(true)
+bool(true)
+-- Changing mode of file to 247 --
+bool(true)
+bool(true)
+-- Changing mode of file to 248 --
+bool(true)
+bool(true)
+-- Changing mode of file to 249 --
+bool(true)
+bool(true)
+-- Changing mode of file to 250 --
+bool(true)
+bool(true)
+-- Changing mode of file to 251 --
+bool(true)
+bool(true)
+-- Changing mode of file to 252 --
+bool(true)
+bool(true)
+-- Changing mode of file to 253 --
+bool(true)
+bool(true)
+-- Changing mode of file to 254 --
+bool(true)
+bool(true)
+-- Changing mode of file to 255 --
+bool(true)
+bool(true)
+-- Changing mode of file to 256 --
+bool(false)
+bool(false)
+-- Changing mode of file to 257 --
+bool(false)
+bool(false)
+-- Changing mode of file to 258 --
+bool(false)
+bool(false)
+-- Changing mode of file to 259 --
+bool(false)
+bool(false)
+-- Changing mode of file to 260 --
+bool(false)
+bool(false)
+-- Changing mode of file to 261 --
+bool(false)
+bool(false)
+-- Changing mode of file to 262 --
+bool(false)
+bool(false)
+-- Changing mode of file to 263 --
+bool(false)
+bool(false)
+-- Changing mode of file to 264 --
+bool(false)
+bool(false)
+-- Changing mode of file to 265 --
+bool(false)
+bool(false)
+-- Changing mode of file to 266 --
+bool(false)
+bool(false)
+-- Changing mode of file to 267 --
+bool(false)
+bool(false)
+-- Changing mode of file to 268 --
+bool(false)
+bool(false)
+-- Changing mode of file to 269 --
+bool(false)
+bool(false)
+-- Changing mode of file to 270 --
+bool(false)
+bool(false)
+-- Changing mode of file to 271 --
+bool(false)
+bool(false)
+-- Changing mode of file to 272 --
+bool(false)
+bool(false)
+-- Changing mode of file to 273 --
+bool(false)
+bool(false)
+-- Changing mode of file to 274 --
+bool(false)
+bool(false)
+-- Changing mode of file to 275 --
+bool(false)
+bool(false)
+-- Changing mode of file to 276 --
+bool(false)
+bool(false)
+-- Changing mode of file to 277 --
+bool(false)
+bool(false)
+-- Changing mode of file to 278 --
+bool(false)
+bool(false)
+-- Changing mode of file to 279 --
+bool(false)
+bool(false)
+-- Changing mode of file to 280 --
+bool(false)
+bool(false)
+-- Changing mode of file to 281 --
+bool(false)
+bool(false)
+-- Changing mode of file to 282 --
+bool(false)
+bool(false)
+-- Changing mode of file to 283 --
+bool(false)
+bool(false)
+-- Changing mode of file to 284 --
+bool(false)
+bool(false)
+-- Changing mode of file to 285 --
+bool(false)
+bool(false)
+-- Changing mode of file to 286 --
+bool(false)
+bool(false)
+-- Changing mode of file to 287 --
+bool(false)
+bool(false)
+-- Changing mode of file to 288 --
+bool(false)
+bool(false)
+-- Changing mode of file to 289 --
+bool(false)
+bool(false)
+-- Changing mode of file to 290 --
+bool(false)
+bool(false)
+-- Changing mode of file to 291 --
+bool(false)
+bool(false)
+-- Changing mode of file to 292 --
+bool(false)
+bool(false)
+-- Changing mode of file to 293 --
+bool(false)
+bool(false)
+-- Changing mode of file to 294 --
+bool(false)
+bool(false)
+-- Changing mode of file to 295 --
+bool(false)
+bool(false)
+-- Changing mode of file to 296 --
+bool(false)
+bool(false)
+-- Changing mode of file to 297 --
+bool(false)
+bool(false)
+-- Changing mode of file to 298 --
+bool(false)
+bool(false)
+-- Changing mode of file to 299 --
+bool(false)
+bool(false)
+-- Changing mode of file to 300 --
+bool(false)
+bool(false)
+-- Changing mode of file to 301 --
+bool(false)
+bool(false)
+-- Changing mode of file to 302 --
+bool(false)
+bool(false)
+-- Changing mode of file to 303 --
+bool(false)
+bool(false)
+-- Changing mode of file to 304 --
+bool(false)
+bool(false)
+-- Changing mode of file to 305 --
+bool(false)
+bool(false)
+-- Changing mode of file to 306 --
+bool(false)
+bool(false)
+-- Changing mode of file to 307 --
+bool(false)
+bool(false)
+-- Changing mode of file to 308 --
+bool(false)
+bool(false)
+-- Changing mode of file to 309 --
+bool(false)
+bool(false)
+-- Changing mode of file to 310 --
+bool(false)
+bool(false)
+-- Changing mode of file to 311 --
+bool(false)
+bool(false)
+-- Changing mode of file to 312 --
+bool(false)
+bool(false)
+-- Changing mode of file to 313 --
+bool(false)
+bool(false)
+-- Changing mode of file to 314 --
+bool(false)
+bool(false)
+-- Changing mode of file to 315 --
+bool(false)
+bool(false)
+-- Changing mode of file to 316 --
+bool(false)
+bool(false)
+-- Changing mode of file to 317 --
+bool(false)
+bool(false)
+-- Changing mode of file to 318 --
+bool(false)
+bool(false)
+-- Changing mode of file to 319 --
+bool(false)
+bool(false)
+-- Changing mode of file to 320 --
+bool(false)
+bool(false)
+-- Changing mode of file to 321 --
+bool(false)
+bool(false)
+-- Changing mode of file to 322 --
+bool(false)
+bool(false)
+-- Changing mode of file to 323 --
+bool(false)
+bool(false)
+-- Changing mode of file to 324 --
+bool(false)
+bool(false)
+-- Changing mode of file to 325 --
+bool(false)
+bool(false)
+-- Changing mode of file to 326 --
+bool(false)
+bool(false)
+-- Changing mode of file to 327 --
+bool(false)
+bool(false)
+-- Changing mode of file to 328 --
+bool(false)
+bool(false)
+-- Changing mode of file to 329 --
+bool(false)
+bool(false)
+-- Changing mode of file to 330 --
+bool(false)
+bool(false)
+-- Changing mode of file to 331 --
+bool(false)
+bool(false)
+-- Changing mode of file to 332 --
+bool(false)
+bool(false)
+-- Changing mode of file to 333 --
+bool(false)
+bool(false)
+-- Changing mode of file to 334 --
+bool(false)
+bool(false)
+-- Changing mode of file to 335 --
+bool(false)
+bool(false)
+-- Changing mode of file to 336 --
+bool(false)
+bool(false)
+-- Changing mode of file to 337 --
+bool(false)
+bool(false)
+-- Changing mode of file to 338 --
+bool(false)
+bool(false)
+-- Changing mode of file to 339 --
+bool(false)
+bool(false)
+-- Changing mode of file to 340 --
+bool(false)
+bool(false)
+-- Changing mode of file to 341 --
+bool(false)
+bool(false)
+-- Changing mode of file to 342 --
+bool(false)
+bool(false)
+-- Changing mode of file to 343 --
+bool(false)
+bool(false)
+-- Changing mode of file to 344 --
+bool(false)
+bool(false)
+-- Changing mode of file to 345 --
+bool(false)
+bool(false)
+-- Changing mode of file to 346 --
+bool(false)
+bool(false)
+-- Changing mode of file to 347 --
+bool(false)
+bool(false)
+-- Changing mode of file to 348 --
+bool(false)
+bool(false)
+-- Changing mode of file to 349 --
+bool(false)
+bool(false)
+-- Changing mode of file to 350 --
+bool(false)
+bool(false)
+-- Changing mode of file to 351 --
+bool(false)
+bool(false)
+-- Changing mode of file to 352 --
+bool(false)
+bool(false)
+-- Changing mode of file to 353 --
+bool(false)
+bool(false)
+-- Changing mode of file to 354 --
+bool(false)
+bool(false)
+-- Changing mode of file to 355 --
+bool(false)
+bool(false)
+-- Changing mode of file to 356 --
+bool(false)
+bool(false)
+-- Changing mode of file to 357 --
+bool(false)
+bool(false)
+-- Changing mode of file to 358 --
+bool(false)
+bool(false)
+-- Changing mode of file to 359 --
+bool(false)
+bool(false)
+-- Changing mode of file to 360 --
+bool(false)
+bool(false)
+-- Changing mode of file to 361 --
+bool(false)
+bool(false)
+-- Changing mode of file to 362 --
+bool(false)
+bool(false)
+-- Changing mode of file to 363 --
+bool(false)
+bool(false)
+-- Changing mode of file to 364 --
+bool(false)
+bool(false)
+-- Changing mode of file to 365 --
+bool(false)
+bool(false)
+-- Changing mode of file to 366 --
+bool(false)
+bool(false)
+-- Changing mode of file to 367 --
+bool(false)
+bool(false)
+-- Changing mode of file to 368 --
+bool(false)
+bool(false)
+-- Changing mode of file to 369 --
+bool(false)
+bool(false)
+-- Changing mode of file to 370 --
+bool(false)
+bool(false)
+-- Changing mode of file to 371 --
+bool(false)
+bool(false)
+-- Changing mode of file to 372 --
+bool(false)
+bool(false)
+-- Changing mode of file to 373 --
+bool(false)
+bool(false)
+-- Changing mode of file to 374 --
+bool(false)
+bool(false)
+-- Changing mode of file to 375 --
+bool(false)
+bool(false)
+-- Changing mode of file to 376 --
+bool(false)
+bool(false)
+-- Changing mode of file to 377 --
+bool(false)
+bool(false)
+-- Changing mode of file to 378 --
+bool(false)
+bool(false)
+-- Changing mode of file to 379 --
+bool(false)
+bool(false)
+-- Changing mode of file to 380 --
+bool(false)
+bool(false)
+-- Changing mode of file to 381 --
+bool(false)
+bool(false)
+-- Changing mode of file to 382 --
+bool(false)
+bool(false)
+-- Changing mode of file to 383 --
+bool(false)
+bool(false)
+-- Changing mode of file to 384 --
+bool(true)
+bool(true)
+-- Changing mode of file to 385 --
+bool(true)
+bool(true)
+-- Changing mode of file to 386 --
+bool(true)
+bool(true)
+-- Changing mode of file to 387 --
+bool(true)
+bool(true)
+-- Changing mode of file to 388 --
+bool(true)
+bool(true)
+-- Changing mode of file to 389 --
+bool(true)
+bool(true)
+-- Changing mode of file to 390 --
+bool(true)
+bool(true)
+-- Changing mode of file to 391 --
+bool(true)
+bool(true)
+-- Changing mode of file to 392 --
+bool(true)
+bool(true)
+-- Changing mode of file to 393 --
+bool(true)
+bool(true)
+-- Changing mode of file to 394 --
+bool(true)
+bool(true)
+-- Changing mode of file to 395 --
+bool(true)
+bool(true)
+-- Changing mode of file to 396 --
+bool(true)
+bool(true)
+-- Changing mode of file to 397 --
+bool(true)
+bool(true)
+-- Changing mode of file to 398 --
+bool(true)
+bool(true)
+-- Changing mode of file to 399 --
+bool(true)
+bool(true)
+-- Changing mode of file to 400 --
+bool(true)
+bool(true)
+-- Changing mode of file to 401 --
+bool(true)
+bool(true)
+-- Changing mode of file to 402 --
+bool(true)
+bool(true)
+-- Changing mode of file to 403 --
+bool(true)
+bool(true)
+-- Changing mode of file to 404 --
+bool(true)
+bool(true)
+-- Changing mode of file to 405 --
+bool(true)
+bool(true)
+-- Changing mode of file to 406 --
+bool(true)
+bool(true)
+-- Changing mode of file to 407 --
+bool(true)
+bool(true)
+-- Changing mode of file to 408 --
+bool(true)
+bool(true)
+-- Changing mode of file to 409 --
+bool(true)
+bool(true)
+-- Changing mode of file to 410 --
+bool(true)
+bool(true)
+-- Changing mode of file to 411 --
+bool(true)
+bool(true)
+-- Changing mode of file to 412 --
+bool(true)
+bool(true)
+-- Changing mode of file to 413 --
+bool(true)
+bool(true)
+-- Changing mode of file to 414 --
+bool(true)
+bool(true)
+-- Changing mode of file to 415 --
+bool(true)
+bool(true)
+-- Changing mode of file to 416 --
+bool(true)
+bool(true)
+-- Changing mode of file to 417 --
+bool(true)
+bool(true)
+-- Changing mode of file to 418 --
+bool(true)
+bool(true)
+-- Changing mode of file to 419 --
+bool(true)
+bool(true)
+-- Changing mode of file to 420 --
+bool(true)
+bool(true)
+-- Changing mode of file to 421 --
+bool(true)
+bool(true)
+-- Changing mode of file to 422 --
+bool(true)
+bool(true)
+-- Changing mode of file to 423 --
+bool(true)
+bool(true)
+-- Changing mode of file to 424 --
+bool(true)
+bool(true)
+-- Changing mode of file to 425 --
+bool(true)
+bool(true)
+-- Changing mode of file to 426 --
+bool(true)
+bool(true)
+-- Changing mode of file to 427 --
+bool(true)
+bool(true)
+-- Changing mode of file to 428 --
+bool(true)
+bool(true)
+-- Changing mode of file to 429 --
+bool(true)
+bool(true)
+-- Changing mode of file to 430 --
+bool(true)
+bool(true)
+-- Changing mode of file to 431 --
+bool(true)
+bool(true)
+-- Changing mode of file to 432 --
+bool(true)
+bool(true)
+-- Changing mode of file to 433 --
+bool(true)
+bool(true)
+-- Changing mode of file to 434 --
+bool(true)
+bool(true)
+-- Changing mode of file to 435 --
+bool(true)
+bool(true)
+-- Changing mode of file to 436 --
+bool(true)
+bool(true)
+-- Changing mode of file to 437 --
+bool(true)
+bool(true)
+-- Changing mode of file to 438 --
+bool(true)
+bool(true)
+-- Changing mode of file to 439 --
+bool(true)
+bool(true)
+-- Changing mode of file to 440 --
+bool(true)
+bool(true)
+-- Changing mode of file to 441 --
+bool(true)
+bool(true)
+-- Changing mode of file to 442 --
+bool(true)
+bool(true)
+-- Changing mode of file to 443 --
+bool(true)
+bool(true)
+-- Changing mode of file to 444 --
+bool(true)
+bool(true)
+-- Changing mode of file to 445 --
+bool(true)
+bool(true)
+-- Changing mode of file to 446 --
+bool(true)
+bool(true)
+-- Changing mode of file to 447 --
+bool(true)
+bool(true)
+-- Changing mode of file to 448 --
+bool(true)
+bool(true)
+-- Changing mode of file to 449 --
+bool(true)
+bool(true)
+-- Changing mode of file to 450 --
+bool(true)
+bool(true)
+-- Changing mode of file to 451 --
+bool(true)
+bool(true)
+-- Changing mode of file to 452 --
+bool(true)
+bool(true)
+-- Changing mode of file to 453 --
+bool(true)
+bool(true)
+-- Changing mode of file to 454 --
+bool(true)
+bool(true)
+-- Changing mode of file to 455 --
+bool(true)
+bool(true)
+-- Changing mode of file to 456 --
+bool(true)
+bool(true)
+-- Changing mode of file to 457 --
+bool(true)
+bool(true)
+-- Changing mode of file to 458 --
+bool(true)
+bool(true)
+-- Changing mode of file to 459 --
+bool(true)
+bool(true)
+-- Changing mode of file to 460 --
+bool(true)
+bool(true)
+-- Changing mode of file to 461 --
+bool(true)
+bool(true)
+-- Changing mode of file to 462 --
+bool(true)
+bool(true)
+-- Changing mode of file to 463 --
+bool(true)
+bool(true)
+-- Changing mode of file to 464 --
+bool(true)
+bool(true)
+-- Changing mode of file to 465 --
+bool(true)
+bool(true)
+-- Changing mode of file to 466 --
+bool(true)
+bool(true)
+-- Changing mode of file to 467 --
+bool(true)
+bool(true)
+-- Changing mode of file to 468 --
+bool(true)
+bool(true)
+-- Changing mode of file to 469 --
+bool(true)
+bool(true)
+-- Changing mode of file to 470 --
+bool(true)
+bool(true)
+-- Changing mode of file to 471 --
+bool(true)
+bool(true)
+-- Changing mode of file to 472 --
+bool(true)
+bool(true)
+-- Changing mode of file to 473 --
+bool(true)
+bool(true)
+-- Changing mode of file to 474 --
+bool(true)
+bool(true)
+-- Changing mode of file to 475 --
+bool(true)
+bool(true)
+-- Changing mode of file to 476 --
+bool(true)
+bool(true)
+-- Changing mode of file to 477 --
+bool(true)
+bool(true)
+-- Changing mode of file to 478 --
+bool(true)
+bool(true)
+-- Changing mode of file to 479 --
+bool(true)
+bool(true)
+-- Changing mode of file to 480 --
+bool(true)
+bool(true)
+-- Changing mode of file to 481 --
+bool(true)
+bool(true)
+-- Changing mode of file to 482 --
+bool(true)
+bool(true)
+-- Changing mode of file to 483 --
+bool(true)
+bool(true)
+-- Changing mode of file to 484 --
+bool(true)
+bool(true)
+-- Changing mode of file to 485 --
+bool(true)
+bool(true)
+-- Changing mode of file to 486 --
+bool(true)
+bool(true)
+-- Changing mode of file to 487 --
+bool(true)
+bool(true)
+-- Changing mode of file to 488 --
+bool(true)
+bool(true)
+-- Changing mode of file to 489 --
+bool(true)
+bool(true)
+-- Changing mode of file to 490 --
+bool(true)
+bool(true)
+-- Changing mode of file to 491 --
+bool(true)
+bool(true)
+-- Changing mode of file to 492 --
+bool(true)
+bool(true)
+-- Changing mode of file to 493 --
+bool(true)
+bool(true)
+-- Changing mode of file to 494 --
+bool(true)
+bool(true)
+-- Changing mode of file to 495 --
+bool(true)
+bool(true)
+-- Changing mode of file to 496 --
+bool(true)
+bool(true)
+-- Changing mode of file to 497 --
+bool(true)
+bool(true)
+-- Changing mode of file to 498 --
+bool(true)
+bool(true)
+-- Changing mode of file to 499 --
+bool(true)
+bool(true)
+-- Changing mode of file to 500 --
+bool(true)
+bool(true)
+-- Changing mode of file to 501 --
+bool(true)
+bool(true)
+-- Changing mode of file to 502 --
+bool(true)
+bool(true)
+-- Changing mode of file to 503 --
+bool(true)
+bool(true)
+-- Changing mode of file to 504 --
+bool(true)
+bool(true)
+-- Changing mode of file to 505 --
+bool(true)
+bool(true)
+-- Changing mode of file to 506 --
+bool(true)
+bool(true)
+-- Changing mode of file to 507 --
+bool(true)
+bool(true)
+-- Changing mode of file to 508 --
+bool(true)
+bool(true)
+-- Changing mode of file to 509 --
+bool(true)
+bool(true)
+-- Changing mode of file to 510 --
+bool(true)
+bool(true)
+-- Changing mode of file to 511 --
+bool(true)
+bool(true)
+Done
diff --git a/ext/standard/tests/file/is_writable_error.phpt b/ext/standard/tests/file/is_writable_error.phpt
new file mode 100644
index 0000000..e3755bc
--- /dev/null
+++ b/ext/standard/tests/file/is_writable_error.phpt
@@ -0,0 +1,45 @@
+--TEST--
+Test is_writable() and its alias is_writeable() function: error conditions
+--FILE--
+<?php
+/* Prototype: bool is_writable ( string $filename );
+ Description: Tells whether the filename is writable.
+
+ is_writeable() is an alias of is_writable()
+*/
+
+echo "*** Testing is_writable(): error conditions ***\n";
+var_dump( is_writable() ); // args < expected
+var_dump( is_writeable() );
+
+echo "\n*** Testing is_writeable(): error conditions ***\n";
+var_dump( is_writable(1, 2) ); // args > expected
+var_dump( is_writeable(1, 2) );
+
+echo "\n*** Testing is_writable() on non-existent file ***\n";
+var_dump( is_writable(dirname(__FILE__)."/is_writable") );
+var_dump( is_writeable(dirname(__FILE__)."/is_writable") );
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing is_writable(): error conditions ***
+
+Warning: is_writable() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: is_writeable() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+*** Testing is_writeable(): error conditions ***
+
+Warning: is_writable() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+
+Warning: is_writeable() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+
+*** Testing is_writable() on non-existent file ***
+bool(false)
+bool(false)
+Done
diff --git a/ext/standard/tests/file/is_writable_variation1.phpt b/ext/standard/tests/file/is_writable_variation1.phpt
new file mode 100644
index 0000000..718c7fb
--- /dev/null
+++ b/ext/standard/tests/file/is_writable_variation1.phpt
@@ -0,0 +1,125 @@
+--TEST--
+Test is_writable() and its alias is_writeable() function: usage variations - diff. path notations
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+
+ // Skip if being run by root (files are always readable, writeable and executable)
+ $filename = dirname(__FILE__)."/is_writable_root_check.tmp";
+ $fp = fopen($filename, 'w');
+ fclose($fp);
+ if(fileowner($filename) == 0) {
+ unlink ($filename);
+ die('skip cannot be run as root');
+ }
+
+ unlink($filename);
+}
+?>
+--FILE--
+<?php
+/* Prototype: bool is_writable ( string $filename );
+ Description: Tells whether the filename is writable.
+
+ is_writeable() is an alias of is_writable()
+*/
+/* test is_writable() & is_writeable() with file having different filepath notation */
+require dirname(__FILE__).'/file.inc';
+echo "*** Testing is_writable(): usage variations ***\n";
+
+$file_path = dirname(__FILE__);
+mkdir("$file_path/is_writable_variation1");
+
+// create a new temporary file
+$fp = fopen("$file_path/is_writable_variation1/bar.tmp", "w");
+fclose($fp);
+
+/* array of files to be tested to check if they are writable
+ using is_writable() function */
+$files_arr = array(
+ "$file_path/is_writable_variation1/bar.tmp",
+
+ /* Testing a file trailing slash */
+ "$file_path/is_writable_variation1/bar.tmp/",
+
+ /* Testing file with double slashes */
+ "$file_path/is_writable_variation1//bar.tmp",
+ "$file_path//is_writable_variation1//bar.tmp",
+ "$file_path/is_writable_variation1/*.tmp",
+ "$file_path/is_writable_variation1/b*.tmp",
+
+ /* Testing Binary safe */
+ "$file_path/is_writable_variation1".chr(0)."bar.tmp",
+ "$file_path".chr(0)."is_writable_variation1/bar.tmp",
+ "$file_path".chr(0)."is_writable_variation1/bar.tmp",
+
+ /* Testing directories */
+ ".", // current directory, exp: bool(true)
+ "$file_path/is_writable_variation1" // temp directory, exp: bool(true)
+);
+$counter = 1;
+/* loop through to test each element in the above array
+ is a writable file */
+foreach($files_arr as $file) {
+ echo "-- Iteration $counter --\n";
+ var_dump( is_writable($file) );
+ var_dump( is_writeable($file) );
+ $counter++;
+ clearstatcache();
+}
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/is_writable_variation1/bar.tmp");
+rmdir(dirname(__FILE__)."/is_writable_variation1/");
+?>
+--EXPECTF--
+*** Testing is_writable(): usage variations ***
+-- Iteration 1 --
+bool(true)
+bool(true)
+-- Iteration 2 --
+bool(%s)
+bool(%s)
+-- Iteration 3 --
+bool(true)
+bool(true)
+-- Iteration 4 --
+bool(true)
+bool(true)
+-- Iteration 5 --
+bool(false)
+bool(false)
+-- Iteration 6 --
+bool(false)
+bool(false)
+-- Iteration 7 --
+
+Warning: is_writable() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+
+Warning: is_writeable() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+-- Iteration 8 --
+
+Warning: is_writable() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+
+Warning: is_writeable() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+-- Iteration 9 --
+
+Warning: is_writable() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+
+Warning: is_writeable() expects parameter 1 to be a valid path, string given in %s on line %d
+NULL
+-- Iteration 10 --
+bool(true)
+bool(true)
+-- Iteration 11 --
+bool(true)
+bool(true)
+Done
diff --git a/ext/standard/tests/file/is_writable_variation2.phpt b/ext/standard/tests/file/is_writable_variation2.phpt
new file mode 100644
index 0000000..f56219c
--- /dev/null
+++ b/ext/standard/tests/file/is_writable_variation2.phpt
@@ -0,0 +1,126 @@
+--TEST--
+Test is_writable() and its alias is_writeable() function: usage variations - file/dir with diff. perms
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. only on LINUX');
+}
+// Skip if being run by root
+$filename = dirname(__FILE__)."/is_readable_root_check.tmp";
+$fp = fopen($filename, 'w');
+fclose($fp);
+if(fileowner($filename) == 0) {
+ unlink ($filename);
+ die('skip cannot be run as root');
+}
+
+unlink ($filename);
+?>
+--FILE--
+<?php
+/* Prototype: bool is_writable ( string $filename );
+ Description: Tells whether the filename is writable.
+
+ is_writeable() is an alias of is_writable()
+*/
+
+/* test is_executable() with file/dir having different permissions */
+
+require dirname(__FILE__).'/file.inc';
+echo "*** Testing is_writable(): usage variations ***\n";
+
+$file_path = dirname(__FILE__);
+mkdir("$file_path/is_writable_variation2");
+
+echo "\n*** Testing is_writable() on directory without write permission ***\n";
+chmod("$file_path/is_writable_variation2", 0004);
+var_dump( is_writable("$file_path/is_writable_variation2") ); // exp: bool(false)
+var_dump( is_writeable("$file_path/is_writable_variation2") ); // exp: bool(false)
+chmod("$file_path/is_writable_variation2", 0777); // chmod to enable deletion of directory
+
+echo "\n*** Testing miscelleneous input for is_writable() function ***\n";
+$name_prefix = "is_writable_variation2";
+create_files(dirname(__FILE__), 1, "numeric", 0755, 1, "w", $name_prefix, 1);
+create_files(dirname(__FILE__), 1, "text", 0755, 1, "w", $name_prefix, 2);
+create_files(dirname(__FILE__), 1, "empty", 0755, 1, "w", $name_prefix, 3);
+create_files(dirname(__FILE__), 1, "numeric", 0555, 1, "w", $name_prefix, 4);
+create_files(dirname(__FILE__), 1, "text", 0222, 1, "w", $name_prefix, 5);
+create_files(dirname(__FILE__), 1, "numeric", 0711, 1, "w", $name_prefix, 6);
+create_files(dirname(__FILE__), 1, "text", 0114, 1, "w", $name_prefix, 7);
+create_files(dirname(__FILE__), 1, "numeric", 0244, 1, "w", $name_prefix, 8);
+create_files(dirname(__FILE__), 1, "text", 0421, 1, "w", $name_prefix, 9);
+create_files(dirname(__FILE__), 1, "text", 0422, 1, "w", $name_prefix, 10);
+
+$misc_files = array (
+ "$file_path/is_writable_variation21.tmp",
+ "$file_path/is_writable_variation22.tmp",
+ "$file_path/is_writable_variation23.tmp",
+ "$file_path/is_writable_variation24.tmp",
+ "$file_path/is_writable_variation25.tmp",
+ "$file_path/is_writable_variation26.tmp",
+ "$file_path/is_writable_variation27.tmp",
+ "$file_path/is_writable_variation28.tmp",
+ "$file_path/is_writable_variation29.tmp",
+ "$file_path/is_writable_variation210.tmp"
+);
+
+$counter = 1;
+/* loop through to test each element in the above array
+ is a writable file */
+foreach($misc_files as $misc_file) {
+ echo "-- Iteration $counter --\n";
+ var_dump( is_writable($misc_file) );
+ var_dump( is_writeable($misc_file) );
+ $counter++;
+ clearstatcache();
+}
+
+// change all file's permissions to 777 before deleting
+change_file_perms($file_path, 10, 0777, $name_prefix);
+delete_files($file_path, 10, $name_prefix);
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+rmdir(dirname(__FILE__)."/is_writable_variation2/");
+?>
+--EXPECTF--
+*** Testing is_writable(): usage variations ***
+
+*** Testing is_writable() on directory without write permission ***
+bool(false)
+bool(false)
+
+*** Testing miscelleneous input for is_writable() function ***
+-- Iteration 1 --
+bool(true)
+bool(true)
+-- Iteration 2 --
+bool(true)
+bool(true)
+-- Iteration 3 --
+bool(true)
+bool(true)
+-- Iteration 4 --
+bool(false)
+bool(false)
+-- Iteration 5 --
+bool(true)
+bool(true)
+-- Iteration 6 --
+bool(true)
+bool(true)
+-- Iteration 7 --
+bool(false)
+bool(false)
+-- Iteration 8 --
+bool(true)
+bool(true)
+-- Iteration 9 --
+bool(false)
+bool(false)
+-- Iteration 10 --
+bool(false)
+bool(false)
+Done
diff --git a/ext/standard/tests/file/is_writable_variation3.phpt b/ext/standard/tests/file/is_writable_variation3.phpt
new file mode 100644
index 0000000..66a80ab
--- /dev/null
+++ b/ext/standard/tests/file/is_writable_variation3.phpt
@@ -0,0 +1,78 @@
+--TEST--
+Test is_writable() and its alias is_writeable() function: usage variations - invalid file names
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ // Skip if being run by root (files are always readable, writeable and executable)
+ $filename = dirname(__FILE__)."/is_writable_root_check.tmp";
+ $fp = fopen($filename, 'w');
+ fclose($fp);
+ if(fileowner($filename) == 0) {
+ unlink ($filename);
+ die('skip cannot be run as root');
+ }
+ unlink($filename);
+}
+?>
+--FILE--
+<?php
+/* Prototype: bool is_writable ( string $filename );
+ Description: Tells whether the filename is writable.
+
+ is_writeable() is an alias of is_writable()
+*/
+
+/* test is_writable() & is_writeable() with invalid arguments */
+
+echo "*** Testing is_writable(): usage variations ***\n";
+
+echo "\n*** Testing is_writable() with invalid filenames ***\n";
+$misc_files = array(
+ 0,
+ 1234,
+ -2.34555,
+ TRUE,
+ FALSE,
+ NULL,
+ " ",
+ @array(),
+ @$file_handle
+);
+/* loop through to test each element in the above array
+ is a writable file */
+foreach( $misc_files as $misc_file ) {
+ var_dump( is_writable($misc_file) );
+ var_dump( is_writeable($misc_file) );
+ clearstatcache();
+}
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing is_writable(): usage variations ***
+
+*** Testing is_writable() with invalid filenames ***
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+
+Warning: is_writable() expects parameter 1 to be a valid path, array given in %s on line %d
+NULL
+
+Warning: is_writeable() expects parameter 1 to be a valid path, array given in %s on line %d
+NULL
+bool(false)
+bool(false)
+Done
+
diff --git a/ext/standard/tests/file/lchgrp_basic.phpt b/ext/standard/tests/file/lchgrp_basic.phpt
new file mode 100644
index 0000000..1713bef
--- /dev/null
+++ b/ext/standard/tests/file/lchgrp_basic.phpt
@@ -0,0 +1,36 @@
+--TEST--
+Test lchgrp() function : basic functionality
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') die('skip no windows support');
+if (!function_exists("posix_getgid")) die("skip no posix_getgid()");
+?>
+--FILE--
+<?php
+$filename = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'lchgrp.txt';
+$symlink = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'symlink.txt';
+
+$gid = posix_getgid();
+
+var_dump( touch( $filename ) );
+var_dump( symlink( $filename, $symlink ) );
+var_dump( lchgrp( $filename, $gid ) );
+var_dump( filegroup( $symlink ) === $gid );
+
+?>
+===DONE===
+--CLEAN--
+<?php
+
+$filename = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'lchgrp.txt';
+$symlink = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'symlink.txt';
+unlink($filename);
+unlink($symlink);
+
+?>
+--EXPECTF--
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+===DONE===
diff --git a/ext/standard/tests/file/lchown_basic.phpt b/ext/standard/tests/file/lchown_basic.phpt
new file mode 100644
index 0000000..9675d3a
--- /dev/null
+++ b/ext/standard/tests/file/lchown_basic.phpt
@@ -0,0 +1,44 @@
+--TEST--
+Test lchown() function : basic functionality
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') die('skip no windows support');
+if (!function_exists("posix_getuid")) die("skip no posix_getuid()");
+?>
+--FILE--
+<?php
+/* Prototype : bool lchown (string filename, mixed user)
+ * Description: Change file owner of a symlink
+ * Source code: ext/standard/filestat.c
+ * Alias to functions:
+ */
+
+echo "*** Testing lchown() : basic functionality ***\n";
+$filename = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'lchown.txt';
+$symlink = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'symlink.txt';
+
+$uid = posix_getuid();
+
+var_dump( touch( $filename ) );
+var_dump( symlink( $filename, $symlink ) );
+var_dump( lchown( $filename, $uid ) );
+var_dump( fileowner( $symlink ) === $uid );
+
+?>
+===DONE===
+--CLEAN--
+<?php
+
+$filename = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'lchown.txt';
+$symlink = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'symlink.txt';
+unlink($filename);
+unlink($symlink);
+
+?>
+--EXPECTF--
+*** Testing lchown() : basic functionality ***
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+===DONE===
diff --git a/ext/standard/tests/file/lchown_error.phpt b/ext/standard/tests/file/lchown_error.phpt
new file mode 100644
index 0000000..979959e
--- /dev/null
+++ b/ext/standard/tests/file/lchown_error.phpt
@@ -0,0 +1,78 @@
+--TEST--
+Test lchown() function : error functionality
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') die('skip no windows support');
+if (!function_exists("posix_getuid")) die("skip no posix_getuid()");
+// Skip if being run by root
+$filename = dirname(__FILE__)."/is_readable_root_check.tmp";
+$fp = fopen($filename, 'w');
+fclose($fp);
+if(fileowner($filename) == 0) {
+ unlink ($filename);
+ die('skip cannot be run as root');
+}
+unlink($filename);
+?>
+--FILE--
+<?php
+/* Prototype : bool lchown (string filename, mixed user)
+ * Description: Change file owner of a symlink
+ * Source code: ext/standard/filestat.c
+ * Alias to functions:
+ */
+
+echo "*** Testing lchown() : error functionality ***\n";
+
+// Set up
+$filename = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'lchown.txt';
+touch( $filename );
+$uid = posix_getuid();
+
+
+// Less than expected arguments
+var_dump( lchown( $filename ) );
+
+// More than expected arguments
+var_dump( lchown( $filename, $uid, 'foobar' ) );
+
+// Non-existant filename
+var_dump( lchown( 'foobar_lchown.txt', $uid ) );
+
+// Wrong argument types
+var_dump( lchown( new StdClass(), $uid ) );
+var_dump( lchown( array(), $uid ) );
+
+// Bad user
+var_dump( lchown( $filename, -5 ) );
+
+?>
+===DONE===
+--CLEAN--
+<?php
+
+$filename = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'lchown.txt';
+unlink($filename);
+
+?>
+--EXPECTF--
+*** Testing lchown() : error functionality ***
+
+Warning: lchown() expects exactly 2 parameters, 1 given in %s on line %d
+bool(true)
+
+Warning: lchown() expects exactly 2 parameters, 3 given in %s on line %d
+bool(true)
+
+Warning: lchown(): No such file or directory in %s on line %d
+bool(false)
+
+Warning: lchown() expects parameter 1 to be a valid path, object given in %s on line %d
+bool(true)
+
+Warning: lchown() expects parameter 1 to be a valid path, array given in %s on line %d
+bool(true)
+
+Warning: lchown(): Operation not permitted in %s on line %d
+bool(false)
+===DONE===
diff --git a/ext/standard/tests/file/link_win32.phpt b/ext/standard/tests/file/link_win32.phpt
new file mode 100644
index 0000000..2bba546
--- /dev/null
+++ b/ext/standard/tests/file/link_win32.phpt
@@ -0,0 +1,26 @@
+--TEST--
+link not working properly on Windows
+--CREDITS--
+Venkat Raman Don
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != 'WIN' ) {
+ die('skip windows only test');
+}
+?>
+--FILE--
+<?php
+$filename = __DIR__ . '\\a.php';
+$content = '<?php echo "Dummy Content.\n" ?>';
+file_put_contents($filename, $content);
+$linkname = __DIR__ . '\\a_link.php';
+link("$filename", "$linkname");
+var_dump(file_exists("$linkname"));
+$linkcontent = file_get_contents($linkname);
+var_dump($content == $linkcontent);
+unlink($filename);
+unlink($linkname);
+?>
+--EXPECT--
+bool(true)
+bool(true)
diff --git a/ext/standard/tests/file/lstat_stat_basic.phpt b/ext/standard/tests/file/lstat_stat_basic.phpt
new file mode 100644
index 0000000..0d1476d
--- /dev/null
+++ b/ext/standard/tests/file/lstat_stat_basic.phpt
@@ -0,0 +1,317 @@
+--TEST--
+Test lstat() & stat() functions: basic functionality
+--SKIPIF--
+<?php
+if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. lstat() not available on Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: array lstat ( string $filename );
+ Description: Gives information about a file or symbolic link
+
+ Prototype: array stat ( string $filename );
+ Description: Gives information about a file
+*/
+
+$file_path = dirname(__FILE__);
+require("$file_path/file.inc");
+
+echo "*** Testing lstat() & stat() : basic functionality ***\n";
+
+/* creating temp directory and file */
+
+// creating dir
+$dirname = "$file_path/lstat_stat_basic";
+@rmdir($dirname);
+mkdir($dirname);
+// stat of the dir created
+$dir_stat = stat($dirname);
+clearstatcache();
+sleep(2);
+
+// creating file
+$filename = "$dirname/lstat_stat_basic.tmp";
+$file_handle = fopen($filename, "w");
+fclose($file_handle);
+// stat of the file created
+$file_stat = stat($filename);
+sleep(2);
+
+// now new stat of the dir after file is created
+$new_dir_stat = stat($dirname);
+clearstatcache();
+
+// create soft link and record stat
+$sym_linkname = "$file_path/lstat_stat_basic_link.tmp";
+symlink($filename, $sym_linkname);
+// stat of the link created
+$link_stat = lstat($sym_linkname);
+sleep(2);
+// new stat of the file, after a softlink to this file is created
+$new_file_stat = stat($filename);
+clearstatcache();
+
+// stat contains 13 different values stored twice, can be accessed using
+// numeric and named keys, compare them to see they are same
+echo "*** Testing stat() and lstat() : validating the values stored in stat ***\n";
+// Initial stat values
+var_dump( compare_self_stat($file_stat) ); //expect true
+var_dump( compare_self_stat($dir_stat) ); //expect true
+var_dump( compare_self_stat($link_stat) ); // expect true
+
+// New stat values taken after creation of file & link
+var_dump( compare_self_stat($new_file_stat) ); //expect true
+var_dump( compare_self_stat($new_dir_stat) ); // expect true
+
+// compare the two stat values, initial stat and stat recorded after
+// creating files and link, also dump the value of stats
+echo "*** Testing stat() and lstat() : comparing stats (recorded before and after file/link creation) ***\n";
+echo "-- comparing difference in dir stats before and after creating file in it --\n";
+$affected_elements = array( 9, 10, 'mtime', 'ctime' );
+var_dump( compare_stats($dir_stat, $new_dir_stat, $affected_elements, '!=', true) ); // expect true
+
+echo "-- comparing difference in file stats before and after creating link to it --\n";
+var_dump( compare_stats($file_stat, $new_file_stat, $all_stat_keys, "==", true) ); // expect true
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink("$file_path/lstat_stat_basic_link.tmp");
+unlink("$file_path/lstat_stat_basic/lstat_stat_basic.tmp");
+rmdir("$file_path/lstat_stat_basic");
+?>
+--EXPECTF--
+*** Testing lstat() & stat() : basic functionality ***
+*** Testing stat() and lstat() : validating the values stored in stat ***
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+*** Testing stat() and lstat() : comparing stats (recorded before and after file/link creation) ***
+-- comparing difference in dir stats before and after creating file in it --
+array(26) {
+ [0]=>
+ int(%i)
+ [1]=>
+ int(%i)
+ [2]=>
+ int(%i)
+ [3]=>
+ int(%i)
+ [4]=>
+ int(%i)
+ [5]=>
+ int(%i)
+ [6]=>
+ int(%i)
+ [7]=>
+ int(%i)
+ [8]=>
+ int(%i)
+ [9]=>
+ int(%i)
+ [10]=>
+ int(%i)
+ [11]=>
+ int(%i)
+ [12]=>
+ int(%i)
+ ["dev"]=>
+ int(%i)
+ ["ino"]=>
+ int(%i)
+ ["mode"]=>
+ int(%i)
+ ["nlink"]=>
+ int(%i)
+ ["uid"]=>
+ int(%i)
+ ["gid"]=>
+ int(%i)
+ ["rdev"]=>
+ int(%i)
+ ["size"]=>
+ int(%i)
+ ["atime"]=>
+ int(%i)
+ ["mtime"]=>
+ int(%i)
+ ["ctime"]=>
+ int(%i)
+ ["blksize"]=>
+ int(%i)
+ ["blocks"]=>
+ int(%i)
+}
+array(26) {
+ [0]=>
+ int(%i)
+ [1]=>
+ int(%i)
+ [2]=>
+ int(%i)
+ [3]=>
+ int(%i)
+ [4]=>
+ int(%i)
+ [5]=>
+ int(%i)
+ [6]=>
+ int(%i)
+ [7]=>
+ int(%i)
+ [8]=>
+ int(%i)
+ [9]=>
+ int(%i)
+ [10]=>
+ int(%i)
+ [11]=>
+ int(%i)
+ [12]=>
+ int(%i)
+ ["dev"]=>
+ int(%i)
+ ["ino"]=>
+ int(%i)
+ ["mode"]=>
+ int(%i)
+ ["nlink"]=>
+ int(%i)
+ ["uid"]=>
+ int(%i)
+ ["gid"]=>
+ int(%i)
+ ["rdev"]=>
+ int(%i)
+ ["size"]=>
+ int(%i)
+ ["atime"]=>
+ int(%i)
+ ["mtime"]=>
+ int(%i)
+ ["ctime"]=>
+ int(%i)
+ ["blksize"]=>
+ int(%i)
+ ["blocks"]=>
+ int(%i)
+}
+bool(true)
+-- comparing difference in file stats before and after creating link to it --
+array(26) {
+ [0]=>
+ int(%i)
+ [1]=>
+ int(%i)
+ [2]=>
+ int(%i)
+ [3]=>
+ int(%i)
+ [4]=>
+ int(%i)
+ [5]=>
+ int(%i)
+ [6]=>
+ int(%i)
+ [7]=>
+ int(%i)
+ [8]=>
+ int(%i)
+ [9]=>
+ int(%i)
+ [10]=>
+ int(%i)
+ [11]=>
+ int(%i)
+ [12]=>
+ int(%i)
+ ["dev"]=>
+ int(%i)
+ ["ino"]=>
+ int(%i)
+ ["mode"]=>
+ int(%i)
+ ["nlink"]=>
+ int(%i)
+ ["uid"]=>
+ int(%i)
+ ["gid"]=>
+ int(%i)
+ ["rdev"]=>
+ int(%i)
+ ["size"]=>
+ int(%i)
+ ["atime"]=>
+ int(%i)
+ ["mtime"]=>
+ int(%i)
+ ["ctime"]=>
+ int(%i)
+ ["blksize"]=>
+ int(%i)
+ ["blocks"]=>
+ int(%i)
+}
+array(26) {
+ [0]=>
+ int(%i)
+ [1]=>
+ int(%i)
+ [2]=>
+ int(%i)
+ [3]=>
+ int(%i)
+ [4]=>
+ int(%i)
+ [5]=>
+ int(%i)
+ [6]=>
+ int(%i)
+ [7]=>
+ int(%i)
+ [8]=>
+ int(%i)
+ [9]=>
+ int(%i)
+ [10]=>
+ int(%i)
+ [11]=>
+ int(%i)
+ [12]=>
+ int(%i)
+ ["dev"]=>
+ int(%i)
+ ["ino"]=>
+ int(%i)
+ ["mode"]=>
+ int(%i)
+ ["nlink"]=>
+ int(%i)
+ ["uid"]=>
+ int(%i)
+ ["gid"]=>
+ int(%i)
+ ["rdev"]=>
+ int(%i)
+ ["size"]=>
+ int(%i)
+ ["atime"]=>
+ int(%i)
+ ["mtime"]=>
+ int(%i)
+ ["ctime"]=>
+ int(%i)
+ ["blksize"]=>
+ int(%i)
+ ["blocks"]=>
+ int(%i)
+}
+bool(true)
+Done
diff --git a/ext/standard/tests/file/lstat_stat_error.phpt b/ext/standard/tests/file/lstat_stat_error.phpt
new file mode 100644
index 0000000..385167f
--- /dev/null
+++ b/ext/standard/tests/file/lstat_stat_error.phpt
@@ -0,0 +1,79 @@
+--TEST--
+Test lstat() and stat() functions: error conditions
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. lstat() not available on Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: array lstat ( string $filename );
+ Description: Gives information about a file or symbolic link
+
+ Prototype: array stat ( string $filename );
+ Description: Gives information about a file
+*/
+
+echo "*** Testing lstat() for error conditions ***\n";
+$file_path = dirname(__FILE__);
+var_dump( lstat() ); // args < expected
+var_dump( lstat(__FILE__, 2) ); // args > expected
+var_dump( lstat("$file_path/temp.tmp") ); // non existing file
+var_dump( lstat(22) ); // scalar argument
+$arr = array(__FILE__);
+var_dump( lstat($arr) ); // array argument
+
+echo "\n*** Testing stat() for error conditions ***\n";
+var_dump( stat() ); // args < expected
+var_dump( stat(__FILE__, 2) ); // file, args > expected
+var_dump( stat(dirname(__FILE__), 2) ); //dir, args > expected
+
+var_dump( stat("$file_path/temp.tmp") ); // non existing file
+var_dump( stat("$file_path/temp/") ); // non existing dir
+var_dump( stat(22) ); // scalar argument
+var_dump( stat($arr) ); // array argument
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing lstat() for error conditions ***
+
+Warning: lstat() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: lstat() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+
+Warning: lstat(): Lstat failed for %s in %s on line %d
+bool(false)
+
+Warning: lstat(): Lstat failed for 22 in %s on line %d
+bool(false)
+
+Warning: lstat() expects parameter 1 to be a valid path, array given in %s on line %d
+NULL
+
+*** Testing stat() for error conditions ***
+
+Warning: stat() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: stat() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+
+Warning: stat() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+
+Warning: stat(): stat failed for %s in %s on line %d
+bool(false)
+
+Warning: stat(): stat failed for %s in %s on line %d
+bool(false)
+
+Warning: stat(): stat failed for 22 in %s on line %d
+bool(false)
+
+Warning: stat() expects parameter 1 to be a valid path, array given in %s on line %d
+NULL
+Done
diff --git a/ext/standard/tests/file/lstat_stat_variation1.phpt b/ext/standard/tests/file/lstat_stat_variation1.phpt
new file mode 100644
index 0000000..30ce9b7
--- /dev/null
+++ b/ext/standard/tests/file/lstat_stat_variation1.phpt
@@ -0,0 +1,61 @@
+--TEST--
+Test lstat() and stat() functions: usage variations - effects of rename() on file
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. Not valid for Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: array lstat ( string $filename );
+ Description: Gives information about a file or symbolic link
+
+ Prototype: array stat ( string $filename );
+ Description: Gives information about a file
+*/
+
+/* test the effects of rename() on stats of file */
+
+$file_path = dirname(__FILE__);
+require "$file_path/file.inc";
+
+/* create temp file */
+$fp = fopen("$file_path/lstat_stat_variation1.tmp", "w"); // temp file
+fclose($fp);
+
+// renaming a file and check stat
+echo "*** Testing stat() for files after being renamed ***\n";
+$file_path = dirname(__FILE__);
+$old_filename = "$file_path/lstat_stat_variation1.tmp";
+$new_filename = "$file_path/lstat_stat_variation1a.tmp";
+$old_stat = stat($old_filename);
+clearstatcache();
+var_dump( rename($old_filename, $new_filename) );
+$new_stat = stat($new_filename);
+
+// compare the self stat
+var_dump( compare_self_stat($old_stat) );
+var_dump( compare_self_stat($new_stat) );
+
+// compare the two stats
+var_dump( compare_stats($old_stat, $old_stat, $all_stat_keys) );
+// clear the cache
+clearstatcache();
+
+echo "\n--- Done ---";
+?>
+
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink("$file_path/lstat_stat_variation1a.tmp");
+?>
+--EXPECTF--
+*** Testing stat() for files after being renamed ***
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+
+--- Done ---
diff --git a/ext/standard/tests/file/lstat_stat_variation10.phpt b/ext/standard/tests/file/lstat_stat_variation10.phpt
new file mode 100644
index 0000000..51ebc25
--- /dev/null
+++ b/ext/standard/tests/file/lstat_stat_variation10.phpt
@@ -0,0 +1,59 @@
+--TEST--
+Test lstat() and stat() functions: usage variations - effects of is_dir()
+--SKIPIF--
+<?php
+if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. Not valid for Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: array lstat ( string $filename );
+ Description: Gives information about a file or symbolic link
+
+ Prototype: array stat ( string $filename );
+ Description: Gives information about a file
+*/
+
+/* test the effects of is_dir() on stats of a dir */
+
+$file_path = dirname(__FILE__);
+require "$file_path/file.inc";
+
+
+/* create temp file, link and directory */
+$dirname = "$file_path/lstat_stat_variation10";
+mkdir($dirname); // temp dir
+
+// is_dir() on a directory
+echo "*** Testing stat() on directory after using is_dir() on it ***\n";
+$old_stat = stat($dirname);
+// clear the cache
+clearstatcache();
+sleep(2);
+var_dump( is_dir($dirname) );
+$new_stat = stat($dirname);
+
+// compare self stats
+var_dump( compare_self_stat($old_stat) );
+var_dump( compare_self_stat($new_stat) );
+// compare the stat
+var_dump( compare_stats($old_stat, $new_stat, $all_stat_keys) );
+
+echo "\n--- Done ---";
+?>
+
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+rmdir("$file_path/lstat_stat_variation10");
+?>
+--EXPECTF--
+*** Testing stat() on directory after using is_dir() on it ***
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+
+--- Done ---
diff --git a/ext/standard/tests/file/lstat_stat_variation11.phpt b/ext/standard/tests/file/lstat_stat_variation11.phpt
new file mode 100644
index 0000000..a75504b
--- /dev/null
+++ b/ext/standard/tests/file/lstat_stat_variation11.phpt
@@ -0,0 +1,60 @@
+--TEST--
+Test lstat() and stat() functions: usage variations - effect of is_file()
+--SKIPIF--
+<?php
+if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. Not valid for Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: array lstat ( string $filename );
+ Description: Gives information about a file or symbolic link
+
+ Prototype: array stat ( string $filename );
+ Description: Gives information about a file
+*/
+
+$file_path = dirname(__FILE__);
+require "$file_path/file.inc";
+
+/* test the effects of is_file() on stats of a file */
+
+/* create temp file */
+$filename = "$file_path/lstat_stat_variation11.tmp";
+$fp = fopen($filename, "w"); // temp file
+fclose($fp);
+
+// is_file() on a file
+echo "*** Testing stat() on a file after using is_file() on it ***\n";
+$old_stat = stat($filename);
+// clear the stat
+clearstatcache();
+sleep(2);
+var_dump( is_file($filename) );
+$new_stat = stat($filename);
+// compare self stats
+var_dump( compare_self_stat($old_stat) );
+var_dump( compare_self_stat($new_stat) );
+// compare the stat
+var_dump( compare_stats($old_stat, $new_stat, $all_stat_keys) );
+// clear the stat
+clearstatcache();
+
+echo "\n--- Done ---";
+?>
+
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink("$file_path/lstat_stat_variation11.tmp");
+?>
+--EXPECTF--
+*** Testing stat() on a file after using is_file() on it ***
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+
+--- Done ---
diff --git a/ext/standard/tests/file/lstat_stat_variation12.phpt b/ext/standard/tests/file/lstat_stat_variation12.phpt
new file mode 100644
index 0000000..8e1edd6
--- /dev/null
+++ b/ext/standard/tests/file/lstat_stat_variation12.phpt
@@ -0,0 +1,66 @@
+--TEST--
+Test lstat() and stat() functions: usage variations - effects of is_link()
+--SKIPIF--
+<?php
+if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. lstat() not available on Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: array lstat ( string $filename );
+ Description: Gives information about a file or symbolic link
+
+ Prototype: array stat ( string $filename );
+ Description: Gives information about a file
+*/
+
+/* test the effects of is_link() on stats of link */
+
+$file_path = dirname(__FILE__);
+require "$file_path/file.inc";
+
+
+/* create temp file, link */
+$filename = "$file_path/lstat_stat_variation12.tmp";
+$fp = fopen($filename, "w"); // temp file
+fclose($fp);
+
+$linkname = "$file_path/lstat_stat_variation12_link.tmp";
+symlink($filename, $linkname); // temp link
+
+// is_link() on a link
+echo "*** Testing stat() on a link after using is_link() on it ***\n";
+$linkname = "$file_path/lstat_stat_variation12_link.tmp";
+$old_stat = lstat($linkname);
+// clear the stat
+clearstatcache();
+sleep(2);
+var_dump( is_link($linkname) );
+$new_stat = lstat($linkname);
+// compare self stats
+var_dump( compare_self_stat($old_stat) );
+var_dump( compare_self_stat($new_stat) );
+// compare the stat
+var_dump( compare_stats($old_stat, $new_stat, $all_stat_keys) );
+// clear the stat
+clearstatcache();
+
+echo "\n--- Done ---";
+?>
+
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink("$file_path/lstat_stat_variation12_link.tmp");
+unlink("$file_path/lstat_stat_variation12.tmp");
+?>
+--EXPECTF--
+*** Testing stat() on a link after using is_link() on it ***
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+
+--- Done ---
diff --git a/ext/standard/tests/file/lstat_stat_variation13.phpt b/ext/standard/tests/file/lstat_stat_variation13.phpt
new file mode 100644
index 0000000..288e0b5
--- /dev/null
+++ b/ext/standard/tests/file/lstat_stat_variation13.phpt
@@ -0,0 +1,58 @@
+--TEST--
+Test lstat() and stat() functions: usage variations - file opened using w and r mode
+--SKIPIF--
+<?php
+if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. Not valid for Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: array lstat ( string $filename );
+ Description: Gives information about a file or symbolic link
+
+ Prototype: array stat ( string $filename );
+ Description: Gives information about a file
+*/
+
+/* use stat on file created using "w" and "r" mode of fopen */
+
+$file_path = dirname(__FILE__);
+require "$file_path/file.inc";
+
+
+$filename = "$file_path/lstat_stat_variation13.tmp";
+
+echo "*** Checking stat() on a file opened using read/write mode ***\n";
+$file_handle = fopen($filename, "w"); // create file
+fclose($file_handle);
+$old_stat = stat($filename);
+// clear the stat
+clearstatcache();
+sleep(2);
+// opening file again in read mode
+$file_handle = fopen($filename, "r"); // read file
+fclose($file_handle);
+$new_stat = stat($filename);
+// compare self stats
+var_dump( compare_self_stat($old_stat) );
+var_dump( compare_self_stat($new_stat) );
+// compare the stat
+var_dump( compare_stats($old_stat, $new_stat, $all_stat_keys) );
+
+echo "\n--- Done ---";
+?>
+
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink("$file_path/lstat_stat_variation13.tmp");
+?>
+--EXPECTF--
+*** Checking stat() on a file opened using read/write mode ***
+bool(true)
+bool(true)
+bool(true)
+
+--- Done ---
diff --git a/ext/standard/tests/file/lstat_stat_variation14.phpt b/ext/standard/tests/file/lstat_stat_variation14.phpt
new file mode 100644
index 0000000..517f77e
--- /dev/null
+++ b/ext/standard/tests/file/lstat_stat_variation14.phpt
@@ -0,0 +1,62 @@
+--TEST--
+Test lstat() and stat() functions: usage variations - hardlink
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. lstat() not available on Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: array lstat ( string $filename );
+ Description: Gives information about a file or symbolic link
+
+ Prototype: array stat ( string $filename );
+ Description: Gives information about a file
+*/
+
+/* test the effects of is_link() on stats of hard link */
+
+$file_path = dirname(__FILE__);
+require "$file_path/file.inc";
+
+
+/* create temp file & link */
+$filename = "$file_path/lstat_stat_variation14.tmp";
+$fp = fopen($filename, "w"); // temp file
+fclose($fp);
+
+echo "*** Checking lstat() and stat() on hard link ***\n";
+$linkname = "$file_path/lstat_stat_variation14_hard.tmp";
+//ensure that link doesn't exists
+@unlink($linkname);
+
+// create the link
+var_dump( link($filename, $linkname) );
+$file_stat = stat($filename);
+$link_stat = lstat($linkname);
+// compare self stats
+var_dump( compare_self_stat($file_stat) );
+var_dump( compare_self_stat($link_stat) );
+// compare the stat
+var_dump( compare_stats($file_stat, $link_stat, $all_stat_keys) );
+// clear the stat
+clearstatcache();
+
+echo "\n--- Done ---";
+?>
+
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink("$file_path/lstat_stat_variation14_hard.tmp");
+unlink("$file_path/lstat_stat_variation14.tmp");
+?>
+--EXPECTF--
+*** Checking lstat() and stat() on hard link ***
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+
+--- Done ---
diff --git a/ext/standard/tests/file/lstat_stat_variation15.phpt b/ext/standard/tests/file/lstat_stat_variation15.phpt
new file mode 100644
index 0000000..8b67338
--- /dev/null
+++ b/ext/standard/tests/file/lstat_stat_variation15.phpt
@@ -0,0 +1,64 @@
+--TEST--
+Test lstat() and stat() functions: usage variations - effects changing permissions of link
+--SKIPIF--
+<?php
+if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. lstat() not available on Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: array lstat ( string $filename );
+ Description: Gives information about a file or symbolic link
+
+ Prototype: array stat ( string $filename );
+ Description: Gives information about a file
+*/
+
+/* test the effects on stats by changing permissions of link */
+
+$file_path = dirname(__FILE__);
+require "$file_path/file.inc";
+
+
+$filename = "$file_path/lstat_stat_variation15.tmp";
+$fp = fopen($filename, "w"); // temp file
+fclose($fp);
+
+// temp link
+$linkname = "$file_path/lstat_stat_variation15_link.tmp";
+symlink($filename, $linkname);
+
+// checking lstat() and stat() on links
+echo "*** Testing lstat() on a link after changing its access permission ***\n";
+clearstatcache();
+$old_stat = lstat($linkname);
+var_dump( chmod($linkname, 0777) );
+// clear the stat
+clearstatcache();
+sleep(2);
+$new_stat = lstat($linkname);
+// compare self stats
+var_dump( compare_self_stat($old_stat) );
+var_dump( compare_self_stat($new_stat) );
+// compare the stat
+var_dump( compare_stats($old_stat, $new_stat, $all_stat_keys, "=") );
+
+echo "\n--- Done ---";
+?>
+
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink("$file_path/lstat_stat_variation15_link.tmp");
+unlink("$file_path/lstat_stat_variation15.tmp");
+?>
+--EXPECTF--
+*** Testing lstat() on a link after changing its access permission ***
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+
+--- Done ---
diff --git a/ext/standard/tests/file/lstat_stat_variation16.phpt b/ext/standard/tests/file/lstat_stat_variation16.phpt
new file mode 100644
index 0000000..9f12765
--- /dev/null
+++ b/ext/standard/tests/file/lstat_stat_variation16.phpt
@@ -0,0 +1,58 @@
+--TEST--
+Test lstat() and stat() functions: usage variations - effects changing permissions of file
+--SKIPIF--
+<?php
+if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. Not valid for Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: array lstat ( string $filename );
+ Description: Gives information about a file or symbolic link
+
+ Prototype: array stat ( string $filename );
+ Description: Gives information about a file
+*/
+
+/* test the effects on stats with changing permissions of file */
+
+$file_path = dirname(__FILE__);
+require "$file_path/file.inc";
+
+$filename = "$file_path/lstat_stat_variation16.tmp";
+$fp = fopen($filename, "w"); // temp file
+fclose($fp);
+
+// checking stat() on file after changing its permission
+echo "*** Testing lstat() on a file after changing its access permission ***\n";
+$old_stat = stat($filename);
+sleep(2);
+var_dump( chmod($filename, 0777) );
+// clear the stat
+clearstatcache();
+$new_stat = stat($filename);
+// compare self stats
+var_dump( compare_self_stat($old_stat) );
+var_dump( compare_self_stat($new_stat) );
+// compare the stat
+$affected_members = array(10, 'ctime');
+var_dump( compare_stats($old_stat, $new_stat, $affected_members, "!=") );
+
+echo "\n--- Done ---";
+?>
+
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink("$file_path/lstat_stat_variation16.tmp");
+?>
+--EXPECTF--
+*** Testing lstat() on a file after changing its access permission ***
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+
+--- Done ---
diff --git a/ext/standard/tests/file/lstat_stat_variation17.phpt b/ext/standard/tests/file/lstat_stat_variation17.phpt
new file mode 100644
index 0000000..f2306de
--- /dev/null
+++ b/ext/standard/tests/file/lstat_stat_variation17.phpt
@@ -0,0 +1,57 @@
+--TEST--
+Test lstat() and stat() functions: usage variations - effects changing permissions of dir
+--SKIPIF--
+<?php
+if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. Not valid for Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: array lstat ( string $filename );
+ Description: Gives information about a file or symbolic link
+
+ Prototype: array stat ( string $filename );
+ Description: Gives information about a file
+*/
+
+/* test the effects on stats by changing permissions of a dir */
+
+$file_path = dirname(__FILE__);
+require "$file_path/file.inc";
+
+// checking stat() on directory
+echo "*** Testing lstat() on a dir after changing its access permission ***\n";
+$dirname = "$file_path/lstat_stat_variation17";
+mkdir($dirname);
+
+$old_stat = stat($dirname);
+sleep(2);
+var_dump( chmod($dirname, 0777) );
+// clear the stat
+clearstatcache();
+$new_stat = stat($dirname);
+// compare self stats
+var_dump( compare_self_stat($old_stat) );
+var_dump( compare_self_stat($new_stat) );
+// compare the stat
+$affected_members = array(2, 10, 'mode', 'ctime');
+var_dump( compare_stats($old_stat, $new_stat, $affected_members, "!=") );
+
+echo "\n--- Done ---";
+?>
+
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+rmdir("$file_path/lstat_stat_variation17");
+?>
+--EXPECTF--
+*** Testing lstat() on a dir after changing its access permission ***
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+
+--- Done ---
diff --git a/ext/standard/tests/file/lstat_stat_variation18.phpt b/ext/standard/tests/file/lstat_stat_variation18.phpt
new file mode 100644
index 0000000..fc98739
--- /dev/null
+++ b/ext/standard/tests/file/lstat_stat_variation18.phpt
@@ -0,0 +1,176 @@
+--TEST--
+Test lstat() and stat() functions: usage variations - dir/file name stored in object
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. Not valid for Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: array lstat ( string $filename );
+ Description: Gives information about a file or symbolic link
+
+ Prototype: array stat ( string $filename );
+ Description: Gives information about a file
+*/
+
+/* test for stats of dir/file when their names are stored in objects */
+
+$file_path = dirname(__FILE__);
+require "$file_path/file.inc";
+
+
+/* create temp file and directory */
+mkdir("$file_path/lstat_stat_variation18/"); // temp dir
+$fp = fopen("$file_path/lstat_stat_variation18.tmp", "w"); // temp file
+fclose($fp);
+
+echo "*** Testing stat() with filename & directory name stored inside an object ***\n";
+
+class names {
+ public $var_name;
+ public function names($name) {
+ $this->var_name = $name;
+ }
+}
+
+// directory name stored in an object
+$dir_name = new names("$file_path/lstat_stat_variation18");
+
+// file name stored in an object
+$file_name = new names("$file_path/lstat_stat_variation18.tmp");
+
+echo "\n-- Testing stat() on filename stored inside an object --\n";
+// dump the stat returned value
+var_dump( stat($file_name->var_name) );
+
+echo "\n-- Testing stat() on directory name stored inside an object --\n";
+// dump the stat returned value
+var_dump( stat($dir_name->var_name) );
+
+echo "\n--- Done ---";
+?>
+
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink("$file_path/lstat_stat_variation18.tmp");
+rmdir("$file_path/lstat_stat_variation18");
+?>
+--EXPECTF--
+*** Testing stat() with filename & directory name stored inside an object ***
+
+-- Testing stat() on filename stored inside an object --
+array(26) {
+ [0]=>
+ int(%d)
+ [1]=>
+ int(%d)
+ [2]=>
+ int(%d)
+ [3]=>
+ int(%d)
+ [4]=>
+ int(%d)
+ [5]=>
+ int(%d)
+ [6]=>
+ int(%d)
+ [7]=>
+ int(%d)
+ [8]=>
+ int(%d)
+ [9]=>
+ int(%d)
+ [10]=>
+ int(%d)
+ [11]=>
+ int(%d)
+ [12]=>
+ int(%d)
+ ["dev"]=>
+ int(%d)
+ ["ino"]=>
+ int(%d)
+ ["mode"]=>
+ int(%d)
+ ["nlink"]=>
+ int(%d)
+ ["uid"]=>
+ int(%d)
+ ["gid"]=>
+ int(%d)
+ ["rdev"]=>
+ int(%d)
+ ["size"]=>
+ int(%d)
+ ["atime"]=>
+ int(%d)
+ ["mtime"]=>
+ int(%d)
+ ["ctime"]=>
+ int(%d)
+ ["blksize"]=>
+ int(%d)
+ ["blocks"]=>
+ int(%d)
+}
+
+-- Testing stat() on directory name stored inside an object --
+array(26) {
+ [0]=>
+ int(%d)
+ [1]=>
+ int(%d)
+ [2]=>
+ int(%d)
+ [3]=>
+ int(%d)
+ [4]=>
+ int(%d)
+ [5]=>
+ int(%d)
+ [6]=>
+ int(%d)
+ [7]=>
+ int(%d)
+ [8]=>
+ int(%d)
+ [9]=>
+ int(%d)
+ [10]=>
+ int(%d)
+ [11]=>
+ int(%d)
+ [12]=>
+ int(%d)
+ ["dev"]=>
+ int(%d)
+ ["ino"]=>
+ int(%d)
+ ["mode"]=>
+ int(%d)
+ ["nlink"]=>
+ int(%d)
+ ["uid"]=>
+ int(%d)
+ ["gid"]=>
+ int(%d)
+ ["rdev"]=>
+ int(%d)
+ ["size"]=>
+ int(%d)
+ ["atime"]=>
+ int(%d)
+ ["mtime"]=>
+ int(%d)
+ ["ctime"]=>
+ int(%d)
+ ["blksize"]=>
+ int(%d)
+ ["blocks"]=>
+ int(%d)
+}
+
+--- Done ---
diff --git a/ext/standard/tests/file/lstat_stat_variation19.phpt b/ext/standard/tests/file/lstat_stat_variation19.phpt
new file mode 100644
index 0000000..c481575
--- /dev/null
+++ b/ext/standard/tests/file/lstat_stat_variation19.phpt
@@ -0,0 +1,285 @@
+--TEST--
+Test lstat() and stat() functions: usage variations - dir/file names in array
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. Not valid for Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: array lstat ( string $filename );
+ Description: Gives information about a file or symbolic link
+
+ Prototype: array stat ( string $filename );
+ Description: Gives information about a file
+*/
+
+/* test for stats of dir/file when their names are stored in an array */
+
+$file_path = dirname(__FILE__);
+require "$file_path/file.inc";
+
+
+/* create temp file, link and directory */
+@rmdir("$file_path/lstat_stat_variation19"); // ensure that dir doesn't exists
+mkdir("$file_path/lstat_stat_variation19"); // temp dir
+
+$fp = fopen("$file_path/lstat_stat_variation19.tmp", "w"); // temp file
+fclose($fp);
+
+echo "*** Testing stat() with filename & directory name stored inside an array ***\n";
+
+// array with default numeric index
+$names = array(
+ "$file_path/lstat_stat_variation19.tmp",
+ "$file_path/lstat_stat_variation19"
+);
+
+//array with string key index
+$names_with_key = array (
+ 'file' => "$file_path/lstat_stat_variation19.tmp",
+ "dir" => "$file_path/lstat_stat_variation19"
+);
+
+echo "\n-- Testing stat() on filename stored inside an array --\n";
+var_dump( stat($names[0]) ); // values stored with numeric index
+var_dump( stat($names_with_key['file']) ); // value stored with string key
+
+echo "\n-- Testing stat() on dir name stored inside an array --\n";
+var_dump( stat($names[1]) ); // values stored with numeric index
+var_dump( stat($names_with_key["dir"]) ); // value stored with string key
+
+echo "\n--- Done ---";
+?>
+
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink("$file_path/lstat_stat_variation19.tmp");
+rmdir("$file_path/lstat_stat_variation19");
+?>
+--EXPECTF--
+*** Testing stat() with filename & directory name stored inside an array ***
+
+-- Testing stat() on filename stored inside an array --
+array(26) {
+ [0]=>
+ int(%d)
+ [1]=>
+ int(%d)
+ [2]=>
+ int(%d)
+ [3]=>
+ int(%d)
+ [4]=>
+ int(%d)
+ [5]=>
+ int(%d)
+ [6]=>
+ int(%d)
+ [7]=>
+ int(%d)
+ [8]=>
+ int(%d)
+ [9]=>
+ int(%d)
+ [10]=>
+ int(%d)
+ [11]=>
+ int(%d)
+ [12]=>
+ int(%d)
+ ["dev"]=>
+ int(%d)
+ ["ino"]=>
+ int(%d)
+ ["mode"]=>
+ int(%d)
+ ["nlink"]=>
+ int(%d)
+ ["uid"]=>
+ int(%d)
+ ["gid"]=>
+ int(%d)
+ ["rdev"]=>
+ int(%d)
+ ["size"]=>
+ int(%d)
+ ["atime"]=>
+ int(%d)
+ ["mtime"]=>
+ int(%d)
+ ["ctime"]=>
+ int(%d)
+ ["blksize"]=>
+ int(%d)
+ ["blocks"]=>
+ int(%d)
+}
+array(26) {
+ [0]=>
+ int(%d)
+ [1]=>
+ int(%d)
+ [2]=>
+ int(%d)
+ [3]=>
+ int(%d)
+ [4]=>
+ int(%d)
+ [5]=>
+ int(%d)
+ [6]=>
+ int(%d)
+ [7]=>
+ int(%d)
+ [8]=>
+ int(%d)
+ [9]=>
+ int(%d)
+ [10]=>
+ int(%d)
+ [11]=>
+ int(%d)
+ [12]=>
+ int(%d)
+ ["dev"]=>
+ int(%d)
+ ["ino"]=>
+ int(%d)
+ ["mode"]=>
+ int(%d)
+ ["nlink"]=>
+ int(%d)
+ ["uid"]=>
+ int(%d)
+ ["gid"]=>
+ int(%d)
+ ["rdev"]=>
+ int(%d)
+ ["size"]=>
+ int(%d)
+ ["atime"]=>
+ int(%d)
+ ["mtime"]=>
+ int(%d)
+ ["ctime"]=>
+ int(%d)
+ ["blksize"]=>
+ int(%d)
+ ["blocks"]=>
+ int(%d)
+}
+
+-- Testing stat() on dir name stored inside an array --
+array(26) {
+ [0]=>
+ int(%d)
+ [1]=>
+ int(%d)
+ [2]=>
+ int(%d)
+ [3]=>
+ int(%d)
+ [4]=>
+ int(%d)
+ [5]=>
+ int(%d)
+ [6]=>
+ int(%d)
+ [7]=>
+ int(%d)
+ [8]=>
+ int(%d)
+ [9]=>
+ int(%d)
+ [10]=>
+ int(%d)
+ [11]=>
+ int(%d)
+ [12]=>
+ int(%d)
+ ["dev"]=>
+ int(%d)
+ ["ino"]=>
+ int(%d)
+ ["mode"]=>
+ int(%d)
+ ["nlink"]=>
+ int(%d)
+ ["uid"]=>
+ int(%d)
+ ["gid"]=>
+ int(%d)
+ ["rdev"]=>
+ int(%d)
+ ["size"]=>
+ int(%d)
+ ["atime"]=>
+ int(%d)
+ ["mtime"]=>
+ int(%d)
+ ["ctime"]=>
+ int(%d)
+ ["blksize"]=>
+ int(%d)
+ ["blocks"]=>
+ int(%d)
+}
+array(26) {
+ [0]=>
+ int(%d)
+ [1]=>
+ int(%d)
+ [2]=>
+ int(%d)
+ [3]=>
+ int(%d)
+ [4]=>
+ int(%d)
+ [5]=>
+ int(%d)
+ [6]=>
+ int(%d)
+ [7]=>
+ int(%d)
+ [8]=>
+ int(%d)
+ [9]=>
+ int(%d)
+ [10]=>
+ int(%d)
+ [11]=>
+ int(%d)
+ [12]=>
+ int(%d)
+ ["dev"]=>
+ int(%d)
+ ["ino"]=>
+ int(%d)
+ ["mode"]=>
+ int(%d)
+ ["nlink"]=>
+ int(%d)
+ ["uid"]=>
+ int(%d)
+ ["gid"]=>
+ int(%d)
+ ["rdev"]=>
+ int(%d)
+ ["size"]=>
+ int(%d)
+ ["atime"]=>
+ int(%d)
+ ["mtime"]=>
+ int(%d)
+ ["ctime"]=>
+ int(%d)
+ ["blksize"]=>
+ int(%d)
+ ["blocks"]=>
+ int(%d)
+}
+
+--- Done ---
diff --git a/ext/standard/tests/file/lstat_stat_variation2.phpt b/ext/standard/tests/file/lstat_stat_variation2.phpt
new file mode 100644
index 0000000..e7d704a
--- /dev/null
+++ b/ext/standard/tests/file/lstat_stat_variation2.phpt
@@ -0,0 +1,62 @@
+--TEST--
+Test lstat() and stat() functions: usage variations - effects of rename() on dir
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. Not valid for Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: array lstat ( string $filename );
+ Description: Gives information about a file or symbolic link
+
+ Prototype: array stat ( string $filename );
+ Description: Gives information about a file
+*/
+
+/* test the effects of rename() on stats of dir */
+
+$file_path = dirname(__FILE__);
+require("file.inc");
+
+/* create temp directory */
+mkdir("$file_path/lstat_stat_variation1/"); // temp dir
+
+// renaming a directory and check stat
+echo "*** Testing stat() for directory after being renamed ***\n";
+$old_dirname = "$file_path/lstat_stat_variation1";
+$new_dirname = "$file_path/lstat_stat_variation1a";
+$old_stat = stat($old_dirname);
+clearstatcache();
+var_dump( rename($old_dirname, $new_dirname) );
+$new_stat = stat($new_dirname);
+
+// compare self stats
+var_dump( compare_self_stat($old_stat) );
+var_dump( compare_self_stat($new_stat) );
+
+// compare the two stats - all except ctime
+$keys_to_compare = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12,
+ "dev", "ino", "mode", "nlink", "uid", "gid",
+ "rdev", "size", "atime", "mtime", "blksize", "blocks");
+var_dump( compare_stats($old_stat, $new_stat, $keys_to_compare) );
+// clear the cache
+clearstatcache();
+
+echo "\n--- Done ---";
+?>
+
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+rmdir("$file_path/lstat_stat_variation1a");
+?>
+--EXPECTF--
+*** Testing stat() for directory after being renamed ***
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+
+--- Done ---
diff --git a/ext/standard/tests/file/lstat_stat_variation20.phpt b/ext/standard/tests/file/lstat_stat_variation20.phpt
new file mode 100644
index 0000000..30b81ad
--- /dev/null
+++ b/ext/standard/tests/file/lstat_stat_variation20.phpt
@@ -0,0 +1,287 @@
+--TEST--
+Test lstat() and stat() functions: usage variations - link names stored in array/object
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. lstat() not available on Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: array lstat ( string $filename );
+ Description: Gives information about a file or symbolic link
+
+ Prototype: array stat ( string $filename );
+ Description: Gives information about a file
+*/
+
+/* test for stats of link when their names are stored in object and array */
+
+$file_path = dirname(__FILE__);
+require "$file_path/file.inc";
+
+$fp = fopen("$file_path/lstat_stat_variation20.tmp", "w"); // temp file
+fclose($fp);
+
+// temp link
+symlink("$file_path/lstat_stat_variation20.tmp", "$file_path/lstat_stat_variation20_link.tmp");
+
+echo "*** Testing lstat() with linkname stored inside an object/array ***\n";
+class names {
+ public $var_name;
+ public function names($name) {
+ $this->var_name = $name;
+ }
+}
+
+// link name stored in an object
+$link_object = new names("$file_path/lstat_stat_variation20_link.tmp");
+
+// link name stored in side an array
+// with default numeric key
+$link_array = array("$file_path/lstat_stat_variation20_link.tmp");
+
+// with string key index
+$link_array_with_key = array("linkname" => "$file_path/lstat_stat_variation20_link.tmp");
+
+echo "\n-- Testing lstat() on link name stored inside an object --\n";
+var_dump( lstat($link_object->var_name) );
+
+echo "\n-- Testing stat() on link name stored inside an array --\n";
+var_dump( stat($link_array[0]) ); // with default numeric index
+var_dump( stat($link_array_with_key["linkname"]) ); // with string key
+var_dump( stat($link_array_with_key['linkname']) );
+
+echo "\n--- Done ---";
+?>
+
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink("$file_path/lstat_stat_variation20_link.tmp");
+unlink("$file_path/lstat_stat_variation20.tmp");
+?>
+--EXPECTF--
+*** Testing lstat() with linkname stored inside an object/array ***
+
+-- Testing lstat() on link name stored inside an object --
+array(26) {
+ [0]=>
+ int(%d)
+ [1]=>
+ int(%d)
+ [2]=>
+ int(%d)
+ [3]=>
+ int(%d)
+ [4]=>
+ int(%d)
+ [5]=>
+ int(%d)
+ [6]=>
+ int(%d)
+ [7]=>
+ int(%d)
+ [8]=>
+ int(%d)
+ [9]=>
+ int(%d)
+ [10]=>
+ int(%d)
+ [11]=>
+ int(%d)
+ [12]=>
+ int(%d)
+ ["dev"]=>
+ int(%d)
+ ["ino"]=>
+ int(%d)
+ ["mode"]=>
+ int(%d)
+ ["nlink"]=>
+ int(%d)
+ ["uid"]=>
+ int(%d)
+ ["gid"]=>
+ int(%d)
+ ["rdev"]=>
+ int(%d)
+ ["size"]=>
+ int(%d)
+ ["atime"]=>
+ int(%d)
+ ["mtime"]=>
+ int(%d)
+ ["ctime"]=>
+ int(%d)
+ ["blksize"]=>
+ int(%d)
+ ["blocks"]=>
+ int(%d)
+}
+
+-- Testing stat() on link name stored inside an array --
+array(26) {
+ [0]=>
+ int(%d)
+ [1]=>
+ int(%d)
+ [2]=>
+ int(%d)
+ [3]=>
+ int(%d)
+ [4]=>
+ int(%d)
+ [5]=>
+ int(%d)
+ [6]=>
+ int(%d)
+ [7]=>
+ int(%d)
+ [8]=>
+ int(%d)
+ [9]=>
+ int(%d)
+ [10]=>
+ int(%d)
+ [11]=>
+ int(%d)
+ [12]=>
+ int(%d)
+ ["dev"]=>
+ int(%d)
+ ["ino"]=>
+ int(%d)
+ ["mode"]=>
+ int(%d)
+ ["nlink"]=>
+ int(%d)
+ ["uid"]=>
+ int(%d)
+ ["gid"]=>
+ int(%d)
+ ["rdev"]=>
+ int(%d)
+ ["size"]=>
+ int(%d)
+ ["atime"]=>
+ int(%d)
+ ["mtime"]=>
+ int(%d)
+ ["ctime"]=>
+ int(%d)
+ ["blksize"]=>
+ int(%d)
+ ["blocks"]=>
+ int(%d)
+}
+array(26) {
+ [0]=>
+ int(%d)
+ [1]=>
+ int(%d)
+ [2]=>
+ int(%d)
+ [3]=>
+ int(%d)
+ [4]=>
+ int(%d)
+ [5]=>
+ int(%d)
+ [6]=>
+ int(%d)
+ [7]=>
+ int(%d)
+ [8]=>
+ int(%d)
+ [9]=>
+ int(%d)
+ [10]=>
+ int(%d)
+ [11]=>
+ int(%d)
+ [12]=>
+ int(%d)
+ ["dev"]=>
+ int(%d)
+ ["ino"]=>
+ int(%d)
+ ["mode"]=>
+ int(%d)
+ ["nlink"]=>
+ int(%d)
+ ["uid"]=>
+ int(%d)
+ ["gid"]=>
+ int(%d)
+ ["rdev"]=>
+ int(%d)
+ ["size"]=>
+ int(%d)
+ ["atime"]=>
+ int(%d)
+ ["mtime"]=>
+ int(%d)
+ ["ctime"]=>
+ int(%d)
+ ["blksize"]=>
+ int(%d)
+ ["blocks"]=>
+ int(%d)
+}
+array(26) {
+ [0]=>
+ int(%d)
+ [1]=>
+ int(%d)
+ [2]=>
+ int(%d)
+ [3]=>
+ int(%d)
+ [4]=>
+ int(%d)
+ [5]=>
+ int(%d)
+ [6]=>
+ int(%d)
+ [7]=>
+ int(%d)
+ [8]=>
+ int(%d)
+ [9]=>
+ int(%d)
+ [10]=>
+ int(%d)
+ [11]=>
+ int(%d)
+ [12]=>
+ int(%d)
+ ["dev"]=>
+ int(%d)
+ ["ino"]=>
+ int(%d)
+ ["mode"]=>
+ int(%d)
+ ["nlink"]=>
+ int(%d)
+ ["uid"]=>
+ int(%d)
+ ["gid"]=>
+ int(%d)
+ ["rdev"]=>
+ int(%d)
+ ["size"]=>
+ int(%d)
+ ["atime"]=>
+ int(%d)
+ ["mtime"]=>
+ int(%d)
+ ["ctime"]=>
+ int(%d)
+ ["blksize"]=>
+ int(%d)
+ ["blocks"]=>
+ int(%d)
+}
+
+--- Done ---
diff --git a/ext/standard/tests/file/lstat_stat_variation21.phpt b/ext/standard/tests/file/lstat_stat_variation21.phpt
new file mode 100644
index 0000000..8620ab0
--- /dev/null
+++ b/ext/standard/tests/file/lstat_stat_variation21.phpt
@@ -0,0 +1,65 @@
+--TEST--
+Test lstat() and stat() functions: usage variations - effects of truncate()
+--SKIPIF--
+<?php
+if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. Not valid for Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: array lstat ( string $filename );
+ Description: Gives information about a file or symbolic link
+
+ Prototype: array stat ( string $filename );
+ Description: Gives information about a file
+*/
+
+/* test the effects of truncate() on stats of a file */
+
+$file_path = dirname(__FILE__);
+require "$file_path/file.inc";
+
+
+/* create temp file */
+$filename = "$file_path/lstat_stat_variation21.tmp";
+$fp = fopen($filename, "w"); // temp file
+fclose($fp);
+
+/* ftruncate the current file and check stat() on the file */
+
+echo "*** Testing stat() on file by truncating it to given size ***\n";
+$old_stat = stat($filename);
+// clear the cache
+clearstatcache();
+sleep(2);
+// opening file in r/w mode
+$file_handle = fopen($filename, "r+");
+var_dump( ftruncate($file_handle, 512) ); // truncate it
+fclose($file_handle);
+
+$new_stat = stat($filename);
+// compare self stats
+var_dump( compare_self_stat($old_stat) );
+var_dump( compare_self_stat($new_stat) );
+// compare the stat
+$affected_members = array(7, 9, 10, 'size', 'mtime', 'ctime');
+var_dump( compare_stats($old_stat, $new_stat, $affected_members, '!=') );
+
+echo "\n--- Done ---";
+?>
+
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink("$file_path/lstat_stat_variation21.tmp");
+?>
+--EXPECTF--
+*** Testing stat() on file by truncating it to given size ***
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+
+--- Done ---
diff --git a/ext/standard/tests/file/lstat_stat_variation22.phpt b/ext/standard/tests/file/lstat_stat_variation22.phpt
new file mode 100644
index 0000000..f9d9047
--- /dev/null
+++ b/ext/standard/tests/file/lstat_stat_variation22.phpt
@@ -0,0 +1,54 @@
+--TEST--
+Test lstat() and stat() functions: usage variations - invalid filenames
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip ... not for Windows');
+}
+--FILE--
+<?php
+/* Prototype: array lstat ( string $filename );
+ Description: Gives information about a file or symbolic link
+
+ Prototype: array stat ( string $filename );
+ Description: Gives information about a file
+*/
+echo "*** testing stat ***\n";
+var_dump(stat(NULL));
+var_dump(stat(false));
+var_dump(stat(''));
+var_dump(stat(' '));
+var_dump(stat('|'));
+
+echo "*** testing lstat ***\n";
+var_dump(lstat(NULL));
+var_dump(lstat(false));
+var_dump(lstat(''));
+var_dump(lstat(' '));
+var_dump(lstat('|'));
+echo "Done";
+?>
+--EXPECTF--
+*** testing stat ***
+bool(false)
+bool(false)
+bool(false)
+
+Warning: stat(): stat failed for in %s on line %d
+bool(false)
+
+Warning: stat(): stat failed for | in %s on line %d
+bool(false)
+*** testing lstat ***
+bool(false)
+bool(false)
+bool(false)
+
+Warning: lstat(): Lstat failed for in %s on line %d
+bool(false)
+
+Warning: lstat(): Lstat failed for | in %s on line %d
+bool(false)
+Done
diff --git a/ext/standard/tests/file/lstat_stat_variation3.phpt b/ext/standard/tests/file/lstat_stat_variation3.phpt
new file mode 100644
index 0000000..e7bae3a
--- /dev/null
+++ b/ext/standard/tests/file/lstat_stat_variation3.phpt
@@ -0,0 +1,62 @@
+--TEST--
+Test lstat() and stat() functions: usage variations - effects of rename() on link
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. Not valid for Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: array lstat ( string $filename );
+ Description: Gives information about a file or symbolic link
+
+ Prototype: array stat ( string $filename );
+ Description: Gives information about a file
+*/
+
+/* test the effects of rename() on stats of link */
+
+$file_path = dirname(__FILE__);
+require "$file_path/file.inc";
+
+/* create temp file & link */
+$fp = fopen("$file_path/lstat_stat_variation3.tmp", "w"); // temp file
+fclose($fp);
+
+// temp link
+symlink("$file_path/lstat_stat_variation3.tmp", "$file_path/lstat_stat_variation_link3.tmp");
+
+// renaming a link
+echo "*** Testing lstat() for link after being renamed ***\n";
+$old_linkname = "$file_path/lstat_stat_variation_link3.tmp";
+$new_linkname = "$file_path/lstat_stat_variation_link3a.tmp";
+$old_stat = lstat($old_linkname);
+clearstatcache();
+var_dump( rename($old_linkname, $new_linkname) );
+$new_stat = lstat($new_linkname);
+
+// compare self stats
+var_dump( compare_self_stat($old_stat) );
+var_dump( compare_self_stat($new_stat) );
+
+// compare the two stats - all except ctime
+$keys_to_compare = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12,
+ "dev", "ino", "mode", "nlink", "uid", "gid",
+ "rdev", "size", "atime", "mtime", "blksize", "blocks");
+var_dump( compare_stats($old_stat, $new_stat, $keys_to_compare) );
+?>
+===Done===
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink("$file_path/lstat_stat_variation3.tmp");
+unlink("$file_path/lstat_stat_variation_link3a.tmp");
+?>
+--EXPECT--
+*** Testing lstat() for link after being renamed ***
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+===Done===
diff --git a/ext/standard/tests/file/lstat_stat_variation4.phpt b/ext/standard/tests/file/lstat_stat_variation4.phpt
new file mode 100644
index 0000000..259beca
--- /dev/null
+++ b/ext/standard/tests/file/lstat_stat_variation4.phpt
@@ -0,0 +1,65 @@
+--TEST--
+Test lstat() and stat() functions: usage variations - effects of touch() on file
+--SKIPIF--
+<?php
+if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. Not valid for Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: array lstat ( string $filename );
+ Description: Gives information about a file or symbolic link
+
+ Prototype: array stat ( string $filename );
+ Description: Gives information about a file
+*/
+
+/* test the effects of touch() on stats of file */
+
+$file_path = dirname(__FILE__);
+require "$file_path/file.inc";
+
+
+/* create temp file */
+
+$file_name = "$file_path/lstat_stat_variation4.tmp";
+$fp = fopen($file_name, "w"); // temp file
+fclose($fp);
+
+// touch a file check stat, there should be difference in atime
+echo "*** Testing stat() for file after using touch() on the file ***\n";
+$old_stat = stat($file_name);
+// clear the cache
+clearstatcache();
+sleep(2);
+var_dump( touch($file_name) );
+$new_stat = stat($file_name);
+
+// compare self stats
+var_dump( compare_self_stat($old_stat) );
+var_dump( compare_self_stat($new_stat) );
+
+// compare the stat
+$affected_members = array(8, 'atime');
+var_dump( compare_stats($old_stat, $new_stat, $affected_members, "<") );
+// clear the cache
+clearstatcache();
+
+echo "\n--- Done ---";
+?>
+
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink("$file_path/lstat_stat_variation4.tmp");
+?>
+--EXPECTF--
+*** Testing stat() for file after using touch() on the file ***
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+
+--- Done ---
diff --git a/ext/standard/tests/file/lstat_stat_variation5.phpt b/ext/standard/tests/file/lstat_stat_variation5.phpt
new file mode 100644
index 0000000..d0c096e
--- /dev/null
+++ b/ext/standard/tests/file/lstat_stat_variation5.phpt
@@ -0,0 +1,66 @@
+--TEST--
+Test lstat() and stat() functions: usage variations - effects of touch() on dir
+--SKIPIF--
+<?php
+if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. Not valid for Windows');
+}
+?>
+?>
+--FILE--
+<?php
+/* Prototype: array lstat ( string $filename );
+ Description: Gives information about a file or symbolic link
+
+ Prototype: array stat ( string $filename );
+ Description: Gives information about a file
+*/
+
+/* test the effects of touch() on stats of dir */
+
+$file_path = dirname(__FILE__);
+require "$file_path/file.inc";
+
+
+/* create temp directory */
+
+$dir_name = "$file_path/lstat_stat_variation5";
+@rmdir($dir_name); //ensure that dir doesn't exists
+mkdir($dir_name); // temp dir
+
+// touch a directory and check stat, there should be difference in atime
+echo "*** Testing stat() for directory after using touch() on the directory ***\n";
+$old_stat = stat($dir_name);
+// clear the cache
+clearstatcache();
+sleep(2);
+var_dump( touch($dir_name) );
+$new_stat = stat($dir_name);
+
+// compare self stats
+var_dump( compare_self_stat($old_stat) );
+var_dump( compare_self_stat($new_stat) );
+
+// compare the stat
+$affected_members = array(8, 9, 10, 'atime', 'mtime', 'ctime');
+var_dump( compare_stats($old_stat, $new_stat, $affected_members, "<") );
+// clear the cache
+clearstatcache();
+
+echo "\n--- Done ---";
+?>
+
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+rmdir("$file_path/lstat_stat_variation5");
+?>
+--EXPECTF--
+*** Testing stat() for directory after using touch() on the directory ***
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+
+--- Done ---
diff --git a/ext/standard/tests/file/lstat_stat_variation6.phpt b/ext/standard/tests/file/lstat_stat_variation6.phpt
new file mode 100644
index 0000000..7e557d0
--- /dev/null
+++ b/ext/standard/tests/file/lstat_stat_variation6.phpt
@@ -0,0 +1,79 @@
+--TEST--
+Test lstat() and stat() functions: usage variations - effects of touch() on link
+--SKIPIF--
+<?php
+if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
+if (!(stristr(PHP_OS, 'linux'))) {
+ die('skip.. test valid for linux only');
+}
+
+// checking for atime update whether it is enabled or disabled
+exec("mount", $mount_output);
+foreach( $mount_output as $out ) {
+ if( stristr($out, "noatime") )
+ die('skip.. atime update is disabled, hence skip the test');
+}
+
+?>
+--FILE--
+<?php
+/* Prototype: array lstat ( string $filename );
+ Description: Gives information about a file or symbolic link
+
+ Prototype: array stat ( string $filename );
+ Description: Gives information about a file
+*/
+
+/* test the effects of touch() on stats of link */
+
+$file_path = dirname(__FILE__);
+require "$file_path/file.inc";
+
+
+/* create temp file, link and directory */
+
+$file_name = "$file_path/lstat_stat_variation6.tmp";
+$fp = fopen($file_name, "w"); // temp file
+fclose($fp);
+$link_name = "$file_path/lstat_stat_variation_link6.tmp";
+symlink($file_name, $link_name); // temp link
+
+// touch a link, check stat, there should be difference in atime
+echo "*** Testing lstat() for link after using touch() on the link ***\n";
+$old_stat = lstat($link_name);
+sleep(2);
+
+// clear the cache
+clearstatcache();
+
+var_dump( touch($link_name) );
+
+$new_stat = stat($file_name);
+
+// compare self stats
+var_dump( compare_self_stat($old_stat) );
+var_dump( compare_self_stat($new_stat) );
+
+// compare the stat
+$affected_members = array(8, 'atime');
+var_dump( compare_stats($old_stat, $new_stat, $affected_members, "<") );
+// clear the stat
+clearstatcache();
+
+echo "\n--- Done ---";
+?>
+
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink("$file_path/lstat_stat_variation6.tmp");
+unlink("$file_path/lstat_stat_variation_link6.tmp");
+?>
+--EXPECTF--
+*** Testing lstat() for link after using touch() on the link ***
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+
+--- Done ---
diff --git a/ext/standard/tests/file/lstat_stat_variation7.phpt b/ext/standard/tests/file/lstat_stat_variation7.phpt
new file mode 100644
index 0000000..2296193
--- /dev/null
+++ b/ext/standard/tests/file/lstat_stat_variation7.phpt
@@ -0,0 +1,57 @@
+--TEST--
+Test lstat() and stat() functions: usage variations - writing data into file
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. Not valid for Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: array lstat ( string $filename );
+ Description: Gives information about a file or symbolic link
+
+ Prototype: array stat ( string $filename );
+ Description: Gives information about a file
+*/
+
+$file_path = dirname(__FILE__);
+require "$file_path/file.inc";
+
+/* test the effects on stats with writing data into a file */
+
+$file_name = "$file_path/lstat_stat_variation7.tmp";
+$fp = fopen($file_name, "w"); // temp file
+fclose($fp);
+
+// writing to an empty file
+echo "*** Testing stat() on file after data is written in it ***\n";
+$fh = fopen($file_name,"w");
+$old_stat = stat($file_name);
+clearstatcache();
+fwrite($fh, str_repeat((binary)"Hello World", $old_stat['blksize']));
+$new_stat = stat($file_name);
+
+// compare self stats
+var_dump( compare_self_stat($old_stat) );
+var_dump( compare_self_stat($new_stat) );
+// compare the stats
+$comp_arr = array(7, 12, 'size', 'blocks');
+var_dump(compare_stats($old_stat, $new_stat, $comp_arr, "<"));
+clearstatcache();
+
+echo "\n--- Done ---";
+?>
+
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink("$file_path/lstat_stat_variation7.tmp");
+?>
+--EXPECTF--
+*** Testing stat() on file after data is written in it ***
+bool(true)
+bool(true)
+bool(true)
+
+--- Done ---
diff --git a/ext/standard/tests/file/lstat_stat_variation8.phpt b/ext/standard/tests/file/lstat_stat_variation8.phpt
new file mode 100644
index 0000000..b0f170d
--- /dev/null
+++ b/ext/standard/tests/file/lstat_stat_variation8.phpt
@@ -0,0 +1,62 @@
+--TEST--
+Test lstat() and stat() functions: usage variations - creating file/subdir
+--SKIPIF--
+<?php
+if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. Not valid for Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: array lstat ( string $filename );
+ Description: Gives information about a file or symbolic link
+
+ Prototype: array stat ( string $filename );
+ Description: Gives information about a file
+*/
+
+$file_path = dirname(__FILE__);
+require "$file_path/file.inc";
+
+/* test the effects on stats with creating file/subdir in a dir
+*/
+
+/* create temp file */
+mkdir("$file_path/lstat_stat_variation8/"); // temp dir
+
+// creating and deleting subdir and files in the dir
+echo "*** Testing stat() on dir after subdir and file is created in it ***\n";
+$dirname = "$file_path/lstat_stat_variation8";
+$old_stat = stat($dirname);
+clearstatcache();
+sleep(2);
+mkdir("$dirname/lstat_stat_variation8_subdir");
+$file_handle = fopen("$dirname/lstat_stat_variation8a.tmp", "w");
+fclose($file_handle);
+$new_stat = stat($dirname);
+
+// compare self stats
+var_dump( compare_self_stat($old_stat) );
+var_dump( compare_self_stat($new_stat) );
+// compare the stats
+$affected_members = array(3, 9, 10, 'nlink', 'mtime', 'ctime');
+clearstatcache();
+var_dump(compare_stats($old_stat, $new_stat, $affected_members, "<"));
+
+echo "\n--- Done ---";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink("$file_path/lstat_stat_variation8/lstat_stat_variation8a.tmp");
+rmdir("$file_path/lstat_stat_variation8/lstat_stat_variation8_subdir/");
+rmdir("$file_path/lstat_stat_variation8");
+?>
+--EXPECTF--
+*** Testing stat() on dir after subdir and file is created in it ***
+bool(true)
+bool(true)
+bool(true)
+
+--- Done ---
diff --git a/ext/standard/tests/file/lstat_stat_variation9.phpt b/ext/standard/tests/file/lstat_stat_variation9.phpt
new file mode 100644
index 0000000..63c6ff8
--- /dev/null
+++ b/ext/standard/tests/file/lstat_stat_variation9.phpt
@@ -0,0 +1,68 @@
+--TEST--
+Test lstat() and stat() functions: usage variations - deleting file/subdir
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. Not valid for Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: array lstat ( string $filename );
+ Description: Gives information about a file or symbolic link
+
+ Prototype: array stat ( string $filename );
+ Description: Gives information about a file
+*/
+
+$file_path = dirname(__FILE__);
+require "$file_path/file.inc";
+
+/* test the effects on stats by deleting file/subdir from a dir
+*/
+
+echo "*** Testing stat() for comparing stats after the deletion of subdir and file ***\n";
+
+/* first create the dir/subdir and files, record the stat */
+@rmdir("$file_path/lstat_stat_variation9/"); // ensure that dir doesn't exists
+mkdir("$file_path/lstat_stat_variation9/"); // temp dir
+
+// creating and deleting subdir and files in the dir
+$dirname = "$file_path/lstat_stat_variation9";
+@rmdir("$dirname/lstat_stat_variation9_subdir"); // ensure that dir doesn't exists
+mkdir("$dirname/lstat_stat_variation9_subdir");
+$file_handle = fopen("$dirname/lstat_stat_variation9a.tmp", "w");
+fclose($file_handle);
+
+$old_stat = stat($dirname);
+
+/* now delete the surdir and file and record the stat */
+unlink("$dirname/lstat_stat_variation9a.tmp");
+rmdir("$dirname/lstat_stat_variation9_subdir");
+
+// comparing stats after the deletion of subdir and file
+$new_stat = stat($dirname);
+// compare self stats
+var_dump( compare_self_stat($old_stat) );
+var_dump( compare_self_stat($new_stat) );
+
+// compare the stats
+$affected_members = array(3, 'nlink');
+var_dump(compare_stats($old_stat, $new_stat, $affected_members, ">"));
+
+echo "\n--- Done ---";
+?>
+
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$dirname = "$file_path/lstat_stat_variation9";
+rmdir($dirname);
+?>
+--EXPECTF--
+*** Testing stat() for comparing stats after the deletion of subdir and file ***
+bool(true)
+bool(true)
+bool(true)
+
+--- Done ---
diff --git a/ext/standard/tests/file/mkdir-001.phpt b/ext/standard/tests/file/mkdir-001.phpt
new file mode 100644
index 0000000..be653da
--- /dev/null
+++ b/ext/standard/tests/file/mkdir-001.phpt
@@ -0,0 +1,36 @@
+--TEST--
+mkdir() tests
+--FILE--
+<?php
+
+var_dump(mkdir("testdir"));
+var_dump(mkdir("testdir/subdir"));
+var_dump(rmdir("testdir/subdir"));
+var_dump(rmdir("testdir"));
+
+var_dump(mkdir("./testdir"));
+var_dump(mkdir("./testdir/subdir"));
+var_dump(rmdir("./testdir/subdir"));
+var_dump(rmdir("./testdir"));
+
+var_dump(mkdir(dirname(__FILE__)."/testdir"));
+var_dump(mkdir(dirname(__FILE__)."/testdir/subdir"));
+var_dump(rmdir(dirname(__FILE__)."/testdir/subdir"));
+var_dump(rmdir(dirname(__FILE__)."/testdir"));
+
+echo "Done\n";
+?>
+--EXPECTF--
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+Done
diff --git a/ext/standard/tests/file/mkdir-002.phpt b/ext/standard/tests/file/mkdir-002.phpt
new file mode 100644
index 0000000..ccfd6c3
--- /dev/null
+++ b/ext/standard/tests/file/mkdir-002.phpt
@@ -0,0 +1,55 @@
+--TEST--
+mkdir(dir, 0777) tests
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip no symlinks on Windows');
+}
+?>
+--FILE--
+<?php
+
+var_dump(mkdir("testdir", 0777));
+var_dump(mkdir("testdir/subdir", 0777));
+var_dump(`ls -l testdir`);
+var_dump(rmdir("testdir/subdir"));
+var_dump(rmdir("testdir"));
+
+var_dump(mkdir("./testdir", 0777));
+var_dump(mkdir("./testdir/subdir", 0777));
+var_dump(`ls -l ./testdir`);
+var_dump(rmdir("./testdir/subdir"));
+var_dump(rmdir("./testdir"));
+
+var_dump(mkdir(dirname(__FILE__)."/testdir", 0777));
+var_dump(mkdir(dirname(__FILE__)."/testdir/subdir", 0777));
+$dirname = dirname(__FILE__)."/testdir";
+var_dump(`ls -l $dirname`);
+var_dump(rmdir(dirname(__FILE__)."/testdir/subdir"));
+var_dump(rmdir(dirname(__FILE__)."/testdir"));
+
+echo "Done\n";
+?>
+--EXPECTF--
+bool(true)
+bool(true)
+string(%d) "%s
+d%s subdir
+"
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+string(%d) "%s
+d%s subdir
+"
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+string(%d) "%s
+d%s subdir
+"
+bool(true)
+bool(true)
+Done
diff --git a/ext/standard/tests/file/mkdir-003.phpt b/ext/standard/tests/file/mkdir-003.phpt
new file mode 100644
index 0000000..50ad5e6
--- /dev/null
+++ b/ext/standard/tests/file/mkdir-003.phpt
@@ -0,0 +1,30 @@
+--TEST--
+recursive mkdir() tests
+--FILE--
+<?php
+
+var_dump(mkdir("testdir/subdir", 0777, true));
+var_dump(rmdir("testdir/subdir"));
+var_dump(rmdir("testdir"));
+
+var_dump(mkdir("./testdir/subdir", 0777, true));
+var_dump(rmdir("./testdir/subdir"));
+var_dump(rmdir("./testdir"));
+
+var_dump(mkdir(dirname(__FILE__)."/testdir/subdir", 0777, true));
+var_dump(rmdir(dirname(__FILE__)."/testdir/subdir"));
+var_dump(rmdir(dirname(__FILE__)."/testdir"));
+
+echo "Done\n";
+?>
+--EXPECTF--
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+Done
diff --git a/ext/standard/tests/file/mkdir-004.phpt b/ext/standard/tests/file/mkdir-004.phpt
new file mode 100644
index 0000000..45c2751
--- /dev/null
+++ b/ext/standard/tests/file/mkdir-004.phpt
@@ -0,0 +1,24 @@
+--TEST--
+recursive mkdir() tests
+--SKIPIF--
+<?php
+chdir("/");
+if (!@mkdir("testtmpskipifdir")) {
+ die("skip for root only");
+}
+rmdir("testtmpskipifdir");
+?>
+--FILE--
+<?php
+
+var_dump(mkdir("/testdir/subdir", 0777, true));
+var_dump(rmdir("/testdir/subdir"));
+var_dump(rmdir("/testdir"));
+
+echo "Done\n";
+?>
+--EXPECTF--
+bool(true)
+bool(true)
+bool(true)
+Done
diff --git a/ext/standard/tests/file/mkdir-005.phpt b/ext/standard/tests/file/mkdir-005.phpt
new file mode 100644
index 0000000..af2387c
--- /dev/null
+++ b/ext/standard/tests/file/mkdir-005.phpt
@@ -0,0 +1,25 @@
+--TEST--
+recursive mkdir() tests
+--SKIPIF--
+<?php
+chdir("/");
+if (!@mkdir("testtmpskipifdir")) {
+ die("skip for root only");
+}
+rmdir("testtmpskipifdir");
+?>
+--FILE--
+<?php
+
+chdir("/");
+var_dump(mkdir("./testdir/subdir", 0777, true));
+var_dump(rmdir("./testdir/subdir"));
+var_dump(rmdir("./testdir"));
+
+echo "Done\n";
+?>
+--EXPECTF--
+bool(true)
+bool(true)
+bool(true)
+Done
diff --git a/ext/standard/tests/file/mkdir-006.phpt b/ext/standard/tests/file/mkdir-006.phpt
new file mode 100644
index 0000000..9fcb928
--- /dev/null
+++ b/ext/standard/tests/file/mkdir-006.phpt
@@ -0,0 +1,20 @@
+--TEST--
+recursive mkdir() with unclean paths
+--FILE--
+<?php
+chdir(dirname(__FILE__));
+$dirpath = "./tmp/foo//bar/logs";
+mkdir($dirpath, 0777, true);
+
+if (is_dir($dirpath)) {
+ echo "Ok.\n";
+} else {
+ echo "Failed.\n";
+}
+rmdir("./tmp/foo/bar/logs");
+rmdir("./tmp/foo/bar/");
+rmdir("./tmp/foo/");
+rmdir("./tmp/");
+?>
+--EXPECT--
+Ok.
diff --git a/ext/standard/tests/file/mkdir_rmdir_error.phpt b/ext/standard/tests/file/mkdir_rmdir_error.phpt
new file mode 100644
index 0000000..17f908c
--- /dev/null
+++ b/ext/standard/tests/file/mkdir_rmdir_error.phpt
@@ -0,0 +1,58 @@
+--TEST--
+Test mkdir() and rmdir() functions : error conditions
+--FILE--
+<?php
+/* Prototype: bool mkdir ( string $pathname [, int $mode [, bool $recursive [, resource $context]]] );
+ Description: Makes directory
+
+ Prototype: bool rmdir ( string $dirname [, resource $context] );
+ Description: Removes directory
+*/
+
+echo "*** Testing mkdir(): error conditions ***\n";
+var_dump( mkdir() ); // args < expected
+var_dump( mkdir(1, 2, 3, 4, 5) ); // args > expected
+var_dump( mkdir("testdir", 0777, false, $context, "test") ); // args > expected
+
+echo "\n*** Testing rmdir(): error conditions ***\n";
+var_dump( rmdir() ); // args < expected
+var_dump( rmdir(1, 2, 3) ); // args > expected
+var_dump( rmdir("testdir", $context, "test") ); // args > expected
+
+echo "\n*** Testing rmdir() on non-existent directory ***\n";
+var_dump( rmdir("temp") );
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing mkdir(): error conditions ***
+
+Warning: mkdir() expects at least 1 parameter, 0 given in %s on line %d
+bool(false)
+
+Warning: mkdir() expects at most 4 parameters, 5 given in %s on line %d
+bool(false)
+
+Notice: Undefined variable: context in %s on line %d
+
+Warning: mkdir() expects at most 4 parameters, 5 given in %s on line %d
+bool(false)
+
+*** Testing rmdir(): error conditions ***
+
+Warning: rmdir() expects at least 1 parameter, 0 given in %s on line %d
+bool(false)
+
+Warning: rmdir() expects at most 2 parameters, 3 given in %s on line %d
+bool(false)
+
+Notice: Undefined variable: context in %s on line %d
+
+Warning: rmdir() expects at most 2 parameters, 3 given in %s on line %d
+bool(false)
+
+*** Testing rmdir() on non-existent directory ***
+
+Warning: rmdir(temp): No such file or directory in %s on line %d
+bool(false)
+Done
diff --git a/ext/standard/tests/file/mkdir_rmdir_variation-win32.phpt b/ext/standard/tests/file/mkdir_rmdir_variation-win32.phpt
new file mode 100644
index 0000000..f9d41d5
--- /dev/null
+++ b/ext/standard/tests/file/mkdir_rmdir_variation-win32.phpt
@@ -0,0 +1,1613 @@
+--TEST--
+Test mkdir() and rmdir() functions: usage variations
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip only for Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: bool mkdir ( string $pathname [, int $mode [, bool $recursive [, resource $context]]] );
+ Description: Makes directory
+*/
+
+echo "*** Testing mkdir() and rmdir() for different permissions ***\n";
+
+$context = stream_context_create();
+
+$file_path = dirname(__FILE__);
+$counter = 1;
+
+for($mode = 0000; $mode <= 0777; $mode++) {
+ echo "-- Changing mode of directory to $mode --\n";
+ var_dump( mkdir("$file_path/mkdir/", $mode, true) );
+ var_dump( rmdir("$file_path/mkdir/") );
+ $counter++;
+}
+
+echo "\n*** Testing mkdir() and rmdir() by giving stream context as fourth argument ***\n";
+var_dump( mkdir("$file_path/mkdir/test/", 0777, true, $context) );
+var_dump( rmdir("$file_path/mkdir/test/", $context) );
+
+echo "\n*** Testing rmdir() on a non-empty directory ***\n";
+var_dump( mkdir("$file_path/mkdir/test/", 0777, true) );
+var_dump( rmdir("$file_path/mkdir/") );
+
+echo "\n*** Testing mkdir() and rmdir() for binary safe functionality ***\n";
+var_dump( mkdir("$file_path/tempx000/") );
+var_dump( rmdir("$file_path/tempx000/") );
+
+echo "\n*** Testing mkdir() with miscelleneous input ***\n";
+/* changing mode of mkdir to prevent creating sub-directory under it */
+var_dump( chmod("$file_path/mkdir/", 0000) );
+/* creating sub-directory test1 under mkdir, expected: false */
+var_dump( mkdir("$file_path/mkdir/test1", 0777, true) );
+var_dump( chmod("$file_path/mkdir/", 0777) ); // chmod to enable removing test1 directory
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+rmdir(dirname(__FILE__)."/mkdir/test/");
+rmdir(dirname(__FILE__)."/mkdir/test1/");
+rmdir(dirname(__FILE__)."/mkdir/");
+?>
+--EXPECTF--
+*** Testing mkdir() and rmdir() for different permissions ***
+-- Changing mode of directory to 0 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 1 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 2 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 3 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 4 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 5 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 6 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 7 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 8 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 9 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 10 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 11 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 12 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 13 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 14 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 15 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 16 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 17 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 18 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 19 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 20 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 21 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 22 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 23 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 24 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 25 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 26 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 27 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 28 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 29 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 30 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 31 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 32 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 33 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 34 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 35 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 36 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 37 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 38 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 39 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 40 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 41 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 42 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 43 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 44 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 45 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 46 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 47 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 48 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 49 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 50 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 51 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 52 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 53 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 54 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 55 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 56 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 57 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 58 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 59 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 60 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 61 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 62 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 63 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 64 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 65 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 66 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 67 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 68 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 69 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 70 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 71 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 72 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 73 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 74 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 75 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 76 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 77 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 78 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 79 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 80 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 81 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 82 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 83 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 84 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 85 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 86 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 87 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 88 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 89 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 90 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 91 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 92 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 93 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 94 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 95 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 96 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 97 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 98 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 99 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 100 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 101 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 102 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 103 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 104 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 105 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 106 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 107 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 108 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 109 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 110 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 111 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 112 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 113 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 114 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 115 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 116 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 117 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 118 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 119 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 120 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 121 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 122 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 123 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 124 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 125 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 126 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 127 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 128 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 129 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 130 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 131 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 132 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 133 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 134 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 135 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 136 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 137 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 138 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 139 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 140 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 141 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 142 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 143 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 144 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 145 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 146 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 147 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 148 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 149 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 150 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 151 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 152 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 153 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 154 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 155 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 156 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 157 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 158 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 159 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 160 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 161 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 162 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 163 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 164 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 165 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 166 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 167 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 168 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 169 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 170 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 171 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 172 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 173 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 174 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 175 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 176 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 177 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 178 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 179 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 180 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 181 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 182 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 183 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 184 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 185 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 186 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 187 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 188 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 189 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 190 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 191 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 192 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 193 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 194 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 195 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 196 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 197 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 198 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 199 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 200 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 201 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 202 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 203 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 204 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 205 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 206 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 207 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 208 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 209 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 210 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 211 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 212 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 213 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 214 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 215 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 216 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 217 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 218 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 219 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 220 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 221 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 222 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 223 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 224 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 225 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 226 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 227 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 228 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 229 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 230 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 231 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 232 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 233 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 234 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 235 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 236 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 237 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 238 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 239 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 240 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 241 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 242 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 243 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 244 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 245 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 246 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 247 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 248 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 249 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 250 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 251 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 252 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 253 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 254 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 255 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 256 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 257 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 258 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 259 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 260 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 261 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 262 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 263 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 264 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 265 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 266 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 267 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 268 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 269 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 270 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 271 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 272 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 273 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 274 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 275 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 276 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 277 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 278 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 279 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 280 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 281 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 282 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 283 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 284 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 285 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 286 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 287 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 288 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 289 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 290 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 291 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 292 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 293 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 294 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 295 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 296 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 297 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 298 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 299 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 300 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 301 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 302 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 303 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 304 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 305 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 306 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 307 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 308 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 309 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 310 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 311 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 312 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 313 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 314 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 315 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 316 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 317 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 318 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 319 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 320 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 321 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 322 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 323 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 324 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 325 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 326 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 327 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 328 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 329 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 330 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 331 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 332 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 333 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 334 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 335 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 336 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 337 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 338 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 339 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 340 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 341 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 342 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 343 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 344 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 345 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 346 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 347 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 348 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 349 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 350 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 351 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 352 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 353 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 354 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 355 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 356 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 357 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 358 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 359 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 360 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 361 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 362 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 363 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 364 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 365 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 366 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 367 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 368 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 369 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 370 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 371 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 372 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 373 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 374 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 375 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 376 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 377 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 378 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 379 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 380 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 381 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 382 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 383 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 384 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 385 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 386 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 387 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 388 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 389 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 390 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 391 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 392 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 393 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 394 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 395 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 396 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 397 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 398 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 399 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 400 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 401 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 402 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 403 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 404 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 405 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 406 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 407 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 408 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 409 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 410 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 411 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 412 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 413 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 414 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 415 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 416 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 417 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 418 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 419 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 420 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 421 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 422 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 423 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 424 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 425 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 426 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 427 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 428 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 429 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 430 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 431 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 432 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 433 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 434 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 435 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 436 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 437 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 438 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 439 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 440 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 441 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 442 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 443 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 444 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 445 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 446 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 447 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 448 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 449 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 450 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 451 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 452 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 453 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 454 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 455 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 456 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 457 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 458 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 459 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 460 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 461 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 462 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 463 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 464 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 465 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 466 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 467 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 468 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 469 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 470 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 471 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 472 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 473 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 474 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 475 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 476 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 477 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 478 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 479 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 480 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 481 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 482 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 483 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 484 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 485 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 486 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 487 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 488 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 489 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 490 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 491 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 492 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 493 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 494 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 495 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 496 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 497 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 498 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 499 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 500 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 501 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 502 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 503 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 504 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 505 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 506 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 507 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 508 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 509 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 510 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 511 --
+bool(true)
+bool(true)
+
+*** Testing mkdir() and rmdir() by giving stream context as fourth argument ***
+bool(true)
+bool(true)
+
+*** Testing rmdir() on a non-empty directory ***
+bool(true)
+
+Warning: rmdir(%s/mkdir/): Directory not empty in %s on line %d
+bool(false)
+
+*** Testing mkdir() and rmdir() for binary safe functionality ***
+bool(true)
+bool(true)
+
+*** Testing mkdir() with miscelleneous input ***
+bool(true)
+bool(true)
+bool(true)
+Done
diff --git a/ext/standard/tests/file/mkdir_rmdir_variation1.phpt b/ext/standard/tests/file/mkdir_rmdir_variation1.phpt
new file mode 100644
index 0000000..5dc7a7a
--- /dev/null
+++ b/ext/standard/tests/file/mkdir_rmdir_variation1.phpt
@@ -0,0 +1,1579 @@
+--TEST--
+Test mkdir() and rmdir() functions: usage variations - perms(0000-0777)
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. only on LINUX');
+}
+// Skip if being run by root (files are always readable, writeable and executable)
+$filename = dirname(__FILE__)."/is_readable_root_check.tmp";
+$fp = fopen($filename, 'w');
+fclose($fp);
+if(fileowner($filename) == 0) {
+ unlink ($filename);
+ die('skip cannot be run as root');
+}
+
+unlink($filename);
+?>
+--FILE--
+<?php
+/* Prototype: bool mkdir ( string $pathname [, int $mode [, bool $recursive [, resource $context]]] );
+ Description: Makes directory
+*/
+
+echo "*** Testing mkdir() and rmdir() for different permissions ***\n";
+
+$context = stream_context_create();
+
+$file_path = dirname(__FILE__);
+$counter = 1;
+
+for($mode = 0000; $mode <= 0777; $mode++) {
+ echo "-- Changing mode of directory to $mode --\n";
+ var_dump( mkdir("$file_path/mkdir_variation1/", $mode, true) );
+ var_dump( rmdir("$file_path/mkdir_variation1/") );
+ $counter++;
+}
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing mkdir() and rmdir() for different permissions ***
+-- Changing mode of directory to 0 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 1 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 2 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 3 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 4 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 5 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 6 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 7 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 8 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 9 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 10 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 11 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 12 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 13 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 14 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 15 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 16 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 17 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 18 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 19 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 20 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 21 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 22 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 23 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 24 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 25 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 26 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 27 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 28 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 29 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 30 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 31 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 32 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 33 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 34 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 35 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 36 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 37 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 38 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 39 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 40 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 41 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 42 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 43 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 44 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 45 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 46 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 47 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 48 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 49 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 50 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 51 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 52 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 53 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 54 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 55 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 56 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 57 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 58 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 59 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 60 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 61 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 62 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 63 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 64 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 65 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 66 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 67 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 68 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 69 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 70 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 71 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 72 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 73 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 74 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 75 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 76 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 77 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 78 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 79 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 80 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 81 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 82 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 83 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 84 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 85 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 86 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 87 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 88 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 89 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 90 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 91 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 92 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 93 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 94 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 95 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 96 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 97 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 98 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 99 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 100 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 101 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 102 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 103 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 104 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 105 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 106 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 107 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 108 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 109 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 110 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 111 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 112 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 113 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 114 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 115 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 116 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 117 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 118 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 119 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 120 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 121 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 122 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 123 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 124 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 125 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 126 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 127 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 128 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 129 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 130 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 131 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 132 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 133 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 134 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 135 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 136 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 137 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 138 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 139 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 140 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 141 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 142 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 143 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 144 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 145 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 146 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 147 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 148 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 149 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 150 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 151 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 152 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 153 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 154 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 155 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 156 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 157 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 158 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 159 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 160 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 161 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 162 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 163 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 164 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 165 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 166 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 167 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 168 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 169 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 170 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 171 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 172 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 173 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 174 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 175 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 176 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 177 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 178 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 179 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 180 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 181 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 182 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 183 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 184 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 185 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 186 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 187 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 188 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 189 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 190 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 191 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 192 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 193 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 194 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 195 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 196 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 197 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 198 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 199 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 200 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 201 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 202 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 203 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 204 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 205 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 206 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 207 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 208 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 209 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 210 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 211 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 212 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 213 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 214 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 215 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 216 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 217 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 218 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 219 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 220 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 221 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 222 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 223 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 224 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 225 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 226 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 227 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 228 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 229 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 230 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 231 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 232 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 233 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 234 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 235 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 236 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 237 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 238 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 239 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 240 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 241 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 242 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 243 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 244 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 245 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 246 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 247 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 248 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 249 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 250 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 251 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 252 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 253 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 254 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 255 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 256 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 257 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 258 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 259 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 260 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 261 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 262 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 263 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 264 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 265 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 266 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 267 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 268 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 269 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 270 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 271 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 272 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 273 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 274 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 275 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 276 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 277 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 278 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 279 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 280 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 281 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 282 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 283 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 284 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 285 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 286 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 287 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 288 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 289 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 290 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 291 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 292 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 293 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 294 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 295 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 296 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 297 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 298 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 299 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 300 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 301 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 302 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 303 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 304 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 305 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 306 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 307 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 308 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 309 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 310 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 311 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 312 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 313 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 314 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 315 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 316 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 317 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 318 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 319 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 320 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 321 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 322 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 323 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 324 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 325 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 326 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 327 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 328 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 329 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 330 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 331 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 332 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 333 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 334 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 335 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 336 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 337 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 338 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 339 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 340 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 341 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 342 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 343 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 344 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 345 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 346 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 347 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 348 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 349 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 350 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 351 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 352 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 353 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 354 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 355 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 356 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 357 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 358 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 359 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 360 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 361 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 362 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 363 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 364 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 365 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 366 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 367 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 368 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 369 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 370 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 371 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 372 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 373 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 374 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 375 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 376 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 377 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 378 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 379 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 380 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 381 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 382 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 383 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 384 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 385 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 386 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 387 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 388 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 389 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 390 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 391 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 392 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 393 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 394 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 395 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 396 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 397 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 398 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 399 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 400 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 401 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 402 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 403 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 404 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 405 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 406 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 407 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 408 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 409 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 410 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 411 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 412 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 413 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 414 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 415 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 416 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 417 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 418 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 419 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 420 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 421 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 422 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 423 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 424 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 425 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 426 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 427 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 428 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 429 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 430 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 431 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 432 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 433 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 434 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 435 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 436 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 437 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 438 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 439 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 440 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 441 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 442 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 443 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 444 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 445 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 446 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 447 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 448 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 449 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 450 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 451 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 452 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 453 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 454 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 455 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 456 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 457 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 458 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 459 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 460 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 461 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 462 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 463 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 464 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 465 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 466 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 467 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 468 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 469 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 470 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 471 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 472 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 473 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 474 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 475 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 476 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 477 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 478 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 479 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 480 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 481 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 482 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 483 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 484 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 485 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 486 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 487 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 488 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 489 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 490 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 491 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 492 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 493 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 494 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 495 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 496 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 497 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 498 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 499 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 500 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 501 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 502 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 503 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 504 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 505 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 506 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 507 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 508 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 509 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 510 --
+bool(true)
+bool(true)
+-- Changing mode of directory to 511 --
+bool(true)
+bool(true)
+Done
diff --git a/ext/standard/tests/file/mkdir_rmdir_variation2.phpt b/ext/standard/tests/file/mkdir_rmdir_variation2.phpt
new file mode 100644
index 0000000..14dd361
--- /dev/null
+++ b/ext/standard/tests/file/mkdir_rmdir_variation2.phpt
@@ -0,0 +1,80 @@
+--TEST--
+Test mkdir() and rmdir() functions: usage variations - misc.
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. only on LINUX');
+}
+// Skip if being run by root (files are always readable, writeable and executable)
+$filename = dirname(__FILE__)."/is_readable_root_check.tmp";
+$fp = fopen($filename, 'w');
+fclose($fp);
+if(fileowner($filename) == 0) {
+ unlink ($filename);
+ die('skip cannot be run as root');
+}
+
+unlink($filename);
+?>
+--FILE--
+<?php
+/* Prototype: bool mkdir ( string $pathname [, int $mode [, bool $recursive [, resource $context]]] );
+ Description: Makes directory
+*/
+
+$context = stream_context_create();
+
+$file_path = dirname(__FILE__);
+
+echo "\n*** Testing mkdir() and rmdir() by giving stream context as fourth argument ***\n";
+var_dump( mkdir("$file_path/mkdir_variation2/test/", 0777, true, $context) );
+var_dump( rmdir("$file_path/mkdir_variation2/test/", $context) );
+
+echo "\n*** Testing rmdir() on a non-empty directory ***\n";
+var_dump( mkdir("$file_path/mkdir_variation2/test/", 0777, true) );
+var_dump( rmdir("$file_path/mkdir_variation2/") );
+
+echo "\n*** Testing mkdir() and rmdir() for binary safe functionality ***\n";
+var_dump( mkdir("$file_path/temp".chr(0)."/") );
+var_dump( rmdir("$file_path/temp".chr(0)."/") );
+
+echo "\n*** Testing mkdir() with miscelleneous input ***\n";
+/* changing mode of mkdir to prevent creating sub-directory under it */
+var_dump( chmod("$file_path/mkdir_variation2/", 0000) );
+/* creating sub-directory test1 under mkdir, expected: false */
+var_dump( mkdir("$file_path/mkdir_variation2/test1", 0777, true) );
+var_dump( chmod("$file_path/mkdir_variation2/", 0777) ); // chmod to enable removing test1 directory
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+rmdir(dirname(__FILE__)."/mkdir_variation2/test/");
+rmdir(dirname(__FILE__)."/mkdir_variation2/");
+?>
+--EXPECTF--
+*** Testing mkdir() and rmdir() by giving stream context as fourth argument ***
+bool(true)
+bool(true)
+
+*** Testing rmdir() on a non-empty directory ***
+bool(true)
+
+Warning: rmdir(%s/mkdir_variation2/): %s on line %d
+bool(false)
+
+*** Testing mkdir() and rmdir() for binary safe functionality ***
+
+Warning: mkdir() expects parameter 1 to be a valid path, string given in %s on line %d
+bool(false)
+
+Warning: rmdir(%s): No such file or directory in %s on line %d
+bool(false)
+
+*** Testing mkdir() with miscelleneous input ***
+bool(true)
+
+Warning: mkdir(): Permission denied in %s on line %d
+bool(false)
+bool(true)
+Done
diff --git a/ext/standard/tests/file/mkdir_variation1-win32.phpt b/ext/standard/tests/file/mkdir_variation1-win32.phpt
new file mode 100644
index 0000000..17f5492
--- /dev/null
+++ b/ext/standard/tests/file/mkdir_variation1-win32.phpt
@@ -0,0 +1,122 @@
+--TEST--
+Test mkdir() function : usage variation: try invalid pathname
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+ die("skip Only valid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype : bool mkdir(string pathname [, int mode [, bool recursive [, resource context]]])
+ * Description: Create a directory
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing mkdir() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase false' =>false,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+
+ // other
+ // php.net bug outputs message File Exists
+ 'single space' => ' ',
+);
+
+// loop through each element of the array for pathname
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ $res = mkdir($value);
+ if ($res == true) {
+ echo "directory created\n";
+ rmdir($value);
+ }
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing mkdir() : usage variation ***
+
+--uppercase NULL--
+Error: 2 - mkdir(): %s, %s(%d)
+
+--lowercase null--
+Error: 2 - mkdir(): %s, %s(%d)
+
+--lowercase false--
+Error: 2 - mkdir(): %s, %s(%d)
+
+--uppercase FALSE--
+Error: 2 - mkdir(): %s, %s(%d)
+
+--empty string DQ--
+Error: 2 - mkdir(): %s, %s(%d)
+
+--empty string SQ--
+Error: 2 - mkdir(): %s, %s(%d)
+
+--undefined var--
+Error: 2 - mkdir(): %s, %s(%d)
+
+--unset var--
+Error: 2 - mkdir(): %s, %s(%d)
+
+--single space--
+Error: 2 - mkdir(): %s, %s(%d)
+===DONE===
diff --git a/ext/standard/tests/file/mkdir_variation1.phpt b/ext/standard/tests/file/mkdir_variation1.phpt
new file mode 100644
index 0000000..b525403
--- /dev/null
+++ b/ext/standard/tests/file/mkdir_variation1.phpt
@@ -0,0 +1,121 @@
+--TEST--
+Test mkdir() function : usage variation: try invalid pathname
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+ die("skip Not valid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype : bool mkdir(string pathname [, int mode [, bool recursive [, resource context]]])
+ * Description: Create a directory
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing mkdir() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase false' =>false,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+
+ // other
+ 'single space' => ' ',
+);
+
+// loop through each element of the array for pathname
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ $res = mkdir($value);
+ if ($res == true) {
+ echo "directory created\n";
+ rmdir($value);
+ }
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing mkdir() : usage variation ***
+
+--uppercase NULL--
+Error: 2 - mkdir(): %s, %s(%d)
+
+--lowercase null--
+Error: 2 - mkdir(): %s, %s(%d)
+
+--lowercase false--
+Error: 2 - mkdir(): %s, %s(%d)
+
+--uppercase FALSE--
+Error: 2 - mkdir(): %s, %s(%d)
+
+--empty string DQ--
+Error: 2 - mkdir(): %s, %s(%d)
+
+--empty string SQ--
+Error: 2 - mkdir(): %s, %s(%d)
+
+--undefined var--
+Error: 2 - mkdir(): %s, %s(%d)
+
+--unset var--
+Error: 2 - mkdir(): %s, %s(%d)
+
+--single space--
+directory created
+===DONE===
diff --git a/ext/standard/tests/file/mkdir_variation2.phpt b/ext/standard/tests/file/mkdir_variation2.phpt
new file mode 100644
index 0000000..ab9a676
--- /dev/null
+++ b/ext/standard/tests/file/mkdir_variation2.phpt
@@ -0,0 +1,189 @@
+--TEST--
+Test mkdir() function : usage variation: different types for mode
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : bool mkdir(string pathname [, int mode [, bool recursive [, resource context]]])
+ * Description: Create a directory
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing mkdir() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$pathname = 'mkdirVar2.tmp';
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float -10.5' => -10.5,
+ 'float 12.3456789000e10' => 12.3456789000e10,
+ 'float -12.3456789000e10' => -12.3456789000e10,
+ 'float .5' => .5,
+
+ // array data
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // string data
+ 'string DQ' => "string",
+ 'string SQ' => 'string',
+ 'mixed case string' => "sTrInG",
+ 'heredoc' => $heredoc,
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for mode
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ $h = mkdir($pathname, $value);
+ if ($h === true) {
+ echo "Directory created\n";
+ rmdir($pathname);
+ }
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing mkdir() : usage variation ***
+
+--float 10.5--
+Directory created
+
+--float -10.5--
+Directory created
+
+--float 12.3456789000e10--
+Directory created
+
+--float -12.3456789000e10--
+Directory created
+
+--float .5--
+Directory created
+
+--empty array--
+Error: 2 - mkdir() expects parameter 2 to be long, array given, %s(%d)
+
+--int indexed array--
+Error: 2 - mkdir() expects parameter 2 to be long, array given, %s(%d)
+
+--associative array--
+Error: 2 - mkdir() expects parameter 2 to be long, array given, %s(%d)
+
+--nested arrays--
+Error: 2 - mkdir() expects parameter 2 to be long, array given, %s(%d)
+
+--uppercase NULL--
+Directory created
+
+--lowercase null--
+Directory created
+
+--lowercase true--
+Directory created
+
+--lowercase false--
+Directory created
+
+--uppercase TRUE--
+Directory created
+
+--uppercase FALSE--
+Directory created
+
+--empty string DQ--
+Error: 2 - mkdir() expects parameter 2 to be long, string given, %s(%d)
+
+--empty string SQ--
+Error: 2 - mkdir() expects parameter 2 to be long, string given, %s(%d)
+
+--string DQ--
+Error: 2 - mkdir() expects parameter 2 to be long, string given, %s(%d)
+
+--string SQ--
+Error: 2 - mkdir() expects parameter 2 to be long, string given, %s(%d)
+
+--mixed case string--
+Error: 2 - mkdir() expects parameter 2 to be long, string given, %s(%d)
+
+--heredoc--
+Error: 2 - mkdir() expects parameter 2 to be long, string given, %s(%d)
+
+--instance of classWithToString--
+Error: 2 - mkdir() expects parameter 2 to be long, object given, %s(%d)
+
+--instance of classWithoutToString--
+Error: 2 - mkdir() expects parameter 2 to be long, object given, %s(%d)
+
+--undefined var--
+Directory created
+
+--unset var--
+Directory created
+===DONE===
diff --git a/ext/standard/tests/file/mkdir_variation3.phpt b/ext/standard/tests/file/mkdir_variation3.phpt
new file mode 100644
index 0000000..7622e5f
--- /dev/null
+++ b/ext/standard/tests/file/mkdir_variation3.phpt
@@ -0,0 +1,208 @@
+--TEST--
+Test mkdir() function : usage variation: different types for recursive
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : bool mkdir(string pathname [, int mode [, bool recursive [, resource context]]])
+ * Description: Create a directory
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing mkdir() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$pathname = 'mkdirVar3.tmp';
+$mode = 0777;
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+ // int data
+ 'int 0' => 0,
+ 'int 1' => 1,
+ 'int 12345' => 12345,
+ 'int -12345' => -2345,
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float -10.5' => -10.5,
+ 'float 12.3456789000e10' => 12.3456789000e10,
+ 'float -12.3456789000e10' => -12.3456789000e10,
+ 'float .5' => .5,
+
+ // array data
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // string data
+ 'string DQ' => "string",
+ 'string SQ' => 'string',
+ 'mixed case string' => "sTrInG",
+ 'heredoc' => $heredoc,
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for recursive
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ $h = mkdir($pathname, $mode, $value);
+ if ($h === true) {
+ echo "Directory created\n";
+ rmdir($pathname);
+ }
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing mkdir() : usage variation ***
+
+--int 0--
+Directory created
+
+--int 1--
+Directory created
+
+--int 12345--
+Directory created
+
+--int -12345--
+Directory created
+
+--float 10.5--
+Directory created
+
+--float -10.5--
+Directory created
+
+--float 12.3456789000e10--
+Directory created
+
+--float -12.3456789000e10--
+Directory created
+
+--float .5--
+Directory created
+
+--empty array--
+Error: 2 - mkdir() expects parameter 3 to be boolean, array given, %s(%d)
+
+--int indexed array--
+Error: 2 - mkdir() expects parameter 3 to be boolean, array given, %s(%d)
+
+--associative array--
+Error: 2 - mkdir() expects parameter 3 to be boolean, array given, %s(%d)
+
+--nested arrays--
+Error: 2 - mkdir() expects parameter 3 to be boolean, array given, %s(%d)
+
+--uppercase NULL--
+Directory created
+
+--lowercase null--
+Directory created
+
+--lowercase true--
+Directory created
+
+--lowercase false--
+Directory created
+
+--uppercase TRUE--
+Directory created
+
+--uppercase FALSE--
+Directory created
+
+--empty string DQ--
+Directory created
+
+--empty string SQ--
+Directory created
+
+--string DQ--
+Directory created
+
+--string SQ--
+Directory created
+
+--mixed case string--
+Directory created
+
+--heredoc--
+Directory created
+
+--instance of classWithToString--
+Error: 2 - mkdir() expects parameter 3 to be boolean, object given, %s(%d)
+
+--instance of classWithoutToString--
+Error: 2 - mkdir() expects parameter 3 to be boolean, object given, %s(%d)
+
+--undefined var--
+Directory created
+
+--unset var--
+Directory created
+===DONE===
diff --git a/ext/standard/tests/file/mkdir_variation4.phpt b/ext/standard/tests/file/mkdir_variation4.phpt
new file mode 100644
index 0000000..b97d4eb
--- /dev/null
+++ b/ext/standard/tests/file/mkdir_variation4.phpt
@@ -0,0 +1,220 @@
+--TEST--
+Test mkdir() function : usage variation: different types for context
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : bool mkdir(string pathname [, int mode [, bool recursive [, resource context]]])
+ * Description: Create a directory
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing mkdir() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$pathname = 'mkdirVar4.tmp';
+$mode = 0777;
+$recursive = false;
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+$fileRes = fopen(__FILE__,'r');
+
+//array of values to iterate over
+$inputs = array(
+
+ // int data
+ 'int 0' => 0,
+ 'int 1' => 1,
+ 'int 12345' => 12345,
+ 'int -12345' => -2345,
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float -10.5' => -10.5,
+ 'float 12.3456789000e10' => 12.3456789000e10,
+ 'float -12.3456789000e10' => -12.3456789000e10,
+ 'float .5' => .5,
+
+ // array data
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // string data
+ 'string DQ' => "string",
+ 'string SQ' => 'string',
+ 'mixed case string' => "sTrInG",
+ 'heredoc' => $heredoc,
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+
+ // non stream context resource
+ 'file resource' => $fileRes,
+);
+
+// loop through each element of the array for context
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ $h = mkdir($pathname, $mode, $recursive, $value);
+ if ($h === true) {
+ echo "Directory created\n";
+ rmdir($pathname);
+ }
+};
+
+fclose($fileRes);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing mkdir() : usage variation ***
+
+--int 0--
+Error: 2 - mkdir() expects parameter 4 to be resource, integer given, %s(%d)
+
+--int 1--
+Error: 2 - mkdir() expects parameter 4 to be resource, integer given, %s(%d)
+
+--int 12345--
+Error: 2 - mkdir() expects parameter 4 to be resource, integer given, %s(%d)
+
+--int -12345--
+Error: 2 - mkdir() expects parameter 4 to be resource, integer given, %s(%d)
+
+--float 10.5--
+Error: 2 - mkdir() expects parameter 4 to be resource, double given, %s(%d)
+
+--float -10.5--
+Error: 2 - mkdir() expects parameter 4 to be resource, double given, %s(%d)
+
+--float 12.3456789000e10--
+Error: 2 - mkdir() expects parameter 4 to be resource, double given, %s(%d)
+
+--float -12.3456789000e10--
+Error: 2 - mkdir() expects parameter 4 to be resource, double given, %s(%d)
+
+--float .5--
+Error: 2 - mkdir() expects parameter 4 to be resource, double given, %s(%d)
+
+--empty array--
+Error: 2 - mkdir() expects parameter 4 to be resource, array given, %s(%d)
+
+--int indexed array--
+Error: 2 - mkdir() expects parameter 4 to be resource, array given, %s(%d)
+
+--associative array--
+Error: 2 - mkdir() expects parameter 4 to be resource, array given, %s(%d)
+
+--nested arrays--
+Error: 2 - mkdir() expects parameter 4 to be resource, array given, %s(%d)
+
+--uppercase NULL--
+Error: 2 - mkdir() expects parameter 4 to be resource, null given, %s(%d)
+
+--lowercase null--
+Error: 2 - mkdir() expects parameter 4 to be resource, null given, %s(%d)
+
+--lowercase true--
+Error: 2 - mkdir() expects parameter 4 to be resource, boolean given, %s(%d)
+
+--lowercase false--
+Error: 2 - mkdir() expects parameter 4 to be resource, boolean given, %s(%d)
+
+--uppercase TRUE--
+Error: 2 - mkdir() expects parameter 4 to be resource, boolean given, %s(%d)
+
+--uppercase FALSE--
+Error: 2 - mkdir() expects parameter 4 to be resource, boolean given, %s(%d)
+
+--empty string DQ--
+Error: 2 - mkdir() expects parameter 4 to be resource, string given, %s(%d)
+
+--empty string SQ--
+Error: 2 - mkdir() expects parameter 4 to be resource, string given, %s(%d)
+
+--string DQ--
+Error: 2 - mkdir() expects parameter 4 to be resource, string given, %s(%d)
+
+--string SQ--
+Error: 2 - mkdir() expects parameter 4 to be resource, string given, %s(%d)
+
+--mixed case string--
+Error: 2 - mkdir() expects parameter 4 to be resource, string given, %s(%d)
+
+--heredoc--
+Error: 2 - mkdir() expects parameter 4 to be resource, string given, %s(%d)
+
+--instance of classWithToString--
+Error: 2 - mkdir() expects parameter 4 to be resource, object given, %s(%d)
+
+--instance of classWithoutToString--
+Error: 2 - mkdir() expects parameter 4 to be resource, object given, %s(%d)
+
+--undefined var--
+Error: 2 - mkdir() expects parameter 4 to be resource, null given, %s(%d)
+
+--unset var--
+Error: 2 - mkdir() expects parameter 4 to be resource, null given, %s(%d)
+
+--file resource--
+Error: 2 - mkdir(): supplied resource is not a valid Stream-Context resource, %s(%d)
+Directory created
+===DONE=== \ No newline at end of file
diff --git a/ext/standard/tests/file/mkdir_variation5-win32.phpt b/ext/standard/tests/file/mkdir_variation5-win32.phpt
new file mode 100644
index 0000000..c7ebd51
--- /dev/null
+++ b/ext/standard/tests/file/mkdir_variation5-win32.phpt
@@ -0,0 +1,105 @@
+--TEST--
+Test mkdir() function : variation: various valid and invalid paths
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+ die("skip Only valid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype : bool mkdir(string pathname [, int mode [, bool recursive [, resource context]]])
+ * Description: Create a directory
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing mkdir() : variation ***\n";
+
+$workDir = "mkdirVar5.tmp";
+$subDir = "aSubDir";
+mkdir($workDir);
+$cwd = getcwd();
+
+$unixifiedDir = '/'.substr(str_replace('\\','/',$cwd).'/'.$workDir.'/'.$subDir, 3);
+
+$dirs = array(
+ // relative
+ $workDir.'\\'.$subDir,
+ '.\\'.$workDir.'\\'.$subDir,
+ $workDir.'\\..\\'.$workDir.'\\'.$subDir,
+
+ // relative bad path
+ $workDir.'\\..\\BADDIR\\'.$subDir,
+ 'BADDIR\\'.$subDir,
+
+ //absolute
+ $cwd.'\\'.$workDir.'\\'.$subDir,
+ $cwd.'\\.\\'.$workDir.'\\'.$subDir,
+ $cwd.'\\'.$workDir.'\\..\\'.$workDir.'\\'.$subDir,
+
+ //absolute bad path
+ $cwd.'\\BADDIR\\'.$subDir,
+
+ //trailing separators
+ $workDir.'\\'.$subDir.'\\',
+ $cwd.'\\'.$workDir.'\\'.$subDir.'\\',
+
+ // multiple separators
+ $workDir.'\\\\'.$subDir,
+ $cwd.'\\\\'.$workDir.'\\\\'.$subDir,
+
+ // Unixified Dir
+ $unixifiedDir,
+
+ );
+
+
+foreach($dirs as $dir) {
+ echo "-- creating $dir --\n";
+ $res = mkdir($dir);
+ if ($res === true) {
+ echo "Directory created\n";
+ rmdir($workDir.'\\'.$subDir);
+ }
+}
+
+rmdir($workDir);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing mkdir() : variation ***
+-- creating mkdirVar5.tmp\aSubDir --
+Directory created
+-- creating .\mkdirVar5.tmp\aSubDir --
+Directory created
+-- creating mkdirVar5.tmp\..\mkdirVar5.tmp\aSubDir --
+Directory created
+-- creating mkdirVar5.tmp\..\BADDIR\aSubDir --
+
+Warning: mkdir(): No such file or directory in %s on line %d
+-- creating BADDIR\aSubDir --
+
+Warning: mkdir(): No such file or directory in %s on line %d
+-- creating %s\mkdirVar5.tmp\aSubDir --
+Directory created
+-- creating %s\.\mkdirVar5.tmp\aSubDir --
+Directory created
+-- creating %s\mkdirVar5.tmp\..\mkdirVar5.tmp\aSubDir --
+Directory created
+-- creating %s\BADDIR\aSubDir --
+
+Warning: mkdir(): No such file or directory in %s on line %d
+-- creating mkdirVar5.tmp\aSubDir\ --
+Directory created
+-- creating %s\mkdirVar5.tmp\aSubDir\ --
+Directory created
+-- creating mkdirVar5.tmp\\aSubDir --
+Directory created
+-- creating %s\\mkdirVar5.tmp\\aSubDir --
+Directory created
+-- creating /%s/mkdirVar5.tmp/aSubDir --
+Directory created
+===DONE===
diff --git a/ext/standard/tests/file/mkdir_variation5.phpt b/ext/standard/tests/file/mkdir_variation5.phpt
new file mode 100644
index 0000000..8a02fe1
--- /dev/null
+++ b/ext/standard/tests/file/mkdir_variation5.phpt
@@ -0,0 +1,98 @@
+--TEST--
+Test mkdir() function : variation: various valid and invalid paths
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+ die("skip Not valid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype : bool mkdir(string pathname [, int mode [, bool recursive [, resource context]]])
+ * Description: Create a directory
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing mkdir() : variation ***\n";
+
+$workDir = "mkdirVar5.tmp";
+$subDir = "aSubDir";
+mkdir($workDir);
+$cwd = getcwd();
+
+$dirs = array(
+ // relative
+ $workDir.'/'.$subDir,
+ './'.$workDir.'/'.$subDir,
+ $workDir.'/../'.$workDir.'/'.$subDir,
+
+ // relative bad path
+ $workDir.'/../BADDIR/'.$subDir,
+ 'BADDIR/'.$subDir,
+
+ //absolute
+ $cwd.'/'.$workDir.'/'.$subDir,
+ $cwd.'/./'.$workDir.'/'.$subDir,
+ $cwd.'/'.$workDir.'/../'.$workDir.'/'.$subDir,
+
+ //absolute bad path
+ $cwd.'/BADDIR/'.$subDir,
+
+ //trailing separators
+ $workDir.'/'.$subDir.'/',
+ $cwd.'/'.$workDir.'/'.$subDir.'/',
+
+ // multiple separators
+ $workDir.'//'.$subDir,
+ $cwd.'//'.$workDir.'//'.$subDir,
+
+ );
+
+
+foreach($dirs as $dir) {
+ echo "-- creating $dir --\n";
+ $res = mkdir($dir);
+ if ($res === true) {
+ echo "Directory created\n";
+ rmdir($dir);
+ }
+}
+
+rmdir($workDir);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing mkdir() : variation ***
+-- creating mkdirVar5.tmp/aSubDir --
+Directory created
+-- creating ./mkdirVar5.tmp/aSubDir --
+Directory created
+-- creating mkdirVar5.tmp/../mkdirVar5.tmp/aSubDir --
+Directory created
+-- creating mkdirVar5.tmp/../BADDIR/aSubDir --
+
+Warning: mkdir(): No such file or directory in %s on line %d
+-- creating BADDIR/aSubDir --
+
+Warning: mkdir(): No such file or directory in %s on line %d
+-- creating %s/mkdirVar5.tmp/aSubDir --
+Directory created
+-- creating %s/./mkdirVar5.tmp/aSubDir --
+Directory created
+-- creating %s/mkdirVar5.tmp/../mkdirVar5.tmp/aSubDir --
+Directory created
+-- creating %s/BADDIR/aSubDir --
+
+Warning: mkdir(): No such file or directory in %s on line %d
+-- creating mkdirVar5.tmp/aSubDir/ --
+Directory created
+-- creating %s/mkdirVar5.tmp/aSubDir/ --
+Directory created
+-- creating mkdirVar5.tmp//aSubDir --
+Directory created
+-- creating %s//mkdirVar5.tmp//aSubDir --
+Directory created
+===DONE===
diff --git a/ext/standard/tests/file/move_uploaded_file_basic.phpt b/ext/standard/tests/file/move_uploaded_file_basic.phpt
new file mode 100644
index 0000000..00bbcf6
--- /dev/null
+++ b/ext/standard/tests/file/move_uploaded_file_basic.phpt
@@ -0,0 +1,76 @@
+--TEST--
+move_uploaded_file() function
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--POST_RAW--
+Content-type: multipart/form-data, boundary=AaB03x
+
+--AaB03x
+content-disposition: form-data; name="field1"
+
+Joe Blow
+--AaB03x
+content-disposition: form-data; name="file1"; filename="file1.txt"
+Content-Type: text/plain
+
+abcdef123456789xxxDDDxxxDDDxxxDDD
+--AaB03x
+content-disposition: form-data; name="file2"; filename="file2.txt"
+Content-Type: text/plain
+
+abcdef123456789
+--AaB03x--
+--FILE--
+<?php
+
+echo "Valid move\n";
+$destination1 = __FILE__ . ".tmp";
+
+var_dump(move_uploaded_file($_FILES['file1']['tmp_name'], $destination1));
+$file_contents = file_get_contents($destination1);
+$contents_matches = ($file_contents == b"abcdef123456789xxxDDDxxxDDDxxxDDD");
+var_dump($contents_matches);
+unlink($destination1);
+echo "\n";
+
+echo "Original name of uploaded file\n";
+$destination2 = __FILE__ . ".tmp2";
+var_dump(move_uploaded_file($_FILES['file1']['name'], $destination2));
+
+echo "Non-uploaded source file\n";
+$source = __FILE__;
+$destination3 = __FILE__ . ".tmp3";
+var_dump(move_uploaded_file($source, $destination3));
+
+echo "Valid move to existing file\n";
+$destination4 = __FILE__ . ".tmp4";
+$fd = fopen($destination4, "w");
+fclose($fd);
+var_dump(move_uploaded_file($_FILES['file2']['tmp_name'], $destination4));
+unlink($destination4);
+
+echo "Wrong parameters\n";
+var_dump(move_uploaded_file());
+var_dump(move_uploaded_file(1, 2, 3));
+
+
+?>
+--EXPECTF--
+Valid move
+bool(true)
+bool(true)
+
+Original name of uploaded file
+bool(false)
+Non-uploaded source file
+bool(false)
+Valid move to existing file
+bool(true)
+Wrong parameters
+
+Warning: move_uploaded_file() expects exactly 2 parameters, 0 given in %s on line %d
+NULL
+
+Warning: move_uploaded_file() expects exactly 2 parameters, 3 given in %s on line %d
+NULL
+
diff --git a/ext/standard/tests/file/parse_ini_file.phpt b/ext/standard/tests/file/parse_ini_file.phpt
new file mode 100644
index 0000000..dab07e5
--- /dev/null
+++ b/ext/standard/tests/file/parse_ini_file.phpt
@@ -0,0 +1,489 @@
+--TEST--
+Test parse_ini_file() function
+--FILE--
+<?php
+/* Prototype: array parse_ini_file(string $filename [,bool $process_sections]);
+ Description: parse_ini_file() loads in the ini file specified in filename,
+ and returns the settings in it in an associative array.
+*/
+
+$file_path = dirname(__FILE__);
+
+$parse_string = <<<EOD
+; Comment starts with semi-colon(;)
+; Section starts with [<section name>]
+
+; start of ini file
+
+[Constans]
+one = 1
+five = 5
+animal = BIRD
+Language = PHP
+PHP_CONSTANT = 1.2345678
+10 = Ten
+HELLO = HELLO
+
+[date]
+date =
+time =
+
+[paths]
+path = /usr/local/bin
+URL = http://www.php.net
+
+[Decimal]
+Decimal_value1 = 100
+Decimal_value2 = -100
+Decimal_value3 = -2147483647
+Decimal_value4 = 2147483647
+Decimal_value5 = -2147483648
+Decimal_value6 = 2147483648
+
+[Octal]
+Octal_value = 0100
+
+[Hex]
+Hex_value1 = 0x101
+Hex_Value2 = 0x102
+Hex_Value2 = 0x103
+
+[Non-alphanumerics_as_values]
+;Non-alpha numeric chars without quotes
+Non_alpha1 = ;
+Non_alpha2 = +
+Non_alpha3 = *
+Non_alpha4 = %
+Non_alpha5 = <>
+Non_alpha6 = @
+Non_alpha7 = #
+Non_alpha8 = ^
+Non_alpha9 = -
+Non_alpha10 = :
+Non_alpha11 = ?
+Non_alpha12 = /
+Non_alpha13 = \
+;These chars have a special meaning when used in the value,
+; hence parser throws an error
+;Non_alpha14 = &
+;Non_alpha15 = {}
+;Non_alpha16 = |
+;Non_alpha17 = ~
+;Non_alpha18 = !
+;Non_alpha19 = $
+;Non_alpha20 = ()
+
+Non_alpha1_quotes = ";"
+Non_alpha2_quotes = "+"
+Non_alpha3_quotes = "*"
+Non_alpha4_quotes = "%"
+Non_alpha5_quotes = "<>"
+Non_alpha6_quotes = "@"
+Non_alpha7_quotes = "#"
+Non_alpha8_quotes = "^"
+Non_alpha9_quotes = "-"
+Non_alpha10_quotes = "="
+Non_alpha11_quotes = ":"
+Non_alpha12_quotes = "?"
+Non_alpha13_quotes = "/"
+;Non_alpha14_quotes = "\"
+Non_alpha15_quotes = "&"
+Non_alpha16_quotes = "{}"
+Non_alpha17_quotes = "|"
+Non_alpha18_quotes = "~"
+Non_alpha19_quotes = "!"
+;Non_alpha20_quotes = "$"
+Non_alpha21_quotes = "()"
+
+[Non-alpha numerics in strings]
+;expected error, as the non-alphanumeric chars not enclosed in double quotes("")
+Non_alpha_string1 = Hello@world
+;Non_alpha_string2 = Hello!world
+;Non_alpha_string3 = Hello#world
+;Non_alpha_string4 = Hello%world
+;Non_alpha_string5 = Hello&world
+;Non_alpha_string6 = Hello*world
+;Non_alpha_string7 = Hello+world
+;Non_alpha_string8 = Hello-world
+;Non_alpha_string9 = Hello'world
+;Non_alpha_string10 = Hello:world
+;Non_alpha_string11 = Hello;world
+;Non_alpha_string12 = Hello<world
+;Non_alpha_string13 = Hello>world
+;Non_alpha_string14 = Hello>world
+;Non_alpha_string15 = Hello?world
+;Non_alpha_string16 = Hello\world
+;Non_alpha_string17 = Hello^world
+;Non_alpha_string18 = Hello_world
+;Non_alpha_string19 = Hello|world
+;Non_alpha_string20 = Hello~world
+;Non_alpha_string21 = Hello`world
+;Non_alpha_string22 = Hello(world)
+
+[Non-alpha numerics in strings -with quotes]
+Non_alpha_string1_quotes = "Hello@world"
+Non_alpha_string2_quotes = "Hello!world"
+Non_alpha_string3_quotes = "Hello#world"
+Non_alpha_string4_quotes = "Hello&world"
+Non_alpha_string5_quotes = "Hello*world"
+Non_alpha_string6_quotes = "Hello+world"
+Non_alpha_string7_quotes = "Hello-world"
+Non_alpha_string8_quotes = "Hello'world"
+Non_alpha_string9_quotes = "Hello:world"
+Non_alpha_string10_quotes = "Hello;world"
+Non_alpha_string11_quotes = "Hello<world"
+Non_alpha_string12_quotes = "Hello>world"
+Non_alpha_string13_quotes = "Hello>world"
+Non_alpha_string14_quotes = "Hello?world"
+Non_alpha_string15_quotes = "Hello\world"
+Non_alpha_string16_quotes = "Hello^world"
+Non_alpha_string17_quotes = "Hello_world"
+Non_alpha_string18_quotes = "Hello|world"
+Non_alpha_string19_quotes = "Hello~world"
+Non_alpha_string20_quotes = "Hello`world"
+Non_alpha_string21_quotes = "Hello(world)"
+
+[Newlines_in_Values]
+String1 = "Hello, world\nGood Morning"
+String2 = "\nHello, world
+ Good Morning\n"
+String3 = 'Hello, world\tGood Morning'
+String4 = "\n"
+String5 = "\n\n"
+String6 = Hello, world\tGood Morning
+
+[ReservedKeys_as_Values]
+Key1 = YES
+Key2 = Yes
+Key3 = yEs
+Key4 = NO
+Key5 = No
+Key6 = nO
+Key7 = TRUE
+Key8 = True
+Key9 = tRUE
+Key10 = true
+Key11 = FALSE
+Key12 = False
+Key13 = false
+Key14 = fAlSE
+Key15 = NULL
+Key16 = Null
+Key17 = nuLL
+Key18 = null
+
+[ReservedKeys_as_Keys]
+; Expected:error, reserved key words must not be used as keys for ini file
+;YES = 1
+;Yes = 2
+;yEs = 1.2
+;YES = YES
+;NO = ""
+;No = "string"
+;nO = "\0"
+;TRUE = 1.1
+;True = 1
+;tRUE = 5
+;true = TRUE
+;FALSE = FALSE
+;False = ""
+;false = "hello"
+;fAlSE = ""
+;NULL = ""
+;Null = 0
+;nuLL = "\0"
+;null = NULL
+
+; end of ini file
+EOD;
+/* creating parse.ini file */
+$file_handle = fopen($file_path."/parse.ini", "w");
+fwrite($file_handle, $parse_string);
+fclose($file_handle);
+
+echo "*** Test parse_ini_file() function: with various keys and values given in parse.ini file ***\n";
+echo "-- ini file without process_sections optional arg --\n";
+define('BIRD', 'Humming bird');
+$ini_array = parse_ini_file($file_path."/parse.ini");
+print_r($ini_array);
+
+echo "\n-- ini file with process_sections as TRUE --\n";
+$ini_array = parse_ini_file($file_path."/parse.ini", TRUE);
+print_r($ini_array);
+
+echo "*** Done **\n";
+?>
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/parse.ini");
+?>
+--EXPECTF--
+*** Test parse_ini_file() function: with various keys and values given in parse.ini file ***
+-- ini file without process_sections optional arg --
+Array
+(
+ [one] => 1
+ [five] => 5
+ [animal] => Humming bird
+ [Language] => PHP
+ [PHP_CONSTANT] => 1.2345678
+ [10] => Ten
+ [HELLO] => HELLO
+ [date] =>
+ [time] =>
+ [path] => /usr/local/bin
+ [URL] => http://www.php.net
+ [Decimal_value1] => 100
+ [Decimal_value2] => -100
+ [Decimal_value3] => -2147483647
+ [Decimal_value4] => 2147483647
+ [Decimal_value5] => -2147483648
+ [Decimal_value6] => 2147483648
+ [Octal_value] => 0100
+ [Hex_value1] => 0x101
+ [Hex_Value2] => 0x103
+ [Non_alpha1] =>
+ [Non_alpha2] => +
+ [Non_alpha3] => *
+ [Non_alpha4] => %
+ [Non_alpha5] => <>
+ [Non_alpha6] => @
+ [Non_alpha7] => #
+ [Non_alpha8] => ^
+ [Non_alpha9] => -
+ [Non_alpha10] => :
+ [Non_alpha11] => ?
+ [Non_alpha12] => /
+ [Non_alpha13] => \
+ [Non_alpha1_quotes] => ;
+ [Non_alpha2_quotes] => +
+ [Non_alpha3_quotes] => *
+ [Non_alpha4_quotes] => %
+ [Non_alpha5_quotes] => <>
+ [Non_alpha6_quotes] => @
+ [Non_alpha7_quotes] => #
+ [Non_alpha8_quotes] => ^
+ [Non_alpha9_quotes] => -
+ [Non_alpha10_quotes] => =
+ [Non_alpha11_quotes] => :
+ [Non_alpha12_quotes] => ?
+ [Non_alpha13_quotes] => /
+ [Non_alpha15_quotes] => &
+ [Non_alpha16_quotes] => {}
+ [Non_alpha17_quotes] => |
+ [Non_alpha18_quotes] => ~
+ [Non_alpha19_quotes] => !
+ [Non_alpha21_quotes] => ()
+ [Non_alpha_string1] => Hello@world
+ [Non_alpha_string1_quotes] => Hello@world
+ [Non_alpha_string2_quotes] => Hello!world
+ [Non_alpha_string3_quotes] => Hello#world
+ [Non_alpha_string4_quotes] => Hello&world
+ [Non_alpha_string5_quotes] => Hello*world
+ [Non_alpha_string6_quotes] => Hello+world
+ [Non_alpha_string7_quotes] => Hello-world
+ [Non_alpha_string8_quotes] => Hello'world
+ [Non_alpha_string9_quotes] => Hello:world
+ [Non_alpha_string10_quotes] => Hello;world
+ [Non_alpha_string11_quotes] => Hello<world
+ [Non_alpha_string12_quotes] => Hello>world
+ [Non_alpha_string13_quotes] => Hello>world
+ [Non_alpha_string14_quotes] => Hello?world
+ [Non_alpha_string15_quotes] => Hello\world
+ [Non_alpha_string16_quotes] => Hello^world
+ [Non_alpha_string17_quotes] => Hello_world
+ [Non_alpha_string18_quotes] => Hello|world
+ [Non_alpha_string19_quotes] => Hello~world
+ [Non_alpha_string20_quotes] => Hello`world
+ [Non_alpha_string21_quotes] => Hello(world)
+ [String1] => Hello, world
+Good Morning
+ [String2] =>
+Hello, world
+ Good Morning
+
+ [String3] => Hello, world Good Morning
+ [String4] =>
+
+ [String5] =>
+
+
+ [String6] => Hello, world Good Morning
+ [Key1] => 1
+ [Key2] => 1
+ [Key3] => 1
+ [Key4] =>
+ [Key5] =>
+ [Key6] =>
+ [Key7] => 1
+ [Key8] => 1
+ [Key9] => 1
+ [Key10] => 1
+ [Key11] =>
+ [Key12] =>
+ [Key13] =>
+ [Key14] =>
+ [Key15] =>
+ [Key16] =>
+ [Key17] =>
+ [Key18] =>
+)
+
+-- ini file with process_sections as TRUE --
+Array
+(
+ [Constans] => Array
+ (
+ [one] => 1
+ [five] => 5
+ [animal] => Humming bird
+ [Language] => PHP
+ [PHP_CONSTANT] => 1.2345678
+ [10] => Ten
+ [HELLO] => HELLO
+ )
+
+ [date] => Array
+ (
+ [date] =>
+ [time] =>
+ )
+
+ [paths] => Array
+ (
+ [path] => /usr/local/bin
+ [URL] => http://www.php.net
+ )
+
+ [Decimal] => Array
+ (
+ [Decimal_value1] => 100
+ [Decimal_value2] => -100
+ [Decimal_value3] => -2147483647
+ [Decimal_value4] => 2147483647
+ [Decimal_value5] => -2147483648
+ [Decimal_value6] => 2147483648
+ )
+
+ [Octal] => Array
+ (
+ [Octal_value] => 0100
+ )
+
+ [Hex] => Array
+ (
+ [Hex_value1] => 0x101
+ [Hex_Value2] => 0x103
+ )
+
+ [Non-alphanumerics_as_values] => Array
+ (
+ [Non_alpha1] =>
+ [Non_alpha2] => +
+ [Non_alpha3] => *
+ [Non_alpha4] => %
+ [Non_alpha5] => <>
+ [Non_alpha6] => @
+ [Non_alpha7] => #
+ [Non_alpha8] => ^
+ [Non_alpha9] => -
+ [Non_alpha10] => :
+ [Non_alpha11] => ?
+ [Non_alpha12] => /
+ [Non_alpha13] => \
+ [Non_alpha1_quotes] => ;
+ [Non_alpha2_quotes] => +
+ [Non_alpha3_quotes] => *
+ [Non_alpha4_quotes] => %
+ [Non_alpha5_quotes] => <>
+ [Non_alpha6_quotes] => @
+ [Non_alpha7_quotes] => #
+ [Non_alpha8_quotes] => ^
+ [Non_alpha9_quotes] => -
+ [Non_alpha10_quotes] => =
+ [Non_alpha11_quotes] => :
+ [Non_alpha12_quotes] => ?
+ [Non_alpha13_quotes] => /
+ [Non_alpha15_quotes] => &
+ [Non_alpha16_quotes] => {}
+ [Non_alpha17_quotes] => |
+ [Non_alpha18_quotes] => ~
+ [Non_alpha19_quotes] => !
+ [Non_alpha21_quotes] => ()
+ )
+
+ [Non-alpha numerics in strings] => Array
+ (
+ [Non_alpha_string1] => Hello@world
+ )
+
+ [Non-alpha numerics in strings -with quotes] => Array
+ (
+ [Non_alpha_string1_quotes] => Hello@world
+ [Non_alpha_string2_quotes] => Hello!world
+ [Non_alpha_string3_quotes] => Hello#world
+ [Non_alpha_string4_quotes] => Hello&world
+ [Non_alpha_string5_quotes] => Hello*world
+ [Non_alpha_string6_quotes] => Hello+world
+ [Non_alpha_string7_quotes] => Hello-world
+ [Non_alpha_string8_quotes] => Hello'world
+ [Non_alpha_string9_quotes] => Hello:world
+ [Non_alpha_string10_quotes] => Hello;world
+ [Non_alpha_string11_quotes] => Hello<world
+ [Non_alpha_string12_quotes] => Hello>world
+ [Non_alpha_string13_quotes] => Hello>world
+ [Non_alpha_string14_quotes] => Hello?world
+ [Non_alpha_string15_quotes] => Hello\world
+ [Non_alpha_string16_quotes] => Hello^world
+ [Non_alpha_string17_quotes] => Hello_world
+ [Non_alpha_string18_quotes] => Hello|world
+ [Non_alpha_string19_quotes] => Hello~world
+ [Non_alpha_string20_quotes] => Hello`world
+ [Non_alpha_string21_quotes] => Hello(world)
+ )
+
+ [Newlines_in_Values] => Array
+ (
+ [String1] => Hello, world
+Good Morning
+ [String2] =>
+Hello, world
+ Good Morning
+
+ [String3] => Hello, world Good Morning
+ [String4] =>
+
+ [String5] =>
+
+
+ [String6] => Hello, world Good Morning
+ )
+
+ [ReservedKeys_as_Values] => Array
+ (
+ [Key1] => 1
+ [Key2] => 1
+ [Key3] => 1
+ [Key4] =>
+ [Key5] =>
+ [Key6] =>
+ [Key7] => 1
+ [Key8] => 1
+ [Key9] => 1
+ [Key10] => 1
+ [Key11] =>
+ [Key12] =>
+ [Key13] =>
+ [Key14] =>
+ [Key15] =>
+ [Key16] =>
+ [Key17] =>
+ [Key18] =>
+ )
+
+ [ReservedKeys_as_Keys] => Array
+ (
+ )
+
+)
+*** Done **
diff --git a/ext/standard/tests/file/parse_ini_file_error.phpt b/ext/standard/tests/file/parse_ini_file_error.phpt
new file mode 100644
index 0000000..14990b2
--- /dev/null
+++ b/ext/standard/tests/file/parse_ini_file_error.phpt
@@ -0,0 +1,47 @@
+--TEST--
+Test parse_ini_file() function : error conditions
+--FILE--
+<?php
+/* Prototype : proto array parse_ini_file(string filename [, bool process_sections])
+ * Description: Parse configuration file
+ * Source code: ext/standard/basic_functions.c
+ * Alias to functions:
+ */
+
+echo "*** Testing parse_ini_file() : error conditions ***\n";
+
+// Zero arguments
+echo "\n-- Testing parse_ini_file() function with Zero arguments --\n";
+var_dump( parse_ini_file() );
+
+//Test parse_ini_file with one more than the expected number of arguments
+echo "\n-- Testing parse_ini_file() function with more than expected no. of arguments --\n";
+$filename = 'string_val';
+$process_sections = true;
+$extra_arg = 10;
+var_dump( parse_ini_file($filename, $process_sections, $extra_arg) );
+
+echo "\n-- Testing parse_ini_file() function with a non-existent file --\n";
+$filename = __FILE__ . 'invalidfilename';
+var_dump( parse_ini_file($filename, $process_sections) );
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing parse_ini_file() : error conditions ***
+
+-- Testing parse_ini_file() function with Zero arguments --
+
+Warning: parse_ini_file() expects at least 1 parameter, 0 given in %s on line %d
+bool(false)
+
+-- Testing parse_ini_file() function with more than expected no. of arguments --
+
+Warning: parse_ini_file(%s): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+-- Testing parse_ini_file() function with a non-existent file --
+
+Warning: parse_ini_file(%s): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+Done
diff --git a/ext/standard/tests/file/parse_ini_file_variation1.phpt b/ext/standard/tests/file/parse_ini_file_variation1.phpt
new file mode 100644
index 0000000..a24bc1c
--- /dev/null
+++ b/ext/standard/tests/file/parse_ini_file_variation1.phpt
@@ -0,0 +1,68 @@
+--TEST--
+Test parse_ini_file() function : variation: identical properties and values are not referenced.
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : array parse_ini_file(string filename [, bool process_sections])
+ * Description: Parse configuration file
+ * Source code: ext/standard/basic_functions.c
+ * Alias to functions:
+ */
+
+echo "*** Testing parse_ini_file() : variation ***\n";
+$output_file = __FILE__.".ini";
+$iniFile = <<<FILE
+[section1]
+value1=original
+value2=original
+[section2]
+value1=original
+value2=different
+FILE;
+
+file_put_contents($output_file, $iniFile);
+
+$a = parse_ini_file($output_file, true);
+var_dump($a);
+$a['section1']['value1'] = 'changed';
+var_dump($a);
+
+unlink($output_file);
+?>
+===DONE===
+--EXPECT--
+*** Testing parse_ini_file() : variation ***
+array(2) {
+ ["section1"]=>
+ array(2) {
+ ["value1"]=>
+ string(8) "original"
+ ["value2"]=>
+ string(8) "original"
+ }
+ ["section2"]=>
+ array(2) {
+ ["value1"]=>
+ string(8) "original"
+ ["value2"]=>
+ string(9) "different"
+ }
+}
+array(2) {
+ ["section1"]=>
+ array(2) {
+ ["value1"]=>
+ string(7) "changed"
+ ["value2"]=>
+ string(8) "original"
+ }
+ ["section2"]=>
+ array(2) {
+ ["value1"]=>
+ string(8) "original"
+ ["value2"]=>
+ string(9) "different"
+ }
+}
+===DONE===
diff --git a/ext/standard/tests/file/parse_ini_file_variation2.phpt b/ext/standard/tests/file/parse_ini_file_variation2.phpt
new file mode 100644
index 0000000..20ad6bb
--- /dev/null
+++ b/ext/standard/tests/file/parse_ini_file_variation2.phpt
@@ -0,0 +1,111 @@
+--TEST--
+Test parse_ini_file() function : variation: handling different boolean values
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : array parse_ini_file(string filename [, bool process_sections])
+ * Description: Parse configuration file
+ * Source code: ext/standard/basic_functions.c
+ * Alias to functions:
+ */
+
+echo "*** Testing parse_ini_file() : variation ***\n";
+$output_file = __FILE__.".ini";
+$iniFile = <<<FILE
+[section1]
+value1=on
+value2=off
+[section2]
+value1=true
+value2=false
+[section3]
+value1=yes
+value2=no
+[section4]
+value1=null
+value2=
+
+[section5]
+value1="on"
+value2="off"
+[section6]
+value1="true"
+value2="false"
+[section7]
+value1="yes"
+value2="no"
+[section8]
+value1="null"
+value2=""
+
+FILE;
+
+file_put_contents($output_file, $iniFile);
+
+$a = parse_ini_file($output_file, true);
+var_dump($a);
+unlink($output_file);
+?>
+===DONE===
+--EXPECT--
+*** Testing parse_ini_file() : variation ***
+array(8) {
+ ["section1"]=>
+ array(2) {
+ ["value1"]=>
+ string(1) "1"
+ ["value2"]=>
+ string(0) ""
+ }
+ ["section2"]=>
+ array(2) {
+ ["value1"]=>
+ string(1) "1"
+ ["value2"]=>
+ string(0) ""
+ }
+ ["section3"]=>
+ array(2) {
+ ["value1"]=>
+ string(1) "1"
+ ["value2"]=>
+ string(0) ""
+ }
+ ["section4"]=>
+ array(2) {
+ ["value1"]=>
+ string(0) ""
+ ["value2"]=>
+ string(0) ""
+ }
+ ["section5"]=>
+ array(2) {
+ ["value1"]=>
+ string(2) "on"
+ ["value2"]=>
+ string(3) "off"
+ }
+ ["section6"]=>
+ array(2) {
+ ["value1"]=>
+ string(4) "true"
+ ["value2"]=>
+ string(5) "false"
+ }
+ ["section7"]=>
+ array(2) {
+ ["value1"]=>
+ string(3) "yes"
+ ["value2"]=>
+ string(2) "no"
+ }
+ ["section8"]=>
+ array(2) {
+ ["value1"]=>
+ string(4) "null"
+ ["value2"]=>
+ string(0) ""
+ }
+}
+===DONE===
diff --git a/ext/standard/tests/file/parse_ini_file_variation3.phpt b/ext/standard/tests/file/parse_ini_file_variation3.phpt
new file mode 100644
index 0000000..43b0274
--- /dev/null
+++ b/ext/standard/tests/file/parse_ini_file_variation3.phpt
@@ -0,0 +1,104 @@
+--TEST--
+Test parse_ini_file() function : variation: include path searching
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : array parse_ini_file(string filename [, bool process_sections])
+ * Description: Parse configuration file
+ * Source code: ext/standard/basic_functions.c
+ * Alias to functions:
+ */
+
+echo "*** Testing parse_ini_file() : variation ***\n";
+$pwd = getcwd();
+$f = "parse_ini_file_variation3";
+$dir1 = $pwd."/".$f.".dir1";
+$dir2 = $pwd."/".$f.".dir2";
+$dir3 = $pwd."/".$f.".dir3";
+$iniFile = "php.ini";
+
+$newdirs = array($dir1, $dir2, $dir3);
+$pathSep = ":";
+$newIncludePath = "";
+if(substr(PHP_OS, 0, 3) == 'WIN' ) {
+ $pathSep = ";";
+}
+foreach($newdirs as $newdir) {
+ mkdir($newdir);
+ $newIncludePath .= $newdir.$pathSep;
+}
+
+set_include_path($newIncludePath);
+$path = get_include_path();
+echo "New include path is : " . $path . "\n";
+
+$output_file = $dir2."/".$iniFile;
+$iniContent = <<<FILE
+error_reporting = E_ALL
+display_errors = On
+display_startup_errors = Off
+log_errors = Off
+log_errors_max_len = 1024
+ignore_repeated_errors = Off
+ignore_repeated_source = Off
+report_memleaks = On
+track_errors = Off
+docref_root = "/phpmanual/"
+docref_ext = .html
+
+FILE;
+
+file_put_contents($output_file, $iniContent);
+var_dump(parse_ini_file($iniFile));
+
+?>
+===Done===
+--CLEAN--
+<?php
+
+$pwd = getcwd();
+$f = "parse_ini_file_variation3";
+$iniFile = "php.ini";
+
+$dir1 = $pwd."/".$f.".dir1";
+$dir2 = $pwd."/".$f.".dir2";
+$dir3 = $pwd."/".$f.".dir3";
+$newdirs = array($dir1, $dir2, $dir3);
+$output_file = $dir2."/".$iniFile;
+
+// Tidy up after test
+unlink($output_file);
+foreach($newdirs as $newdir) {
+ rmdir($newdir);
+}
+
+?>
+--EXPECTF--
+*** Testing parse_ini_file() : variation ***
+New include path is : %sparse_ini_file_variation3.dir1%sparse_ini_file_variation3.dir2%sparse_ini_file_variation3.dir3%S
+array(11) {
+ ["error_reporting"]=>
+ string(5) "32767"
+ ["display_errors"]=>
+ string(1) "1"
+ ["display_startup_errors"]=>
+ string(0) ""
+ ["log_errors"]=>
+ string(0) ""
+ ["log_errors_max_len"]=>
+ string(4) "1024"
+ ["ignore_repeated_errors"]=>
+ string(0) ""
+ ["ignore_repeated_source"]=>
+ string(0) ""
+ ["report_memleaks"]=>
+ string(1) "1"
+ ["track_errors"]=>
+ string(0) ""
+ ["docref_root"]=>
+ string(11) "/phpmanual/"
+ ["docref_ext"]=>
+ string(5) ".html"
+}
+===Done===
diff --git a/ext/standard/tests/file/parse_ini_file_variation4.phpt b/ext/standard/tests/file/parse_ini_file_variation4.phpt
new file mode 100644
index 0000000..66cab3b
--- /dev/null
+++ b/ext/standard/tests/file/parse_ini_file_variation4.phpt
@@ -0,0 +1,211 @@
+--TEST--
+Test parse_ini_file() function : usage variation
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : array parse_ini_file(string filename [, bool process_sections])
+ * Description: Parse configuration file
+ * Source code: ext/standard/basic_functions.c
+ * Alias to functions:
+ */
+
+echo "*** Testing parse_ini_file() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$process_sections = false;
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+ // int data
+ 'int 0' => 0,
+ 'int 1' => 1,
+ 'int 12345' => 12345,
+ 'int -12345' => -2345,
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float -10.5' => -10.5,
+ 'float 12.3456789000e10' => 12.3456789000e10,
+ 'float -12.3456789000e10' => -12.3456789000e10,
+ 'float .5' => .5,
+
+ // array data
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for filename
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( parse_ini_file($value, $process_sections) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing parse_ini_file() : usage variation ***
+
+--int 0--
+Error: 2 - parse_ini_file(0): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--int 1--
+Error: 2 - parse_ini_file(1): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--int 12345--
+Error: 2 - parse_ini_file(12345): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--int -12345--
+Error: 2 - parse_ini_file(-2345): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--float 10.5--
+Error: 2 - parse_ini_file(10.5): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--float -10.5--
+Error: 2 - parse_ini_file(-10.5): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--float 12.3456789000e10--
+Error: 2 - parse_ini_file(123456789000): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--float -12.3456789000e10--
+Error: 2 - parse_ini_file(-123456789000): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--float .5--
+Error: 2 - parse_ini_file(0.5): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--empty array--
+Error: 2 - parse_ini_file() expects parameter 1 to be a valid path, array given, %s(%d)
+bool(false)
+
+--int indexed array--
+Error: 2 - parse_ini_file() expects parameter 1 to be a valid path, array given, %s(%d)
+bool(false)
+
+--associative array--
+Error: 2 - parse_ini_file() expects parameter 1 to be a valid path, array given, %s(%d)
+bool(false)
+
+--nested arrays--
+Error: 2 - parse_ini_file() expects parameter 1 to be a valid path, array given, %s(%d)
+bool(false)
+
+--uppercase NULL--
+Error: 2 - parse_ini_file(): Filename cannot be empty!, %s(%d)
+bool(false)
+
+--lowercase null--
+Error: 2 - parse_ini_file(): Filename cannot be empty!, %s(%d)
+bool(false)
+
+--lowercase true--
+Error: 2 - parse_ini_file(1): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--lowercase false--
+Error: 2 - parse_ini_file(): Filename cannot be empty!, %s(%d)
+bool(false)
+
+--uppercase TRUE--
+Error: 2 - parse_ini_file(1): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--uppercase FALSE--
+Error: 2 - parse_ini_file(): Filename cannot be empty!, %s(%d)
+bool(false)
+
+--empty string DQ--
+Error: 2 - parse_ini_file(): Filename cannot be empty!, %s(%d)
+bool(false)
+
+--empty string SQ--
+Error: 2 - parse_ini_file(): Filename cannot be empty!, %s(%d)
+bool(false)
+
+--instance of classWithToString--
+Error: 2 - parse_ini_file(Class A object): failed to open stream: No such file or directory, %s(%d)
+bool(false)
+
+--instance of classWithoutToString--
+Error: 2 - parse_ini_file() expects parameter 1 to be a valid path, object given, %s(%d)
+bool(false)
+
+--undefined var--
+Error: 2 - parse_ini_file(): Filename cannot be empty!, %s(%d)
+bool(false)
+
+--unset var--
+Error: 2 - parse_ini_file(): Filename cannot be empty!, %s(%d)
+bool(false)
+===DONE===
+
diff --git a/ext/standard/tests/file/parse_ini_file_variation5.phpt b/ext/standard/tests/file/parse_ini_file_variation5.phpt
new file mode 100644
index 0000000..eea7b7d
--- /dev/null
+++ b/ext/standard/tests/file/parse_ini_file_variation5.phpt
@@ -0,0 +1,254 @@
+--TEST--
+Test parse_ini_file() function : usage variation
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : array parse_ini_file(string filename [, bool process_sections])
+ * Description: Parse configuration file
+ * Source code: ext/standard/basic_functions.c
+ * Alias to functions:
+ */
+
+echo "*** Testing parse_ini_file() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$filename = __FILE__."ParseIniFileVar5.ini";
+$contents = "a=test";
+@unlink($filename);
+file_put_contents($filename, $contents);
+
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+ // int data
+ 'int 0' => 0,
+ 'int 1' => 1,
+ 'int 12345' => 12345,
+ 'int -12345' => -2345,
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float -10.5' => -10.5,
+ 'float 12.3456789000e10' => 12.3456789000e10,
+ 'float -12.3456789000e10' => -12.3456789000e10,
+ 'float .5' => .5,
+
+ // array data
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // string data
+ 'string DQ' => "string",
+ 'string SQ' => 'string',
+ 'mixed case string' => "sTrInG",
+ 'heredoc' => $heredoc,
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for process_sections
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( parse_ini_file($filename, $value) );
+};
+
+unlink($filename);
+?>
+===DONE===
+--EXPECTF--
+*** Testing parse_ini_file() : usage variation ***
+
+--int 0--
+array(1) {
+ ["a"]=>
+ string(4) "test"
+}
+
+--int 1--
+array(1) {
+ ["a"]=>
+ string(4) "test"
+}
+
+--int 12345--
+array(1) {
+ ["a"]=>
+ string(4) "test"
+}
+
+--int -12345--
+array(1) {
+ ["a"]=>
+ string(4) "test"
+}
+
+--float 10.5--
+array(1) {
+ ["a"]=>
+ string(4) "test"
+}
+
+--float -10.5--
+array(1) {
+ ["a"]=>
+ string(4) "test"
+}
+
+--float 12.3456789000e10--
+array(1) {
+ ["a"]=>
+ string(4) "test"
+}
+
+--float -12.3456789000e10--
+array(1) {
+ ["a"]=>
+ string(4) "test"
+}
+
+--float .5--
+array(1) {
+ ["a"]=>
+ string(4) "test"
+}
+
+--empty array--
+Error: 2 - parse_ini_file() expects parameter 2 to be boolean, array given, %s(%d)
+bool(false)
+
+--int indexed array--
+Error: 2 - parse_ini_file() expects parameter 2 to be boolean, array given, %s(%d)
+bool(false)
+
+--associative array--
+Error: 2 - parse_ini_file() expects parameter 2 to be boolean, array given, %s(%d)
+bool(false)
+
+--nested arrays--
+Error: 2 - parse_ini_file() expects parameter 2 to be boolean, array given, %s(%d)
+bool(false)
+
+--uppercase NULL--
+array(1) {
+ ["a"]=>
+ string(4) "test"
+}
+
+--lowercase null--
+array(1) {
+ ["a"]=>
+ string(4) "test"
+}
+
+--empty string DQ--
+array(1) {
+ ["a"]=>
+ string(4) "test"
+}
+
+--empty string SQ--
+array(1) {
+ ["a"]=>
+ string(4) "test"
+}
+
+--string DQ--
+array(1) {
+ ["a"]=>
+ string(4) "test"
+}
+
+--string SQ--
+array(1) {
+ ["a"]=>
+ string(4) "test"
+}
+
+--mixed case string--
+array(1) {
+ ["a"]=>
+ string(4) "test"
+}
+
+--heredoc--
+array(1) {
+ ["a"]=>
+ string(4) "test"
+}
+
+--instance of classWithToString--
+Error: 2 - parse_ini_file() expects parameter 2 to be boolean, object given, %s(%d)
+bool(false)
+
+--instance of classWithoutToString--
+Error: 2 - parse_ini_file() expects parameter 2 to be boolean, object given, %s(%d)
+bool(false)
+
+--undefined var--
+array(1) {
+ ["a"]=>
+ string(4) "test"
+}
+
+--unset var--
+array(1) {
+ ["a"]=>
+ string(4) "test"
+}
+===DONE===
+
diff --git a/ext/standard/tests/file/parse_ini_file_variation6-win32.phpt b/ext/standard/tests/file/parse_ini_file_variation6-win32.phpt
new file mode 100644
index 0000000..6dfbee9
--- /dev/null
+++ b/ext/standard/tests/file/parse_ini_file_variation6-win32.phpt
@@ -0,0 +1,143 @@
+--TEST--
+Test parse_ini_file() function : variation - various absolute and relative paths
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+ die("skip Only run on Windows");
+?>
+--FILE--
+<?php
+/* Prototype : array parse_ini_file(string filename [, bool process_sections])
+ * Description: Parse configuration file
+ * Source code: ext/standard/basic_functions.c
+ * Alias to functions:
+ */
+
+echo "*** Testing parse_ini_file() : variation ***\n";
+$mainDir = "parseIniFileVar6.dir";
+$subDir = "parseIniFileVar6Sub";
+$absMainDir = dirname(__FILE__)."\\".$mainDir;
+mkdir($absMainDir);
+$absSubDir = $absMainDir."\\".$subDir;
+mkdir($absSubDir);
+
+$old_dir_path = getcwd();
+chdir(dirname(__FILE__));
+$unixifiedDir = '/'.substr(str_replace('\\','/',$absSubDir),3);
+
+$allDirs = array(
+ // absolute paths
+ "$absSubDir\\",
+ "$absSubDir\\..\\".$subDir,
+ "$absSubDir\\\\..\\.\\".$subDir,
+ "$absSubDir\\..\\..\\".$mainDir."\\.\\".$subDir,
+ "$absSubDir\\..\\\\\\".$subDir."\\\\..\\\\..\\".$subDir,
+ "$absSubDir\\BADDIR",
+
+ // relative paths
+ $mainDir."\\".$subDir,
+ $mainDir."\\\\".$subDir,
+ $mainDir."\\\\\\".$subDir,
+ ".\\".$mainDir."\\..\\".$mainDir."\\".$subDir,
+ "BADDIR",
+
+ // unixifed path
+ $unixifiedDir,
+);
+
+$filename = 'ParseIniFileVar6.ini';
+$content="a=test";
+$absFile = $absSubDir.'/'.$filename;
+$h = fopen($absFile,"w");
+fwrite($h, $content);
+fclose($h);
+
+for($i = 0; $i<count($allDirs); $i++) {
+ $j = $i+1;
+ $dir = $allDirs[$i];
+ echo "\n-- Iteration $j --\n";
+ var_dump(parse_ini_file($dir."\\".$filename));
+}
+
+unlink($absFile);
+chdir($old_dir_path);
+rmdir($absSubDir);
+rmdir($absMainDir);
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing parse_ini_file() : variation ***
+
+-- Iteration 1 --
+array(1) {
+ ["a"]=>
+ string(4) "test"
+}
+
+-- Iteration 2 --
+array(1) {
+ ["a"]=>
+ string(4) "test"
+}
+
+-- Iteration 3 --
+array(1) {
+ ["a"]=>
+ string(4) "test"
+}
+
+-- Iteration 4 --
+array(1) {
+ ["a"]=>
+ string(4) "test"
+}
+
+-- Iteration 5 --
+
+Warning: parse_ini_file(%sparseIniFileVar6.dir\parseIniFileVar6Sub\..\\\parseIniFileVar6Sub\\..\\..\parseIniFileVar6Sub\ParseIniFileVar6.ini): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+-- Iteration 6 --
+
+Warning: parse_ini_file(%sparseIniFileVar6.dir\parseIniFileVar6Sub\BADDIR\ParseIniFileVar6.ini): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+-- Iteration 7 --
+array(1) {
+ ["a"]=>
+ string(4) "test"
+}
+
+-- Iteration 8 --
+array(1) {
+ ["a"]=>
+ string(4) "test"
+}
+
+-- Iteration 9 --
+array(1) {
+ ["a"]=>
+ string(4) "test"
+}
+
+-- Iteration 10 --
+array(1) {
+ ["a"]=>
+ string(4) "test"
+}
+
+-- Iteration 11 --
+
+Warning: parse_ini_file(BADDIR\ParseIniFileVar6.ini): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+-- Iteration 12 --
+array(1) {
+ ["a"]=>
+ string(4) "test"
+}
+
+*** Done *** \ No newline at end of file
diff --git a/ext/standard/tests/file/parse_ini_file_variation6.phpt b/ext/standard/tests/file/parse_ini_file_variation6.phpt
new file mode 100644
index 0000000..e9844e9
--- /dev/null
+++ b/ext/standard/tests/file/parse_ini_file_variation6.phpt
@@ -0,0 +1,129 @@
+--TEST--
+Test parse_ini_file() function : variation - various absolute and relative paths
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : array parse_ini_file(string filename [, bool process_sections])
+ * Description: Parse configuration file
+ * Source code: ext/standard/basic_functions.c
+ * Alias to functions:
+ */
+
+echo "*** Testing parse_ini_file() : variation ***\n";
+$mainDir = "parseIniFileVar6.dir";
+$subDir = "parseIniFileVar6Sub";
+$absMainDir = dirname(__FILE__)."/".$mainDir;
+mkdir($absMainDir);
+$absSubDir = $absMainDir."/".$subDir;
+mkdir($absSubDir);
+
+$old_dir_path = getcwd();
+chdir(dirname(__FILE__));
+
+$allDirs = array(
+ // absolute paths
+ "$absSubDir/",
+ "$absSubDir/../".$subDir,
+ "$absSubDir//.././".$subDir,
+ "$absSubDir/../../".$mainDir."/./".$subDir,
+ "$absSubDir/..///".$subDir."//..//../".$subDir,
+ "$absSubDir/BADDIR",
+
+ // relative paths
+ $mainDir."/".$subDir,
+ $mainDir."//".$subDir,
+ $mainDir."///".$subDir,
+ "./".$mainDir."/../".$mainDir."/".$subDir,
+ "BADDIR",
+
+);
+
+$filename = 'ParseIniFileVar6.ini';
+$content="a=test";
+$absFile = $absSubDir.'/'.$filename;
+$h = fopen($absFile,"w");
+fwrite($h, $content);
+fclose($h);
+
+for($i = 0; $i<count($allDirs); $i++) {
+ $j = $i+1;
+ $dir = $allDirs[$i];
+ echo "\n-- Iteration $j --\n";
+ var_dump(parse_ini_file($dir."/".$filename));
+}
+
+unlink($absFile);
+chdir($old_dir_path);
+rmdir($absSubDir);
+rmdir($absMainDir);
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing parse_ini_file() : variation ***
+
+-- Iteration 1 --
+array(1) {
+ ["a"]=>
+ string(4) "test"
+}
+
+-- Iteration 2 --
+array(1) {
+ ["a"]=>
+ string(4) "test"
+}
+
+-- Iteration 3 --
+array(1) {
+ ["a"]=>
+ string(4) "test"
+}
+
+-- Iteration 4 --
+array(1) {
+ ["a"]=>
+ string(4) "test"
+}
+
+-- Iteration 5 --
+
+Warning: parse_ini_file(%sparseIniFileVar6.dir/parseIniFileVar6Sub/..///parseIniFileVar6Sub//..//../parseIniFileVar6Sub/ParseIniFileVar6.ini): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+-- Iteration 6 --
+
+Warning: parse_ini_file(%sparseIniFileVar6.dir/parseIniFileVar6Sub/BADDIR/ParseIniFileVar6.ini): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+-- Iteration 7 --
+array(1) {
+ ["a"]=>
+ string(4) "test"
+}
+
+-- Iteration 8 --
+array(1) {
+ ["a"]=>
+ string(4) "test"
+}
+
+-- Iteration 9 --
+array(1) {
+ ["a"]=>
+ string(4) "test"
+}
+
+-- Iteration 10 --
+array(1) {
+ ["a"]=>
+ string(4) "test"
+}
+
+-- Iteration 11 --
+
+Warning: parse_ini_file(BADDIR/ParseIniFileVar6.ini): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+*** Done *** \ No newline at end of file
diff --git a/ext/standard/tests/file/pathinfo_basic.phpt b/ext/standard/tests/file/pathinfo_basic.phpt
new file mode 100644
index 0000000..53eda5a
--- /dev/null
+++ b/ext/standard/tests/file/pathinfo_basic.phpt
@@ -0,0 +1,401 @@
+--TEST--
+Test pathinfo() function: basic functionality
+--FILE--
+<?php
+/* Prototype: mixed pathinfo ( string $path [, int $options] );
+ Description: Returns information about a file path
+*/
+
+echo "*** Testing basic functions of pathinfo() ***\n";
+
+$file_path = dirname(__FILE__);
+
+$paths = array (
+ /* Testing basic file notation */
+ "$file_path/foo/symlink.link",
+ "www.example.co.in",
+ "/var/www/html/example.html",
+ "/dir/test.tar.gz",
+
+ /* Testing a file with trailing slash */
+ "$file_path/foo/symlink.link/",
+
+ /* Testing file with double slashes */
+ "$file_path/foo//symlink.link",
+ "$file_path/foo//symlink.link",
+ "$file_path/foo//symlink.link//",
+
+ /* Testing file with trailing double slashes */
+ "$file_path/foo/symlink.link//",
+
+ /* Testing Binary safe files */
+ "$file_path/foo".chr(47)."symlink.link",
+ "$file_path".chr(47)."foo/symlink.link",
+ "$file_path".chr(47)."foo".chr(47)."symlink.link",
+ b"$file_path/foo/symlink.link",
+
+ /* Testing directories */
+ ".", // current directory
+ "$file_path/foo/",
+ "$file_path/foo//",
+ "$file_path/../foo/",
+ "../foo/bar",
+ "./foo/bar",
+ "//foo//bar//",
+
+ /* Testing with homedir notation */
+ "~/PHP/php5.2.0/",
+
+ /* Testing normal directory notation */
+ "/home/example/test/",
+ "http://httpd.apache.org/core.html#acceptpathinfo"
+);
+
+$counter = 1;
+/* loop through $paths to test each $path in the above array */
+foreach($paths as $path) {
+ echo "-- Iteration $counter --\n";
+ var_dump( pathinfo($path, PATHINFO_DIRNAME) );
+ var_dump( pathinfo($path, PATHINFO_BASENAME) );
+ var_dump( pathinfo($path, PATHINFO_EXTENSION) );
+ var_dump( pathinfo($path, PATHINFO_FILENAME) );
+ var_dump( pathinfo($path) );
+ $counter++;
+}
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing basic functions of pathinfo() ***
+-- Iteration 1 --
+%unicode|string%(%d) "%s/foo"
+%unicode|string%(12) "symlink.link"
+%unicode|string%(4) "link"
+%unicode|string%(7) "symlink"
+array(4) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(%d) "%s/foo"
+ [%u|b%"basename"]=>
+ %unicode|string%(12) "symlink.link"
+ [%u|b%"extension"]=>
+ %unicode|string%(4) "link"
+ [%u|b%"filename"]=>
+ %unicode|string%(7) "symlink"
+}
+-- Iteration 2 --
+%unicode|string%(1) "."
+%unicode|string%(17) "www.example.co.in"
+%unicode|string%(2) "in"
+%unicode|string%(14) "www.example.co"
+array(4) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(1) "."
+ [%u|b%"basename"]=>
+ %unicode|string%(17) "www.example.co.in"
+ [%u|b%"extension"]=>
+ %unicode|string%(2) "in"
+ [%u|b%"filename"]=>
+ %unicode|string%(14) "www.example.co"
+}
+-- Iteration 3 --
+%unicode|string%(13) "/var/www/html"
+%unicode|string%(12) "example.html"
+%unicode|string%(4) "html"
+%unicode|string%(7) "example"
+array(4) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(13) "/var/www/html"
+ [%u|b%"basename"]=>
+ %unicode|string%(12) "example.html"
+ [%u|b%"extension"]=>
+ %unicode|string%(4) "html"
+ [%u|b%"filename"]=>
+ %unicode|string%(7) "example"
+}
+-- Iteration 4 --
+%unicode|string%(4) "/dir"
+%unicode|string%(11) "test.tar.gz"
+%unicode|string%(2) "gz"
+%unicode|string%(8) "test.tar"
+array(4) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(4) "/dir"
+ [%u|b%"basename"]=>
+ %unicode|string%(11) "test.tar.gz"
+ [%u|b%"extension"]=>
+ %unicode|string%(2) "gz"
+ [%u|b%"filename"]=>
+ %unicode|string%(8) "test.tar"
+}
+-- Iteration 5 --
+%unicode|string%(%d) "%s/foo"
+%unicode|string%(12) "symlink.link"
+%unicode|string%(4) "link"
+%unicode|string%(7) "symlink"
+array(4) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(%d) "%s/foo"
+ [%u|b%"basename"]=>
+ %unicode|string%(12) "symlink.link"
+ [%u|b%"extension"]=>
+ %unicode|string%(4) "link"
+ [%u|b%"filename"]=>
+ %unicode|string%(7) "symlink"
+}
+-- Iteration 6 --
+%unicode|string%(%d) "%s/foo"
+%unicode|string%(12) "symlink.link"
+%unicode|string%(4) "link"
+%unicode|string%(7) "symlink"
+array(4) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(%d) "%s/foo"
+ [%u|b%"basename"]=>
+ %unicode|string%(12) "symlink.link"
+ [%u|b%"extension"]=>
+ %unicode|string%(4) "link"
+ [%u|b%"filename"]=>
+ %unicode|string%(7) "symlink"
+}
+-- Iteration 7 --
+%unicode|string%(%d) "%s/foo"
+%unicode|string%(12) "symlink.link"
+%unicode|string%(4) "link"
+%unicode|string%(7) "symlink"
+array(4) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(%d) "%s/foo"
+ [%u|b%"basename"]=>
+ %unicode|string%(12) "symlink.link"
+ [%u|b%"extension"]=>
+ %unicode|string%(4) "link"
+ [%u|b%"filename"]=>
+ %unicode|string%(7) "symlink"
+}
+-- Iteration 8 --
+%unicode|string%(%d) "%s/foo"
+%unicode|string%(12) "symlink.link"
+%unicode|string%(4) "link"
+%unicode|string%(7) "symlink"
+array(4) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(%d) "%s/foo"
+ [%u|b%"basename"]=>
+ %unicode|string%(12) "symlink.link"
+ [%u|b%"extension"]=>
+ %unicode|string%(4) "link"
+ [%u|b%"filename"]=>
+ %unicode|string%(7) "symlink"
+}
+-- Iteration 9 --
+%unicode|string%(%d) "%s/foo"
+%unicode|string%(12) "symlink.link"
+%unicode|string%(4) "link"
+%unicode|string%(7) "symlink"
+array(4) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(%d) "%s/foo"
+ [%u|b%"basename"]=>
+ %unicode|string%(12) "symlink.link"
+ [%u|b%"extension"]=>
+ %unicode|string%(4) "link"
+ [%u|b%"filename"]=>
+ %unicode|string%(7) "symlink"
+}
+-- Iteration 10 --
+%unicode|string%(%d) "%s/foo"
+%unicode|string%(12) "symlink.link"
+%unicode|string%(4) "link"
+%unicode|string%(7) "symlink"
+array(4) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(%d) "%s/foo"
+ [%u|b%"basename"]=>
+ %unicode|string%(12) "symlink.link"
+ [%u|b%"extension"]=>
+ %unicode|string%(4) "link"
+ [%u|b%"filename"]=>
+ %unicode|string%(7) "symlink"
+}
+-- Iteration 11 --
+%unicode|string%(%d) "%s/foo"
+%unicode|string%(12) "symlink.link"
+%unicode|string%(4) "link"
+%unicode|string%(7) "symlink"
+array(4) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(%d) "%s/foo"
+ [%u|b%"basename"]=>
+ %unicode|string%(12) "symlink.link"
+ [%u|b%"extension"]=>
+ %unicode|string%(4) "link"
+ [%u|b%"filename"]=>
+ %unicode|string%(7) "symlink"
+}
+-- Iteration 12 --
+%unicode|string%(%d) "%s/foo"
+%unicode|string%(12) "symlink.link"
+%unicode|string%(4) "link"
+%unicode|string%(7) "symlink"
+array(4) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(%d) "%s/foo"
+ [%u|b%"basename"]=>
+ %unicode|string%(12) "symlink.link"
+ [%u|b%"extension"]=>
+ %unicode|string%(4) "link"
+ [%u|b%"filename"]=>
+ %unicode|string%(7) "symlink"
+}
+-- Iteration 13 --
+string(%d) "%s/foo"
+string(12) "symlink.link"
+string(4) "link"
+string(7) "symlink"
+array(4) {
+ [%u|b%"dirname"]=>
+ string(%d) "%s/foo"
+ [%u|b%"basename"]=>
+ string(12) "symlink.link"
+ [%u|b%"extension"]=>
+ string(4) "link"
+ [%u|b%"filename"]=>
+ string(7) "symlink"
+}
+-- Iteration 14 --
+%unicode|string%(1) "."
+%unicode|string%(1) "."
+%unicode|string%(0) ""
+%unicode|string%(0) ""
+array(4) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(1) "."
+ [%u|b%"basename"]=>
+ %unicode|string%(1) "."
+ [%u|b%"extension"]=>
+ %unicode|string%(0) ""
+ [%u|b%"filename"]=>
+ %unicode|string%(0) ""
+}
+-- Iteration 15 --
+%unicode|string%(%d) "%s"
+%unicode|string%(3) "foo"
+%unicode|string%(0) ""
+%unicode|string%(3) "foo"
+array(3) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(%d) "%s"
+ [%u|b%"basename"]=>
+ %unicode|string%(3) "foo"
+ [%u|b%"filename"]=>
+ %unicode|string%(3) "foo"
+}
+-- Iteration 16 --
+%unicode|string%(%d) "%s"
+%unicode|string%(3) "foo"
+%unicode|string%(0) ""
+%unicode|string%(3) "foo"
+array(3) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(%d) "%s"
+ [%u|b%"basename"]=>
+ %unicode|string%(3) "foo"
+ [%u|b%"filename"]=>
+ %unicode|string%(3) "foo"
+}
+-- Iteration 17 --
+%unicode|string%(%d) "%s/.."
+%unicode|string%(3) "foo"
+%unicode|string%(0) ""
+%unicode|string%(3) "foo"
+array(3) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(%d) "%s/.."
+ [%u|b%"basename"]=>
+ %unicode|string%(3) "foo"
+ [%u|b%"filename"]=>
+ %unicode|string%(3) "foo"
+}
+-- Iteration 18 --
+%unicode|string%(6) "../foo"
+%unicode|string%(3) "bar"
+%unicode|string%(0) ""
+%unicode|string%(3) "bar"
+array(3) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(6) "../foo"
+ [%u|b%"basename"]=>
+ %unicode|string%(3) "bar"
+ [%u|b%"filename"]=>
+ %unicode|string%(3) "bar"
+}
+-- Iteration 19 --
+%unicode|string%(5) "./foo"
+%unicode|string%(3) "bar"
+%unicode|string%(0) ""
+%unicode|string%(3) "bar"
+array(3) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(5) "./foo"
+ [%u|b%"basename"]=>
+ %unicode|string%(3) "bar"
+ [%u|b%"filename"]=>
+ %unicode|string%(3) "bar"
+}
+-- Iteration 20 --
+%unicode|string%(5) "//foo"
+%unicode|string%(3) "bar"
+%unicode|string%(0) ""
+%unicode|string%(3) "bar"
+array(3) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(5) "//foo"
+ [%u|b%"basename"]=>
+ %unicode|string%(3) "bar"
+ [%u|b%"filename"]=>
+ %unicode|string%(3) "bar"
+}
+-- Iteration 21 --
+%unicode|string%(5) "~/PHP"
+%unicode|string%(8) "php5.2.0"
+%unicode|string%(1) "0"
+%unicode|string%(6) "php5.2"
+array(4) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(5) "~/PHP"
+ [%u|b%"basename"]=>
+ %unicode|string%(8) "php5.2.0"
+ [%u|b%"extension"]=>
+ %unicode|string%(1) "0"
+ [%u|b%"filename"]=>
+ %unicode|string%(6) "php5.2"
+}
+-- Iteration 22 --
+%unicode|string%(13) "/home/example"
+%unicode|string%(4) "test"
+%unicode|string%(0) ""
+%unicode|string%(4) "test"
+array(3) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(13) "/home/example"
+ [%u|b%"basename"]=>
+ %unicode|string%(4) "test"
+ [%u|b%"filename"]=>
+ %unicode|string%(4) "test"
+}
+-- Iteration 23 --
+%unicode|string%(23) "http://httpd.apache.org"
+%unicode|string%(24) "core.html#acceptpathinfo"
+%unicode|string%(19) "html#acceptpathinfo"
+%unicode|string%(4) "core"
+array(4) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(23) "http://httpd.apache.org"
+ [%u|b%"basename"]=>
+ %unicode|string%(24) "core.html#acceptpathinfo"
+ [%u|b%"extension"]=>
+ %unicode|string%(19) "html#acceptpathinfo"
+ [%u|b%"filename"]=>
+ %unicode|string%(4) "core"
+}
+Done
diff --git a/ext/standard/tests/file/pathinfo_basic1-win32.phpt b/ext/standard/tests/file/pathinfo_basic1-win32.phpt
new file mode 100644
index 0000000..9e84b99
--- /dev/null
+++ b/ext/standard/tests/file/pathinfo_basic1-win32.phpt
@@ -0,0 +1,609 @@
+--TEST--
+Test pathinfo() function: basic functionality
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+ die("skip Only valid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype: mixed pathinfo ( string $path [, int $options] );
+ Description: Returns information about a file path
+*/
+
+echo "*** Testing basic functions of pathinfo() ***\n";
+
+$paths = array (
+ '',
+ ' ',
+ 'c:',
+ 'c:\\',
+ 'c:/',
+ 'afile',
+ 'c:\test\adir',
+ 'c:\test\adir\\',
+ '/usr/include/arpa',
+ '/usr/include/arpa/',
+ 'usr/include/arpa',
+ 'usr/include/arpa/',
+ 'c:\test\afile',
+ 'c:\\test\\afile',
+ 'c://test//afile',
+ 'c:\test\afile\\',
+ 'c:\test\prog.exe',
+ 'c:\\test\\prog.exe',
+ 'c:/test/prog.exe',
+ '/usr/include/arpa/inet.h',
+ '//usr/include//arpa/inet.h',
+ '\\',
+ '\\\\',
+ '/',
+ '//',
+ '///',
+ '/usr/include/arpa/inet.h',
+ 'c:\windows/system32\drivers/etc\hosts',
+ '/usr\include/arpa\inet.h',
+ ' c:\test\adir\afile.txt',
+ 'c:\test\adir\afile.txt ',
+ ' c:\test\adir\afile.txt ',
+ ' /usr/include/arpa/inet.h',
+ '/usr/include/arpa/inet.h ',
+ ' /usr/include/arpa/inet.h ',
+ ' c:',
+ ' c:\test\adir\afile.txt',
+ '/usr',
+ '/usr/'
+);
+
+$counter = 1;
+/* loop through $paths to test each $path in the above array */
+foreach($paths as $path) {
+ echo "-- Iteration $counter --\n";
+ var_dump( pathinfo($path, PATHINFO_DIRNAME) );
+ var_dump( pathinfo($path, PATHINFO_BASENAME) );
+ var_dump( pathinfo($path, PATHINFO_EXTENSION) );
+ var_dump( pathinfo($path, PATHINFO_FILENAME) );
+ var_dump( pathinfo($path) );
+ $counter++;
+}
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing basic functions of pathinfo() ***
+-- Iteration 1 --
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+array(2) {
+ ["basename"]=>
+ string(0) ""
+ ["filename"]=>
+ string(0) ""
+}
+-- Iteration 2 --
+string(1) "."
+string(1) " "
+string(0) ""
+string(1) " "
+array(3) {
+ ["dirname"]=>
+ string(1) "."
+ ["basename"]=>
+ string(1) " "
+ ["filename"]=>
+ string(1) " "
+}
+-- Iteration 3 --
+string(2) "c:"
+string(2) "c:"
+string(0) ""
+string(2) "c:"
+array(3) {
+ ["dirname"]=>
+ string(2) "c:"
+ ["basename"]=>
+ string(2) "c:"
+ ["filename"]=>
+ string(2) "c:"
+}
+-- Iteration 4 --
+string(3) "c:\"
+string(2) "c:"
+string(0) ""
+string(2) "c:"
+array(3) {
+ ["dirname"]=>
+ string(3) "c:\"
+ ["basename"]=>
+ string(2) "c:"
+ ["filename"]=>
+ string(2) "c:"
+}
+-- Iteration 5 --
+string(3) "c:\"
+string(2) "c:"
+string(0) ""
+string(2) "c:"
+array(3) {
+ ["dirname"]=>
+ string(3) "c:\"
+ ["basename"]=>
+ string(2) "c:"
+ ["filename"]=>
+ string(2) "c:"
+}
+-- Iteration 6 --
+string(1) "."
+string(5) "afile"
+string(0) ""
+string(5) "afile"
+array(3) {
+ ["dirname"]=>
+ string(1) "."
+ ["basename"]=>
+ string(5) "afile"
+ ["filename"]=>
+ string(5) "afile"
+}
+-- Iteration 7 --
+string(7) "c:\test"
+string(4) "adir"
+string(0) ""
+string(4) "adir"
+array(3) {
+ ["dirname"]=>
+ string(7) "c:\test"
+ ["basename"]=>
+ string(4) "adir"
+ ["filename"]=>
+ string(4) "adir"
+}
+-- Iteration 8 --
+string(7) "c:\test"
+string(4) "adir"
+string(0) ""
+string(4) "adir"
+array(3) {
+ ["dirname"]=>
+ string(7) "c:\test"
+ ["basename"]=>
+ string(4) "adir"
+ ["filename"]=>
+ string(4) "adir"
+}
+-- Iteration 9 --
+string(12) "/usr/include"
+string(4) "arpa"
+string(0) ""
+string(4) "arpa"
+array(3) {
+ ["dirname"]=>
+ string(12) "/usr/include"
+ ["basename"]=>
+ string(4) "arpa"
+ ["filename"]=>
+ string(4) "arpa"
+}
+-- Iteration 10 --
+string(12) "/usr/include"
+string(4) "arpa"
+string(0) ""
+string(4) "arpa"
+array(3) {
+ ["dirname"]=>
+ string(12) "/usr/include"
+ ["basename"]=>
+ string(4) "arpa"
+ ["filename"]=>
+ string(4) "arpa"
+}
+-- Iteration 11 --
+string(11) "usr/include"
+string(4) "arpa"
+string(0) ""
+string(4) "arpa"
+array(3) {
+ ["dirname"]=>
+ string(11) "usr/include"
+ ["basename"]=>
+ string(4) "arpa"
+ ["filename"]=>
+ string(4) "arpa"
+}
+-- Iteration 12 --
+string(11) "usr/include"
+string(4) "arpa"
+string(0) ""
+string(4) "arpa"
+array(3) {
+ ["dirname"]=>
+ string(11) "usr/include"
+ ["basename"]=>
+ string(4) "arpa"
+ ["filename"]=>
+ string(4) "arpa"
+}
+-- Iteration 13 --
+string(7) "c:\test"
+string(5) "afile"
+string(0) ""
+string(5) "afile"
+array(3) {
+ ["dirname"]=>
+ string(7) "c:\test"
+ ["basename"]=>
+ string(5) "afile"
+ ["filename"]=>
+ string(5) "afile"
+}
+-- Iteration 14 --
+string(7) "c:\test"
+string(5) "afile"
+string(0) ""
+string(5) "afile"
+array(3) {
+ ["dirname"]=>
+ string(7) "c:\test"
+ ["basename"]=>
+ string(5) "afile"
+ ["filename"]=>
+ string(5) "afile"
+}
+-- Iteration 15 --
+string(8) "c://test"
+string(5) "afile"
+string(0) ""
+string(5) "afile"
+array(3) {
+ ["dirname"]=>
+ string(8) "c://test"
+ ["basename"]=>
+ string(5) "afile"
+ ["filename"]=>
+ string(5) "afile"
+}
+-- Iteration 16 --
+string(7) "c:\test"
+string(5) "afile"
+string(0) ""
+string(5) "afile"
+array(3) {
+ ["dirname"]=>
+ string(7) "c:\test"
+ ["basename"]=>
+ string(5) "afile"
+ ["filename"]=>
+ string(5) "afile"
+}
+-- Iteration 17 --
+string(7) "c:\test"
+string(8) "prog.exe"
+string(3) "exe"
+string(4) "prog"
+array(4) {
+ ["dirname"]=>
+ string(7) "c:\test"
+ ["basename"]=>
+ string(8) "prog.exe"
+ ["extension"]=>
+ string(3) "exe"
+ ["filename"]=>
+ string(4) "prog"
+}
+-- Iteration 18 --
+string(7) "c:\test"
+string(8) "prog.exe"
+string(3) "exe"
+string(4) "prog"
+array(4) {
+ ["dirname"]=>
+ string(7) "c:\test"
+ ["basename"]=>
+ string(8) "prog.exe"
+ ["extension"]=>
+ string(3) "exe"
+ ["filename"]=>
+ string(4) "prog"
+}
+-- Iteration 19 --
+string(7) "c:/test"
+string(8) "prog.exe"
+string(3) "exe"
+string(4) "prog"
+array(4) {
+ ["dirname"]=>
+ string(7) "c:/test"
+ ["basename"]=>
+ string(8) "prog.exe"
+ ["extension"]=>
+ string(3) "exe"
+ ["filename"]=>
+ string(4) "prog"
+}
+-- Iteration 20 --
+string(17) "/usr/include/arpa"
+string(6) "inet.h"
+string(1) "h"
+string(4) "inet"
+array(4) {
+ ["dirname"]=>
+ string(17) "/usr/include/arpa"
+ ["basename"]=>
+ string(6) "inet.h"
+ ["extension"]=>
+ string(1) "h"
+ ["filename"]=>
+ string(4) "inet"
+}
+-- Iteration 21 --
+string(19) "//usr/include//arpa"
+string(6) "inet.h"
+string(1) "h"
+string(4) "inet"
+array(4) {
+ ["dirname"]=>
+ string(19) "//usr/include//arpa"
+ ["basename"]=>
+ string(6) "inet.h"
+ ["extension"]=>
+ string(1) "h"
+ ["filename"]=>
+ string(4) "inet"
+}
+-- Iteration 22 --
+string(1) "\"
+string(0) ""
+string(0) ""
+string(0) ""
+array(3) {
+ ["dirname"]=>
+ string(1) "\"
+ ["basename"]=>
+ string(0) ""
+ ["filename"]=>
+ string(0) ""
+}
+-- Iteration 23 --
+string(1) "\"
+string(0) ""
+string(0) ""
+string(0) ""
+array(3) {
+ ["dirname"]=>
+ string(1) "\"
+ ["basename"]=>
+ string(0) ""
+ ["filename"]=>
+ string(0) ""
+}
+-- Iteration 24 --
+string(1) "\"
+string(0) ""
+string(0) ""
+string(0) ""
+array(3) {
+ ["dirname"]=>
+ string(1) "\"
+ ["basename"]=>
+ string(0) ""
+ ["filename"]=>
+ string(0) ""
+}
+-- Iteration 25 --
+string(1) "\"
+string(0) ""
+string(0) ""
+string(0) ""
+array(3) {
+ ["dirname"]=>
+ string(1) "\"
+ ["basename"]=>
+ string(0) ""
+ ["filename"]=>
+ string(0) ""
+}
+-- Iteration 26 --
+string(1) "\"
+string(0) ""
+string(0) ""
+string(0) ""
+array(3) {
+ ["dirname"]=>
+ string(1) "\"
+ ["basename"]=>
+ string(0) ""
+ ["filename"]=>
+ string(0) ""
+}
+-- Iteration 27 --
+string(17) "/usr/include/arpa"
+string(6) "inet.h"
+string(1) "h"
+string(4) "inet"
+array(4) {
+ ["dirname"]=>
+ string(17) "/usr/include/arpa"
+ ["basename"]=>
+ string(6) "inet.h"
+ ["extension"]=>
+ string(1) "h"
+ ["filename"]=>
+ string(4) "inet"
+}
+-- Iteration 28 --
+string(31) "c:\windows/system32\drivers/etc"
+string(5) "hosts"
+string(0) ""
+string(5) "hosts"
+array(3) {
+ ["dirname"]=>
+ string(31) "c:\windows/system32\drivers/etc"
+ ["basename"]=>
+ string(5) "hosts"
+ ["filename"]=>
+ string(5) "hosts"
+}
+-- Iteration 29 --
+string(17) "/usr\include/arpa"
+string(6) "inet.h"
+string(1) "h"
+string(4) "inet"
+array(4) {
+ ["dirname"]=>
+ string(17) "/usr\include/arpa"
+ ["basename"]=>
+ string(6) "inet.h"
+ ["extension"]=>
+ string(1) "h"
+ ["filename"]=>
+ string(4) "inet"
+}
+-- Iteration 30 --
+string(15) " c:\test\adir"
+string(9) "afile.txt"
+string(3) "txt"
+string(5) "afile"
+array(4) {
+ ["dirname"]=>
+ string(15) " c:\test\adir"
+ ["basename"]=>
+ string(9) "afile.txt"
+ ["extension"]=>
+ string(3) "txt"
+ ["filename"]=>
+ string(5) "afile"
+}
+-- Iteration 31 --
+string(12) "c:\test\adir"
+string(12) "afile.txt "
+string(6) "txt "
+string(5) "afile"
+array(4) {
+ ["dirname"]=>
+ string(12) "c:\test\adir"
+ ["basename"]=>
+ string(12) "afile.txt "
+ ["extension"]=>
+ string(6) "txt "
+ ["filename"]=>
+ string(5) "afile"
+}
+-- Iteration 32 --
+string(15) " c:\test\adir"
+string(12) "afile.txt "
+string(6) "txt "
+string(5) "afile"
+array(4) {
+ ["dirname"]=>
+ string(15) " c:\test\adir"
+ ["basename"]=>
+ string(12) "afile.txt "
+ ["extension"]=>
+ string(6) "txt "
+ ["filename"]=>
+ string(5) "afile"
+}
+-- Iteration 33 --
+string(20) " /usr/include/arpa"
+string(6) "inet.h"
+string(1) "h"
+string(4) "inet"
+array(4) {
+ ["dirname"]=>
+ string(20) " /usr/include/arpa"
+ ["basename"]=>
+ string(6) "inet.h"
+ ["extension"]=>
+ string(1) "h"
+ ["filename"]=>
+ string(4) "inet"
+}
+-- Iteration 34 --
+string(17) "/usr/include/arpa"
+string(9) "inet.h "
+string(4) "h "
+string(4) "inet"
+array(4) {
+ ["dirname"]=>
+ string(17) "/usr/include/arpa"
+ ["basename"]=>
+ string(9) "inet.h "
+ ["extension"]=>
+ string(4) "h "
+ ["filename"]=>
+ string(4) "inet"
+}
+-- Iteration 35 --
+string(20) " /usr/include/arpa"
+string(9) "inet.h "
+string(4) "h "
+string(4) "inet"
+array(4) {
+ ["dirname"]=>
+ string(20) " /usr/include/arpa"
+ ["basename"]=>
+ string(9) "inet.h "
+ ["extension"]=>
+ string(4) "h "
+ ["filename"]=>
+ string(4) "inet"
+}
+-- Iteration 36 --
+string(1) "."
+string(3) " c:"
+string(0) ""
+string(3) " c:"
+array(3) {
+ ["dirname"]=>
+ string(1) "."
+ ["basename"]=>
+ string(3) " c:"
+ ["filename"]=>
+ string(3) " c:"
+}
+-- Iteration 37 --
+string(14) " c:\test\adir"
+string(9) "afile.txt"
+string(3) "txt"
+string(5) "afile"
+array(4) {
+ ["dirname"]=>
+ string(14) " c:\test\adir"
+ ["basename"]=>
+ string(9) "afile.txt"
+ ["extension"]=>
+ string(3) "txt"
+ ["filename"]=>
+ string(5) "afile"
+}
+-- Iteration 38 --
+string(1) "\"
+string(3) "usr"
+string(0) ""
+string(3) "usr"
+array(3) {
+ ["dirname"]=>
+ string(1) "\"
+ ["basename"]=>
+ string(3) "usr"
+ ["filename"]=>
+ string(3) "usr"
+}
+-- Iteration 39 --
+string(1) "\"
+string(3) "usr"
+string(0) ""
+string(3) "usr"
+array(3) {
+ ["dirname"]=>
+ string(1) "\"
+ ["basename"]=>
+ string(3) "usr"
+ ["filename"]=>
+ string(3) "usr"
+}
+Done
diff --git a/ext/standard/tests/file/pathinfo_basic1.phpt b/ext/standard/tests/file/pathinfo_basic1.phpt
new file mode 100644
index 0000000..92f0524
--- /dev/null
+++ b/ext/standard/tests/file/pathinfo_basic1.phpt
@@ -0,0 +1,610 @@
+--TEST--
+Test pathinfo() function: basic functionality
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+ die("skip Not valid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype: mixed pathinfo ( string $path [, int $options] );
+ Description: Returns information about a file path
+*/
+
+echo "*** Testing basic functions of pathinfo() ***\n";
+
+$paths = array (
+ '',
+ ' ',
+ 'c:',
+ 'c:\\',
+ 'c:/',
+ 'afile',
+ 'c:\test\adir',
+ 'c:\test\adir\\',
+ '/usr/include/arpa',
+ '/usr/include/arpa/',
+ 'usr/include/arpa',
+ 'usr/include/arpa/',
+ 'c:\test\afile',
+ 'c:\\test\\afile',
+ 'c://test//afile',
+ 'c:\test\afile\\',
+ 'c:\test\prog.exe',
+ 'c:\\test\\prog.exe',
+ 'c:/test/prog.exe',
+ '/usr/include/arpa/inet.h',
+ '//usr/include//arpa/inet.h',
+ '\\',
+ '\\\\',
+ '/',
+ '//',
+ '///',
+ '/usr/include/arpa/inet.h',
+ 'c:\windows/system32\drivers/etc\hosts',
+ '/usr\include/arpa\inet.h',
+ ' c:\test\adir\afile.txt',
+ 'c:\test\adir\afile.txt ',
+ ' c:\test\adir\afile.txt ',
+ ' /usr/include/arpa/inet.h',
+ '/usr/include/arpa/inet.h ',
+ ' /usr/include/arpa/inet.h ',
+ ' c:',
+ ' c:\test\adir\afile.txt',
+ '/usr',
+ '/usr/'
+);
+
+$counter = 1;
+/* loop through $paths to test each $path in the above array */
+foreach($paths as $path) {
+ echo "-- Iteration $counter --\n";
+ var_dump( pathinfo($path, PATHINFO_DIRNAME) );
+ var_dump( pathinfo($path, PATHINFO_BASENAME) );
+ var_dump( pathinfo($path, PATHINFO_EXTENSION) );
+ var_dump( pathinfo($path, PATHINFO_FILENAME) );
+ var_dump( pathinfo($path) );
+ $counter++;
+}
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing basic functions of pathinfo() ***
+-- Iteration 1 --
+%unicode|string%(0) ""
+%unicode|string%(0) ""
+%unicode|string%(0) ""
+%unicode|string%(0) ""
+array(2) {
+ [%u|b%"basename"]=>
+ %unicode|string%(0) ""
+ [%u|b%"filename"]=>
+ %unicode|string%(0) ""
+}
+-- Iteration 2 --
+%unicode|string%(1) "."
+%unicode|string%(1) " "
+%unicode|string%(0) ""
+%unicode|string%(1) " "
+array(3) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(1) "."
+ [%u|b%"basename"]=>
+ %unicode|string%(1) " "
+ [%u|b%"filename"]=>
+ %unicode|string%(1) " "
+}
+-- Iteration 3 --
+%unicode|string%(1) "."
+%unicode|string%(2) "c:"
+%unicode|string%(0) ""
+%unicode|string%(2) "c:"
+array(3) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(1) "."
+ [%u|b%"basename"]=>
+ %unicode|string%(2) "c:"
+ [%u|b%"filename"]=>
+ %unicode|string%(2) "c:"
+}
+-- Iteration 4 --
+%unicode|string%(1) "."
+%unicode|string%(3) "c:\"
+%unicode|string%(0) ""
+%unicode|string%(3) "c:\"
+array(3) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(1) "."
+ [%u|b%"basename"]=>
+ %unicode|string%(3) "c:\"
+ [%u|b%"filename"]=>
+ %unicode|string%(3) "c:\"
+}
+-- Iteration 5 --
+%unicode|string%(1) "."
+%unicode|string%(2) "c:"
+%unicode|string%(0) ""
+%unicode|string%(2) "c:"
+array(3) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(1) "."
+ [%u|b%"basename"]=>
+ %unicode|string%(2) "c:"
+ [%u|b%"filename"]=>
+ %unicode|string%(2) "c:"
+}
+-- Iteration 6 --
+%unicode|string%(1) "."
+%unicode|string%(5) "afile"
+%unicode|string%(0) ""
+%unicode|string%(5) "afile"
+array(3) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(1) "."
+ [%u|b%"basename"]=>
+ %unicode|string%(5) "afile"
+ [%u|b%"filename"]=>
+ %unicode|string%(5) "afile"
+}
+-- Iteration 7 --
+%unicode|string%(1) "."
+%unicode|string%(12) "c:\test\adir"
+%unicode|string%(0) ""
+%unicode|string%(12) "c:\test\adir"
+array(3) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(1) "."
+ [%u|b%"basename"]=>
+ %unicode|string%(12) "c:\test\adir"
+ [%u|b%"filename"]=>
+ %unicode|string%(12) "c:\test\adir"
+}
+-- Iteration 8 --
+%unicode|string%(1) "."
+%unicode|string%(13) "c:\test\adir\"
+%unicode|string%(0) ""
+%unicode|string%(13) "c:\test\adir\"
+array(3) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(1) "."
+ [%u|b%"basename"]=>
+ %unicode|string%(13) "c:\test\adir\"
+ [%u|b%"filename"]=>
+ %unicode|string%(13) "c:\test\adir\"
+}
+-- Iteration 9 --
+%unicode|string%(12) "/usr/include"
+%unicode|string%(4) "arpa"
+%unicode|string%(0) ""
+%unicode|string%(4) "arpa"
+array(3) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(12) "/usr/include"
+ [%u|b%"basename"]=>
+ %unicode|string%(4) "arpa"
+ [%u|b%"filename"]=>
+ %unicode|string%(4) "arpa"
+}
+-- Iteration 10 --
+%unicode|string%(12) "/usr/include"
+%unicode|string%(4) "arpa"
+%unicode|string%(0) ""
+%unicode|string%(4) "arpa"
+array(3) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(12) "/usr/include"
+ [%u|b%"basename"]=>
+ %unicode|string%(4) "arpa"
+ [%u|b%"filename"]=>
+ %unicode|string%(4) "arpa"
+}
+-- Iteration 11 --
+%unicode|string%(11) "usr/include"
+%unicode|string%(4) "arpa"
+%unicode|string%(0) ""
+%unicode|string%(4) "arpa"
+array(3) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(11) "usr/include"
+ [%u|b%"basename"]=>
+ %unicode|string%(4) "arpa"
+ [%u|b%"filename"]=>
+ %unicode|string%(4) "arpa"
+}
+-- Iteration 12 --
+%unicode|string%(11) "usr/include"
+%unicode|string%(4) "arpa"
+%unicode|string%(0) ""
+%unicode|string%(4) "arpa"
+array(3) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(11) "usr/include"
+ [%u|b%"basename"]=>
+ %unicode|string%(4) "arpa"
+ [%u|b%"filename"]=>
+ %unicode|string%(4) "arpa"
+}
+-- Iteration 13 --
+%unicode|string%(1) "."
+%unicode|string%(13) "c:\test\afile"
+%unicode|string%(0) ""
+%unicode|string%(13) "c:\test\afile"
+array(3) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(1) "."
+ [%u|b%"basename"]=>
+ %unicode|string%(13) "c:\test\afile"
+ [%u|b%"filename"]=>
+ %unicode|string%(13) "c:\test\afile"
+}
+-- Iteration 14 --
+%unicode|string%(1) "."
+%unicode|string%(13) "c:\test\afile"
+%unicode|string%(0) ""
+%unicode|string%(13) "c:\test\afile"
+array(3) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(1) "."
+ [%u|b%"basename"]=>
+ %unicode|string%(13) "c:\test\afile"
+ [%u|b%"filename"]=>
+ %unicode|string%(13) "c:\test\afile"
+}
+-- Iteration 15 --
+%unicode|string%(8) "c://test"
+%unicode|string%(5) "afile"
+%unicode|string%(0) ""
+%unicode|string%(5) "afile"
+array(3) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(8) "c://test"
+ [%u|b%"basename"]=>
+ %unicode|string%(5) "afile"
+ [%u|b%"filename"]=>
+ %unicode|string%(5) "afile"
+}
+-- Iteration 16 --
+%unicode|string%(1) "."
+%unicode|string%(14) "c:\test\afile\"
+%unicode|string%(0) ""
+%unicode|string%(14) "c:\test\afile\"
+array(3) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(1) "."
+ [%u|b%"basename"]=>
+ %unicode|string%(14) "c:\test\afile\"
+ [%u|b%"filename"]=>
+ %unicode|string%(14) "c:\test\afile\"
+}
+-- Iteration 17 --
+%unicode|string%(1) "."
+%unicode|string%(16) "c:\test\prog.exe"
+%unicode|string%(3) "exe"
+%unicode|string%(12) "c:\test\prog"
+array(4) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(1) "."
+ [%u|b%"basename"]=>
+ %unicode|string%(16) "c:\test\prog.exe"
+ [%u|b%"extension"]=>
+ %unicode|string%(3) "exe"
+ [%u|b%"filename"]=>
+ %unicode|string%(12) "c:\test\prog"
+}
+-- Iteration 18 --
+%unicode|string%(1) "."
+%unicode|string%(16) "c:\test\prog.exe"
+%unicode|string%(3) "exe"
+%unicode|string%(12) "c:\test\prog"
+array(4) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(1) "."
+ [%u|b%"basename"]=>
+ %unicode|string%(16) "c:\test\prog.exe"
+ [%u|b%"extension"]=>
+ %unicode|string%(3) "exe"
+ [%u|b%"filename"]=>
+ %unicode|string%(12) "c:\test\prog"
+}
+-- Iteration 19 --
+%unicode|string%(7) "c:/test"
+%unicode|string%(8) "prog.exe"
+%unicode|string%(3) "exe"
+%unicode|string%(4) "prog"
+array(4) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(7) "c:/test"
+ [%u|b%"basename"]=>
+ %unicode|string%(8) "prog.exe"
+ [%u|b%"extension"]=>
+ %unicode|string%(3) "exe"
+ [%u|b%"filename"]=>
+ %unicode|string%(4) "prog"
+}
+-- Iteration 20 --
+%unicode|string%(17) "/usr/include/arpa"
+%unicode|string%(6) "inet.h"
+%unicode|string%(1) "h"
+%unicode|string%(4) "inet"
+array(4) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(17) "/usr/include/arpa"
+ [%u|b%"basename"]=>
+ %unicode|string%(6) "inet.h"
+ [%u|b%"extension"]=>
+ %unicode|string%(1) "h"
+ [%u|b%"filename"]=>
+ %unicode|string%(4) "inet"
+}
+-- Iteration 21 --
+%unicode|string%(19) "//usr/include//arpa"
+%unicode|string%(6) "inet.h"
+%unicode|string%(1) "h"
+%unicode|string%(4) "inet"
+array(4) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(19) "//usr/include//arpa"
+ [%u|b%"basename"]=>
+ %unicode|string%(6) "inet.h"
+ [%u|b%"extension"]=>
+ %unicode|string%(1) "h"
+ [%u|b%"filename"]=>
+ %unicode|string%(4) "inet"
+}
+-- Iteration 22 --
+%unicode|string%(1) "."
+%unicode|string%(1) "\"
+%unicode|string%(0) ""
+%unicode|string%(1) "\"
+array(3) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(1) "."
+ [%u|b%"basename"]=>
+ %unicode|string%(1) "\"
+ [%u|b%"filename"]=>
+ %unicode|string%(1) "\"
+}
+-- Iteration 23 --
+%unicode|string%(1) "."
+%unicode|string%(2) "\\"
+%unicode|string%(0) ""
+%unicode|string%(2) "\\"
+array(3) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(1) "."
+ [%u|b%"basename"]=>
+ %unicode|string%(2) "\\"
+ [%u|b%"filename"]=>
+ %unicode|string%(2) "\\"
+}
+-- Iteration 24 --
+%unicode|string%(1) "/"
+%unicode|string%(0) ""
+%unicode|string%(0) ""
+%unicode|string%(0) ""
+array(3) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(1) "/"
+ [%u|b%"basename"]=>
+ %unicode|string%(0) ""
+ [%u|b%"filename"]=>
+ %unicode|string%(0) ""
+}
+-- Iteration 25 --
+%unicode|string%(1) "/"
+%unicode|string%(0) ""
+%unicode|string%(0) ""
+%unicode|string%(0) ""
+array(3) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(1) "/"
+ [%u|b%"basename"]=>
+ %unicode|string%(0) ""
+ [%u|b%"filename"]=>
+ %unicode|string%(0) ""
+}
+-- Iteration 26 --
+%unicode|string%(1) "/"
+%unicode|string%(0) ""
+%unicode|string%(0) ""
+%unicode|string%(0) ""
+array(3) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(1) "/"
+ [%u|b%"basename"]=>
+ %unicode|string%(0) ""
+ [%u|b%"filename"]=>
+ %unicode|string%(0) ""
+}
+-- Iteration 27 --
+%unicode|string%(17) "/usr/include/arpa"
+%unicode|string%(6) "inet.h"
+%unicode|string%(1) "h"
+%unicode|string%(4) "inet"
+array(4) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(17) "/usr/include/arpa"
+ [%u|b%"basename"]=>
+ %unicode|string%(6) "inet.h"
+ [%u|b%"extension"]=>
+ %unicode|string%(1) "h"
+ [%u|b%"filename"]=>
+ %unicode|string%(4) "inet"
+}
+-- Iteration 28 --
+%unicode|string%(27) "c:\windows/system32\drivers"
+%unicode|string%(9) "etc\hosts"
+%unicode|string%(0) ""
+%unicode|string%(9) "etc\hosts"
+array(3) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(27) "c:\windows/system32\drivers"
+ [%u|b%"basename"]=>
+ %unicode|string%(9) "etc\hosts"
+ [%u|b%"filename"]=>
+ %unicode|string%(9) "etc\hosts"
+}
+-- Iteration 29 --
+%unicode|string%(12) "/usr\include"
+%unicode|string%(11) "arpa\inet.h"
+%unicode|string%(1) "h"
+%unicode|string%(9) "arpa\inet"
+array(4) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(12) "/usr\include"
+ [%u|b%"basename"]=>
+ %unicode|string%(11) "arpa\inet.h"
+ [%u|b%"extension"]=>
+ %unicode|string%(1) "h"
+ [%u|b%"filename"]=>
+ %unicode|string%(9) "arpa\inet"
+}
+-- Iteration 30 --
+%unicode|string%(1) "."
+%unicode|string%(25) " c:\test\adir\afile.txt"
+%unicode|string%(3) "txt"
+%unicode|string%(21) " c:\test\adir\afile"
+array(4) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(1) "."
+ [%u|b%"basename"]=>
+ %unicode|string%(25) " c:\test\adir\afile.txt"
+ [%u|b%"extension"]=>
+ %unicode|string%(3) "txt"
+ [%u|b%"filename"]=>
+ %unicode|string%(21) " c:\test\adir\afile"
+}
+-- Iteration 31 --
+%unicode|string%(1) "."
+%unicode|string%(25) "c:\test\adir\afile.txt "
+%unicode|string%(6) "txt "
+%unicode|string%(18) "c:\test\adir\afile"
+array(4) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(1) "."
+ [%u|b%"basename"]=>
+ %unicode|string%(25) "c:\test\adir\afile.txt "
+ [%u|b%"extension"]=>
+ %unicode|string%(6) "txt "
+ [%u|b%"filename"]=>
+ %unicode|string%(18) "c:\test\adir\afile"
+}
+-- Iteration 32 --
+%unicode|string%(1) "."
+%unicode|string%(28) " c:\test\adir\afile.txt "
+%unicode|string%(6) "txt "
+%unicode|string%(21) " c:\test\adir\afile"
+array(4) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(1) "."
+ [%u|b%"basename"]=>
+ %unicode|string%(28) " c:\test\adir\afile.txt "
+ [%u|b%"extension"]=>
+ %unicode|string%(6) "txt "
+ [%u|b%"filename"]=>
+ %unicode|string%(21) " c:\test\adir\afile"
+}
+-- Iteration 33 --
+%unicode|string%(20) " /usr/include/arpa"
+%unicode|string%(6) "inet.h"
+%unicode|string%(1) "h"
+%unicode|string%(4) "inet"
+array(4) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(20) " /usr/include/arpa"
+ [%u|b%"basename"]=>
+ %unicode|string%(6) "inet.h"
+ [%u|b%"extension"]=>
+ %unicode|string%(1) "h"
+ [%u|b%"filename"]=>
+ %unicode|string%(4) "inet"
+}
+-- Iteration 34 --
+%unicode|string%(17) "/usr/include/arpa"
+%unicode|string%(9) "inet.h "
+%unicode|string%(4) "h "
+%unicode|string%(4) "inet"
+array(4) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(17) "/usr/include/arpa"
+ [%u|b%"basename"]=>
+ %unicode|string%(9) "inet.h "
+ [%u|b%"extension"]=>
+ %unicode|string%(4) "h "
+ [%u|b%"filename"]=>
+ %unicode|string%(4) "inet"
+}
+-- Iteration 35 --
+%unicode|string%(20) " /usr/include/arpa"
+%unicode|string%(9) "inet.h "
+%unicode|string%(4) "h "
+%unicode|string%(4) "inet"
+array(4) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(20) " /usr/include/arpa"
+ [%u|b%"basename"]=>
+ %unicode|string%(9) "inet.h "
+ [%u|b%"extension"]=>
+ %unicode|string%(4) "h "
+ [%u|b%"filename"]=>
+ %unicode|string%(4) "inet"
+}
+-- Iteration 36 --
+%unicode|string%(1) "."
+%unicode|string%(3) " c:"
+%unicode|string%(0) ""
+%unicode|string%(3) " c:"
+array(3) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(1) "."
+ [%u|b%"basename"]=>
+ %unicode|string%(3) " c:"
+ [%u|b%"filename"]=>
+ %unicode|string%(3) " c:"
+}
+-- Iteration 37 --
+%unicode|string%(1) "."
+%unicode|string%(24) " c:\test\adir\afile.txt"
+%unicode|string%(3) "txt"
+%unicode|string%(20) " c:\test\adir\afile"
+array(4) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(1) "."
+ [%u|b%"basename"]=>
+ %unicode|string%(24) " c:\test\adir\afile.txt"
+ [%u|b%"extension"]=>
+ %unicode|string%(3) "txt"
+ [%u|b%"filename"]=>
+ %unicode|string%(20) " c:\test\adir\afile"
+}
+-- Iteration 38 --
+%unicode|string%(1) "/"
+%unicode|string%(3) "usr"
+%unicode|string%(0) ""
+%unicode|string%(3) "usr"
+array(3) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(1) "/"
+ [%u|b%"basename"]=>
+ %unicode|string%(3) "usr"
+ [%u|b%"filename"]=>
+ %unicode|string%(3) "usr"
+}
+-- Iteration 39 --
+%unicode|string%(1) "/"
+%unicode|string%(3) "usr"
+%unicode|string%(0) ""
+%unicode|string%(3) "usr"
+array(3) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(1) "/"
+ [%u|b%"basename"]=>
+ %unicode|string%(3) "usr"
+ [%u|b%"filename"]=>
+ %unicode|string%(3) "usr"
+}
+Done
+
diff --git a/ext/standard/tests/file/pathinfo_basic2-win32.phpt b/ext/standard/tests/file/pathinfo_basic2-win32.phpt
new file mode 100644
index 0000000..c88bc25
--- /dev/null
+++ b/ext/standard/tests/file/pathinfo_basic2-win32.phpt
@@ -0,0 +1,270 @@
+--TEST--
+Test pathinfo() function: basic functionality
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+ die("skip Only valid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype: mixed pathinfo ( string $path [, int $options] );
+ Description: Returns information about a file path
+*/
+
+echo "*** Testing basic functions of pathinfo() ***\n";
+
+$paths = array (
+ 'c:\..\dir1',
+ 'c:\test\..\test2\.\adir\afile.txt',
+ '/usr/include/../arpa/./inet.h',
+ 'c:\test\adir\afile..txt',
+ '/usr/include/arpa/inet..h',
+ 'c:\test\adir\afile.',
+ '/usr/include/arpa/inet.',
+ '/usr/include/arpa/inet,h',
+ 'c:afile.txt',
+ '..\.\..\test\afile.txt',
+ '.././../test/afile',
+ '.',
+ '..',
+ '...',
+ '/usr/lib/.../afile'
+
+);
+
+$counter = 1;
+/* loop through $paths to test each $path in the above array */
+foreach($paths as $path) {
+ echo "-- Iteration $counter --\n";
+ var_dump( pathinfo($path, PATHINFO_DIRNAME) );
+ var_dump( pathinfo($path, PATHINFO_BASENAME) );
+ var_dump( pathinfo($path, PATHINFO_EXTENSION) );
+ var_dump( pathinfo($path, PATHINFO_FILENAME) );
+ var_dump( pathinfo($path) );
+ $counter++;
+}
+
+echo "Done\n";
+?>
+--EXPECT--
+*** Testing basic functions of pathinfo() ***
+-- Iteration 1 --
+string(5) "c:\.."
+string(4) "dir1"
+string(0) ""
+string(4) "dir1"
+array(3) {
+ ["dirname"]=>
+ string(5) "c:\.."
+ ["basename"]=>
+ string(4) "dir1"
+ ["filename"]=>
+ string(4) "dir1"
+}
+-- Iteration 2 --
+string(23) "c:\test\..\test2\.\adir"
+string(9) "afile.txt"
+string(3) "txt"
+string(5) "afile"
+array(4) {
+ ["dirname"]=>
+ string(23) "c:\test\..\test2\.\adir"
+ ["basename"]=>
+ string(9) "afile.txt"
+ ["extension"]=>
+ string(3) "txt"
+ ["filename"]=>
+ string(5) "afile"
+}
+-- Iteration 3 --
+string(22) "/usr/include/../arpa/."
+string(6) "inet.h"
+string(1) "h"
+string(4) "inet"
+array(4) {
+ ["dirname"]=>
+ string(22) "/usr/include/../arpa/."
+ ["basename"]=>
+ string(6) "inet.h"
+ ["extension"]=>
+ string(1) "h"
+ ["filename"]=>
+ string(4) "inet"
+}
+-- Iteration 4 --
+string(12) "c:\test\adir"
+string(10) "afile..txt"
+string(3) "txt"
+string(6) "afile."
+array(4) {
+ ["dirname"]=>
+ string(12) "c:\test\adir"
+ ["basename"]=>
+ string(10) "afile..txt"
+ ["extension"]=>
+ string(3) "txt"
+ ["filename"]=>
+ string(6) "afile."
+}
+-- Iteration 5 --
+string(17) "/usr/include/arpa"
+string(7) "inet..h"
+string(1) "h"
+string(5) "inet."
+array(4) {
+ ["dirname"]=>
+ string(17) "/usr/include/arpa"
+ ["basename"]=>
+ string(7) "inet..h"
+ ["extension"]=>
+ string(1) "h"
+ ["filename"]=>
+ string(5) "inet."
+}
+-- Iteration 6 --
+string(12) "c:\test\adir"
+string(6) "afile."
+string(0) ""
+string(5) "afile"
+array(4) {
+ ["dirname"]=>
+ string(12) "c:\test\adir"
+ ["basename"]=>
+ string(6) "afile."
+ ["extension"]=>
+ string(0) ""
+ ["filename"]=>
+ string(5) "afile"
+}
+-- Iteration 7 --
+string(17) "/usr/include/arpa"
+string(5) "inet."
+string(0) ""
+string(4) "inet"
+array(4) {
+ ["dirname"]=>
+ string(17) "/usr/include/arpa"
+ ["basename"]=>
+ string(5) "inet."
+ ["extension"]=>
+ string(0) ""
+ ["filename"]=>
+ string(4) "inet"
+}
+-- Iteration 8 --
+string(17) "/usr/include/arpa"
+string(6) "inet,h"
+string(0) ""
+string(6) "inet,h"
+array(3) {
+ ["dirname"]=>
+ string(17) "/usr/include/arpa"
+ ["basename"]=>
+ string(6) "inet,h"
+ ["filename"]=>
+ string(6) "inet,h"
+}
+-- Iteration 9 --
+string(3) "c:."
+string(11) "c:afile.txt"
+string(3) "txt"
+string(7) "c:afile"
+array(4) {
+ ["dirname"]=>
+ string(3) "c:."
+ ["basename"]=>
+ string(11) "c:afile.txt"
+ ["extension"]=>
+ string(3) "txt"
+ ["filename"]=>
+ string(7) "c:afile"
+}
+-- Iteration 10 --
+string(12) "..\.\..\test"
+string(9) "afile.txt"
+string(3) "txt"
+string(5) "afile"
+array(4) {
+ ["dirname"]=>
+ string(12) "..\.\..\test"
+ ["basename"]=>
+ string(9) "afile.txt"
+ ["extension"]=>
+ string(3) "txt"
+ ["filename"]=>
+ string(5) "afile"
+}
+-- Iteration 11 --
+string(12) ".././../test"
+string(5) "afile"
+string(0) ""
+string(5) "afile"
+array(3) {
+ ["dirname"]=>
+ string(12) ".././../test"
+ ["basename"]=>
+ string(5) "afile"
+ ["filename"]=>
+ string(5) "afile"
+}
+-- Iteration 12 --
+string(1) "."
+string(1) "."
+string(0) ""
+string(0) ""
+array(4) {
+ ["dirname"]=>
+ string(1) "."
+ ["basename"]=>
+ string(1) "."
+ ["extension"]=>
+ string(0) ""
+ ["filename"]=>
+ string(0) ""
+}
+-- Iteration 13 --
+string(1) "."
+string(2) ".."
+string(0) ""
+string(1) "."
+array(4) {
+ ["dirname"]=>
+ string(1) "."
+ ["basename"]=>
+ string(2) ".."
+ ["extension"]=>
+ string(0) ""
+ ["filename"]=>
+ string(1) "."
+}
+-- Iteration 14 --
+string(1) "."
+string(3) "..."
+string(0) ""
+string(2) ".."
+array(4) {
+ ["dirname"]=>
+ string(1) "."
+ ["basename"]=>
+ string(3) "..."
+ ["extension"]=>
+ string(0) ""
+ ["filename"]=>
+ string(2) ".."
+}
+-- Iteration 15 --
+string(12) "/usr/lib/..."
+string(5) "afile"
+string(0) ""
+string(5) "afile"
+array(3) {
+ ["dirname"]=>
+ string(12) "/usr/lib/..."
+ ["basename"]=>
+ string(5) "afile"
+ ["filename"]=>
+ string(5) "afile"
+}
+Done \ No newline at end of file
diff --git a/ext/standard/tests/file/pathinfo_basic2.phpt b/ext/standard/tests/file/pathinfo_basic2.phpt
new file mode 100644
index 0000000..23c0768
--- /dev/null
+++ b/ext/standard/tests/file/pathinfo_basic2.phpt
@@ -0,0 +1,273 @@
+--TEST--
+Test pathinfo() function: basic functionality
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+ die("skip Not valid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype: mixed pathinfo ( string $path [, int $options] );
+ Description: Returns information about a file path
+*/
+
+echo "*** Testing basic functions of pathinfo() ***\n";
+
+$paths = array (
+ 'c:\..\dir1',
+ 'c:\test\..\test2\.\adir\afile.txt',
+ '/usr/include/../arpa/./inet.h',
+ 'c:\test\adir\afile..txt',
+ '/usr/include/arpa/inet..h',
+ 'c:\test\adir\afile.',
+ '/usr/include/arpa/inet.',
+ '/usr/include/arpa/inet,h',
+ 'c:afile.txt',
+ '..\.\..\test\afile.txt',
+ '.././../test/afile',
+ '.',
+ '..',
+ '...',
+ '/usr/lib/.../afile'
+
+);
+
+$counter = 1;
+/* loop through $paths to test each $path in the above array */
+foreach($paths as $path) {
+ echo "-- Iteration $counter --\n";
+ var_dump( pathinfo($path, PATHINFO_DIRNAME) );
+ var_dump( pathinfo($path, PATHINFO_BASENAME) );
+ var_dump( pathinfo($path, PATHINFO_EXTENSION) );
+ var_dump( pathinfo($path, PATHINFO_FILENAME) );
+ var_dump( pathinfo($path) );
+ $counter++;
+}
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing basic functions of pathinfo() ***
+-- Iteration 1 --
+%unicode|string%(1) "."
+%unicode|string%(10) "c:\..\dir1"
+%unicode|string%(5) "\dir1"
+%unicode|string%(4) "c:\."
+array(4) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(1) "."
+ [%u|b%"basename"]=>
+ %unicode|string%(10) "c:\..\dir1"
+ [%u|b%"extension"]=>
+ %unicode|string%(5) "\dir1"
+ [%u|b%"filename"]=>
+ %unicode|string%(4) "c:\."
+}
+-- Iteration 2 --
+%unicode|string%(1) "."
+%unicode|string%(33) "c:\test\..\test2\.\adir\afile.txt"
+%unicode|string%(3) "txt"
+%unicode|string%(29) "c:\test\..\test2\.\adir\afile"
+array(4) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(1) "."
+ [%u|b%"basename"]=>
+ %unicode|string%(33) "c:\test\..\test2\.\adir\afile.txt"
+ [%u|b%"extension"]=>
+ %unicode|string%(3) "txt"
+ [%u|b%"filename"]=>
+ %unicode|string%(29) "c:\test\..\test2\.\adir\afile"
+}
+-- Iteration 3 --
+%unicode|string%(22) "/usr/include/../arpa/."
+%unicode|string%(6) "inet.h"
+%unicode|string%(1) "h"
+%unicode|string%(4) "inet"
+array(4) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(22) "/usr/include/../arpa/."
+ [%u|b%"basename"]=>
+ %unicode|string%(6) "inet.h"
+ [%u|b%"extension"]=>
+ %unicode|string%(1) "h"
+ [%u|b%"filename"]=>
+ %unicode|string%(4) "inet"
+}
+-- Iteration 4 --
+%unicode|string%(1) "."
+%unicode|string%(23) "c:\test\adir\afile..txt"
+%unicode|string%(3) "txt"
+%unicode|string%(19) "c:\test\adir\afile."
+array(4) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(1) "."
+ [%u|b%"basename"]=>
+ %unicode|string%(23) "c:\test\adir\afile..txt"
+ [%u|b%"extension"]=>
+ %unicode|string%(3) "txt"
+ [%u|b%"filename"]=>
+ %unicode|string%(19) "c:\test\adir\afile."
+}
+-- Iteration 5 --
+%unicode|string%(17) "/usr/include/arpa"
+%unicode|string%(7) "inet..h"
+%unicode|string%(1) "h"
+%unicode|string%(5) "inet."
+array(4) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(17) "/usr/include/arpa"
+ [%u|b%"basename"]=>
+ %unicode|string%(7) "inet..h"
+ [%u|b%"extension"]=>
+ %unicode|string%(1) "h"
+ [%u|b%"filename"]=>
+ %unicode|string%(5) "inet."
+}
+-- Iteration 6 --
+%unicode|string%(1) "."
+%unicode|string%(19) "c:\test\adir\afile."
+%unicode|string%(0) ""
+%unicode|string%(18) "c:\test\adir\afile"
+array(4) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(1) "."
+ [%u|b%"basename"]=>
+ %unicode|string%(19) "c:\test\adir\afile."
+ [%u|b%"extension"]=>
+ %unicode|string%(0) ""
+ [%u|b%"filename"]=>
+ %unicode|string%(18) "c:\test\adir\afile"
+}
+-- Iteration 7 --
+%unicode|string%(17) "/usr/include/arpa"
+%unicode|string%(5) "inet."
+%unicode|string%(0) ""
+%unicode|string%(4) "inet"
+array(4) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(17) "/usr/include/arpa"
+ [%u|b%"basename"]=>
+ %unicode|string%(5) "inet."
+ [%u|b%"extension"]=>
+ %unicode|string%(0) ""
+ [%u|b%"filename"]=>
+ %unicode|string%(4) "inet"
+}
+-- Iteration 8 --
+%unicode|string%(17) "/usr/include/arpa"
+%unicode|string%(6) "inet,h"
+%unicode|string%(0) ""
+%unicode|string%(6) "inet,h"
+array(3) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(17) "/usr/include/arpa"
+ [%u|b%"basename"]=>
+ %unicode|string%(6) "inet,h"
+ [%u|b%"filename"]=>
+ %unicode|string%(6) "inet,h"
+}
+-- Iteration 9 --
+%unicode|string%(1) "."
+%unicode|string%(11) "c:afile.txt"
+%unicode|string%(3) "txt"
+%unicode|string%(7) "c:afile"
+array(4) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(1) "."
+ [%u|b%"basename"]=>
+ %unicode|string%(11) "c:afile.txt"
+ [%u|b%"extension"]=>
+ %unicode|string%(3) "txt"
+ [%u|b%"filename"]=>
+ %unicode|string%(7) "c:afile"
+}
+-- Iteration 10 --
+%unicode|string%(1) "."
+%unicode|string%(22) "..\.\..\test\afile.txt"
+%unicode|string%(3) "txt"
+%unicode|string%(18) "..\.\..\test\afile"
+array(4) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(1) "."
+ [%u|b%"basename"]=>
+ %unicode|string%(22) "..\.\..\test\afile.txt"
+ [%u|b%"extension"]=>
+ %unicode|string%(3) "txt"
+ [%u|b%"filename"]=>
+ %unicode|string%(18) "..\.\..\test\afile"
+}
+-- Iteration 11 --
+%unicode|string%(12) ".././../test"
+%unicode|string%(5) "afile"
+%unicode|string%(0) ""
+%unicode|string%(5) "afile"
+array(3) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(12) ".././../test"
+ [%u|b%"basename"]=>
+ %unicode|string%(5) "afile"
+ [%u|b%"filename"]=>
+ %unicode|string%(5) "afile"
+}
+-- Iteration 12 --
+%unicode|string%(1) "."
+%unicode|string%(1) "."
+%unicode|string%(0) ""
+%unicode|string%(0) ""
+array(4) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(1) "."
+ [%u|b%"basename"]=>
+ %unicode|string%(1) "."
+ [%u|b%"extension"]=>
+ %unicode|string%(0) ""
+ [%u|b%"filename"]=>
+ %unicode|string%(0) ""
+}
+-- Iteration 13 --
+%unicode|string%(1) "."
+%unicode|string%(2) ".."
+%unicode|string%(0) ""
+%unicode|string%(1) "."
+array(4) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(1) "."
+ [%u|b%"basename"]=>
+ %unicode|string%(2) ".."
+ [%u|b%"extension"]=>
+ %unicode|string%(0) ""
+ [%u|b%"filename"]=>
+ %unicode|string%(1) "."
+}
+-- Iteration 14 --
+%unicode|string%(1) "."
+%unicode|string%(3) "..."
+%unicode|string%(0) ""
+%unicode|string%(2) ".."
+array(4) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(1) "."
+ [%u|b%"basename"]=>
+ %unicode|string%(3) "..."
+ [%u|b%"extension"]=>
+ %unicode|string%(0) ""
+ [%u|b%"filename"]=>
+ %unicode|string%(2) ".."
+}
+-- Iteration 15 --
+%unicode|string%(12) "/usr/lib/..."
+%unicode|string%(5) "afile"
+%unicode|string%(0) ""
+%unicode|string%(5) "afile"
+array(3) {
+ [%u|b%"dirname"]=>
+ %unicode|string%(12) "/usr/lib/..."
+ [%u|b%"basename"]=>
+ %unicode|string%(5) "afile"
+ [%u|b%"filename"]=>
+ %unicode|string%(5) "afile"
+}
+Done
+
diff --git a/ext/standard/tests/file/pathinfo_error.phpt b/ext/standard/tests/file/pathinfo_error.phpt
new file mode 100644
index 0000000..903fc5b
--- /dev/null
+++ b/ext/standard/tests/file/pathinfo_error.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Test pathinfo() function: error conditions
+--FILE--
+<?php
+/* Prototype: mixed pathinfo ( string $path [, int $options] );
+ Description: Returns information about a file path
+*/
+
+echo "*** Testing pathinfo() for error conditions ***\n";
+/* unexpected no. of arguments */
+var_dump( pathinfo() ); /* args < expected */
+var_dump( pathinfo("/home/1.html", 1, 3) ); /* args > expected */
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing pathinfo() for error conditions ***
+
+Warning: pathinfo() expects at least 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: pathinfo() expects at most 2 parameters, 3 given in %s on line %d
+NULL
+Done
diff --git a/ext/standard/tests/file/pathinfo_variation1.phpt b/ext/standard/tests/file/pathinfo_variation1.phpt
new file mode 100644
index 0000000..ff4c1eb
--- /dev/null
+++ b/ext/standard/tests/file/pathinfo_variation1.phpt
@@ -0,0 +1,190 @@
+--TEST--
+Test pathinfo() function : usage variation
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : array pathinfo(string path[, int options])
+ * Description: Returns information about a certain string
+ * Source code: ext/standard/string.c
+ * Alias to functions:
+ */
+
+echo "*** Testing pathinfo() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$options = PATHINFO_DIRNAME;
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+ // int data
+ 'int 0' => 0,
+ 'int 1' => 1,
+ 'int 12345' => 12345,
+ 'int -12345' => -2345,
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float -10.5' => -10.5,
+ 'float 12.3456789000e10' => 12.3456789000e10,
+ 'float -12.3456789000e10' => -12.3456789000e10,
+ 'float .5' => .5,
+
+ // array data
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for path
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( pathinfo($value, $options) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing pathinfo() : usage variation ***
+
+--int 0--
+string(1) "."
+
+--int 1--
+string(1) "."
+
+--int 12345--
+string(1) "."
+
+--int -12345--
+string(1) "."
+
+--float 10.5--
+string(1) "."
+
+--float -10.5--
+string(1) "."
+
+--float 12.3456789000e10--
+string(1) "."
+
+--float -12.3456789000e10--
+string(1) "."
+
+--float .5--
+string(1) "."
+
+--empty array--
+Error: 2 - pathinfo() expects parameter 1 to be string, array given, %s(%d)
+NULL
+
+--int indexed array--
+Error: 2 - pathinfo() expects parameter 1 to be string, array given, %s(%d)
+NULL
+
+--associative array--
+Error: 2 - pathinfo() expects parameter 1 to be string, array given, %s(%d)
+NULL
+
+--nested arrays--
+Error: 2 - pathinfo() expects parameter 1 to be string, array given, %s(%d)
+NULL
+
+--uppercase NULL--
+string(0) ""
+
+--lowercase null--
+string(0) ""
+
+--lowercase true--
+string(1) "."
+
+--lowercase false--
+string(0) ""
+
+--uppercase TRUE--
+string(1) "."
+
+--uppercase FALSE--
+string(0) ""
+
+--empty string DQ--
+string(0) ""
+
+--empty string SQ--
+string(0) ""
+
+--instance of classWithToString--
+string(1) "."
+
+--instance of classWithoutToString--
+Error: 2 - pathinfo() expects parameter 1 to be string, object given, %s(%d)
+NULL
+
+--undefined var--
+string(0) ""
+
+--unset var--
+string(0) ""
+===DONE===
diff --git a/ext/standard/tests/file/pathinfo_variation2.phpt b/ext/standard/tests/file/pathinfo_variation2.phpt
new file mode 100644
index 0000000..9d18a4b
--- /dev/null
+++ b/ext/standard/tests/file/pathinfo_variation2.phpt
@@ -0,0 +1,197 @@
+--TEST--
+Test pathinfo() function : usage variation
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : array pathinfo(string path[, int options])
+ * Description: Returns information about a certain string
+ * Source code: ext/standard/string.c
+ * Alias to functions:
+ */
+
+echo "*** Testing pathinfo() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$path = '/usr/include/arpa/inet.h';
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float -10.5' => -10.5,
+ 'float 12.3456789000e10' => 12.3456789000e10,
+ 'float -12.3456789000e10' => -12.3456789000e10,
+ 'float .5' => .5,
+
+ // array data
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // string data
+ 'string DQ' => "string",
+ 'string SQ' => 'string',
+ 'mixed case string' => "sTrInG",
+ 'heredoc' => $heredoc,
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for options
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( pathinfo($path, $value) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing pathinfo() : usage variation ***
+
+--float 10.5--
+string(6) "inet.h"
+
+--float -10.5--
+string(6) "inet.h"
+
+--float 12.3456789000e10--
+string(%d) %s
+
+--float -12.3456789000e10--
+string(%d) %s
+
+--float .5--
+string(%d) %s
+
+--empty array--
+Error: 2 - pathinfo() expects parameter 2 to be long, array given, %s(%d)
+NULL
+
+--int indexed array--
+Error: 2 - pathinfo() expects parameter 2 to be long, array given, %s(%d)
+NULL
+
+--associative array--
+Error: 2 - pathinfo() expects parameter 2 to be long, array given, %s(%d)
+NULL
+
+--nested arrays--
+Error: 2 - pathinfo() expects parameter 2 to be long, array given, %s(%d)
+NULL
+
+--uppercase NULL--
+string(0) ""
+
+--lowercase null--
+string(0) ""
+
+--lowercase true--
+string(17) "/usr/include/arpa"
+
+--lowercase false--
+string(0) ""
+
+--uppercase TRUE--
+string(17) "/usr/include/arpa"
+
+--uppercase FALSE--
+string(0) ""
+
+--empty string DQ--
+Error: 2 - pathinfo() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--empty string SQ--
+Error: 2 - pathinfo() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--string DQ--
+Error: 2 - pathinfo() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--string SQ--
+Error: 2 - pathinfo() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--mixed case string--
+Error: 2 - pathinfo() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--heredoc--
+Error: 2 - pathinfo() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--instance of classWithToString--
+Error: 2 - pathinfo() expects parameter 2 to be long, object given, %s(%d)
+NULL
+
+--instance of classWithoutToString--
+Error: 2 - pathinfo() expects parameter 2 to be long, object given, %s(%d)
+NULL
+
+--undefined var--
+string(0) ""
+
+--unset var--
+string(0) ""
+===DONE===
diff --git a/ext/standard/tests/file/pathinfo_variation3.phpt b/ext/standard/tests/file/pathinfo_variation3.phpt
new file mode 100644
index 0000000..333aa56
--- /dev/null
+++ b/ext/standard/tests/file/pathinfo_variation3.phpt
@@ -0,0 +1,80 @@
+--TEST--
+Test pathinfo() function : usage variation
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : array pathinfo(string path[, int options])
+ * Description: Returns information about a certain string
+ * Source code: ext/standard/string.c
+ * Alias to functions:
+ */
+
+echo "*** Testing pathinfo() : usage variation ***\n";
+
+$testfile = "/usr/include/arpa/inet.h";
+
+var_dump(pathinfo("./"));
+var_dump(pathinfo("/."));
+var_dump(pathinfo(".cvsignore"));
+var_dump(pathinfo($testfile, PATHINFO_BASENAME));
+var_dump(pathinfo($testfile, PATHINFO_FILENAME));
+var_dump(pathinfo($testfile, PATHINFO_EXTENSION));
+var_dump(pathinfo($testfile, PATHINFO_DIRNAME));
+var_dump(pathinfo($testfile, PATHINFO_EXTENSION|PATHINFO_FILENAME|PATHINFO_DIRNAME));
+var_dump(pathinfo($testfile, PATHINFO_EXTENSION|PATHINFO_FILENAME|PATHINFO_BASENAME));
+var_dump(pathinfo($testfile, PATHINFO_EXTENSION|PATHINFO_FILENAME));
+var_dump(pathinfo($testfile, PATHINFO_EXTENSION|PATHINFO_BASENAME));
+var_dump(pathinfo($testfile, PATHINFO_FILENAME|PATHINFO_DIRNAME));
+var_dump(pathinfo($testfile, PATHINFO_FILENAME|PATHINFO_BASENAME));
+var_dump(pathinfo($testfile, PATHINFO_DIRNAME|PATHINFO_EXTENSION));
+var_dump(pathinfo($testfile, PATHINFO_DIRNAME|PATHINFO_BASENAME));
+
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing pathinfo() : usage variation ***
+array(4) {
+ ["dirname"]=>
+ string(1) "."
+ ["basename"]=>
+ string(1) "."
+ ["extension"]=>
+ string(0) ""
+ ["filename"]=>
+ string(0) ""
+}
+array(4) {
+ ["dirname"]=>
+ string(1) "%s"
+ ["basename"]=>
+ string(1) "."
+ ["extension"]=>
+ string(0) ""
+ ["filename"]=>
+ string(0) ""
+}
+array(4) {
+ ["dirname"]=>
+ string(1) "."
+ ["basename"]=>
+ string(10) ".cvsignore"
+ ["extension"]=>
+ string(9) "cvsignore"
+ ["filename"]=>
+ string(0) ""
+}
+string(6) "inet.h"
+string(4) "inet"
+string(1) "h"
+string(17) "/usr/include/arpa"
+string(17) "/usr/include/arpa"
+string(6) "inet.h"
+string(1) "h"
+string(6) "inet.h"
+string(17) "/usr/include/arpa"
+string(6) "inet.h"
+string(17) "/usr/include/arpa"
+string(17) "/usr/include/arpa"
+===DONE=== \ No newline at end of file
diff --git a/ext/standard/tests/file/pathinfo_variaton.phpt b/ext/standard/tests/file/pathinfo_variaton.phpt
new file mode 100644
index 0000000..d6c6c77
--- /dev/null
+++ b/ext/standard/tests/file/pathinfo_variaton.phpt
@@ -0,0 +1,442 @@
+--TEST--
+Test pathinfo() function: usage variations
+--FILE--
+<?php
+/* Prototype: mixed pathinfo ( string $path [, int $options] );
+ Description: Returns information about a file path
+*/
+
+echo "*** Testing pathinfo() with miscelleneous input arguments ***\n";
+
+$fp = fopen(__FILE__, "r");
+unset($fp);
+
+class object_temp {
+ public $url_var = "www.foo.com";
+ var $html_var = "/var/html/testdir/example.html";
+ var $dir_var = "/testdir/foo/test/";
+ public $file_var = "/foo//symlink.link";
+ var $number = 12345;
+}
+$obj = new object_temp();
+
+$path_arr = array (
+ "www.example.com",
+ "/testdir/foo//test/",
+ "../foo/test.link",
+ "./test/work/scratch/mydir/yourdir/ourdir/test1/test2/test3/test4/test5/test6/test.tmp",
+ 2.345
+);
+
+$paths = array (
+ /* pathname containing numeric string */
+ 0,
+ 1234,
+ -1234,
+ 2.3456,
+
+ /* pathname as boolean */
+ TRUE,
+ FALSE,
+
+ /* pathname as an array */
+ "./array(1, 2)",
+ "array( array(), null)",
+
+ /* pathname as object */
+ $obj,
+
+ /* pathname as spaces */
+ " ",
+ ' ',
+
+ /* empty pathname */
+ "",
+ '',
+
+ /* pathname as NULL */
+ NULL,
+ null,
+
+ /* filename as resource */
+ $fp,
+
+ /* pathname as members of object */
+ $obj->url_var,
+ $obj->html_var,
+ $obj->dir_var,
+ $obj->file_var,
+ $obj->number,
+
+ /* pathname as member of array */
+ $path_arr[0],
+ $path_arr[1],
+ $path_arr[2],
+ $path_arr[3],
+ $path_arr[4]
+);
+
+$counter = 1;
+/* loop through $paths to test each $path in the above array */
+foreach($paths as $path) {
+ echo "-- Iteration $counter --\n";
+ var_dump( pathinfo($path) );
+ var_dump( pathinfo($path, PATHINFO_DIRNAME) );
+ var_dump( pathinfo($path, PATHINFO_BASENAME) );
+ var_dump( pathinfo($path, PATHINFO_EXTENSION) );
+ var_dump( pathinfo($path, PATHINFO_FILENAME) );
+ $counter++;
+}
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing pathinfo() with miscelleneous input arguments ***
+
+Notice: Undefined variable: fp in %s on line %d
+-- Iteration 1 --
+array(3) {
+ ["dirname"]=>
+ string(1) "."
+ ["basename"]=>
+ string(1) "0"
+ ["filename"]=>
+ string(1) "0"
+}
+string(1) "."
+string(1) "0"
+string(0) ""
+string(1) "0"
+-- Iteration 2 --
+array(3) {
+ ["dirname"]=>
+ string(1) "."
+ ["basename"]=>
+ string(4) "1234"
+ ["filename"]=>
+ string(4) "1234"
+}
+string(1) "."
+string(4) "1234"
+string(0) ""
+string(4) "1234"
+-- Iteration 3 --
+array(3) {
+ ["dirname"]=>
+ string(1) "."
+ ["basename"]=>
+ string(5) "-1234"
+ ["filename"]=>
+ string(5) "-1234"
+}
+string(1) "."
+string(5) "-1234"
+string(0) ""
+string(5) "-1234"
+-- Iteration 4 --
+array(4) {
+ ["dirname"]=>
+ string(1) "."
+ ["basename"]=>
+ string(6) "2.3456"
+ ["extension"]=>
+ string(4) "3456"
+ ["filename"]=>
+ string(1) "2"
+}
+string(1) "."
+string(6) "2.3456"
+string(4) "3456"
+string(1) "2"
+-- Iteration 5 --
+array(3) {
+ ["dirname"]=>
+ string(1) "."
+ ["basename"]=>
+ string(1) "1"
+ ["filename"]=>
+ string(1) "1"
+}
+string(1) "."
+string(1) "1"
+string(0) ""
+string(1) "1"
+-- Iteration 6 --
+array(2) {
+ ["basename"]=>
+ string(0) ""
+ ["filename"]=>
+ string(0) ""
+}
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+-- Iteration 7 --
+array(3) {
+ ["dirname"]=>
+ string(1) "."
+ ["basename"]=>
+ string(11) "array(1, 2)"
+ ["filename"]=>
+ string(11) "array(1, 2)"
+}
+string(1) "."
+string(11) "array(1, 2)"
+string(0) ""
+string(11) "array(1, 2)"
+-- Iteration 8 --
+array(3) {
+ ["dirname"]=>
+ string(1) "."
+ ["basename"]=>
+ string(21) "array( array(), null)"
+ ["filename"]=>
+ string(21) "array( array(), null)"
+}
+string(1) "."
+string(21) "array( array(), null)"
+string(0) ""
+string(21) "array( array(), null)"
+-- Iteration 9 --
+
+Warning: pathinfo() expects parameter 1 to be string, object given in %s on line %d
+NULL
+
+Warning: pathinfo() expects parameter 1 to be string, object given in %s on line %d
+NULL
+
+Warning: pathinfo() expects parameter 1 to be string, object given in %s on line %d
+NULL
+
+Warning: pathinfo() expects parameter 1 to be string, object given in %s on line %d
+NULL
+
+Warning: pathinfo() expects parameter 1 to be string, object given in %s on line %d
+NULL
+-- Iteration 10 --
+array(3) {
+ ["dirname"]=>
+ string(1) "."
+ ["basename"]=>
+ string(1) " "
+ ["filename"]=>
+ string(1) " "
+}
+string(1) "."
+string(1) " "
+string(0) ""
+string(1) " "
+-- Iteration 11 --
+array(3) {
+ ["dirname"]=>
+ string(1) "."
+ ["basename"]=>
+ string(1) " "
+ ["filename"]=>
+ string(1) " "
+}
+string(1) "."
+string(1) " "
+string(0) ""
+string(1) " "
+-- Iteration 12 --
+array(2) {
+ ["basename"]=>
+ string(0) ""
+ ["filename"]=>
+ string(0) ""
+}
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+-- Iteration 13 --
+array(2) {
+ ["basename"]=>
+ string(0) ""
+ ["filename"]=>
+ string(0) ""
+}
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+-- Iteration 14 --
+array(2) {
+ ["basename"]=>
+ string(0) ""
+ ["filename"]=>
+ string(0) ""
+}
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+-- Iteration 15 --
+array(2) {
+ ["basename"]=>
+ string(0) ""
+ ["filename"]=>
+ string(0) ""
+}
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+-- Iteration 16 --
+array(2) {
+ ["basename"]=>
+ string(0) ""
+ ["filename"]=>
+ string(0) ""
+}
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+-- Iteration 17 --
+array(4) {
+ ["dirname"]=>
+ string(1) "."
+ ["basename"]=>
+ string(11) "www.foo.com"
+ ["extension"]=>
+ string(3) "com"
+ ["filename"]=>
+ string(7) "www.foo"
+}
+string(1) "."
+string(11) "www.foo.com"
+string(3) "com"
+string(7) "www.foo"
+-- Iteration 18 --
+array(4) {
+ ["dirname"]=>
+ string(17) "/var/html/testdir"
+ ["basename"]=>
+ string(12) "example.html"
+ ["extension"]=>
+ string(4) "html"
+ ["filename"]=>
+ string(7) "example"
+}
+string(17) "/var/html/testdir"
+string(12) "example.html"
+string(4) "html"
+string(7) "example"
+-- Iteration 19 --
+array(3) {
+ ["dirname"]=>
+ string(12) "/testdir/foo"
+ ["basename"]=>
+ string(4) "test"
+ ["filename"]=>
+ string(4) "test"
+}
+string(12) "/testdir/foo"
+string(4) "test"
+string(0) ""
+string(4) "test"
+-- Iteration 20 --
+array(4) {
+ ["dirname"]=>
+ string(4) "/foo"
+ ["basename"]=>
+ string(12) "symlink.link"
+ ["extension"]=>
+ string(4) "link"
+ ["filename"]=>
+ string(7) "symlink"
+}
+string(4) "/foo"
+string(12) "symlink.link"
+string(4) "link"
+string(7) "symlink"
+-- Iteration 21 --
+array(3) {
+ ["dirname"]=>
+ string(1) "."
+ ["basename"]=>
+ string(5) "12345"
+ ["filename"]=>
+ string(5) "12345"
+}
+string(1) "."
+string(5) "12345"
+string(0) ""
+string(5) "12345"
+-- Iteration 22 --
+array(4) {
+ ["dirname"]=>
+ string(1) "."
+ ["basename"]=>
+ string(15) "www.example.com"
+ ["extension"]=>
+ string(3) "com"
+ ["filename"]=>
+ string(11) "www.example"
+}
+string(1) "."
+string(15) "www.example.com"
+string(3) "com"
+string(11) "www.example"
+-- Iteration 23 --
+array(3) {
+ ["dirname"]=>
+ string(12) "/testdir/foo"
+ ["basename"]=>
+ string(4) "test"
+ ["filename"]=>
+ string(4) "test"
+}
+string(12) "/testdir/foo"
+string(4) "test"
+string(0) ""
+string(4) "test"
+-- Iteration 24 --
+array(4) {
+ ["dirname"]=>
+ string(6) "../foo"
+ ["basename"]=>
+ string(9) "test.link"
+ ["extension"]=>
+ string(4) "link"
+ ["filename"]=>
+ string(4) "test"
+}
+string(6) "../foo"
+string(9) "test.link"
+string(4) "link"
+string(4) "test"
+-- Iteration 25 --
+array(4) {
+ ["dirname"]=>
+ string(76) "./test/work/scratch/mydir/yourdir/ourdir/test1/test2/test3/test4/test5/test6"
+ ["basename"]=>
+ string(8) "test.tmp"
+ ["extension"]=>
+ string(3) "tmp"
+ ["filename"]=>
+ string(4) "test"
+}
+string(76) "./test/work/scratch/mydir/yourdir/ourdir/test1/test2/test3/test4/test5/test6"
+string(8) "test.tmp"
+string(3) "tmp"
+string(4) "test"
+-- Iteration 26 --
+array(4) {
+ ["dirname"]=>
+ string(1) "."
+ ["basename"]=>
+ string(5) "2.345"
+ ["extension"]=>
+ string(3) "345"
+ ["filename"]=>
+ string(1) "2"
+}
+string(1) "."
+string(5) "2.345"
+string(3) "345"
+string(1) "2"
+Done
diff --git a/ext/standard/tests/file/pclose_variation1.phpt b/ext/standard/tests/file/pclose_variation1.phpt
new file mode 100644
index 0000000..07b5f3f
--- /dev/null
+++ b/ext/standard/tests/file/pclose_variation1.phpt
@@ -0,0 +1,232 @@
+--TEST--
+Test pclose() function : usage variation
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : int pclose(resource fp)
+ * Description: Close a file pointer opened by popen()
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing pclose() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+ // int data
+ 'int 0' => 0,
+ 'int 1' => 1,
+ 'int 12345' => 12345,
+ 'int -12345' => -2345,
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float -10.5' => -10.5,
+ 'float 12.3456789000e10' => 12.3456789000e10,
+ 'float -12.3456789000e10' => -12.3456789000e10,
+ 'float .5' => .5,
+
+ // array data
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // string data
+ 'string DQ' => "string",
+ 'string SQ' => 'string',
+ 'mixed case string' => "sTrInG",
+ 'heredoc' => $heredoc,
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for fp
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( pclose($value) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing pclose() : usage variation ***
+
+--int 0--
+Error: 2 - pclose() expects parameter 1 to be resource, integer given, %s(%d)
+bool(false)
+
+--int 1--
+Error: 2 - pclose() expects parameter 1 to be resource, integer given, %s(%d)
+bool(false)
+
+--int 12345--
+Error: 2 - pclose() expects parameter 1 to be resource, integer given, %s(%d)
+bool(false)
+
+--int -12345--
+Error: 2 - pclose() expects parameter 1 to be resource, integer given, %s(%d)
+bool(false)
+
+--float 10.5--
+Error: 2 - pclose() expects parameter 1 to be resource, double given, %s(%d)
+bool(false)
+
+--float -10.5--
+Error: 2 - pclose() expects parameter 1 to be resource, double given, %s(%d)
+bool(false)
+
+--float 12.3456789000e10--
+Error: 2 - pclose() expects parameter 1 to be resource, double given, %s(%d)
+bool(false)
+
+--float -12.3456789000e10--
+Error: 2 - pclose() expects parameter 1 to be resource, double given, %s(%d)
+bool(false)
+
+--float .5--
+Error: 2 - pclose() expects parameter 1 to be resource, double given, %s(%d)
+bool(false)
+
+--empty array--
+Error: 2 - pclose() expects parameter 1 to be resource, array given, %s(%d)
+bool(false)
+
+--int indexed array--
+Error: 2 - pclose() expects parameter 1 to be resource, array given, %s(%d)
+bool(false)
+
+--associative array--
+Error: 2 - pclose() expects parameter 1 to be resource, array given, %s(%d)
+bool(false)
+
+--nested arrays--
+Error: 2 - pclose() expects parameter 1 to be resource, array given, %s(%d)
+bool(false)
+
+--uppercase NULL--
+Error: 2 - pclose() expects parameter 1 to be resource, null given, %s(%d)
+bool(false)
+
+--lowercase null--
+Error: 2 - pclose() expects parameter 1 to be resource, null given, %s(%d)
+bool(false)
+
+--lowercase true--
+Error: 2 - pclose() expects parameter 1 to be resource, boolean given, %s(%d)
+bool(false)
+
+--lowercase false--
+Error: 2 - pclose() expects parameter 1 to be resource, boolean given, %s(%d)
+bool(false)
+
+--uppercase TRUE--
+Error: 2 - pclose() expects parameter 1 to be resource, boolean given, %s(%d)
+bool(false)
+
+--uppercase FALSE--
+Error: 2 - pclose() expects parameter 1 to be resource, boolean given, %s(%d)
+bool(false)
+
+--empty string DQ--
+Error: 2 - pclose() expects parameter 1 to be resource, string given, %s(%d)
+bool(false)
+
+--empty string SQ--
+Error: 2 - pclose() expects parameter 1 to be resource, string given, %s(%d)
+bool(false)
+
+--string DQ--
+Error: 2 - pclose() expects parameter 1 to be resource, string given, %s(%d)
+bool(false)
+
+--string SQ--
+Error: 2 - pclose() expects parameter 1 to be resource, string given, %s(%d)
+bool(false)
+
+--mixed case string--
+Error: 2 - pclose() expects parameter 1 to be resource, string given, %s(%d)
+bool(false)
+
+--heredoc--
+Error: 2 - pclose() expects parameter 1 to be resource, string given, %s(%d)
+bool(false)
+
+--instance of classWithToString--
+Error: 2 - pclose() expects parameter 1 to be resource, object given, %s(%d)
+bool(false)
+
+--instance of classWithoutToString--
+Error: 2 - pclose() expects parameter 1 to be resource, object given, %s(%d)
+bool(false)
+
+--undefined var--
+Error: 2 - pclose() expects parameter 1 to be resource, null given, %s(%d)
+bool(false)
+
+--unset var--
+Error: 2 - pclose() expects parameter 1 to be resource, null given, %s(%d)
+bool(false)
+===DONE===
+
diff --git a/ext/standard/tests/file/php_fd_wrapper_01.phpt b/ext/standard/tests/file/php_fd_wrapper_01.phpt
new file mode 100644
index 0000000..037edd7
--- /dev/null
+++ b/ext/standard/tests/file/php_fd_wrapper_01.phpt
@@ -0,0 +1,11 @@
+--TEST--
+php://fd wrapper: basic test
+--FILE--
+<?php
+$f = fopen("php://fd/1", "wb");
+fwrite($f, "hi!");
+
+echo "\nDone.\n";
+--EXPECT--
+hi!
+Done.
diff --git a/ext/standard/tests/file/php_fd_wrapper_02.phpt b/ext/standard/tests/file/php_fd_wrapper_02.phpt
new file mode 100644
index 0000000..6d40dc9
--- /dev/null
+++ b/ext/standard/tests/file/php_fd_wrapper_02.phpt
@@ -0,0 +1,11 @@
+--TEST--
+php://fd wrapper: mode is ignored
+--FILE--
+<?php
+$f = fopen("php://fd/1", "rkkk");
+fwrite($f, "hi!");
+
+echo "\nDone.\n";
+--EXPECT--
+hi!
+Done.
diff --git a/ext/standard/tests/file/php_fd_wrapper_03.phpt b/ext/standard/tests/file/php_fd_wrapper_03.phpt
new file mode 100644
index 0000000..c004a43
--- /dev/null
+++ b/ext/standard/tests/file/php_fd_wrapper_03.phpt
@@ -0,0 +1,22 @@
+--TEST--
+php://fd wrapper: bad syntax
+--FILE--
+<?php
+fopen("php://fd", "w");
+fopen("php://fd/", "w");
+fopen("php://fd/-2", "w");
+fopen("php://fd/1/", "w");
+
+echo "\nDone.\n";
+--EXPECTF--
+Warning: fopen(): Invalid php:// URL specified in %s on line %d
+
+Warning: fopen(php://fd): failed to open stream: operation failed in %s on line 2
+
+Warning: fopen(php://fd/): failed to open stream: php://fd/ stream must be specified in the form php://fd/<orig fd> in %s on line %d
+
+Warning: fopen(php://fd/-2): failed to open stream: The file descriptors must be non-negative numbers smaller than %d in %s on line %d
+
+Warning: fopen(php://fd/1/): failed to open stream: php://fd/ stream must be specified in the form php://fd/<orig fd> in %s on line %d
+
+Done.
diff --git a/ext/standard/tests/file/php_fd_wrapper_04.phpt b/ext/standard/tests/file/php_fd_wrapper_04.phpt
new file mode 100644
index 0000000..51f4d9f
--- /dev/null
+++ b/ext/standard/tests/file/php_fd_wrapper_04.phpt
@@ -0,0 +1,20 @@
+--TEST--
+php://fd wrapper: invalid file descriptor
+--SKIPIF--
+<?php include('skipif.inc');
+if(substr(PHP_OS, 0, 3) == "WIN")
+ die("skip Not for Windows");
+
+//we'd need a release and a test variation for windows, because in debug builds we get this message:
+//Warning: Invalid parameter detected in CRT function '_dup' (f:\dd\vctools\crt_bld\self_x86\crt\src\dup.c:52)
+//I greped the CRT sources and found no function capable of validating a file descriptor
+
+--FILE--
+<?php
+fopen("php://fd/12", "w");
+
+echo "\nDone.\n";
+--EXPECTF--
+Warning: fopen(php://fd/12): failed to open stream: Error duping file descriptor 12; possibly it doesn't exist: [9]: %s in %s on line %d
+
+Done.
diff --git a/ext/standard/tests/file/popen_pclose_basic-win32.phpt b/ext/standard/tests/file/popen_pclose_basic-win32.phpt
new file mode 100644
index 0000000..6351d86
--- /dev/null
+++ b/ext/standard/tests/file/popen_pclose_basic-win32.phpt
@@ -0,0 +1,75 @@
+--TEST--
+Test popen() and pclose function: basic functionality
+
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != 'WIN' )
+ die("skip Not Valid for Linux");
+?>
+
+--FILE--
+<?php
+/*
+ * Prototype: resource popen ( string command, string mode )
+ * Description: Opens process file pointer.
+
+ * Prototype: int pclose ( resource handle );
+ * Description: Closes process file pointer.
+ */
+
+echo "*** Testing popen(): reading from the pipe ***\n";
+
+$file_path = dirname(__FILE__);
+
+$string = "Sample String";
+$file_handle = popen(" echo $string", "r");
+fpassthru($file_handle);
+pclose($file_handle);
+
+echo "*** Testing popen(): writing to the pipe ***\n";
+$arr = array("ggg", "ddd", "aaa", "sss");
+// popen("sort", "w") fails if variables_order="GPCS"
+// this is set in the default INI file
+// it doesn't seem to be changeable in the --INI-- section
+// also, doing: ini_set('variables_order', ''); doesn't work!
+//
+// the only solution is to either put the absolute path here, or
+// remove variables_order= from PHP.ini (setting it in run-test's
+// default INI will fail too)
+//
+// since we can't depend on PHP.ini being set a certain way,
+// have to put the absolute path here.
+
+$sysroot = exec('echo %SYSTEMROOT%');
+
+$file_handle = popen("$sysroot/system32/sort", "w");
+$newline = "\n";
+foreach($arr as $str) {
+ fwrite($file_handle, (binary)$str);
+ fwrite($file_handle, (binary)(binary)(binary)(binary)(binary)(binary)(binary)(binary)(binary)$newline);
+}
+pclose($file_handle);
+
+echo "*** Testing popen() and pclose(): return type ***\n";
+$return_value_popen = popen("echo $string", "r");
+fpassthru($return_value_popen);
+var_dump( is_resource($return_value_popen) );
+$return_value_pclose = pclose($return_value_popen);
+var_dump( is_int($return_value_pclose) );
+
+echo "\n--- Done ---";
+?>
+--EXPECTF--
+*** Testing popen(): reading from the pipe ***
+Sample String
+*** Testing popen(): writing to the pipe ***
+aaa
+ddd
+ggg
+sss
+*** Testing popen() and pclose(): return type ***
+Sample String
+bool(true)
+bool(true)
+
+--- Done ---
diff --git a/ext/standard/tests/file/popen_pclose_basic.phpt b/ext/standard/tests/file/popen_pclose_basic.phpt
new file mode 100644
index 0000000..9812193
--- /dev/null
+++ b/ext/standard/tests/file/popen_pclose_basic.phpt
@@ -0,0 +1,103 @@
+--TEST--
+Test popen() and pclose function: basic functionality
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == 'WIN' )
+ die("skip Not Valid for Windows");
+?>
+
+--FILE--
+<?php
+/*
+ * Prototype: resource popen ( string command, string mode )
+ * Description: Opens process file pointer.
+ *
+ * Prototype: int pclose ( resource handle );
+ * Description: Closes process file pointer.
+ */
+
+$file_path = dirname(__FILE__);
+require($file_path."/file.inc");
+
+echo "*** Testing popen() and pclose() with different processes ***\n";
+
+echo "-- Testing popen(): reading from the pipe --\n";
+$dirpath = $file_path."/popen_basic";
+mkdir($dirpath);
+touch($dirpath."/popen_basic.tmp");
+define('CMD', "ls $dirpath");
+$file_handle = popen(CMD, 'r');
+fpassthru($file_handle);
+pclose($file_handle);
+
+echo "-- Testing popen(): reading from a file using 'cat' command --\n";
+create_files($dirpath, 1, "text_with_new_line", 0755, 100, "w", "popen_basic", 1, "bytes");
+$filename = $dirpath."/popen_basic1.tmp";
+$command = "cat $filename";
+$file_handle = popen($command, "r");
+$return_value = fpassthru($file_handle);
+echo "\n";
+var_dump($return_value);
+pclose($file_handle);
+delete_files($dirpath, 1);
+
+echo "*** Testing popen(): writing to the pipe ***\n";
+$arr = array("ggg", "ddd", "aaa", "sss");
+$file_handle = popen("sort", "w");
+$counter = 0;
+$newline = "\n";
+foreach($arr as $str) {
+ fwrite($file_handle, (binary)$str);
+ fwrite($file_handle, (binary)$newline);
+}
+pclose($file_handle);
+
+
+echo "*** Testing for return type of popen() and pclose() functions ***\n";
+$string = "Test String";
+$return_value_popen = popen("echo $string", "r");
+var_dump( is_resource($return_value_popen) );
+fpassthru($return_value_popen);
+$return_value_pclose = pclose($return_value_popen);
+var_dump( is_int($return_value_pclose) );
+
+echo "\n--- Done ---";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$dirpath = $file_path."/popen_basic";
+unlink($dirpath."/popen_basic.tmp");
+unlink($dirpath."/popen_basic1.tmp");
+rmdir($dirpath);
+?>
+
+--EXPECTF--
+*** Testing popen() and pclose() with different processes ***
+-- Testing popen(): reading from the pipe --
+popen_basic.tmp
+-- Testing popen(): reading from a file using 'cat' command --
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line
+int(100)
+*** Testing popen(): writing to the pipe ***
+aaa
+ddd
+ggg
+sss
+*** Testing for return type of popen() and pclose() functions ***
+bool(true)
+Test String
+bool(true)
+
+--- Done ---
diff --git a/ext/standard/tests/file/popen_pclose_error-sunos.phpt b/ext/standard/tests/file/popen_pclose_error-sunos.phpt
new file mode 100644
index 0000000..b63dbeb
--- /dev/null
+++ b/ext/standard/tests/file/popen_pclose_error-sunos.phpt
@@ -0,0 +1,55 @@
+--TEST--
+Test popen() and pclose function: error conditions
+--SKIPIF--
+<?php
+if( substr(PHP_OS, 0, 3) != 'Sun')
+ die("skip Only valid for Sun Solaris");
+?>
+
+--FILE--
+<?php
+/*
+ * Prototype: resource popen ( string command, string mode )
+ * Description: Opens process file pointer.
+
+ * Prototype: int pclose ( resource handle );
+ * Description: Closes process file pointer.
+ */
+$file_path = dirname(__FILE__);
+echo "*** Testing for error conditions ***\n";
+var_dump( popen() ); // Zero Arguments
+var_dump( popen("abc.txt") ); // Single Argument
+var_dump( popen("abc.txt", "rw") ); // Invalid mode Argument
+var_dump( pclose() );
+$file_handle = fopen($file_path."/popen.tmp", "w");
+var_dump( pclose($file_handle, $file_handle) );
+fclose($file_handle);
+var_dump( pclose(1) );
+echo "\n--- Done ---";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/popen.tmp");
+?>
+--EXPECTF--
+*** Testing for error conditions ***
+
+Warning: Wrong parameter count for popen() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for popen() in %s on line %d
+NULL
+sh: abc.txt: not found
+resource(%d) of type (stream)
+
+Warning: Wrong parameter count for pclose() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for pclose() in %s on line %d
+NULL
+
+Warning: pclose(): supplied argument is not a valid stream resource in %s on line %d
+bool(false)
+
+--- Done ---
diff --git a/ext/standard/tests/file/popen_pclose_error-win32-debug.phpt b/ext/standard/tests/file/popen_pclose_error-win32-debug.phpt
new file mode 100644
index 0000000..e41d6b1
--- /dev/null
+++ b/ext/standard/tests/file/popen_pclose_error-win32-debug.phpt
@@ -0,0 +1,63 @@
+--TEST--
+Test popen() and pclose function: error conditions
+
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != 'WIN' && PHP_DEBUG) die("skip Valid only on Windows");
+if(!PHP_DEBUG) die("skip Not Valid for release builds");
+
+ob_start();phpinfo(INFO_GENERAL);$inf=ob_get_contents(); ob_end_clean();
+if (!(strpos($inf, 'MSVC9') || strpos($inf, 'MSVC8'))) die("skip Not Valid for build done with VC < 8");
+?>
+
+--FILE--
+<?php
+/*
+ * Prototype: resource popen ( string command, string mode )
+ * Description: Opens process file pointer.
+
+ * Prototype: int pclose ( resource handle );
+ * Description: Closes process file pointer.
+ */
+$file_path = dirname(__FILE__);
+echo "*** Testing for error conditions ***\n";
+var_dump( popen() ); // Zero Arguments
+var_dump( popen("abc.txt") ); // Single Argument
+var_dump( popen("abc.txt", "rw") ); // Invalid mode Argument
+var_dump( pclose() );
+$file_handle = fopen($file_path."/popen.tmp", "w");
+var_dump( pclose($file_handle, $file_handle) );
+pclose($file_handle);
+var_dump( pclose(1) );
+echo "\n--- Done ---";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/popen.tmp");
+?>
+--EXPECTF--
+*** Testing for error conditions ***
+
+Warning: popen() expects exactly 2 parameters, 0 given in %s on line %d
+NULL
+
+Warning: popen() expects exactly 2 parameters, 1 given in %s on line %d
+NULL
+
+Warning: Invalid parameter detected in CRT function '_fdopen' (%s:%d) in %s on line %d
+
+Warning: popen(abc.txt,rw): Invalid argument in %s on line %d
+bool(false)
+
+Warning: pclose() expects exactly 1 parameter, 0 given in %s on line %d
+bool(false)
+
+Warning: pclose() expects exactly 1 parameter, 2 given in %s on line %d
+bool(false)
+
+Warning: pclose() expects parameter 1 to be resource, integer given in %s on line %d
+bool(false)
+
+--- Done ---'abc.txt' is not recognized as an internal or external command,
+operable program or batch file.
diff --git a/ext/standard/tests/file/popen_pclose_error-win32.phpt b/ext/standard/tests/file/popen_pclose_error-win32.phpt
new file mode 100644
index 0000000..9f9593c
--- /dev/null
+++ b/ext/standard/tests/file/popen_pclose_error-win32.phpt
@@ -0,0 +1,59 @@
+--TEST--
+Test popen() and pclose function: error conditions
+
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') die("skip Valid only on Windows");
+if (PHP_DEBUG) die("skip Not Valid for debug builds");
+?>
+
+--FILE--
+<?php
+/*
+ * Prototype: resource popen ( string command, string mode )
+ * Description: Opens process file pointer.
+
+ * Prototype: int pclose ( resource handle );
+ * Description: Closes process file pointer.
+ */
+$file_path = dirname(__FILE__);
+echo "*** Testing for error conditions ***" . PHP_EOL;
+var_dump( popen() ); // Zero Arguments
+var_dump( popen("abc.txt") ); // Single Argument
+var_dump( popen("abc.txt", "rw") ); // Invalid mode Argument
+var_dump( pclose() );
+$file_handle = fopen($file_path."/popen.tmp", "w");
+var_dump( pclose($file_handle, $file_handle) );
+pclose($file_handle);
+var_dump( pclose(1) );
+echo PHP_EOL . PHP_EOL . "--- Done ---";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/popen.tmp");
+?>
+--EXPECTF--
+*** Testing for error conditions ***
+
+Warning: popen() expects exactly 2 parameters, 0 given in %s on line %d
+NULL
+
+Warning: popen() expects exactly 2 parameters, 1 given in %s on line %d
+NULL
+
+Warning: popen(abc.txt,rw): Invalid argument in %s on line %d
+bool(false)
+
+Warning: pclose() expects exactly 1 parameter, 0 given in %s on line %d
+bool(false)
+
+Warning: pclose() expects exactly 1 parameter, 2 given in %s on line %d
+bool(false)
+
+Warning: pclose() expects parameter 1 to be resource, integer given in %s on line %d
+bool(false)
+
+
+--- Done ---'abc.txt' is not recognized as an internal or external command,
+operable program or batch file.
diff --git a/ext/standard/tests/file/popen_pclose_error.phpt b/ext/standard/tests/file/popen_pclose_error.phpt
new file mode 100644
index 0000000..72ce734
--- /dev/null
+++ b/ext/standard/tests/file/popen_pclose_error.phpt
@@ -0,0 +1,56 @@
+--TEST--
+Test popen() and pclose function: error conditions
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == 'WIN' || strtoupper( substr(PHP_OS, 0, 3) ) == 'SUN')
+ die("skip Not Valid for Windows & Sun Solaris");
+?>
+
+--FILE--
+<?php
+/*
+ * Prototype: resource popen ( string command, string mode )
+ * Description: Opens process file pointer.
+
+ * Prototype: int pclose ( resource handle );
+ * Description: Closes process file pointer.
+ */
+$file_path = dirname(__FILE__);
+echo "*** Testing for error conditions ***\n";
+var_dump( popen() ); // Zero Arguments
+var_dump( popen("abc.txt") ); // Single Argument
+var_dump( popen("abc.txt", "rw") ); // Invalid mode Argument
+var_dump( pclose() );
+$file_handle = fopen($file_path."/popen.tmp", "w");
+var_dump( pclose($file_handle, $file_handle) );
+fclose($file_handle);
+var_dump( pclose(1) );
+echo "\n--- Done ---";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/popen.tmp");
+?>
+--EXPECTF--
+*** Testing for error conditions ***
+
+Warning: popen() expects exactly 2 parameters, 0 given in %s on line %d
+NULL
+
+Warning: popen() expects exactly 2 parameters, 1 given in %s on line %d
+NULL
+
+Warning: popen(abc.txt,rw): %s on line %d
+bool(false)
+
+Warning: pclose() expects exactly 1 parameter, 0 given in %s on line %d
+bool(false)
+
+Warning: pclose() expects exactly 1 parameter, 2 given in %s on line %d
+bool(false)
+
+Warning: pclose() expects parameter 1 to be resource, integer given in %s on line %d
+bool(false)
+
+--- Done ---
diff --git a/ext/standard/tests/file/proc_open01.phpt b/ext/standard/tests/file/proc_open01.phpt
new file mode 100644
index 0000000..3348403
--- /dev/null
+++ b/ext/standard/tests/file/proc_open01.phpt
@@ -0,0 +1,69 @@
+--TEST--
+proc_open() regression test 1 (proc_open() leak)
+--FILE--
+<?php
+$pipes = array(1, 2, 3);
+$orig_pipes = $pipes;
+$php = getenv('TEST_PHP_EXECUTABLE');
+if ($php === false) {
+ die("no php executable defined");
+}
+$proc = proc_open(
+ "$php -n",
+ array(0 => array('pipe', 'r'), 1 => array('pipe', 'w')),
+ $pipes, getcwd(), array(), array('binary_pipes' => true)
+);
+if ($proc === false) {
+ print "something went wrong.\n";
+}
+var_dump($pipes);
+stream_set_blocking($pipes[1], FALSE);
+$test_string = b"yay!\n";
+fwrite($pipes[0], $test_string);
+fflush($pipes[0]);
+fclose($pipes[0]);
+$cnt = '';
+$n=0;
+for ($left = strlen($test_string); $left > 0;) {
+ if (++$n >1000) {
+ print "terminated after 1000 iterations\n";
+ break;
+ }
+ $read_fds = array($pipes[1]);
+ $write_fds = NULL;
+ $exp_fds = NULL;
+ $retval = stream_select($read_fds, $write_fds, $exp_fds, 5);
+ if ($retval === false) {
+ print "select() failed\n";
+ break;
+ }
+ if ($retval === 0) {
+ print "timed out\n";
+ break;
+ }
+ $buf = fread($pipes[1], 1024);
+ $cnt .= $buf;
+ $left -= strlen($buf);
+}
+var_dump($cnt);
+fclose($pipes[1]);
+proc_close($proc);
+var_dump($orig_pipes);
+?>
+--EXPECTF--
+array(2) {
+ [0]=>
+ resource(%d) of type (stream)
+ [1]=>
+ resource(%d) of type (stream)
+}
+%unicode|string%(5) "yay!
+"
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+}
diff --git a/ext/standard/tests/file/readfile_basic-win32.phpt b/ext/standard/tests/file/readfile_basic-win32.phpt
new file mode 100644
index 0000000..05e18a2
--- /dev/null
+++ b/ext/standard/tests/file/readfile_basic-win32.phpt
@@ -0,0 +1,530 @@
+--TEST--
+Test readfile() function: basic functionality
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip.. only on Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: int readfile ( string $filename [, bool $use_include_path [, resource $context]] );
+ Description: Outputs a file
+*/
+// common file used
+require(dirname(__FILE__) . '/file.inc');
+
+echo "*** Testing readfile() : basic functionality ***\n";
+$file_path = dirname(__FILE__);
+$file_prefix = "readfile_basic"; // temp files created with this prefix
+
+// the content that is filled into the temp files as created
+$filetypes = array("numeric", "text", "empty", "alphanumeric", "text_with_new_line");
+// different file modes
+$filemodes = array("w", "wt", "wb", "w+", "w+b", "w+t",
+ "a", "at", "ab", "a+", "a+b", "a+t",
+ "x", "xb", "xt", "x+", "x+b", "x+t");
+
+// create file, read the file content, delete file
+foreach($filetypes as $type) {
+ echo "\n-- File filled with content type: $type --\n";
+ foreach($filemodes as $mode) {
+ echo "-- File opened with mode: $mode --\n";
+ if ( strstr($mode, "x") ) {
+ $fp = fopen($file_path."/".$file_prefix."1.tmp", $mode);
+ fill_file($fp, $type, 100);
+ fclose($fp);
+ } else {
+ // creating file in write mode
+ create_files($file_path, 1, $type, 0755, 100, $mode, $file_prefix, 1, "byte");
+ }
+ $count = readfile($file_path."/".$file_prefix."1.tmp");
+ echo "\n";
+ var_dump($count);
+ // delete files created
+ delete_files($file_path, 1, $file_prefix, 1);
+ }
+}
+echo "Done\n";
+?>
+--EXPECT--
+*** Testing readfile() : basic functionality ***
+
+-- File filled with content type: numeric --
+-- File opened with mode: w --
+2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
+int(100)
+-- File opened with mode: wt --
+2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
+int(100)
+-- File opened with mode: wb --
+2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
+int(100)
+-- File opened with mode: w+ --
+2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
+int(100)
+-- File opened with mode: w+b --
+2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
+int(100)
+-- File opened with mode: w+t --
+2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
+int(100)
+-- File opened with mode: a --
+2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
+int(100)
+-- File opened with mode: at --
+2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
+int(100)
+-- File opened with mode: ab --
+2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
+int(100)
+-- File opened with mode: a+ --
+2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
+int(100)
+-- File opened with mode: a+b --
+2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
+int(100)
+-- File opened with mode: a+t --
+2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
+int(100)
+-- File opened with mode: x --
+2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
+int(100)
+-- File opened with mode: xb --
+2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
+int(100)
+-- File opened with mode: xt --
+2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
+int(100)
+-- File opened with mode: x+ --
+2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
+int(100)
+-- File opened with mode: x+b --
+2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
+int(100)
+-- File opened with mode: x+t --
+2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
+int(100)
+
+-- File filled with content type: text --
+-- File opened with mode: w --
+text text text text text text text text text text text text text text text text text text text text
+int(100)
+-- File opened with mode: wt --
+text text text text text text text text text text text text text text text text text text text text
+int(100)
+-- File opened with mode: wb --
+text text text text text text text text text text text text text text text text text text text text
+int(100)
+-- File opened with mode: w+ --
+text text text text text text text text text text text text text text text text text text text text
+int(100)
+-- File opened with mode: w+b --
+text text text text text text text text text text text text text text text text text text text text
+int(100)
+-- File opened with mode: w+t --
+text text text text text text text text text text text text text text text text text text text text
+int(100)
+-- File opened with mode: a --
+text text text text text text text text text text text text text text text text text text text text
+int(100)
+-- File opened with mode: at --
+text text text text text text text text text text text text text text text text text text text text
+int(100)
+-- File opened with mode: ab --
+text text text text text text text text text text text text text text text text text text text text
+int(100)
+-- File opened with mode: a+ --
+text text text text text text text text text text text text text text text text text text text text
+int(100)
+-- File opened with mode: a+b --
+text text text text text text text text text text text text text text text text text text text text
+int(100)
+-- File opened with mode: a+t --
+text text text text text text text text text text text text text text text text text text text text
+int(100)
+-- File opened with mode: x --
+text text text text text text text text text text text text text text text text text text text text
+int(100)
+-- File opened with mode: xb --
+text text text text text text text text text text text text text text text text text text text text
+int(100)
+-- File opened with mode: xt --
+text text text text text text text text text text text text text text text text text text text text
+int(100)
+-- File opened with mode: x+ --
+text text text text text text text text text text text text text text text text text text text text
+int(100)
+-- File opened with mode: x+b --
+text text text text text text text text text text text text text text text text text text text text
+int(100)
+-- File opened with mode: x+t --
+text text text text text text text text text text text text text text text text text text text text
+int(100)
+
+-- File filled with content type: empty --
+-- File opened with mode: w --
+
+int(0)
+-- File opened with mode: wt --
+
+int(0)
+-- File opened with mode: wb --
+
+int(0)
+-- File opened with mode: w+ --
+
+int(0)
+-- File opened with mode: w+b --
+
+int(0)
+-- File opened with mode: w+t --
+
+int(0)
+-- File opened with mode: a --
+
+int(0)
+-- File opened with mode: at --
+
+int(0)
+-- File opened with mode: ab --
+
+int(0)
+-- File opened with mode: a+ --
+
+int(0)
+-- File opened with mode: a+b --
+
+int(0)
+-- File opened with mode: a+t --
+
+int(0)
+-- File opened with mode: x --
+
+int(0)
+-- File opened with mode: xb --
+
+int(0)
+-- File opened with mode: xt --
+
+int(0)
+-- File opened with mode: x+ --
+
+int(0)
+-- File opened with mode: x+b --
+
+int(0)
+-- File opened with mode: x+t --
+
+int(0)
+
+-- File filled with content type: alphanumeric --
+-- File opened with mode: w --
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12
+int(100)
+-- File opened with mode: wt --
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12
+int(100)
+-- File opened with mode: wb --
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12
+int(100)
+-- File opened with mode: w+ --
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12
+int(100)
+-- File opened with mode: w+b --
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12
+int(100)
+-- File opened with mode: w+t --
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12
+int(100)
+-- File opened with mode: a --
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12
+int(100)
+-- File opened with mode: at --
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12
+int(100)
+-- File opened with mode: ab --
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12
+int(100)
+-- File opened with mode: a+ --
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12
+int(100)
+-- File opened with mode: a+b --
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12
+int(100)
+-- File opened with mode: a+t --
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12
+int(100)
+-- File opened with mode: x --
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12
+int(100)
+-- File opened with mode: xb --
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12
+int(100)
+-- File opened with mode: xt --
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12
+int(100)
+-- File opened with mode: x+ --
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12
+int(100)
+-- File opened with mode: x+b --
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12
+int(100)
+-- File opened with mode: x+t --
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12
+int(100)
+
+-- File filled with content type: text_with_new_line --
+-- File opened with mode: w --
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line
+int(100)
+-- File opened with mode: wt --
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line
+int(111)
+-- File opened with mode: wb --
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line
+int(100)
+-- File opened with mode: w+ --
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line
+int(100)
+-- File opened with mode: w+b --
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line
+int(100)
+-- File opened with mode: w+t --
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line
+int(111)
+-- File opened with mode: a --
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line
+int(100)
+-- File opened with mode: at --
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line
+int(111)
+-- File opened with mode: ab --
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line
+int(100)
+-- File opened with mode: a+ --
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line
+int(100)
+-- File opened with mode: a+b --
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line
+int(100)
+-- File opened with mode: a+t --
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line
+int(111)
+-- File opened with mode: x --
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line
+int(100)
+-- File opened with mode: xb --
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line
+int(100)
+-- File opened with mode: xt --
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line
+int(111)
+-- File opened with mode: x+ --
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line
+int(100)
+-- File opened with mode: x+b --
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line
+int(100)
+-- File opened with mode: x+t --
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line
+int(111)
+Done
diff --git a/ext/standard/tests/file/readfile_basic.phpt b/ext/standard/tests/file/readfile_basic.phpt
new file mode 100644
index 0000000..e67fd58
--- /dev/null
+++ b/ext/standard/tests/file/readfile_basic.phpt
@@ -0,0 +1,530 @@
+--TEST--
+Test readfile() function: basic functionality
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. only on Linux');
+}
+?>
+--FILE--
+<?php
+/* Prototype: int readfile ( string $filename [, bool $use_include_path [, resource $context]] );
+ Description: Outputs a file
+*/
+// common file used
+require(dirname(__FILE__) . '/file.inc');
+
+echo "*** Testing readfile() : basic functionality ***\n";
+$file_path = dirname(__FILE__);
+$file_prefix = "readfile_basic"; // temp files created with this prefix
+
+// the content that is filled into the temp files as created
+$filetypes = array("numeric", "text", "empty", "alphanumeric", "text_with_new_line");
+// different file modes
+$filemodes = array("w", "wt", "wb", "w+", "w+b", "w+t",
+ "a", "at", "ab", "a+", "a+b", "a+t",
+ "x", "xb", "xt", "x+", "x+b", "x+t");
+
+// create file, read the file content, delete file
+foreach($filetypes as $type) {
+ echo "\n-- File filled with content type: $type --\n";
+ foreach($filemodes as $mode) {
+ echo "-- File opened with mode: $mode --\n";
+ if ( strstr($mode, "x") ) {
+ $fp = fopen($file_path."/".$file_prefix."1.tmp", $mode);
+ fill_file($fp, $type, 100);
+ fclose($fp);
+ } else {
+ // creating file in write mode
+ create_files($file_path, 1, $type, 0755, 100, $mode, $file_prefix, 1, "byte");
+ }
+ $count = readfile($file_path."/".$file_prefix."1.tmp");
+ echo "\n";
+ var_dump($count);
+ // delete files created
+ delete_files($file_path, 1, $file_prefix, 1);
+ }
+}
+echo "Done\n";
+?>
+--EXPECT--
+*** Testing readfile() : basic functionality ***
+
+-- File filled with content type: numeric --
+-- File opened with mode: w --
+2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
+int(100)
+-- File opened with mode: wt --
+2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
+int(100)
+-- File opened with mode: wb --
+2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
+int(100)
+-- File opened with mode: w+ --
+2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
+int(100)
+-- File opened with mode: w+b --
+2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
+int(100)
+-- File opened with mode: w+t --
+2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
+int(100)
+-- File opened with mode: a --
+2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
+int(100)
+-- File opened with mode: at --
+2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
+int(100)
+-- File opened with mode: ab --
+2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
+int(100)
+-- File opened with mode: a+ --
+2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
+int(100)
+-- File opened with mode: a+b --
+2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
+int(100)
+-- File opened with mode: a+t --
+2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
+int(100)
+-- File opened with mode: x --
+2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
+int(100)
+-- File opened with mode: xb --
+2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
+int(100)
+-- File opened with mode: xt --
+2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
+int(100)
+-- File opened with mode: x+ --
+2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
+int(100)
+-- File opened with mode: x+b --
+2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
+int(100)
+-- File opened with mode: x+t --
+2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
+int(100)
+
+-- File filled with content type: text --
+-- File opened with mode: w --
+text text text text text text text text text text text text text text text text text text text text
+int(100)
+-- File opened with mode: wt --
+text text text text text text text text text text text text text text text text text text text text
+int(100)
+-- File opened with mode: wb --
+text text text text text text text text text text text text text text text text text text text text
+int(100)
+-- File opened with mode: w+ --
+text text text text text text text text text text text text text text text text text text text text
+int(100)
+-- File opened with mode: w+b --
+text text text text text text text text text text text text text text text text text text text text
+int(100)
+-- File opened with mode: w+t --
+text text text text text text text text text text text text text text text text text text text text
+int(100)
+-- File opened with mode: a --
+text text text text text text text text text text text text text text text text text text text text
+int(100)
+-- File opened with mode: at --
+text text text text text text text text text text text text text text text text text text text text
+int(100)
+-- File opened with mode: ab --
+text text text text text text text text text text text text text text text text text text text text
+int(100)
+-- File opened with mode: a+ --
+text text text text text text text text text text text text text text text text text text text text
+int(100)
+-- File opened with mode: a+b --
+text text text text text text text text text text text text text text text text text text text text
+int(100)
+-- File opened with mode: a+t --
+text text text text text text text text text text text text text text text text text text text text
+int(100)
+-- File opened with mode: x --
+text text text text text text text text text text text text text text text text text text text text
+int(100)
+-- File opened with mode: xb --
+text text text text text text text text text text text text text text text text text text text text
+int(100)
+-- File opened with mode: xt --
+text text text text text text text text text text text text text text text text text text text text
+int(100)
+-- File opened with mode: x+ --
+text text text text text text text text text text text text text text text text text text text text
+int(100)
+-- File opened with mode: x+b --
+text text text text text text text text text text text text text text text text text text text text
+int(100)
+-- File opened with mode: x+t --
+text text text text text text text text text text text text text text text text text text text text
+int(100)
+
+-- File filled with content type: empty --
+-- File opened with mode: w --
+
+int(0)
+-- File opened with mode: wt --
+
+int(0)
+-- File opened with mode: wb --
+
+int(0)
+-- File opened with mode: w+ --
+
+int(0)
+-- File opened with mode: w+b --
+
+int(0)
+-- File opened with mode: w+t --
+
+int(0)
+-- File opened with mode: a --
+
+int(0)
+-- File opened with mode: at --
+
+int(0)
+-- File opened with mode: ab --
+
+int(0)
+-- File opened with mode: a+ --
+
+int(0)
+-- File opened with mode: a+b --
+
+int(0)
+-- File opened with mode: a+t --
+
+int(0)
+-- File opened with mode: x --
+
+int(0)
+-- File opened with mode: xb --
+
+int(0)
+-- File opened with mode: xt --
+
+int(0)
+-- File opened with mode: x+ --
+
+int(0)
+-- File opened with mode: x+b --
+
+int(0)
+-- File opened with mode: x+t --
+
+int(0)
+
+-- File filled with content type: alphanumeric --
+-- File opened with mode: w --
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12
+int(100)
+-- File opened with mode: wt --
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12
+int(100)
+-- File opened with mode: wb --
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12
+int(100)
+-- File opened with mode: w+ --
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12
+int(100)
+-- File opened with mode: w+b --
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12
+int(100)
+-- File opened with mode: w+t --
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12
+int(100)
+-- File opened with mode: a --
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12
+int(100)
+-- File opened with mode: at --
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12
+int(100)
+-- File opened with mode: ab --
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12
+int(100)
+-- File opened with mode: a+ --
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12
+int(100)
+-- File opened with mode: a+b --
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12
+int(100)
+-- File opened with mode: a+t --
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12
+int(100)
+-- File opened with mode: x --
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12
+int(100)
+-- File opened with mode: xb --
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12
+int(100)
+-- File opened with mode: xt --
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12
+int(100)
+-- File opened with mode: x+ --
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12
+int(100)
+-- File opened with mode: x+b --
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12
+int(100)
+-- File opened with mode: x+t --
+ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12 ab12
+int(100)
+
+-- File filled with content type: text_with_new_line --
+-- File opened with mode: w --
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line
+int(100)
+-- File opened with mode: wt --
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line
+int(100)
+-- File opened with mode: wb --
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line
+int(100)
+-- File opened with mode: w+ --
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line
+int(100)
+-- File opened with mode: w+b --
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line
+int(100)
+-- File opened with mode: w+t --
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line
+int(100)
+-- File opened with mode: a --
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line
+int(100)
+-- File opened with mode: at --
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line
+int(100)
+-- File opened with mode: ab --
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line
+int(100)
+-- File opened with mode: a+ --
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line
+int(100)
+-- File opened with mode: a+b --
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line
+int(100)
+-- File opened with mode: a+t --
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line
+int(100)
+-- File opened with mode: x --
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line
+int(100)
+-- File opened with mode: xb --
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line
+int(100)
+-- File opened with mode: xt --
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line
+int(100)
+-- File opened with mode: x+ --
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line
+int(100)
+-- File opened with mode: x+b --
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line
+int(100)
+-- File opened with mode: x+t --
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line
+int(100)
+Done
diff --git a/ext/standard/tests/file/readfile_error.phpt b/ext/standard/tests/file/readfile_error.phpt
new file mode 100644
index 0000000..2d5d377
--- /dev/null
+++ b/ext/standard/tests/file/readfile_error.phpt
@@ -0,0 +1,61 @@
+--TEST--
+Test readfile() function: error conditions
+--FILE--
+<?php
+/* Prototype: int readfile ( string $filename [, bool $use_include_path [, resource $context]] );
+ Description: Outputs a file
+*/
+
+$context = stream_context_create();
+
+echo "*** Test readfile(): error conditions ***\n";
+echo "-- Testing readfile() with unexpected no. of arguments --\n";
+var_dump( readfile() ); // args < expected
+var_dump( readfile(__FILE__, true, $context, 4) ); // args > expected
+
+echo "\n-- Testing readfile() with invalid arguments --\n";
+// invalid arguments
+var_dump( readfile(NULL) ); // NULL as $filename
+var_dump( readfile('') ); // empty string as $filename
+var_dump( readfile(false) ); // boolean false as $filename
+var_dump( readfile(__FILE__, false, '') ); // empty string as $context
+var_dump( readfile(__FILE__, true, false) ); // boolean false as $context
+
+echo "\n-- Testing readfile() with non-existent file --\n";
+$non_existent_file = dirname(__FILE__)."/non_existent_file.tmp";
+var_dump( readfile($non_existent_file) );
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Test readfile(): error conditions ***
+-- Testing readfile() with unexpected no. of arguments --
+
+Warning: readfile() expects at least 1 parameter, 0 given in %s on line %d
+bool(false)
+
+Warning: readfile() expects at most 3 parameters, 4 given in %s on line %d
+bool(false)
+
+-- Testing readfile() with invalid arguments --
+
+Warning: readfile(): Filename cannot be empty in %s on line %d
+bool(false)
+
+Warning: readfile(): Filename cannot be empty in %s on line %d
+bool(false)
+
+Warning: readfile(): Filename cannot be empty in %s on line %d
+bool(false)
+
+Warning: readfile() expects parameter 3 to be resource, string given in %s on line %d
+bool(false)
+
+Warning: readfile() expects parameter 3 to be resource, boolean given in %s on line %d
+bool(false)
+
+-- Testing readfile() with non-existent file --
+
+Warning: readfile(%s/non_existent_file.tmp): failed to open stream: %s in %s on line %d
+bool(false)
+Done
diff --git a/ext/standard/tests/file/readfile_variation1.phpt b/ext/standard/tests/file/readfile_variation1.phpt
new file mode 100644
index 0000000..6bfe7dd
--- /dev/null
+++ b/ext/standard/tests/file/readfile_variation1.phpt
@@ -0,0 +1,46 @@
+--TEST--
+Test readfile() function: usage variation - stream_context
+--FILE--
+<?php
+/* Prototype: int readfile ( string $filename [, bool $use_include_path [, resource $context]] );
+ Description: Outputs a file
+*/
+
+/* test readfile() with third argument : context */
+
+// include file.inc
+require("file.inc");
+$file_path = dirname(__FILE__);
+
+/* Variation 1 : Check working of third argument of readfile() */
+
+echo "*** Testing readfile(): checking third argument ***\n";
+// creating a context
+$context = stream_context_create();
+// temp file name used here
+$filename = "$file_path/readfile_variation1.tmp";
+
+// create file
+$fp = fopen($filename, "w");
+fill_file($fp, "text_with_new_line", 50);
+fclose($fp);
+$count = readfile($filename, true, $context);
+echo "\n";
+var_dump($count);
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/readfile_variation1.tmp");
+?>
+--EXPECT--
+*** Testing readfile(): checking third argument ***
+line
+line of text
+line
+line of text
+line
+line of t
+int(50)
+Done
diff --git a/ext/standard/tests/file/readfile_variation10-win32.phpt b/ext/standard/tests/file/readfile_variation10-win32.phpt
new file mode 100644
index 0000000..61f6aba
--- /dev/null
+++ b/ext/standard/tests/file/readfile_variation10-win32.phpt
@@ -0,0 +1,87 @@
+--TEST--
+Test readfile() function : variation - various invalid paths
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+ die("skip run only on Windows");
+?>
+--FILE--
+<?php
+/* Prototype : int readfile(string filename [, bool use_include_path[, resource context]])
+ * Description: Output a file or a URL
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing readfile() : variation ***\n";
+
+/* An array of files */
+$names_arr = array(
+ /* Invalid args */
+ "-1" => -1,
+ "TRUE" => TRUE,
+ "FALSE" => FALSE,
+ "NULL" => NULL,
+ "\"\"" => "",
+ "\" \"" => " ",
+ "\\0" => "\0",
+ "array()" => array(),
+
+ /* prefix with path separator of a non existing directory*/
+ "/no/such/file/dir" => "/no/such/file/dir",
+ "php/php"=> "php/php"
+
+);
+
+foreach($names_arr as $key => $value) {
+ echo "\n-- Filename: $key --\n";
+ readfile($value);
+};
+
+?>
+===Done===
+--EXPECTF--
+*** Testing readfile() : variation ***
+
+-- Filename: -1 --
+
+Warning: readfile(-1): failed to open stream: No such file or directory in %s on line %d
+
+-- Filename: TRUE --
+
+Warning: readfile(1): failed to open stream: No such file or directory in %s on line %d
+
+-- Filename: FALSE --
+
+Warning: readfile(): Filename cannot be empty in %s on line %d
+
+-- Filename: NULL --
+
+Warning: readfile(): Filename cannot be empty in %s on line %d
+
+-- Filename: "" --
+
+Warning: readfile(): Filename cannot be empty in %s on line %d
+
+-- Filename: " " --
+
+Warning: readfile( ): failed to open stream: Permission denied in %s on line %d
+
+-- Filename: \0 --
+
+Warning: readfile() expects parameter 1 to be a valid path, string given in %s on line %d
+
+-- Filename: array() --
+
+Warning: readfile() expects parameter 1 to be a valid path, array given in %s on line %d
+
+-- Filename: /no/such/file/dir --
+
+Warning: readfile(/no/such/file/dir): failed to open stream: No such file or directory in %s on line %d
+
+-- Filename: php/php --
+
+Warning: readfile(php/php): failed to open stream: No such file or directory in %s on line %d
+===Done===
diff --git a/ext/standard/tests/file/readfile_variation10.phpt b/ext/standard/tests/file/readfile_variation10.phpt
new file mode 100644
index 0000000..3bbc329
--- /dev/null
+++ b/ext/standard/tests/file/readfile_variation10.phpt
Binary files differ
diff --git a/ext/standard/tests/file/readfile_variation2.phpt b/ext/standard/tests/file/readfile_variation2.phpt
new file mode 100644
index 0000000..0c43bf5
--- /dev/null
+++ b/ext/standard/tests/file/readfile_variation2.phpt
@@ -0,0 +1,87 @@
+--TEST--
+Test readfile() function: usage variations - links
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. only on Linux');
+}
+?>
+--FILE--
+<?php
+/* Prototype: int readfile ( string $filename [, bool $use_include_path [, resource $context]] );
+ Description: Outputs a file
+*/
+
+/* Variation 2 : Create file
+ Create soft/hard link to it
+ Read link using readfile()
+ Delete file and its link
+*/
+
+// include file.inc
+require("file.inc");
+
+$file_path = dirname(__FILE__);
+
+// temp file used here
+$filename = "$file_path/readfile_variation2.tmp";
+
+// create temp file and insert data into it
+$fp = fopen($filename, "w");
+fill_file($fp, "text_with_new_line", 50);
+fclose($fp);
+
+// temp link name used
+$linkname = "$file_path/readfile_variation2_link.tmp";
+
+/* Checking readfile() operation on soft link */
+echo "*** Testing readfile() on soft link ***\n";
+
+// create soft link to $filename
+var_dump( symlink($filename, $linkname) );
+// readfile() on soft link
+$count = readfile($linkname); // with default args
+echo "\n";
+var_dump($count);
+// delete link
+unlink($linkname);
+
+/* Checking readfile() operation on hard link */
+echo "\n*** Testing readfile() on hard link ***\n";
+// create hard link to $filename
+var_dump( link($filename, $linkname) );
+// readfile() on hard link
+$count = readfile($linkname); // default args
+echo "\n";
+var_dump($count);
+// delete link
+unlink($linkname);
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink("$file_path/readfile_variation2.tmp");
+?>
+--EXPECTF--
+*** Testing readfile() on soft link ***
+bool(true)
+line
+line of text
+line
+line of text
+line
+line of t
+int(50)
+
+*** Testing readfile() on hard link ***
+bool(true)
+line
+line of text
+line
+line of text
+line
+line of t
+int(50)
+Done
diff --git a/ext/standard/tests/file/readfile_variation3.phpt b/ext/standard/tests/file/readfile_variation3.phpt
new file mode 100644
index 0000000..854642a
--- /dev/null
+++ b/ext/standard/tests/file/readfile_variation3.phpt
@@ -0,0 +1,63 @@
+--TEST--
+Test readfile() function: usage variation - include path
+--FILE--
+<?php
+/* Prototype: int readfile ( string $filename [, bool $use_include_path [, resource $context]] );
+ Description: Outputs a file
+*/
+/* test readfile() by providing an include path, second argument */
+
+// include file.inc
+require("file.inc");
+
+$file_path = dirname(__FILE__);
+$dirname = "$file_path/readfile_variation3";
+
+echo "*** Testing readfile(): checking second argument, include path ***\n";
+// temp dir created
+mkdir($dirname);
+// temp file name used here
+$filename = "$dirname/readfile_variation3.tmp";
+// create file
+$fp = fopen($filename, "w");
+fill_file($fp, "text_with_new_line", 50);
+fclose($fp);
+
+// including $dirname in 'include_path'
+ini_set('include_path',$dirname);
+// 'include_path' set to true
+$count = readfile("readfile_variation3.tmp", true);
+echo "\n";
+var_dump($count);
+// use the context argument with include path
+echo "*** Testing readfile(): checking second argument, include path with context specified ***\n";
+$context = stream_context_create();
+$count = readfile("readfile_variation3.tmp", true, $context);
+echo "\n";
+var_dump($count);
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/readfile_variation3/readfile_variation3.tmp");
+rmdir(dirname(__FILE__)."/readfile_variation3");
+?>
+--EXPECT--
+*** Testing readfile(): checking second argument, include path ***
+line
+line of text
+line
+line of text
+line
+line of t
+int(50)
+*** Testing readfile(): checking second argument, include path with context specified ***
+line
+line of text
+line
+line of text
+line
+line of t
+int(50)
+Done
diff --git a/ext/standard/tests/file/readfile_variation4.phpt b/ext/standard/tests/file/readfile_variation4.phpt
new file mode 100644
index 0000000..94b3326
--- /dev/null
+++ b/ext/standard/tests/file/readfile_variation4.phpt
@@ -0,0 +1,251 @@
+--TEST--
+Test readfile() function : usage variation
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : int readfile(string filename [, bool use_include_path[, resource context]])
+ * Description: Output a file or a URL
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing readfile() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$filename = 'readFileVar4.tmp';
+$use_include_path = false;
+$h = fopen($filename,'wb');
+fwrite($h, "testing readfile");
+fclose($h);
+
+
+$fileRes = fopen(__FILE__, 'r');
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+ // int data
+ 'int 0' => 0,
+ 'int 1' => 1,
+ 'int 12345' => 12345,
+ 'int -12345' => -2345,
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float -10.5' => -10.5,
+ 'float 12.3456789000e10' => 12.3456789000e10,
+ 'float -12.3456789000e10' => -12.3456789000e10,
+ 'float .5' => .5,
+
+ // array data
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // string data
+ 'string DQ' => "string",
+ 'string SQ' => 'string',
+ 'mixed case string' => "sTrInG",
+ 'heredoc' => $heredoc,
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+
+ // file resource
+ 'file resource' => $fileRes,
+);
+
+// loop through each element of the array for context
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ $h = readfile($filename, $use_include_path, $value);
+ if ($h == false) {
+ echo "file not read\n";
+ }
+ else {
+ echo "\n";
+ }
+};
+
+unlink($filename);
+fclose($fileRes);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing readfile() : usage variation ***
+
+--int 0--
+Error: 2 - readfile() expects parameter 3 to be resource, integer given, %s(%d)
+file not read
+
+--int 1--
+Error: 2 - readfile() expects parameter 3 to be resource, integer given, %s(%d)
+file not read
+
+--int 12345--
+Error: 2 - readfile() expects parameter 3 to be resource, integer given, %s(%d)
+file not read
+
+--int -12345--
+Error: 2 - readfile() expects parameter 3 to be resource, integer given, %s(%d)
+file not read
+
+--float 10.5--
+Error: 2 - readfile() expects parameter 3 to be resource, double given, %s(%d)
+file not read
+
+--float -10.5--
+Error: 2 - readfile() expects parameter 3 to be resource, double given, %s(%d)
+file not read
+
+--float 12.3456789000e10--
+Error: 2 - readfile() expects parameter 3 to be resource, double given, %s(%d)
+file not read
+
+--float -12.3456789000e10--
+Error: 2 - readfile() expects parameter 3 to be resource, double given, %s(%d)
+file not read
+
+--float .5--
+Error: 2 - readfile() expects parameter 3 to be resource, double given, %s(%d)
+file not read
+
+--empty array--
+Error: 2 - readfile() expects parameter 3 to be resource, array given, %s(%d)
+file not read
+
+--int indexed array--
+Error: 2 - readfile() expects parameter 3 to be resource, array given, %s(%d)
+file not read
+
+--associative array--
+Error: 2 - readfile() expects parameter 3 to be resource, array given, %s(%d)
+file not read
+
+--nested arrays--
+Error: 2 - readfile() expects parameter 3 to be resource, array given, %s(%d)
+file not read
+
+--uppercase NULL--
+testing readfile
+
+--lowercase null--
+testing readfile
+
+--lowercase true--
+Error: 2 - readfile() expects parameter 3 to be resource, boolean given, %s(%d)
+file not read
+
+--lowercase false--
+Error: 2 - readfile() expects parameter 3 to be resource, boolean given, %s(%d)
+file not read
+
+--uppercase TRUE--
+Error: 2 - readfile() expects parameter 3 to be resource, boolean given, %s(%d)
+file not read
+
+--uppercase FALSE--
+Error: 2 - readfile() expects parameter 3 to be resource, boolean given, %s(%d)
+file not read
+
+--empty string DQ--
+Error: 2 - readfile() expects parameter 3 to be resource, string given, %s(%d)
+file not read
+
+--empty string SQ--
+Error: 2 - readfile() expects parameter 3 to be resource, string given, %s(%d)
+file not read
+
+--string DQ--
+Error: 2 - readfile() expects parameter 3 to be resource, string given, %s(%d)
+file not read
+
+--string SQ--
+Error: 2 - readfile() expects parameter 3 to be resource, string given, %s(%d)
+file not read
+
+--mixed case string--
+Error: 2 - readfile() expects parameter 3 to be resource, string given, %s(%d)
+file not read
+
+--heredoc--
+Error: 2 - readfile() expects parameter 3 to be resource, string given, %s(%d)
+file not read
+
+--instance of classWithToString--
+Error: 2 - readfile() expects parameter 3 to be resource, object given, %s(%d)
+file not read
+
+--instance of classWithoutToString--
+Error: 2 - readfile() expects parameter 3 to be resource, object given, %s(%d)
+file not read
+
+--undefined var--
+testing readfile
+
+--unset var--
+testing readfile
+
+--file resource--
+Error: 2 - readfile(): supplied resource is not a valid Stream-Context resource, %s(%d)
+testing readfile
+===DONE===
diff --git a/ext/standard/tests/file/readfile_variation5.phpt b/ext/standard/tests/file/readfile_variation5.phpt
new file mode 100644
index 0000000..21856f8
--- /dev/null
+++ b/ext/standard/tests/file/readfile_variation5.phpt
@@ -0,0 +1,221 @@
+--TEST--
+Test readfile() function : usage variation
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : int readfile(string filename [, bool use_include_path[, resource context]])
+ * Description: Output a file or a URL
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing readfile() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$filename = 'readFileVar5.tmp';
+$use_include_path = false;
+$h = fopen($filename,'wb');
+fwrite($h, "testing readfile");
+fclose($h);
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+ // int data
+ 'int 0' => 0,
+ 'int 1' => 1,
+ 'int 12345' => 12345,
+ 'int -12345' => -2345,
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float -10.5' => -10.5,
+ 'float 12.3456789000e10' => 12.3456789000e10,
+ 'float -12.3456789000e10' => -12.3456789000e10,
+ 'float .5' => .5,
+
+ // array data
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // string data
+ 'string DQ' => "string",
+ 'string SQ' => 'string',
+ 'mixed case string' => "sTrInG",
+ 'heredoc' => $heredoc,
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for use_include_path
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ $res = readfile($filename, $value);
+ if ($res == false) {
+ echo "File not read\n";
+ }
+ else {
+ echo "\n";
+ }
+};
+
+unlink($filename);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing readfile() : usage variation ***
+
+--int 0--
+testing readfile
+
+--int 1--
+testing readfile
+
+--int 12345--
+testing readfile
+
+--int -12345--
+testing readfile
+
+--float 10.5--
+testing readfile
+
+--float -10.5--
+testing readfile
+
+--float 12.3456789000e10--
+testing readfile
+
+--float -12.3456789000e10--
+testing readfile
+
+--float .5--
+testing readfile
+
+--empty array--
+Error: 2 - readfile() expects parameter 2 to be boolean, array given, %s(%d)
+File not read
+
+--int indexed array--
+Error: 2 - readfile() expects parameter 2 to be boolean, array given, %s(%d)
+File not read
+
+--associative array--
+Error: 2 - readfile() expects parameter 2 to be boolean, array given, %s(%d)
+File not read
+
+--nested arrays--
+Error: 2 - readfile() expects parameter 2 to be boolean, array given, %s(%d)
+File not read
+
+--uppercase NULL--
+testing readfile
+
+--lowercase null--
+testing readfile
+
+--lowercase true--
+testing readfile
+
+--lowercase false--
+testing readfile
+
+--uppercase TRUE--
+testing readfile
+
+--uppercase FALSE--
+testing readfile
+
+--empty string DQ--
+testing readfile
+
+--empty string SQ--
+testing readfile
+
+--string DQ--
+testing readfile
+
+--string SQ--
+testing readfile
+
+--mixed case string--
+testing readfile
+
+--heredoc--
+testing readfile
+
+--instance of classWithToString--
+Error: 2 - readfile() expects parameter 2 to be boolean, object given, %s(%d)
+File not read
+
+--instance of classWithoutToString--
+Error: 2 - readfile() expects parameter 2 to be boolean, object given, %s(%d)
+File not read
+
+--undefined var--
+testing readfile
+
+--unset var--
+testing readfile
+===DONE===
diff --git a/ext/standard/tests/file/readfile_variation6.phpt b/ext/standard/tests/file/readfile_variation6.phpt
new file mode 100644
index 0000000..02e7082
--- /dev/null
+++ b/ext/standard/tests/file/readfile_variation6.phpt
@@ -0,0 +1,50 @@
+--TEST--
+Test readfile() function : variation - test include path
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : int readfile(string filename [, bool use_include_path[, resource context]])
+ * Description: Output a file or a URL
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+require_once('fopen_include_path.inc');
+
+echo "*** Testing readfile() : variation ***\n";
+// this doesn't create the include dirs in this directory
+// we change to this to ensure we are not part of the
+// include paths.
+$thisTestDir = "readfileVar6.dir";
+mkdir($thisTestDir);
+chdir($thisTestDir);
+
+$filename = "afile.txt";
+$secondFile = $dir2."/".$filename;
+
+$newpath = create_include_path();
+set_include_path($newpath);
+runtest();
+teardown_include_path();
+restore_include_path();
+chdir("..");
+rmdir($thisTestDir);
+
+
+function runtest() {
+ global $secondFile, $filename;
+ $h = fopen($secondFile, "w");
+ fwrite($h, "File in include path");
+ fclose($h);
+ readfile($filename, true);
+ echo "\n";
+ unlink($secondFile);
+}
+
+?>
+===DONE===
+--EXPECT--
+*** Testing readfile() : variation ***
+File in include path
+===DONE===
diff --git a/ext/standard/tests/file/readfile_variation7.phpt b/ext/standard/tests/file/readfile_variation7.phpt
new file mode 100644
index 0000000..d26f52f
--- /dev/null
+++ b/ext/standard/tests/file/readfile_variation7.phpt
@@ -0,0 +1,50 @@
+--TEST--
+Test readfile() function : variation
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : int readfile(string filename [, bool use_include_path[, resource context]])
+ * Description: Output a file or a URL
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+require_once('fopen_include_path.inc');
+
+echo "*** Testing readfile() : variation ***\n";
+// this doesn't create the include dirs in this directory
+// we change to this to ensure we are not part of the
+// include paths.
+$thisTestDir = "readfileVar7.dir";
+mkdir($thisTestDir);
+chdir($thisTestDir);
+
+$filename = "readFileVar7.tmp";
+$scriptLocFile = dirname(__FILE__)."/".$filename;
+
+$newpath = create_include_path();
+set_include_path($newpath);
+runtest();
+teardown_include_path();
+restore_include_path();
+chdir("..");
+rmdir($thisTestDir);
+
+
+function runtest() {
+ global $scriptLocFile, $filename;
+ $h = fopen($scriptLocFile, "w");
+ fwrite($h, "File in script location");
+ fclose($h);
+ readfile($filename, true);
+ echo "\n";
+ unlink($scriptLocFile);
+}
+
+?>
+===DONE===
+--EXPECT--
+*** Testing readfile() : variation ***
+File in script location
+===DONE===
diff --git a/ext/standard/tests/file/readfile_variation8-win32.phpt b/ext/standard/tests/file/readfile_variation8-win32.phpt
new file mode 100644
index 0000000..a66af5d
--- /dev/null
+++ b/ext/standard/tests/file/readfile_variation8-win32.phpt
@@ -0,0 +1,109 @@
+--TEST--
+Test readfile() function : variation
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+ die("skip Only valid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype : int readfile(string filename [, bool use_include_path[, resource context]])
+ * Description: Output a file or a URL
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing readfile() : variation ***\n";
+$mainDir = "readfileVar8";
+$subDir = "readfileVar8Sub";
+$absMainDir = dirname(__FILE__)."\\".$mainDir;
+mkdir($absMainDir);
+$absSubDir = $absMainDir."\\".$subDir;
+mkdir($absSubDir);
+
+$theFile = "fileToRead.tmp";
+$absFile = $absSubDir.'/'.$theFile;
+
+// create the file
+$h = fopen($absFile,"w");
+fwrite($h, "The File Contents");
+fclose($h);
+
+
+$old_dir_path = getcwd();
+chdir(dirname(__FILE__));
+$unixifiedDir = '/'.substr(str_replace('\\','/',$absSubDir),3);
+
+$allDirs = array(
+ // absolute paths
+ "$absSubDir\\",
+ "$absSubDir\\..\\".$subDir,
+ "$absSubDir\\\\..\\.\\".$subDir,
+ "$absSubDir\\..\\..\\".$mainDir."\\.\\".$subDir,
+ "$absSubDir\\..\\\\\\".$subDir."\\\\..\\\\..\\".$subDir,
+ "$absSubDir\\BADDIR",
+
+ // relative paths
+ $mainDir."\\".$subDir,
+ $mainDir."\\\\".$subDir,
+ $mainDir."\\\\\\".$subDir,
+ ".\\".$mainDir."\\..\\".$mainDir."\\".$subDir,
+ "BADDIR",
+
+ // unixifed path
+ $unixifiedDir,
+);
+
+for($i = 0; $i<count($allDirs); $i++) {
+ $j = $i+1;
+ $dir = $allDirs[$i];
+ echo "\n-- $dir --\n";
+ $ok = readfile($dir.'\\'.$theFile);
+ if ($ok === 1) {
+ echo "\n";
+ }
+}
+
+unlink($absFile);
+chdir($old_dir_path);
+rmdir($absSubDir);
+rmdir($absMainDir);
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing readfile() : variation ***
+
+-- %s\readfileVar8\readfileVar8Sub\ --
+The File Contents
+-- %s\readfileVar8\readfileVar8Sub\..\readfileVar8Sub --
+The File Contents
+-- %s\readfileVar8\readfileVar8Sub\\..\.\readfileVar8Sub --
+The File Contents
+-- %s\readfileVar8\readfileVar8Sub\..\..\readfileVar8\.\readfileVar8Sub --
+The File Contents
+-- %s\readfileVar8\readfileVar8Sub\..\\\readfileVar8Sub\\..\\..\readfileVar8Sub --
+
+Warning: readfile(%s\readfileVar8\readfileVar8Sub\..\\\readfileVar8Sub\\..\\..\readfileVar8Sub\fileToRead.tmp): failed to open stream: No such file or directory in %s on line %d
+
+-- %s\readfileVar8\readfileVar8Sub\BADDIR --
+
+Warning: readfile(%s\readfileVar8\readfileVar8Sub\BADDIR\fileToRead.tmp): failed to open stream: No such file or directory in %s on line %d
+
+-- readfileVar8\readfileVar8Sub --
+The File Contents
+-- readfileVar8\\readfileVar8Sub --
+The File Contents
+-- readfileVar8\\\readfileVar8Sub --
+The File Contents
+-- .\readfileVar8\..\readfileVar8\readfileVar8Sub --
+The File Contents
+-- BADDIR --
+
+Warning: readfile(BADDIR\fileToRead.tmp): failed to open stream: No such file or directory in %s on line %d
+
+-- /%s/readfileVar8/readfileVar8Sub --
+The File Contents
+*** Done *** \ No newline at end of file
diff --git a/ext/standard/tests/file/readfile_variation9.phpt b/ext/standard/tests/file/readfile_variation9.phpt
new file mode 100644
index 0000000..c802f40
--- /dev/null
+++ b/ext/standard/tests/file/readfile_variation9.phpt
@@ -0,0 +1,99 @@
+--TEST--
+Test readfile() function : variation - variable types of path
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : int readfile(string filename [, bool use_include_path[, resource context]])
+ * Description: Output a file or a URL
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing readfile() : variation ***\n";
+$mainDir = "readfileVar8";
+$subDir = "readfileVar8Sub";
+$absMainDir = dirname(__FILE__)."/".$mainDir;
+mkdir($absMainDir);
+$absSubDir = $absMainDir."/".$subDir;
+mkdir($absSubDir);
+
+$theFile = "fileToRead.tmp";
+$absFile = $absSubDir.'/'.$theFile;
+
+// create the file
+$h = fopen($absFile,"w");
+fwrite($h, "The File Contents");
+fclose($h);
+
+
+$old_dir_path = getcwd();
+chdir(dirname(__FILE__));
+
+$allDirs = array(
+ // absolute paths
+ "$absSubDir/",
+ "$absSubDir/../".$subDir,
+ "$absSubDir//.././".$subDir,
+ "$absSubDir/../../".$mainDir."/./".$subDir,
+ "$absSubDir/..///".$subDir."//..//../".$subDir,
+ "$absSubDir/BADDIR",
+
+
+ // relative paths
+ $mainDir."/".$subDir,
+ $mainDir."//".$subDir,
+ $mainDir."///".$subDir,
+ "./".$mainDir."/../".$mainDir."/".$subDir,
+ "BADDIR",
+);
+
+for($i = 0; $i<count($allDirs); $i++) {
+ $j = $i+1;
+ $dir = $allDirs[$i];
+ echo "\n-- Iteration $j --\n";
+ $ok = readfile($dir.'/'.$theFile);
+ if ($ok === 1) {
+ echo "\n";
+ }
+}
+
+unlink($absFile);
+chdir($old_dir_path);
+rmdir($absSubDir);
+rmdir($absMainDir);
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing readfile() : variation ***
+
+-- Iteration 1 --
+The File Contents
+-- Iteration 2 --
+The File Contents
+-- Iteration 3 --
+The File Contents
+-- Iteration 4 --
+The File Contents
+-- Iteration 5 --
+
+Warning: readfile(%sreadfileVar8Sub/..///readfileVar8Sub//..//../readfileVar8Sub/fileToRead.tmp): failed to open stream: No such file or directory in %s on line %d
+
+-- Iteration 6 --
+
+Warning: readfile(%sreadfileVar8Sub/BADDIR/fileToRead.tmp): failed to open stream: No such file or directory in %s on line %d
+
+-- Iteration 7 --
+The File Contents
+-- Iteration 8 --
+The File Contents
+-- Iteration 9 --
+The File Contents
+-- Iteration 10 --
+The File Contents
+-- Iteration 11 --
+
+Warning: readfile(BADDIR/fileToRead.tmp): failed to open stream: No such file or directory in %s on line %d
+
+*** Done *** \ No newline at end of file
diff --git a/ext/standard/tests/file/readlink_realpath_basic1.phpt b/ext/standard/tests/file/readlink_realpath_basic1.phpt
new file mode 100644
index 0000000..99195e2
--- /dev/null
+++ b/ext/standard/tests/file/readlink_realpath_basic1.phpt
@@ -0,0 +1,111 @@
+--TEST--
+Test readlink() and realpath functions: basic functionality - diff. path notation for links(Bug #42038)
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip no symlinks on Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: string readlink ( string $path );
+ Description: Returns the target of a symbolic link
+
+ Prototype: string realpath ( string $path );
+ Description: Returns canonicalized absolute pathname
+*/
+
+/* creating directories, symbolic links and files */
+$file_path = dirname(__FILE__);
+mkdir("$file_path/readlink_realpath_basic1/home/test/", 0777, true);
+
+$file_handle1 = fopen("$file_path/readlink_realpath_basic1/home/test/readlink_realpath_basic1.tmp", "w");
+$file_handle2 = fopen("$file_path/readlink_realpath_basic1/home/readlink_realpath_basic1.tmp", "w");
+$file_handle3 = fopen("$file_path/readlink_realpath_basic1/readlink_realpath_basic1.tmp", "w");
+fclose($file_handle1);
+fclose($file_handle2);
+fclose($file_handle3);
+
+symlink("$file_path/readlink_realpath_basic1/home/test/readlink_realpath_basic1.tmp",
+ "$file_path/readlink_realpath_basic1/home/test/readlink_realpath_basic1_link.tmp");
+symlink("$file_path/readlink_realpath_basic1/home/readlink_realpath_basic1.tmp",
+ "$file_path/readlink_realpath_basic1/home/readlink_realpath_basic1_link.tmp");
+
+
+echo "*** Testing readlink() and realpath(): with valid and invalid path ***\n";
+$linknames = array (
+ /* linknames resulting in valid paths */
+ "$file_path/readlink_realpath_basic1/home/readlink_realpath_basic1_link.tmp",
+ "$file_path/readlink_realpath_basic1/home/test/readlink_realpath_basic1_link.tmp",
+ "$file_path/readlink_realpath_basic1//home/test//../test/./readlink_realpath_basic1_link.tmp",
+
+ /* linknames with invalid linkpath */
+ "$file_path///readlink_realpath_basic1/home//..//././test//readlink_realpath_basic1_link.tmp",
+ "$file_path/readlink_realpath_basic1/home/../home/../test/../readlink_realpath_basic1_link.tmp",
+ "$file_path/readlink_realpath_basic1/..readlink_realpath_basic1_link.tmp",
+ "$file_path/readlink_realpath_basic1/home/test/readlink_realpath_basic1_link.tmp/"
+);
+
+$counter = 1;
+/* loop through $files to read the linkpath of
+ the link created from each $file in the above array */
+foreach($linknames as $link) {
+ echo "\n-- Iteration $counter --\n";
+ var_dump( readlink($link) );
+ var_dump( realpath($link) );
+ $counter++;
+}
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+$name_prefix = dirname(__FILE__)."/readlink_realpath_basic1";
+unlink("$name_prefix/home/test/readlink_realpath_basic1.tmp");
+unlink("$name_prefix/home/readlink_realpath_basic1.tmp");
+unlink("$name_prefix/readlink_realpath_basic1.tmp");
+unlink("$name_prefix/home/test/readlink_realpath_basic1_link.tmp");
+unlink("$name_prefix/home/readlink_realpath_basic1_link.tmp");
+rmdir("$name_prefix/home/test/");
+rmdir("$name_prefix/home/");
+rmdir("$name_prefix/");
+?>
+--EXPECTF--
+*** Testing readlink() and realpath(): with valid and invalid path ***
+
+-- Iteration 1 --
+string(%d) "%s/readlink_realpath_basic1/home/readlink_realpath_basic1.tmp"
+string(%d) "%s/readlink_realpath_basic1/home/readlink_realpath_basic1.tmp"
+
+-- Iteration 2 --
+string(%d) "%s/readlink_realpath_basic1/home/test/readlink_realpath_basic1.tmp"
+string(%d) "%s/readlink_realpath_basic1/home/test/readlink_realpath_basic1.tmp"
+
+-- Iteration 3 --
+string(%d) "%s/readlink_realpath_basic1/home/test/readlink_realpath_basic1.tmp"
+string(%d) "%s/readlink_realpath_basic1/home/test/readlink_realpath_basic1.tmp"
+
+-- Iteration 4 --
+
+Warning: readlink(): No such file or directory in %s on line %d
+bool(false)
+bool(false)
+
+-- Iteration 5 --
+
+Warning: readlink(): No such file or directory in %s on line %d
+bool(false)
+bool(false)
+
+-- Iteration 6 --
+
+Warning: readlink(): No such file or directory in %s on line %d
+bool(false)
+%s
+
+-- Iteration 7 --
+
+Warning: readlink(): %s in %s on line %d
+bool(false)
+%s
+Done
diff --git a/ext/standard/tests/file/readlink_realpath_basic2.phpt b/ext/standard/tests/file/readlink_realpath_basic2.phpt
new file mode 100644
index 0000000..91955cd
--- /dev/null
+++ b/ext/standard/tests/file/readlink_realpath_basic2.phpt
@@ -0,0 +1,86 @@
+--TEST--
+Test readlink() and realpath functions: basic functionality - diff. path notation for files
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip no symlinks on Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: string readlink ( string $path );
+ Description: Returns the target of a symbolic link
+
+ Prototype: string realpath ( string $path );
+ Description: Returns canonicalized absolute pathname
+*/
+
+/* creating directories, symbolic links and files */
+$file_path = dirname(__FILE__);
+mkdir("$file_path/readlink_realpath_basic2/home/test/", 0777, true);
+
+$file_handle1 = fopen("$file_path/readlink_realpath_basic2/home/test/readlink_realpath_basic2.tmp", "w");
+$file_handle2 = fopen("$file_path/readlink_realpath_basic2/home/readlink_realpath_basic2.tmp", "w");
+$file_handle3 = fopen("$file_path/readlink_realpath_basic2/readlink_realpath_basic2.tmp", "w");
+fclose($file_handle1);
+fclose($file_handle2);
+fclose($file_handle3);
+
+echo "\n*** Testing realpath() on filenames ***\n";
+$filenames = array (
+ /* filenames resulting in valid paths */
+ "$file_path/readlink_realpath_basic2/home/readlink_realpath_basic2.tmp",
+ "$file_path/readlink_realpath_basic2/readlink_realpath_basic2.tmp",
+ "$file_path/readlink_realpath_basic2//home/test//../test/./readlink_realpath_basic2.tmp",
+ "$file_path/readlink_realpath_basic2/home//../././readlink_realpath_basic2.tmp",
+
+ /* filenames with invalid path */
+ "$file_path///readlink_realpath_basic2/home//..//././test//readlink_realpath_basic2.tmp",
+ "$file_path/readlink_realpath_basic2/home/../home/../test/../readlink_realpath_basic2.tmp",
+ "$file_path/readlink_realpath_basic2/readlink_realpath_basic2.tmp/"
+);
+
+$counter = 1;
+/* loop through $files to read the filepath of $file in the above array */
+foreach($filenames as $file) {
+ echo "\n-- Iteration $counter --\n";
+ var_dump( realpath($file) );
+ $counter++;
+}
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+$name_prefix = dirname(__FILE__)."/readlink_realpath_basic2";
+unlink("$name_prefix/home/test/readlink_realpath_basic2.tmp");
+unlink("$name_prefix/home/readlink_realpath_basic2.tmp");
+unlink("$name_prefix/readlink_realpath_basic2.tmp");
+rmdir("$name_prefix/home/test/");
+rmdir("$name_prefix/home/");
+rmdir("$name_prefix/");
+?>
+--EXPECTF--
+*** Testing realpath() on filenames ***
+
+-- Iteration 1 --
+string(%d) "%s/readlink_realpath_basic2/home/readlink_realpath_basic2.tmp"
+
+-- Iteration 2 --
+string(%d) "%s/readlink_realpath_basic2/readlink_realpath_basic2.tmp"
+
+-- Iteration 3 --
+string(%d) "%s/readlink_realpath_basic2/home/test/readlink_realpath_basic2.tmp"
+
+-- Iteration 4 --
+string(%d) "%s/readlink_realpath_basic2/readlink_realpath_basic2.tmp"
+
+-- Iteration 5 --
+bool(false)
+
+-- Iteration 6 --
+bool(false)
+
+-- Iteration 7 --
+%s
+Done
diff --git a/ext/standard/tests/file/readlink_realpath_error.phpt b/ext/standard/tests/file/readlink_realpath_error.phpt
new file mode 100644
index 0000000..dc042bf
--- /dev/null
+++ b/ext/standard/tests/file/readlink_realpath_error.phpt
@@ -0,0 +1,73 @@
+--TEST--
+Test readlink() and realpath() functions: error conditions
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip no symlinks on Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: string readlink ( string $path );
+ Description: Returns the target of a symbolic link
+
+ Prototype: string realpath ( string $path );
+ Description: Returns canonicalized absolute pathname
+*/
+
+echo "*** Testing readlink(): error conditions ***\n";
+var_dump( readlink() ); // args < expected
+var_dump( readlink(__FILE__, 2) ); // args > expected
+
+echo "\n*** Testing readlink() on a non-existent link ***\n";
+var_dump( readlink(dirname(__FILE__)."/readlink_error.tmp") );
+
+echo "\n*** Testing readlink() on existing file ***\n";
+var_dump( readlink(__FILE__) );
+
+echo "\n*** Testing readlink() on existing directory ***\n";
+var_dump( readlink(dirname(__FILE__)) );
+
+echo "*** Testing realpath(): error conditions ***\n";
+var_dump( realpath() ); // args < expected
+var_dump( realpath(1, 2) ); // args > expected
+
+echo "\n*** Testing realpath() on a non-existent file ***\n";
+var_dump( realpath(dirname(__FILE__)."/realpath_error.tmp") );
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing readlink(): error conditions ***
+
+Warning: readlink() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: readlink() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+
+*** Testing readlink() on a non-existent link ***
+
+Warning: readlink(): No such file or directory in %s on line %d
+bool(false)
+
+*** Testing readlink() on existing file ***
+
+Warning: readlink(): Invalid argument in %s on line %d
+bool(false)
+
+*** Testing readlink() on existing directory ***
+
+Warning: readlink(): Invalid argument in %s on line %d
+bool(false)
+*** Testing realpath(): error conditions ***
+
+Warning: realpath() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: realpath() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+
+*** Testing realpath() on a non-existent file ***
+%s
+Done
diff --git a/ext/standard/tests/file/readlink_realpath_variation1.phpt b/ext/standard/tests/file/readlink_realpath_variation1.phpt
new file mode 100644
index 0000000..9c795e9
--- /dev/null
+++ b/ext/standard/tests/file/readlink_realpath_variation1.phpt
@@ -0,0 +1,99 @@
+--TEST--
+Test readlink() and realpath() functions: usage variation - linkname/filename stored in object(Bug #42038)
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip no symlinks on Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: string readlink ( string $path );
+ Description: Returns the target of a symbolic link
+
+ Prototype: string realpath ( string $path );
+ Description: Returns canonicalized absolute pathname
+*/
+
+echo "*** Testing readlink() and realpath() : usage variations ***\n";
+$name_prefix = dirname(__FILE__);
+$filename = "$name_prefix/readlink_realpath_variation1/home/tests/link/readlink_realpath_variation1.tmp";
+mkdir("$name_prefix/readlink_realpath_variation1/home/tests/link/", 0777, true);
+
+echo "\n*** Testing readlink() and realpath() with linkname stored inside a object ***\n";
+// create a temp file
+$file_handle = fopen($filename, "w");
+fclose($file_handle);
+
+// creating object with members as linkname
+class object_temp {
+ public $linkname;
+ function object_temp($link) {
+ $this->linkname = $link;
+ }
+}
+$obj1 = new object_temp("$name_prefix/readlink_realpath_variation1/../././readlink_realpath_variation1/home/readlink_realpath_variation1_link.tmp");
+$obj2 = new object_temp("$name_prefix/readlink_realpath_variation1/home/../..///readlink_realpath_variation1_link.tmp");
+
+echo "\n-- Testing readlink() and realpath() with softlink, linkname stored inside an object --\n";
+// creating the links
+var_dump( symlink($filename, $obj1->linkname) );
+var_dump( readlink($obj1->linkname) );
+var_dump( realpath($obj1->linkname) );
+var_dump( symlink($filename, $obj2->linkname) );
+var_dump( readlink($obj2->linkname) );
+var_dump( realpath($obj2->linkname) );
+
+// deleting the link
+unlink($obj1->linkname);
+unlink($obj2->linkname);
+
+echo "\n-- Testing readlink() and realpath() with hardlink, linkname stored inside an object --\n";
+// creating hard links
+var_dump( link($filename, $obj1->linkname) );
+var_dump( readlink($obj1->linkname) ); // invalid because readlink doesn't work with hardlink
+var_dump( realpath($obj1->linkname) );
+var_dump( link($filename, $obj2->linkname) );
+var_dump( readlink($obj2->linkname) ); // invalid because readlink doesn't work with hardlink
+var_dump( realpath($obj2->linkname) );
+
+// delete the links
+unlink($obj1->linkname);
+unlink($obj2->linkname);
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+$name_prefix = dirname(__FILE__)."/readlink_realpath_variation1";
+unlink("$name_prefix/home/tests/link/readlink_realpath_variation1.tmp");
+rmdir("$name_prefix/home/tests/link/");
+rmdir("$name_prefix/home/tests/");
+rmdir("$name_prefix/home/");
+rmdir("$name_prefix/");
+?>
+--EXPECTF--
+*** Testing readlink() and realpath() : usage variations ***
+
+*** Testing readlink() and realpath() with linkname stored inside a object ***
+
+-- Testing readlink() and realpath() with softlink, linkname stored inside an object --
+bool(true)
+string(%d) "%s/readlink_realpath_variation1/home/tests/link/readlink_realpath_variation1.tmp"
+string(%d) "%s/readlink_realpath_variation1/home/tests/link/readlink_realpath_variation1.tmp"
+bool(true)
+string(%d) "%s/readlink_realpath_variation1/home/tests/link/readlink_realpath_variation1.tmp"
+string(%d) "%s/readlink_realpath_variation1/home/tests/link/readlink_realpath_variation1.tmp"
+
+-- Testing readlink() and realpath() with hardlink, linkname stored inside an object --
+bool(true)
+
+Warning: readlink(): Invalid argument in %s on line %d
+bool(false)
+string(%d) "%s/readlink_realpath_variation1/home/readlink_realpath_variation1_link.tmp"
+bool(true)
+
+Warning: readlink(): Invalid argument in %s on line %d
+bool(false)
+string(%d) "%s/readlink_realpath_variation1_link.tmp"
+Done
diff --git a/ext/standard/tests/file/readlink_realpath_variation2.phpt b/ext/standard/tests/file/readlink_realpath_variation2.phpt
new file mode 100644
index 0000000..0e74857
--- /dev/null
+++ b/ext/standard/tests/file/readlink_realpath_variation2.phpt
@@ -0,0 +1,104 @@
+--TEST--
+Test readlink() and realpath() functions: usage variation - linkname/filename stored in array(Bug #42038)
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip no symlinks on Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: string readlink ( string $path );
+ Description: Returns the target of a symbolic link
+
+ Prototype: string realpath ( string $path );
+ Description: Returns canonicalized absolute pathname
+*/
+
+echo "*** Testing readlink() and realpath() : usage variations ***\n";
+$name_prefix = dirname(__FILE__);
+// create temp dir
+mkdir("$name_prefix/readlink_realpath_variation2/home/tests/link/", 0777, true);
+// create the file
+$filename = "$name_prefix/readlink_realpath_variation2/home/tests/link/readlink_realpath_variation2.tmp";
+$fp = fopen($filename, "w");
+fclose($fp);
+
+echo "\n*** Testing readlink() and realpath() with linkname stored in an array ***\n";
+$link_arr = array (
+ "$name_prefix////readlink_realpath_variation2/home/tests/link/readlink_realpath_variation2_link.tmp",
+ "$name_prefix/./readlink_realpath_variation2/home/../home//tests//..//..//..//home//readlink_realpath_variation2_link.tmp/"
+);
+
+echo "\n-- Testing readlink() and realpath() with softlink, linkname stored inside an array --\n";
+// creating the links
+var_dump( symlink($filename, $link_arr[0]) );
+var_dump( readlink($link_arr[0]) );
+var_dump( realpath($link_arr[0]) );
+var_dump( symlink($filename, $link_arr[1]) );
+var_dump( readlink($link_arr[1]) );
+var_dump( realpath($link_arr[1]) );
+
+// deleting the link
+unlink($link_arr[0]);
+unlink($link_arr[1]);
+
+echo "\n-- Testing readlink() and realpath() with hardlink, linkname stored inside an array --\n";
+// creating hard links
+var_dump( link($filename, $link_arr[0]) );
+var_dump( readlink($link_arr[0]) ); // invalid because readlink doesn't work with hardlink
+var_dump( realpath($link_arr[0]) );
+var_dump( link($filename, $link_arr[1]) );
+var_dump( readlink($link_arr[1]) ); // invalid because readlink doesn't work with hardlink
+var_dump( realpath($link_arr[1]) );
+
+// delete the links
+unlink($link_arr[0]);
+unlink($link_arr[1]);
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+$name_prefix = dirname(__FILE__)."/readlink_realpath_variation2";
+unlink("$name_prefix/home/tests/link/readlink_realpath_variation2.tmp");
+rmdir("$name_prefix/home/tests/link/");
+rmdir("$name_prefix/home/tests/");
+rmdir("$name_prefix/home/");
+rmdir("$name_prefix/");
+?>
+--EXPECTF--
+*** Testing readlink() and realpath() : usage variations ***
+
+*** Testing readlink() and realpath() with linkname stored in an array ***
+
+-- Testing readlink() and realpath() with softlink, linkname stored inside an array --
+bool(true)
+string(%d) "%s/readlink_realpath_variation2/home/tests/link/readlink_realpath_variation2.tmp"
+string(%d) "%s/readlink_realpath_variation2/home/tests/link/readlink_realpath_variation2.tmp"
+
+Warning: symlink(): No such file or directory in %s on line %d
+bool(false)
+
+Warning: readlink(): No such file or directory in %s on line %d
+bool(false)
+bool(false)
+
+Warning: unlink(%s/./readlink_realpath_variation2/home/../home//tests//..//..//..//home//readlink_realpath_variation2_link.tmp/): No such file or directory in %s on line %d
+
+-- Testing readlink() and realpath() with hardlink, linkname stored inside an array --
+bool(true)
+
+Warning: readlink(): Invalid argument in %s on line %d
+bool(false)
+string(%d) "%s/readlink_realpath_variation2/home/tests/link/readlink_realpath_variation2_link.tmp"
+
+Warning: link(): No such file or directory in %s on line %d
+bool(false)
+
+Warning: readlink(): No such file or directory in %s on line %d
+bool(false)
+bool(false)
+
+Warning: unlink(%s/./readlink_realpath_variation2/home/../home//tests//..//..//..//home//readlink_realpath_variation2_link.tmp/): No such file or directory in %s on line %d
+Done
diff --git a/ext/standard/tests/file/readlink_realpath_variation3.phpt b/ext/standard/tests/file/readlink_realpath_variation3.phpt
new file mode 100644
index 0000000..3766a5b
--- /dev/null
+++ b/ext/standard/tests/file/readlink_realpath_variation3.phpt
@@ -0,0 +1,77 @@
+--TEST--
+Test readlink() and realpath() functions: usage variation - invalid args
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip no symlinks on Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: string readlink ( string $path );
+ Description: Returns the target of a symbolic link
+
+ Prototype: string realpath ( string $path );
+ Description: Returns canonicalized absolute pathname
+*/
+
+echo "*** Testing readlink() and realpath() : usage variations ***\n";
+
+echo "\n*** Testing readlink() and realpath() with linkname as empty string, NULL and single space ***\n";
+$link_string = array (
+ /* linkname as spaces */
+ " ",
+ ' ',
+
+ /* empty linkname */
+ "",
+ '',
+ NULL,
+ null
+ );
+for($loop_counter = 0; $loop_counter < count($link_string); $loop_counter++) {
+ echo "-- Iteration";
+ echo $loop_counter + 1;
+ echo " --\n";
+
+ var_dump( readlink($link_string[$loop_counter]) );
+ var_dump( realpath($link_string[$loop_counter]) );
+}
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing readlink() and realpath() : usage variations ***
+
+*** Testing readlink() and realpath() with linkname as empty string, NULL and single space ***
+-- Iteration1 --
+
+Warning: readlink(): %s in %s on line %d
+bool(false)
+%s
+-- Iteration2 --
+
+Warning: readlink(): %s in %s on line %d
+bool(false)
+%s
+-- Iteration3 --
+
+Warning: readlink(): %s in %s on line %d
+bool(false)
+string(%d) "%s"
+-- Iteration4 --
+
+Warning: readlink(): %s in %s on line %d
+bool(false)
+string(%d) "%s"
+-- Iteration5 --
+
+Warning: readlink(): %s in %s on line %d
+bool(false)
+string(%d) "%s"
+-- Iteration6 --
+
+Warning: readlink(): %s in %s on line %d
+bool(false)
+string(%d) "%s"
+Done
diff --git a/ext/standard/tests/file/readlink_variation1.phpt b/ext/standard/tests/file/readlink_variation1.phpt
new file mode 100644
index 0000000..1dae17c
--- /dev/null
+++ b/ext/standard/tests/file/readlink_variation1.phpt
@@ -0,0 +1,78 @@
+--TEST--
+Test readlink() function: usage variations - invalid filenames
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip no links on Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: string readlink ( string $path );
+ Description: Returns the target of a symbolic link */
+
+/* Testing readlink() with invalid arguments -int, float, bool, NULL, resource */
+
+$file_path = dirname(__FILE__);
+$file_handle = fopen($file_path."/readlink_variation2.tmp", "w");
+
+echo "*** Testing Invalid file types ***\n";
+$filenames = array(
+ /* Invalid filenames */
+ -2.34555,
+ "",
+ TRUE,
+ FALSE,
+ NULL,
+ $file_handle,
+
+ /* scalars */
+ 1234,
+ 0
+);
+
+/* loop through to test each element the above array */
+foreach( $filenames as $filename ) {
+ var_dump( readlink($filename) );
+ clearstatcache();
+}
+fclose($file_handle);
+
+echo "\n*** Done ***";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/readlink_variation2.tmp");
+?>
+--EXPECTF--
+*** Testing Invalid file types ***
+
+Warning: readlink(): %s in %s on line %d
+bool(false)
+
+Warning: readlink(): %s in %s on line %d
+bool(false)
+
+Warning: readlink(): %s in %s on line %d
+bool(false)
+
+Warning: readlink(): %s in %s on line %d
+bool(false)
+
+Warning: readlink(): %s in %s on line %d
+bool(false)
+
+Warning: readlink() expects parameter 1 to be string, resource given in %s on line %d
+NULL
+
+Warning: readlink(): %s in %s on line %d
+bool(false)
+
+Warning: readlink(): %s in %s on line %d
+bool(false)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/realpath_basic-win32.phpt b/ext/standard/tests/file/realpath_basic-win32.phpt
new file mode 100644
index 0000000..5ebfcff
--- /dev/null
+++ b/ext/standard/tests/file/realpath_basic-win32.phpt
@@ -0,0 +1,89 @@
+--TEST--
+Test realpath() function: basic functionality
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip only on Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: string realpath ( string $path );
+ Description: Returns canonicalized absolute pathname
+*/
+
+echo "\n*** Testing basic functions of realpath() with files ***\n";
+
+/* creating directories and files */
+$file_path = dirname(__FILE__);
+mkdir("$file_path/realpath_basic/home/test/", 0777, true);
+
+$file_handle1 = fopen("$file_path/realpath_basic/home/test/realpath_basic.tmp", "w");
+$file_handle2 = fopen("$file_path/realpath_basic/home/realpath_basic.tmp", "w");
+$file_handle3 = fopen("$file_path/realpath_basic/realpath_basic.tmp", "w");
+fclose($file_handle1);
+fclose($file_handle2);
+fclose($file_handle3);
+
+echo "\n*** Testing realpath() on filenames ***\n";
+$filenames = array (
+ /* filenames resulting in valid paths */
+ "$file_path/realpath_basic/home/realpath_basic.tmp",
+ "$file_path/realpath_basic/realpath_basic.tmp/",
+ "$file_path/realpath_basic//home/test//../test/./realpath_basic.tmp",
+ "$file_path/realpath_basic/home//../././realpath_basic.tmp//",
+
+ // checking for binary safe
+ b"$file_path/realpath_basic/home/realpath_basic.tmp",
+
+ /* filenames with invalid path */
+ "$file_path///realpath_basic/home//..//././test//realpath_basic.tmp",
+ "$file_path/realpath_basic/home/../home/../test/../..realpath_basic.tmp"
+);
+
+$counter = 1;
+/* loop through $files to read the filepath of $file in the above array */
+foreach($filenames as $file) {
+ echo "\n-- Iteration $counter --\n";
+ var_dump( realpath($file) );
+ $counter++;
+}
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+$name_prefix = dirname(__FILE__)."/realpath_basic";
+unlink("$name_prefix/home/test/realpath_basic.tmp");
+unlink("$name_prefix/home/realpath_basic.tmp");
+unlink("$name_prefix/realpath_basic.tmp");
+rmdir("$name_prefix/home/test/");
+rmdir("$name_prefix/home/");
+rmdir("$name_prefix/");
+?>
+--EXPECTF--
+*** Testing basic functions of realpath() with files ***
+
+*** Testing realpath() on filenames ***
+
+-- Iteration 1 --
+string(%d) "%s\realpath_basic\home\realpath_basic.tmp"
+
+-- Iteration 2 --
+bool(false)
+
+-- Iteration 3 --
+string(%d) "%s\realpath_basic\home\test\realpath_basic.tmp"
+
+-- Iteration 4 --
+bool(false)
+
+-- Iteration 5 --
+string(%d) "%s\realpath_basic\home\realpath_basic.tmp"
+
+-- Iteration 6 --
+bool(false)
+
+-- Iteration 7 --
+bool(false)
+Done
diff --git a/ext/standard/tests/file/realpath_basic2.phpt b/ext/standard/tests/file/realpath_basic2.phpt
new file mode 100644
index 0000000..87fc8ba
--- /dev/null
+++ b/ext/standard/tests/file/realpath_basic2.phpt
@@ -0,0 +1,13 @@
+--TEST--
+realpath() with relative directory
+--FILE--
+<?php
+
+var_dump(realpath('.') == realpath(getcwd()));
+chdir('..');
+var_dump(realpath('.') == realpath(getcwd()));
+
+?>
+--EXPECT--
+bool(true)
+bool(true)
diff --git a/ext/standard/tests/file/realpath_basic3.phpt b/ext/standard/tests/file/realpath_basic3.phpt
new file mode 100644
index 0000000..ce93855
--- /dev/null
+++ b/ext/standard/tests/file/realpath_basic3.phpt
@@ -0,0 +1,86 @@
+--TEST--
+Test realpath() with relative paths
+--FILE--
+<?php
+/* Prototype: string realpath ( string $path );
+ Description: Returns canonicalized absolute pathname
+*/
+
+echo "\n*** Testing basic functions of realpath() with files ***\n";
+
+/* creating directories and files */
+$file_path = dirname(__FILE__);
+mkdir("$file_path/realpath_basic/home/test/", 0777, true);
+
+$file_handle1 = fopen("$file_path/realpath_basic/home/test/realpath_basic.tmp", "w");
+$file_handle2 = fopen("$file_path/realpath_basic/home/realpath_basic.tmp", "w");
+$file_handle3 = fopen("$file_path/realpath_basic/realpath_basic.tmp", "w");
+fclose($file_handle1);
+fclose($file_handle2);
+fclose($file_handle3);
+
+echo "\n*** Testing realpath() on filenames ***\n";
+$filenames = array (
+ /* filenames resulting in valid paths */
+ "./realpath_basic/home/realpath_basic.tmp",
+ "./realpath_basic/realpath_basic.tmp",
+ "./realpath_basic//home/test//../test/./realpath_basic.tmp",
+ "./realpath_basic/home//../././realpath_basic.tmp",
+
+ /* filenames with invalid path */
+ // checking for binary safe
+ "./realpath_basicx000/home/realpath_basic.tmp",
+
+ ".///realpath_basic/home//..//././test//realpath_basic.tmp",
+ "./realpath_basic/home/../home/../test/..realpath_basic.tmp"
+);
+
+chdir("$file_path/..");
+chdir($file_path);
+
+$counter = 1;
+/* loop through $files to read the filepath of $file in the above array */
+foreach($filenames as $file) {
+ echo "\n-- Iteration $counter --\n";
+ var_dump( realpath($file) );
+ $counter++;
+}
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+$name_prefix = dirname(__FILE__)."/realpath_basic";
+unlink("$name_prefix/home/test/realpath_basic.tmp");
+unlink("$name_prefix/home/realpath_basic.tmp");
+unlink("$name_prefix/realpath_basic.tmp");
+rmdir("$name_prefix/home/test/");
+rmdir("$name_prefix/home/");
+rmdir("$name_prefix/");
+?>
+--EXPECTF--
+*** Testing basic functions of realpath() with files ***
+
+*** Testing realpath() on filenames ***
+
+-- Iteration 1 --
+string(%d) "%srealpath_basic%shome%srealpath_basic.tmp"
+
+-- Iteration 2 --
+string(%d) "%srealpath_basic%srealpath_basic.tmp"
+
+-- Iteration 3 --
+string(%d) "%srealpath_basic%shome%stest%srealpath_basic.tmp"
+
+-- Iteration 4 --
+string(%d) "%srealpath_basic%srealpath_basic.tmp"
+
+-- Iteration 5 --
+bool(false)
+
+-- Iteration 6 --
+bool(false)
+
+-- Iteration 7 --
+bool(false)
+Done
diff --git a/ext/standard/tests/file/realpath_basic4.phpt b/ext/standard/tests/file/realpath_basic4.phpt
new file mode 100644
index 0000000..d782b6d
--- /dev/null
+++ b/ext/standard/tests/file/realpath_basic4.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Test realpath() with relative paths
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip no symlinks on Windows');
+}
+?>
+--FILE--
+<?php
+$file_path = dirname(__FILE__);
+@mkdir("$file_path/realpath_basic/home/test", 0777, true);
+@symlink("$file_path/realpath_basic/home", "$file_path/realpath_basic/link1");
+@symlink("$file_path/realpath_basic/link1", "$file_path/realpath_basic/link2");
+echo "1. " . realpath("$file_path/realpath_basic/link2") . "\n";
+echo "2. " . realpath("$file_path/realpath_basic/link2/test") . "\n";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink("$file_path/realpath_basic/link2");
+unlink("$file_path/realpath_basic/link1");
+rmdir("$file_path/realpath_basic/home/test");
+rmdir("$file_path/realpath_basic/home");
+rmdir("$file_path/realpath_basic");
+?>
+--EXPECTF--
+1. %s%erealpath_basic%ehome
+2. %s%erealpath_basic%ehome%etest
diff --git a/ext/standard/tests/file/realpath_cache.phpt b/ext/standard/tests/file/realpath_cache.phpt
new file mode 100644
index 0000000..0eb9dc5
--- /dev/null
+++ b/ext/standard/tests/file/realpath_cache.phpt
@@ -0,0 +1,30 @@
+--TEST--
+realpath_cache_size() and realpath_cache_get()
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip not on Windows');
+}
+?>
+--FILE--
+<?php
+
+var_dump(realpath_cache_size());
+$data = realpath_cache_get();
+var_dump($data[__DIR__]);
+
+echo "Done\n";
+?>
+--EXPECTF--
+int(%d)
+array(4) {
+ ["key"]=>
+ %s(%f)
+ ["is_dir"]=>
+ bool(true)
+ ["realpath"]=>
+ string(%d) "%sfile"
+ ["expires"]=>
+ int(%d)
+}
+Done
diff --git a/ext/standard/tests/file/realpath_cache_win32.phpt b/ext/standard/tests/file/realpath_cache_win32.phpt
new file mode 100644
index 0000000..a4c663f
--- /dev/null
+++ b/ext/standard/tests/file/realpath_cache_win32.phpt
@@ -0,0 +1,38 @@
+--TEST--
+realpath_cache_size() and realpath_cache_get()
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip only on Windows');
+}
+?>
+--FILE--
+<?php
+
+var_dump(realpath_cache_size());
+$data = realpath_cache_get();
+var_dump($data[__DIR__]);
+
+echo "Done\n";
+?>
+--EXPECTF--
+int(%d)
+array(8) {
+ ["key"]=>
+ %s(%d)
+ ["is_dir"]=>
+ bool(true)
+ ["realpath"]=>
+ string(%d) "%sfile"
+ ["expires"]=>
+ int(%d)
+ ["is_rvalid"]=>
+ bool(%s)
+ ["is_wvalid"]=>
+ bool(%s)
+ ["is_readable"]=>
+ bool(%s)
+ ["is_writable"]=>
+ bool(%s)
+}
+Done
diff --git a/ext/standard/tests/file/realpath_error-win32.phpt b/ext/standard/tests/file/realpath_error-win32.phpt
new file mode 100644
index 0000000..2fd221e
--- /dev/null
+++ b/ext/standard/tests/file/realpath_error-win32.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Test realpath() function: error conditions
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip only on Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: string realpath ( string $path );
+ Description: Returns canonicalized absolute pathname
+*/
+
+echo "*** Testing realpath() for error conditions ***\n";
+var_dump( realpath() ); // args < expected
+var_dump( realpath(1, 2) ); // args > expected
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing realpath() for error conditions ***
+
+Warning: realpath() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: realpath() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+Done
diff --git a/ext/standard/tests/file/realpath_variation-win32.phpt b/ext/standard/tests/file/realpath_variation-win32.phpt
new file mode 100644
index 0000000..59db125
--- /dev/null
+++ b/ext/standard/tests/file/realpath_variation-win32.phpt
@@ -0,0 +1,102 @@
+--TEST--
+Test realpath() function: usage variation
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip only on Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: string realpath ( string $path );
+ Description: Returns canonicalized absolute pathname
+*/
+
+require dirname(__FILE__).'/file.inc';
+
+echo "*** Testing realpath(): usage variations ***\n";
+$name_prefix = dirname(__FILE__);
+$filename = "$name_prefix/realpath_variation/home/tests/realpath_variation.tmp";
+mkdir("$name_prefix/realpath_variation/home/tests/", 0777, true);
+
+echo "\n*** Testing realpath() with filename stored inside a object ***\n";
+// create a temp file
+$file_handle = fopen($filename, "w");
+fclose($file_handle);
+
+// creating object with members as filename
+class object_temp {
+ public $filename;
+ function object_temp($file) {
+ $this->filename = $file;
+ }
+}
+$obj1 = new object_temp("$name_prefix/realpath_variation/../././realpath_variation/home/tests/realpath_variation.tmp");
+$obj2 = new object_temp("$name_prefix/realpath_variation/home/..///realpath_variation.tmp");
+
+var_dump( realpath($obj1->filename) );
+var_dump( realpath($obj2->filename) );
+
+echo "\n*** Testing realpath() with filename stored in an array ***\n";
+$file_arr = array (
+ "$name_prefix////realpath_variation/home/tests/realpath_variation.tmp",
+ "$name_prefix/./realpath_variation/home/../home//tests//..//..//..//home//realpath_variation.tmp/"
+);
+
+var_dump( realpath($file_arr[0]) );
+var_dump( realpath($file_arr[1]) );
+
+echo "\n*** Testing realpath() with filename as empty string, NULL and single space ***\n";
+$file_string = array (
+ /* filename as spaces */
+ " ",
+ ' ',
+
+ /* empty filename */
+ "",
+ '',
+ NULL,
+ null
+ );
+for($loop_counter = 0; $loop_counter < count($file_string); $loop_counter++) {
+ echo "-- Iteration";
+ echo $loop_counter + 1;
+ echo " --\n";
+ var_dump( realpath($file_string[$loop_counter]) );
+}
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+$name_prefix = dirname(__FILE__)."/realpath_variation";
+unlink("$name_prefix/home/tests/realpath_variation.tmp");
+rmdir("$name_prefix/home/tests/");
+rmdir("$name_prefix/home/");
+rmdir("$name_prefix/");
+?>
+--EXPECTF--
+*** Testing realpath(): usage variations ***
+
+*** Testing realpath() with filename stored inside a object ***
+string(%d) "%s\realpath_variation\home\tests\realpath_variation.tmp"
+bool(false)
+
+*** Testing realpath() with filename stored in an array ***
+string(%d) "%s\realpath_variation\home\tests\realpath_variation.tmp"
+bool(false)
+
+*** Testing realpath() with filename as empty string, NULL and single space ***
+-- Iteration1 --
+bool(false)
+-- Iteration2 --
+bool(false)
+-- Iteration3 --
+string(%d) "%s"
+-- Iteration4 --
+string(%d) "%s"
+-- Iteration5 --
+string(%d) "%s"
+-- Iteration6 --
+string(%d) "%s"
+Done
diff --git a/ext/standard/tests/file/realpath_variation2.phpt b/ext/standard/tests/file/realpath_variation2.phpt
new file mode 100644
index 0000000..a5031aa
--- /dev/null
+++ b/ext/standard/tests/file/realpath_variation2.phpt
@@ -0,0 +1,74 @@
+--TEST--
+Test realpath() function : variation
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == 'WIN' )
+ die("skip Not Valid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype : string realpath(string path)
+ * Description: Return the resolved path
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing realpath() : variation ***\n";
+
+$paths = array('c:\\',
+ 'c:',
+ 'c' ,
+ '\\' ,
+ '/',
+ 'c:temp',
+ 'c:\\/',
+ '/tmp/',
+ '/tmp/\\',
+ '\\tmp',
+ '\\tmp\\');
+
+foreach($paths as $path) {
+ echo "\n--$path--\n";
+ var_dump( realpath($path) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing realpath() : variation ***
+
+--c:\--
+bool(false)
+
+--c:--
+bool(false)
+
+--c--
+bool(false)
+
+--\--
+bool(false)
+
+--/--
+string(1) "/"
+
+--c:temp--
+bool(false)
+
+--c:\/--
+bool(false)
+
+--/tmp/--
+string(%d) %s/tmp"
+
+--/tmp/\--
+bool(false)
+
+--\tmp--
+bool(false)
+
+--\tmp\--
+bool(false)
+===DONE=== \ No newline at end of file
diff --git a/ext/standard/tests/file/rename_basic.phpt b/ext/standard/tests/file/rename_basic.phpt
new file mode 100644
index 0000000..c589c51
--- /dev/null
+++ b/ext/standard/tests/file/rename_basic.phpt
@@ -0,0 +1,45 @@
+--TEST--
+Test rename() function: basic functionality
+--FILE--
+<?php
+/* Prototype: bool rename ( string $oldname, string $newname [, resource $context] );
+ Description: Renames a file or directory
+*/
+
+echo "*** Testing rename() on non-existing file ***\n";
+$file_path = dirname(__FILE__);
+require "$file_path/file.inc";
+
+$src_name = "$file_path/rename_basic.tmp";
+$dest_name = "$file_path/rename_basic_new.tmp";
+
+// create the file
+$fp = fopen($src_name, "w");
+$old_stat = stat($src_name);
+fclose($fp);
+
+var_dump( rename($src_name, $dest_name) ); // expecting true
+var_dump( file_exists($src_name) ); // expecting false
+var_dump( file_exists($dest_name) ); // expecting true
+
+$new_stat = stat("$file_path/rename_basic_new.tmp");
+
+// checking statistics of old and renamed file - both should be same except ctime
+$keys_to_compare = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12,
+ "dev", "ino", "mode", "nlink", "uid", "gid",
+ "rdev", "size", "atime", "mtime", "blksize", "blocks");
+var_dump( compare_stats($old_stat, $new_stat, $keys_to_compare) );
+
+?>
+===Done===
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/rename_basic_new.tmp");
+?>
+--EXPECT--
+*** Testing rename() on non-existing file ***
+bool(true)
+bool(false)
+bool(true)
+bool(true)
+===Done===
diff --git a/ext/standard/tests/file/rename_error.phpt b/ext/standard/tests/file/rename_error.phpt
new file mode 100644
index 0000000..fae2b4f
--- /dev/null
+++ b/ext/standard/tests/file/rename_error.phpt
@@ -0,0 +1,35 @@
+--TEST--
+Test rename() function: error conditions
+--FILE--
+<?php
+/* Prototype: bool rename ( string $oldname, string $newname [, resource $context] );
+ Description: Renames a file or directory
+*/
+
+echo "*** Testing rename() for error conditions ***\n";
+//Zero argument
+var_dump( rename() );
+
+// less than expected,1 argument
+var_dump( rename(__FILE__) );
+
+// more than expected no. of arguments
+$context = stream_context_create();
+$filename = __FILE__;
+$new_filename = __FILE__.".tmp";
+var_dump( rename($filename, $new_filename, $context, "extra_args") );
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing rename() for error conditions ***
+
+Warning: rename() expects at least 2 parameters, 0 given in %s on line %d
+bool(false)
+
+Warning: rename() expects at least 2 parameters, 1 given in %s on line %d
+bool(false)
+
+Warning: rename() expects at most 3 parameters, 4 given in %s on line %d
+bool(false)
+Done
diff --git a/ext/standard/tests/file/rename_variation-win32.phpt b/ext/standard/tests/file/rename_variation-win32.phpt
new file mode 100644
index 0000000..a10c6df
--- /dev/null
+++ b/ext/standard/tests/file/rename_variation-win32.phpt
@@ -0,0 +1,87 @@
+--TEST--
+Test rename() function: usage variations
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip.. only for Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: bool rename ( string $oldname, string $newname [, resource $context] );
+ Description: Renames a file or directory
+*/
+
+require dirname(__FILE__).'/file.inc';
+
+/* create directory */
+$file_path = dirname(__FILE__);
+mkdir("$file_path/rename_variation");
+
+/* rename files across directories */
+echo "*** Testing rename() : rename files across directories ***\n";
+$src_filenames = array(
+ "$file_path/rename_variation/rename_variation.tmp",
+
+ /* Testing a file trailing slash */
+ "$file_path/rename_variation/rename_variation.tmp/",
+
+ /* Testing file with double slashes */
+ "$file_path/rename_variation//rename_variation.tmp",
+ "$file_path//rename_variation//rename_variation.tmp",
+);
+
+$counter = 1;
+
+/* loop through each $file and rename it to rename_variation2.tmp */
+foreach($src_filenames as $src_filename) {
+ echo "-- Iteration $counter --\n";
+ $fp = fopen("$file_path/rename_variation/rename_variation.tmp", "w");
+ fclose($fp);
+ $dest_filename = "$file_path/rename_variation2.tmp";
+ var_dump( rename($src_filename, $dest_filename) );
+
+ // ensure that file got renamed to new name
+ var_dump( file_exists($src_filename) ); // expecting false
+ var_dump( file_exists($dest_filename) ); // expecting true
+ $counter++;
+
+ // unlink the file
+ unlink($dest_filename);
+}
+
+rmdir("$file_path/rename_variation");
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/rename_variation_link.tmp");
+unlink($file_path."/rename_variation.tmp");
+rmdir($file_path."/rename_variation_dir");
+?>
+--EXPECTF--
+*** Testing rename() : rename files across directories ***
+-- Iteration 1 --
+bool(true)
+bool(false)
+bool(true)
+-- Iteration 2 --
+
+Warning: rename(%s/rename_variation/rename_variation.tmp/,%s/rename_variation2.tmp): The filename, directory name, or volume label syntax is incorrect. (code: 123) in %s on line %d
+bool(false)
+bool(false)
+bool(false)
+
+Warning: unlink(%s/rename_variation2.tmp): No such file or directory in %s on line %d
+-- Iteration 3 --
+bool(true)
+bool(false)
+bool(true)
+-- Iteration 4 --
+bool(true)
+bool(false)
+bool(true)
+Done
+
diff --git a/ext/standard/tests/file/rename_variation.phpt b/ext/standard/tests/file/rename_variation.phpt
new file mode 100644
index 0000000..00dc309
--- /dev/null
+++ b/ext/standard/tests/file/rename_variation.phpt
@@ -0,0 +1,72 @@
+--TEST--
+Test rename() function: usage variations-1 (Bug#42638)
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. only for Linux');
+}
+?>
+--FILE--
+<?php
+
+/* creating directory */
+$file_path = dirname(__FILE__);
+mkdir("$file_path/rename_variation");
+
+/* rename files across directories */
+echo "*** Testing rename() : rename files across directories ***\n";
+$src_filenames = array(
+ "$file_path/rename_variation/rename_variation.tmp",
+
+ /* Testing a file trailing slash */
+ "$file_path/rename_variation/rename_variation.tmp/",
+
+ /* Testing file with double slashes */
+ "$file_path/rename_variation//rename_variation.tmp",
+ "$file_path//rename_variation//rename_variation.tmp",
+);
+$counter = 1;
+/* loop through each $file and rename it to rename_variation2.tmp */
+foreach($src_filenames as $src_filename) {
+ echo "-- Iteration $counter --\n";
+ $fp = fopen("$file_path/rename_variation/rename_variation.tmp", "w");
+ fclose($fp);
+ $dest_filename = "$file_path/rename_variation2.tmp";
+ var_dump( rename($src_filename, $dest_filename) );
+ // ensure that file got renamed to new name
+ var_dump( file_exists($src_filename) ); // expecting false
+ var_dump( file_exists($dest_filename) ); // expecting true
+ $counter++;
+
+ // unlink the file
+ unlink($dest_filename);
+}
+
+// clean the temp dir and file
+rmdir("$file_path/rename_variation");
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing rename() : rename files across directories ***
+-- Iteration 1 --
+bool(true)
+bool(false)
+bool(true)
+-- Iteration 2 --
+
+Warning: rename(%s,%s): Not a directory in %s on line %d
+bool(false)
+bool(false)
+bool(false)
+
+Warning: unlink(%s): No such file or directory in %s on line %d
+-- Iteration 3 --
+bool(true)
+bool(false)
+bool(true)
+-- Iteration 4 --
+bool(true)
+bool(false)
+bool(true)
+Done
diff --git a/ext/standard/tests/file/rename_variation1-win32.phpt b/ext/standard/tests/file/rename_variation1-win32.phpt
new file mode 100644
index 0000000..0955096
--- /dev/null
+++ b/ext/standard/tests/file/rename_variation1-win32.phpt
@@ -0,0 +1,81 @@
+--TEST--
+Test rename() function: usage variations
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip.. only for Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: bool rename ( string $oldname, string $newname [, resource $context] );
+ Description: Renames a file or directory
+*/
+
+require dirname(__FILE__).'/file.inc';
+
+/* creating directory */
+$file_path = dirname(__FILE__);
+
+// rename dirs across directories
+echo "\n*** Testing rename() : renaming directory across directories ***\n";
+$src_dirs = array (
+ /* Testing simple directory tree */
+ "$file_path/rename_variation/",
+
+ /* Testing a dir with trailing slash */
+ "$file_path/rename_variation/",
+
+ /* Testing dir with double trailing slashes */
+ "$file_path//rename_variation//",
+);
+
+$dest_dir = "$file_path/rename_variation_dir";
+
+// create the $dest_dir
+mkdir($dest_dir);
+
+$counter = 1;
+
+/* loop through each $src_dirs and rename it to $dest_dir */
+foreach($src_dirs as $src_dir) {
+ echo "-- Iteration $counter --\n";
+
+ // create the src dir
+ mkdir("$file_path/rename_variation/");
+ // rename the src dir to a new dir in dest dir
+ var_dump( rename($src_dir, $dest_dir."/new_dir") );
+ // ensure that dir was renamed
+ var_dump( file_exists($src_dir) ); // expecting false
+ var_dump( file_exists($dest_dir."/new_dir") ); // expecting true
+
+ // remove the new dir
+ rmdir($dest_dir."/new_dir");
+ $counter++;
+}
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/rename_variation_link.tmp");
+unlink($file_path."/rename_variation.tmp");
+rmdir($file_path."/rename_variation_dir");
+?>
+--EXPECTF--
+*** Testing rename() : renaming directory across directories ***
+-- Iteration 1 --
+bool(true)
+bool(false)
+bool(true)
+-- Iteration 2 --
+bool(true)
+bool(false)
+bool(true)
+-- Iteration 3 --
+bool(true)
+bool(false)
+bool(true)
+Done
+
diff --git a/ext/standard/tests/file/rename_variation1.phpt b/ext/standard/tests/file/rename_variation1.phpt
new file mode 100644
index 0000000..0f7321e
--- /dev/null
+++ b/ext/standard/tests/file/rename_variation1.phpt
@@ -0,0 +1,71 @@
+--TEST--
+Test rename() function: usage variations-2
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. only for Linux');
+}
+?>
+--FILE--
+<?php
+
+/* creating directory */
+$file_path = dirname(__FILE__);
+
+// rename dirs across directories
+echo "\n*** Testing rename() : renaming directory across directories ***\n";
+$src_dirs = array (
+ /* Testing simple directory tree */
+ "$file_path/rename_variation/",
+
+ /* Testing a dir with trailing slash */
+ "$file_path/rename_variation/",
+
+ /* Testing dir with double trailing slashes */
+ "$file_path//rename_variation//",
+);
+
+$dest_dir = "$file_path/rename_variation_dir";
+// create the $dest_dir
+mkdir($dest_dir);
+
+$counter = 1;
+/* loop through each $src_dirs and rename it to $dest_dir */
+foreach($src_dirs as $src_dir) {
+ echo "-- Iteration $counter --\n";
+
+ // create the src dir
+ mkdir("$file_path/rename_variation/");
+ // rename the src dir to a new dir in dest dir
+ var_dump( rename($src_dir, $dest_dir."/new_dir") );
+ // ensure that dir was renamed
+ var_dump( file_exists($src_dir) ); // expecting false
+ var_dump( file_exists($dest_dir."/new_dir") ); // expecting true
+
+ // remove the new dir
+ rmdir($dest_dir."/new_dir");
+ $counter++;
+}
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+rmdir($file_path."/rename_variation_dir");
+?>
+--EXPECTF--
+*** Testing rename() : renaming directory across directories ***
+-- Iteration 1 --
+bool(true)
+bool(false)
+bool(true)
+-- Iteration 2 --
+bool(true)
+bool(false)
+bool(true)
+-- Iteration 3 --
+bool(true)
+bool(false)
+bool(true)
+Done
diff --git a/ext/standard/tests/file/rename_variation10.phpt b/ext/standard/tests/file/rename_variation10.phpt
new file mode 100644
index 0000000..fbb109c
--- /dev/null
+++ b/ext/standard/tests/file/rename_variation10.phpt
@@ -0,0 +1,253 @@
+--TEST--
+Test rename() function : usage variation - different types for context
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : bool rename(string old_name, string new_name[, resource context])
+ * Description: Rename a file
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing rename() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$old_name = __FILE__.'.tmp';
+$new_name = __FILE__.'.renamed';
+
+//file resource
+$fileRes = fopen(__FILE__, 'r');
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+ // int data
+ 'int 0' => 0,
+ 'int 1' => 1,
+ 'int 12345' => 12345,
+ 'int -12345' => -2345,
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float -10.5' => -10.5,
+ 'float 12.3456789000e10' => 12.3456789000e10,
+ 'float -12.3456789000e10' => -12.3456789000e10,
+ 'float .5' => .5,
+
+ // array data
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // string data
+ 'string DQ' => "string",
+ 'string SQ' => 'string',
+ 'mixed case string' => "sTrInG",
+ 'heredoc' => $heredoc,
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+
+ // file resource
+ 'file resource' => $fileRes,
+);
+
+// loop through each element of the array for context
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ touch($old_name);
+ $res = rename($old_name, $new_name, $value);
+ var_dump($res);
+ if ($res == true) {
+ unlink($new_name);
+ }
+ else {
+ unlink($old_name);
+ }
+};
+
+fclose($fileRes);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing rename() : usage variation ***
+
+--int 0--
+Error: 2 - rename() expects parameter 3 to be resource, integer given, %s(%d)
+bool(false)
+
+--int 1--
+Error: 2 - rename() expects parameter 3 to be resource, integer given, %s(%d)
+bool(false)
+
+--int 12345--
+Error: 2 - rename() expects parameter 3 to be resource, integer given, %s(%d)
+bool(false)
+
+--int -12345--
+Error: 2 - rename() expects parameter 3 to be resource, integer given, %s(%d)
+bool(false)
+
+--float 10.5--
+Error: 2 - rename() expects parameter 3 to be resource, double given, %s(%d)
+bool(false)
+
+--float -10.5--
+Error: 2 - rename() expects parameter 3 to be resource, double given, %s(%d)
+bool(false)
+
+--float 12.3456789000e10--
+Error: 2 - rename() expects parameter 3 to be resource, double given, %s(%d)
+bool(false)
+
+--float -12.3456789000e10--
+Error: 2 - rename() expects parameter 3 to be resource, double given, %s(%d)
+bool(false)
+
+--float .5--
+Error: 2 - rename() expects parameter 3 to be resource, double given, %s(%d)
+bool(false)
+
+--empty array--
+Error: 2 - rename() expects parameter 3 to be resource, array given, %s(%d)
+bool(false)
+
+--int indexed array--
+Error: 2 - rename() expects parameter 3 to be resource, array given, %s(%d)
+bool(false)
+
+--associative array--
+Error: 2 - rename() expects parameter 3 to be resource, array given, %s(%d)
+bool(false)
+
+--nested arrays--
+Error: 2 - rename() expects parameter 3 to be resource, array given, %s(%d)
+bool(false)
+
+--uppercase NULL--
+Error: 2 - rename() expects parameter 3 to be resource, null given, %s(%d)
+bool(false)
+
+--lowercase null--
+Error: 2 - rename() expects parameter 3 to be resource, null given, %s(%d)
+bool(false)
+
+--lowercase true--
+Error: 2 - rename() expects parameter 3 to be resource, boolean given, %s(%d)
+bool(false)
+
+--lowercase false--
+Error: 2 - rename() expects parameter 3 to be resource, boolean given, %s(%d)
+bool(false)
+
+--uppercase TRUE--
+Error: 2 - rename() expects parameter 3 to be resource, boolean given, %s(%d)
+bool(false)
+
+--uppercase FALSE--
+Error: 2 - rename() expects parameter 3 to be resource, boolean given, %s(%d)
+bool(false)
+
+--empty string DQ--
+Error: 2 - rename() expects parameter 3 to be resource, string given, %s(%d)
+bool(false)
+
+--empty string SQ--
+Error: 2 - rename() expects parameter 3 to be resource, string given, %s(%d)
+bool(false)
+
+--string DQ--
+Error: 2 - rename() expects parameter 3 to be resource, string given, %s(%d)
+bool(false)
+
+--string SQ--
+Error: 2 - rename() expects parameter 3 to be resource, string given, %s(%d)
+bool(false)
+
+--mixed case string--
+Error: 2 - rename() expects parameter 3 to be resource, string given, %s(%d)
+bool(false)
+
+--heredoc--
+Error: 2 - rename() expects parameter 3 to be resource, string given, %s(%d)
+bool(false)
+
+--instance of classWithToString--
+Error: 2 - rename() expects parameter 3 to be resource, object given, %s(%d)
+bool(false)
+
+--instance of classWithoutToString--
+Error: 2 - rename() expects parameter 3 to be resource, object given, %s(%d)
+bool(false)
+
+--undefined var--
+Error: 2 - rename() expects parameter 3 to be resource, null given, %s(%d)
+bool(false)
+
+--unset var--
+Error: 2 - rename() expects parameter 3 to be resource, null given, %s(%d)
+bool(false)
+
+--file resource--
+Error: 2 - rename(): supplied resource is not a valid Stream-Context resource, %s(%d)
+bool(true)
+===DONE===
diff --git a/ext/standard/tests/file/rename_variation11-win32.phpt b/ext/standard/tests/file/rename_variation11-win32.phpt
new file mode 100644
index 0000000..c13a09a
--- /dev/null
+++ b/ext/standard/tests/file/rename_variation11-win32.phpt
@@ -0,0 +1,128 @@
+--TEST--
+Test rename() function : variation - various relative, absolute paths
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+ die("skip Only valid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype : bool rename(string old_name, string new_name[, resource context])
+ * Description: Rename a file
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing rename() with absolute and relative paths ***\n";
+$mainDir = "renameVar11";
+$subDir = "renameVar11Sub";
+$absMainDir = dirname(__FILE__)."\\".$mainDir;
+mkdir($absMainDir);
+$absSubDir = $absMainDir."\\".$subDir;
+mkdir($absSubDir);
+
+$fromFile = "renameMe.tmp";
+$toFile = "IwasRenamed.tmp";
+
+$old_dir_path = getcwd();
+chdir(dirname(__FILE__));
+$unixifiedDir = '/'.substr(str_replace('\\','/',$absSubDir),3);
+
+
+$allDirs = array(
+ // absolute paths
+ "$absSubDir\\",
+ "$absSubDir\\..\\".$subDir,
+ "$absSubDir\\\\..\\.\\".$subDir,
+ "$absSubDir\\..\\..\\".$mainDir."\\.\\".$subDir,
+ "$absSubDir\\..\\\\\\".$subDir."\\\\..\\\\..\\".$subDir,
+ "$absSubDir\\BADDIR",
+
+ // relative paths
+ $mainDir."\\".$subDir,
+ $mainDir."\\\\".$subDir,
+ $mainDir."\\\\\\".$subDir,
+ ".\\".$mainDir."\\..\\".$mainDir."\\".$subDir,
+ "BADDIR",
+
+ // unixifed path
+ $unixifiedDir,
+);
+
+for($i = 0; $i<count($allDirs); $i++) {
+ $j = $i+1;
+ $dir = $allDirs[$i];
+ echo "\n-- Iteration $j --\n";
+ touch($absSubDir."\\".$fromFile);
+ $res = rename($dir."\\".$fromFile, $dir."\\".$toFile);
+ var_dump($res);
+ if ($res == true) {
+ $res = rename($dir."\\".$toFile, $dir."\\".$fromFile);
+ var_dump($res);
+ }
+ unlink($absSubDir."\\".$fromFile);
+}
+
+chdir($old_dir_path);
+rmdir($absSubDir);
+rmdir($absMainDir);
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing rename() with absolute and relative paths ***
+
+-- Iteration 1 --
+bool(true)
+bool(true)
+
+-- Iteration 2 --
+bool(true)
+bool(true)
+
+-- Iteration 3 --
+bool(true)
+bool(true)
+
+-- Iteration 4 --
+bool(true)
+bool(true)
+
+-- Iteration 5 --
+
+Warning: rename(%s\renameVar11\renameVar11Sub\..\\\renameVar11Sub\\..\\..\renameVar11Sub\renameMe.tmp,%s\renameVar11\renameVar11Sub\..\\\renameVar11Sub\\..\\..\renameVar11Sub\IwasRenamed.tmp): The system cannot find the path specified. (code: 3) in %s on line %d
+bool(false)
+
+-- Iteration 6 --
+
+Warning: rename(%s\renameVar11\renameVar11Sub\BADDIR\renameMe.tmp,%s\renameVar11\renameVar11Sub\BADDIR\IwasRenamed.tmp): The system cannot find the path specified. (code: 3) in %s on line %d
+bool(false)
+
+-- Iteration 7 --
+bool(true)
+bool(true)
+
+-- Iteration 8 --
+bool(true)
+bool(true)
+
+-- Iteration 9 --
+bool(true)
+bool(true)
+
+-- Iteration 10 --
+bool(true)
+bool(true)
+
+-- Iteration 11 --
+
+Warning: rename(BADDIR\renameMe.tmp,BADDIR\IwasRenamed.tmp): The system cannot find the path specified. (code: 3) in %s on line %d
+bool(false)
+
+-- Iteration 12 --
+bool(true)
+bool(true)
+
+*** Done *** \ No newline at end of file
diff --git a/ext/standard/tests/file/rename_variation12-win32.phpt b/ext/standard/tests/file/rename_variation12-win32.phpt
new file mode 100644
index 0000000..de5fc14
--- /dev/null
+++ b/ext/standard/tests/file/rename_variation12-win32.phpt
@@ -0,0 +1,121 @@
+--TEST--
+Test rename() function : variation - various relative, absolute paths
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') die('skip.. for Windows');
+?>
+--FILE--
+<?php
+/* Prototype : bool rename(string old_name, string new_name[, resource context])
+ * Description: Rename a file
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+/* Creating unique files in various dirs by passing relative paths to $dir arg */
+
+echo "*** Testing rename() with absolute and relative paths ***\n";
+$mainDir = "renameVar11";
+$subDir = "renameVar11Sub";
+$absMainDir = dirname(__FILE__)."/".$mainDir;
+mkdir($absMainDir);
+$absSubDir = $absMainDir."/".$subDir;
+mkdir($absSubDir);
+
+$fromFile = "renameMe.tmp";
+$toFile = "IwasRenamed.tmp";
+
+$old_dir_path = getcwd();
+chdir(dirname(__FILE__));
+
+$allDirs = array(
+ // absolute paths
+ "$absSubDir/",
+ "$absSubDir/../".$subDir,
+ "$absSubDir//.././".$subDir,
+ "$absSubDir/../../".$mainDir."/./".$subDir,
+ "$absSubDir/..///".$subDir."//..//../".$subDir,
+ "$absSubDir/BADDIR",
+
+
+ // relative paths
+ $mainDir."/".$subDir,
+ $mainDir."//".$subDir,
+ $mainDir."///".$subDir,
+ "./".$mainDir."/../".$mainDir."/".$subDir,
+ "BADDIR",
+);
+
+for($i = 0; $i<count($allDirs); $i++) {
+ $j = $i+1;
+ $dir = $allDirs[$i];
+ echo "\n-- Iteration $j --\n";
+ touch($absSubDir."/".$fromFile);
+ $res = rename($dir."/".$fromFile, $dir."/".$toFile);
+ var_dump($res);
+ if ($res == true) {
+ $res = rename($dir."/".$toFile, $dir."/".$fromFile);
+ var_dump($res);
+ }
+ unlink($absSubDir."/".$fromFile);
+}
+
+chdir($old_dir_path);
+rmdir($absSubDir);
+rmdir($absMainDir);
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing rename() with absolute and relative paths ***
+
+-- Iteration 1 --
+bool(true)
+bool(true)
+
+-- Iteration 2 --
+bool(true)
+bool(true)
+
+-- Iteration 3 --
+bool(true)
+bool(true)
+
+-- Iteration 4 --
+bool(true)
+bool(true)
+
+-- Iteration 5 --
+
+Warning: rename(%s/renameVar11/renameVar11Sub/..///renameVar11Sub//..//../renameVar11Sub/renameMe.tmp,%s/renameVar11/renameVar11Sub/..///renameVar11Sub//..//../renameVar11Sub/IwasRenamed.tmp): The system cannot find the path specified. (code: 3) in %s on line %d
+bool(false)
+
+-- Iteration 6 --
+
+Warning: rename(%s/renameVar11/renameVar11Sub/BADDIR/renameMe.tmp,%s/renameVar11/renameVar11Sub/BADDIR/IwasRenamed.tmp): The system cannot find the path specified. (code: 3) in %s on line %d
+bool(false)
+
+-- Iteration 7 --
+bool(true)
+bool(true)
+
+-- Iteration 8 --
+bool(true)
+bool(true)
+
+-- Iteration 9 --
+bool(true)
+bool(true)
+
+-- Iteration 10 --
+bool(true)
+bool(true)
+
+-- Iteration 11 --
+
+Warning: rename(BADDIR/renameMe.tmp,BADDIR/IwasRenamed.tmp): The system cannot find the path specified. (code: 3) in %s on line %d
+bool(false)
+
+*** Done *** \ No newline at end of file
diff --git a/ext/standard/tests/file/rename_variation12.phpt b/ext/standard/tests/file/rename_variation12.phpt
new file mode 100644
index 0000000..168beef
--- /dev/null
+++ b/ext/standard/tests/file/rename_variation12.phpt
@@ -0,0 +1,121 @@
+--TEST--
+Test rename() function : variation - various relative, absolute paths
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') die('skip.. not for Windows');
+?>
+--FILE--
+<?php
+/* Prototype : bool rename(string old_name, string new_name[, resource context])
+ * Description: Rename a file
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+/* Creating unique files in various dirs by passing relative paths to $dir arg */
+
+echo "*** Testing rename() with absolute and relative paths ***\n";
+$mainDir = "renameVar11";
+$subDir = "renameVar11Sub";
+$absMainDir = dirname(__FILE__)."/".$mainDir;
+mkdir($absMainDir);
+$absSubDir = $absMainDir."/".$subDir;
+mkdir($absSubDir);
+
+$fromFile = "renameMe.tmp";
+$toFile = "IwasRenamed.tmp";
+
+$old_dir_path = getcwd();
+chdir(dirname(__FILE__));
+
+$allDirs = array(
+ // absolute paths
+ "$absSubDir/",
+ "$absSubDir/../".$subDir,
+ "$absSubDir//.././".$subDir,
+ "$absSubDir/../../".$mainDir."/./".$subDir,
+ "$absSubDir/..///".$subDir."//..//../".$subDir,
+ "$absSubDir/BADDIR",
+
+
+ // relative paths
+ $mainDir."/".$subDir,
+ $mainDir."//".$subDir,
+ $mainDir."///".$subDir,
+ "./".$mainDir."/../".$mainDir."/".$subDir,
+ "BADDIR",
+);
+
+for($i = 0; $i<count($allDirs); $i++) {
+ $j = $i+1;
+ $dir = $allDirs[$i];
+ echo "\n-- Iteration $j --\n";
+ touch($absSubDir."/".$fromFile);
+ $res = rename($dir."/".$fromFile, $dir."/".$toFile);
+ var_dump($res);
+ if ($res == true) {
+ $res = rename($dir."/".$toFile, $dir."/".$fromFile);
+ var_dump($res);
+ }
+ unlink($absSubDir."/".$fromFile);
+}
+
+chdir($old_dir_path);
+rmdir($absSubDir);
+rmdir($absMainDir);
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing rename() with absolute and relative paths ***
+
+-- Iteration 1 --
+bool(true)
+bool(true)
+
+-- Iteration 2 --
+bool(true)
+bool(true)
+
+-- Iteration 3 --
+bool(true)
+bool(true)
+
+-- Iteration 4 --
+bool(true)
+bool(true)
+
+-- Iteration 5 --
+
+Warning: rename(%s/renameVar11/renameVar11Sub/..///renameVar11Sub//..//../renameVar11Sub/renameMe.tmp,%s/renameVar11/renameVar11Sub/..///renameVar11Sub//..//../renameVar11Sub/IwasRenamed.tmp): %s in %s on line %d
+bool(false)
+
+-- Iteration 6 --
+
+Warning: rename(%s/renameVar11/renameVar11Sub/BADDIR/renameMe.tmp,%s/renameVar11/renameVar11Sub/BADDIR/IwasRenamed.tmp): %s in %s on line %d
+bool(false)
+
+-- Iteration 7 --
+bool(true)
+bool(true)
+
+-- Iteration 8 --
+bool(true)
+bool(true)
+
+-- Iteration 9 --
+bool(true)
+bool(true)
+
+-- Iteration 10 --
+bool(true)
+bool(true)
+
+-- Iteration 11 --
+
+Warning: rename(BADDIR/renameMe.tmp,BADDIR/IwasRenamed.tmp): %s in %s on line %d
+bool(false)
+
+*** Done ***
diff --git a/ext/standard/tests/file/rename_variation13-win32.phpt b/ext/standard/tests/file/rename_variation13-win32.phpt
new file mode 100644
index 0000000..a503076
--- /dev/null
+++ b/ext/standard/tests/file/rename_variation13-win32.phpt
Binary files differ
diff --git a/ext/standard/tests/file/rename_variation13.phpt b/ext/standard/tests/file/rename_variation13.phpt
new file mode 100644
index 0000000..ec1ee7c
--- /dev/null
+++ b/ext/standard/tests/file/rename_variation13.phpt
@@ -0,0 +1,133 @@
+--TEST--
+Test rename() function : variation - various invalid paths
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+ die("skip. Not for Windows");
+?>
+--FILE--
+<?php
+/* Prototype : bool rename(string old_name, string new_name[, resource context])
+ * Description: Rename a file
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing rename() with obscure files ***\n";
+$file_path = dirname(__FILE__)."/renameVar13";
+$aFile = $file_path.'/afile.tmp';
+
+mkdir($file_path);
+
+/* An array of files */
+$names_arr = array(
+ /* Invalid args */
+ -1,
+ TRUE,
+ FALSE,
+ NULL,
+ "",
+ " ",
+ "\0",
+ array(),
+
+ /* prefix with path separator of a non existing directory*/
+ "/no/such/file/dir",
+ "php/php"
+
+);
+
+for( $i=0; $i<count($names_arr); $i++ ) {
+ $name = $names_arr[$i];
+ echo @"-- testing '$name' --\n";
+ touch($aFile);
+ var_dump(rename($aFile, $name));
+ if (file_exists($name)) {
+ unlink($name);
+ }
+ if (file_exists($aFile)) {
+ unlink($aFile);
+ }
+ var_dump(rename($name, $aFile));
+ if (file_exists($aFile)) {
+ unlink($aFile);
+ }
+}
+
+rmdir($file_path);
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing rename() with obscure files ***
+-- testing '-1' --
+bool(true)
+
+Warning: rename(-1,%s/renameVar13/afile.tmp): No such file or directory in %s on line %d
+bool(false)
+-- testing '1' --
+bool(true)
+
+Warning: rename(1,%s/renameVar13/afile.tmp): No such file or directory in %s on line %d
+bool(false)
+-- testing '' --
+
+Warning: rename(%s/renameVar13/afile.tmp,): %s in %s on line %d
+bool(false)
+
+Warning: rename(,%s/renameVar13/afile.tmp): %s in %s on line %d
+bool(false)
+-- testing '' --
+
+Warning: rename(%s/renameVar13/afile.tmp,): %s in %s on line %d
+bool(false)
+
+Warning: rename(,%s/renameVar13/afile.tmp): %s in %s on line %d
+bool(false)
+-- testing '' --
+
+Warning: rename(%s/renameVar13/afile.tmp,): %s in %s on line %d
+bool(false)
+
+Warning: rename(,%s/renameVar13/afile.tmp): %s in %s on line %d
+bool(false)
+-- testing ' ' --
+bool(true)
+
+Warning: rename( ,%s/renameVar13/afile.tmp): No such file or directory in %s on line %d
+bool(false)
+-- testing '%s' --
+
+Warning: rename() %s in %s on line %d
+bool(false)
+
+Warning: file_exists() expects parameter 1 to be a valid path, string given in %s on line %d
+
+Warning: rename() expects parameter 1 to be a valid path, string given in %s on line %d
+bool(false)
+-- testing 'Array' --
+
+Warning: rename() expects parameter 2 to be a valid path, array given in %s on line %d
+bool(false)
+
+Warning: file_exists() expects parameter 1 to be a valid path, array given in %s on line %d
+
+Warning: rename() expects parameter 1 to be a valid path, array given in %s on line %d
+bool(false)
+-- testing '/no/such/file/dir' --
+
+Warning: rename(%s/renameVar13/afile.tmp,/no/such/file/dir): No such file or directory in %s on line %d
+bool(false)
+
+Warning: rename(/no/such/file/dir,%s/renameVar13/afile.tmp): No such file or directory in %s on line %d
+bool(false)
+-- testing 'php/php' --
+
+Warning: rename(%s/renameVar13/afile.tmp,php/php): %s directory in %s on line %d
+bool(false)
+
+Warning: rename(php/php,%s/renameVar13/afile.tmp): %s directory in %s on line %d
+bool(false)
+
+*** Done ***
diff --git a/ext/standard/tests/file/rename_variation2-win32.phpt b/ext/standard/tests/file/rename_variation2-win32.phpt
new file mode 100644
index 0000000..87f4e7d
--- /dev/null
+++ b/ext/standard/tests/file/rename_variation2-win32.phpt
@@ -0,0 +1,61 @@
+--TEST--
+Test rename() function: usage variations
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip.. only for Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: bool rename ( string $oldname, string $newname [, resource $context] );
+ Description: Renames a file or directory
+*/
+
+require dirname(__FILE__).'/file.inc';
+
+$file_path = dirname(__FILE__);
+mkdir("$file_path/rename_variation_dir");
+
+/* Renaming a file and directory to numeric name */
+echo "\n*** Testing rename() by renaming a file and directory to numeric name ***\n";
+$fp = fopen($file_path."/rename_variation.tmp", "w");
+fclose($fp);
+
+// renaming existing file to numeric name
+var_dump( rename($file_path."/rename_variation.tmp", $file_path."/12345") );
+
+// ensure that rename worked fine
+var_dump( file_exists($file_path."/rename_variation.tmp" ) ); // expecting false
+var_dump( file_exists($file_path."/12345" ) ); // expecting true
+
+unlink($file_path."/12345");
+
+// renaming a directory to numeric name
+var_dump( rename($file_path."/rename_variation_dir/", $file_path."/12345") );
+
+// ensure that rename worked fine
+var_dump( file_exists($file_path."/rename_variation_dir" ) ); // expecting false
+var_dump( file_exists($file_path."/12345" ) ); // expecting true
+
+rmdir($file_path."/12345");
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/rename_variation_link.tmp");
+unlink($file_path."/rename_variation.tmp");
+rmdir($file_path."/rename_variation_dir");
+?>
+--EXPECTF--
+*** Testing rename() by renaming a file and directory to numeric name ***
+bool(true)
+bool(false)
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+Done
+
diff --git a/ext/standard/tests/file/rename_variation2.phpt b/ext/standard/tests/file/rename_variation2.phpt
new file mode 100644
index 0000000..fa3ee1e
--- /dev/null
+++ b/ext/standard/tests/file/rename_variation2.phpt
@@ -0,0 +1,65 @@
+--TEST--
+Test rename() function: usage variations-3
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. only for Linux');
+}
+?>
+--FILE--
+<?php
+
+$file_path = dirname(__FILE__);
+
+$dest_dir = "$file_path/rename_variation_dir";
+// create the $dest_dir
+mkdir($dest_dir);
+
+/* Testing rename() on soft and hard links with different permissions */
+echo "\n*** Testing rename() on soft links ***\n";
+// create the file
+$filename = $file_path."/rename_variation2.tmp";
+@unlink($filename);
+var_dump(touch($filename));
+
+// create the soft links to the file
+$linkname = $file_path."/rename_variation_soft_link1.tmp";
+var_dump(symlink($filename, $linkname));
+
+//rename the link to a new name in the same dir
+$dest_linkname = $file_path."/rename_variation_soft_link2.tmp";
+var_dump( rename( $linkname, $dest_linkname) );
+//ensure that link was renamed
+clearstatcache();
+var_dump( file_exists($linkname) ); // expecting false
+var_dump( file_exists($dest_linkname) ); // expecting true
+
+// rename a link across dir
+var_dump( rename($dest_linkname, $dest_dir."/rename_variation_soft_link2.tmp"));
+//ensure that link got renamed
+clearstatcache();
+var_dump( file_exists($dest_linkname) ); // expecting false
+var_dump( file_exists($dest_dir."/rename_variation_soft_link2.tmp") ); // expecting true
+
+// delete the link file now
+unlink($dest_dir."/rename_variation_soft_link2.tmp");
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/rename_variation2.tmp");
+rmdir($file_path."/rename_variation_dir");
+?>
+--EXPECTF--
+*** Testing rename() on soft links ***
+bool(true)
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+Done
diff --git a/ext/standard/tests/file/rename_variation3-win32.phpt b/ext/standard/tests/file/rename_variation3-win32.phpt
new file mode 100644
index 0000000..b5da587
--- /dev/null
+++ b/ext/standard/tests/file/rename_variation3-win32.phpt
@@ -0,0 +1,84 @@
+--TEST--
+Test rename() function: usage variations
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip.. only for Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: bool rename ( string $oldname, string $newname [, resource $context] );
+ Description: Renames a file or directory
+*/
+
+require dirname(__FILE__).'/file.inc';
+
+/* creating directory */
+$file_path = dirname(__FILE__);
+$dirname = "$file_path/rename_variation3_dir";
+mkdir($dirname);
+
+/* test rename() by trying to rename an existing file/dir to the same name
+ and one another */
+
+$filename = "$file_path/rename_variation3.tmp";
+$fp = fopen($filename, "w");
+if (!$fp) {
+ die("Cannot create $filename\n");
+}
+fclose($fp);
+
+echo "\n-- Renaming file to same file name --\n";
+var_dump( rename($filename, $filename) );
+var_dump( file_exists($filename) );
+
+echo "\n-- Renaming directory to same directory name --\n";
+var_dump( rename($dirname, $dirname) );
+var_dump( file_exists($dirname) );
+
+echo "\n-- Renaming existing file to existing directory name --\n";
+var_dump( rename($filename, $dirname) );
+var_dump( file_exists($filename) );
+var_dump( file_exists($dirname) );
+
+echo "\n-- Renaming existing directory to existing file name --\n";
+$fp = fopen($filename, "w");
+fclose($fp);
+
+var_dump( rename($dirname, $filename) );
+var_dump( file_exists($filename) );
+var_dump( file_exists($dirname) );
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/rename_variation3_link.tmp");
+unlink($file_path."/rename_variation3.tmp");
+rmdir($file_path."/rename_variation3_dir");
+rmdir($file_path."/rename_variation3.tmp");
+?>
+--EXPECTF--
+-- Renaming file to same file name --
+bool(true)
+bool(true)
+
+-- Renaming directory to same directory name --
+bool(true)
+bool(true)
+
+-- Renaming existing file to existing directory name --
+
+Warning: rename(%s/rename_variation3.tmp,%s/rename_variation3_dir): Access is denied. (code: 5) in %s on line %d
+bool(false)
+bool(true)
+bool(true)
+
+-- Renaming existing directory to existing file name --
+bool(true)
+bool(true)
+bool(false)
+Done
+
diff --git a/ext/standard/tests/file/rename_variation3.phpt b/ext/standard/tests/file/rename_variation3.phpt
new file mode 100644
index 0000000..ce89216
--- /dev/null
+++ b/ext/standard/tests/file/rename_variation3.phpt
@@ -0,0 +1,60 @@
+--TEST--
+Test rename() function: usage variations-4
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. only for Linux');
+}
+?>
+--FILE--
+<?php
+
+$file_path = dirname(__FILE__);
+
+$dest_dir = "$file_path/rename_variation_dir";
+// create the $dest_dir
+mkdir($dest_dir);
+
+echo "\n*** Testing rename() on hard links ***\n";
+$filename = $file_path."/rename_variation1.tmp";
+@unlink($filename);
+var_dump(touch($filename));
+
+$linkname = $file_path."/rename_variation_hard_link1.tmp";
+var_dump(link($filename, $linkname));
+
+//rename the link to a new name in the same dir
+$dest_linkname = $file_path."/rename_variation_hard_link2.tmp";
+var_dump( rename( $filename, $dest_linkname) );
+//ensure that link was renamed
+var_dump( file_exists($filename) ); // expecting false
+var_dump( file_exists($dest_linkname) ); // expecting true
+
+// rename a hard link across dir
+var_dump( rename($dest_linkname, $dest_dir."/rename_variation_hard_link2.tmp") );
+//ensure that link got renamed
+var_dump( file_exists($dest_linkname) ); // expecting false
+var_dump( file_exists($dest_dir."/rename_variation_hard_link2.tmp") ); // expecting true
+
+// delete the link file now
+unlink($dest_dir."/rename_variation_hard_link2.tmp");
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/rename_variation_hard_link1.tmp");
+rmdir($file_path."/rename_variation_dir");
+?>
+--EXPECTF--
+*** Testing rename() on hard links ***
+bool(true)
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+Done
diff --git a/ext/standard/tests/file/rename_variation4.phpt b/ext/standard/tests/file/rename_variation4.phpt
new file mode 100644
index 0000000..2965f75
--- /dev/null
+++ b/ext/standard/tests/file/rename_variation4.phpt
@@ -0,0 +1,51 @@
+--TEST--
+Test rename() function: usage variations-5
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. only for Linux');
+}
+?>
+--FILE--
+<?php
+
+$file_path = dirname(__FILE__);
+
+require dirname(__FILE__).'/file.inc';
+
+/* Renaming a file, link and directory to numeric name */
+echo "\n*** Testing rename() by renaming a file, link and directory to numeric name ***\n";
+$fp = fopen($file_path."/rename_variation.tmp", "w");
+fclose($fp);
+// renaming existing file to numeric name
+var_dump( rename($file_path."/rename_variation.tmp", $file_path."/12345") );
+// ensure that rename worked fine
+var_dump( file_exists($file_path."/rename_variation.tmp" ) ); // expecting false
+var_dump( file_exists($file_path."/12345" ) ); // expecting true
+// remove the file
+unlink($file_path."/12345");
+
+mkdir($file_path."/rename_variation_dir");
+
+// renaming a directory to numeric name
+var_dump( rename($file_path."/rename_variation_dir/", $file_path."/12345") );
+// ensure that rename worked fine
+var_dump( file_exists($file_path."/rename_variation_dir" ) ); // expecting false
+var_dump( file_exists($file_path."/12345" ) ); // expecting true
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+rmdir($file_path."/12345");
+?>
+--EXPECTF--
+*** Testing rename() by renaming a file, link and directory to numeric name ***
+bool(true)
+bool(false)
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+Done
diff --git a/ext/standard/tests/file/rename_variation5.phpt b/ext/standard/tests/file/rename_variation5.phpt
new file mode 100644
index 0000000..bf43e49
--- /dev/null
+++ b/ext/standard/tests/file/rename_variation5.phpt
@@ -0,0 +1,96 @@
+--TEST--
+Test rename() function: usage variations-6
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. only for Linux');
+}
+?>
+--FILE--
+<?php
+
+/* test rename() by trying to rename an existing file/dir/link to the same name
+ and one another */
+// create a dir
+$file_path = dirname(__FILE__);
+$dirname = "$file_path/rename_variation_dir";
+mkdir($dirname);
+//create a file
+$filename = "$file_path/rename_variation.tmp";
+$fp = fopen($filename, "w");
+fclose($fp);
+// create a link
+$linkname = "$file_path/rename_variation_link.tmp";
+symlink($filename, $linkname);
+
+echo "\n-- Renaming link to same link name --\n";
+var_dump( rename($linkname, $linkname) );
+
+echo "\n-- Renaming file to same file name --\n";
+var_dump( rename($filename, $filename) );
+
+echo "\n-- Renaming directory to same directory name --\n";
+var_dump( rename($dirname, $dirname) );
+
+echo "\n-- Renaming existing link to existing directory name --\n";
+var_dump( rename($linkname, $dirname) );
+echo "\n-- Renaming existing link to existing file name --\n";
+var_dump( rename($linkname, $filename) );
+
+echo "\n-- Renaming existing file to existing directory name --\n";
+var_dump( rename($filename, $dirname) );
+echo "\n-- Renaming existing file to existing link name --\n";
+var_dump( rename($filename, $linkname) );
+
+echo "\n-- Renaming existing directory to existing file name --\n";
+$fp = fopen($filename, "w");
+fclose($fp);
+var_dump( rename($dirname, $filename) );
+echo "\n-- Renaming existing directory to existing link name --\n";
+var_dump( rename($dirname, $linkname) );
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/rename_variation_link.tmp");
+unlink($file_path."/rename_variation.tmp");
+rmdir($file_path."/rename_variation_dir");
+?>
+--EXPECTF--
+-- Renaming link to same link name --
+bool(true)
+
+-- Renaming file to same file name --
+bool(true)
+
+-- Renaming directory to same directory name --
+bool(true)
+
+-- Renaming existing link to existing directory name --
+
+Warning: rename(%s,%s): Is a directory in %s on line %d
+bool(false)
+
+-- Renaming existing link to existing file name --
+bool(true)
+
+-- Renaming existing file to existing directory name --
+
+Warning: rename(%s,%s): Is a directory in %s on line %d
+bool(false)
+
+-- Renaming existing file to existing link name --
+bool(true)
+
+-- Renaming existing directory to existing file name --
+
+Warning: rename(%s,%s): Not a directory in %s on line %d
+bool(false)
+
+-- Renaming existing directory to existing link name --
+
+Warning: rename(%s,%s): Not a directory in %s on line %d
+bool(false)
+Done
diff --git a/ext/standard/tests/file/rename_variation6-win32.phpt b/ext/standard/tests/file/rename_variation6-win32.phpt
new file mode 100644
index 0000000..9aab0a7
--- /dev/null
+++ b/ext/standard/tests/file/rename_variation6-win32.phpt
@@ -0,0 +1,40 @@
+--TEST--
+Test rename() function: usage variations-6
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') die('skip.. for Windows');
+if (!function_exists("symlink")) die("skip symlinks are not supported");
+$ret = exec('mklink rename_variation13tmp.lnk ' . __FILE__ .' 2>&1', $out);
+if (strpos($ret, 'privilege')) {
+ die('skip. SeCreateSymbolicLinkPrivilege not enable for this user.');
+}
+?>
+--FILE--
+<?php
+
+$tmp_file = __FILE__.".tmp";
+$tmp_link = __FILE__.".tmp.link";
+$tmp_link2 = __FILE__.".tmp.link2";
+
+touch($tmp_file);
+symlink($tmp_file, $tmp_link);
+rename($tmp_link, $tmp_link2);
+
+clearstatcache();
+
+var_dump(readlink($tmp_link));
+var_dump(readlink($tmp_link2));
+var_dump(file_exists($tmp_file));
+
+@unlink($tmp_link);
+@unlink($tmp_link2);
+@unlink($tmp_file);
+
+echo "Done\n";
+?>
+--EXPECTF--
+Warning: readlink(): %s in %s on line %d
+bool(false)
+string(%d) "%srename_variation6-win32.php.tmp"
+bool(true)
+Done
diff --git a/ext/standard/tests/file/rename_variation6.phpt b/ext/standard/tests/file/rename_variation6.phpt
new file mode 100644
index 0000000..413dc6e
--- /dev/null
+++ b/ext/standard/tests/file/rename_variation6.phpt
@@ -0,0 +1,36 @@
+--TEST--
+Test rename() function: usage variations-6
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') die('skip.. not for Windows');
+if (!function_exists("symlink")) die("skip symlinks are not supported");
+?>
+--FILE--
+<?php
+
+$tmp_file = __FILE__.".tmp";
+$tmp_link = __FILE__.".tmp.link";
+$tmp_link2 = __FILE__.".tmp.link2";
+
+touch($tmp_file);
+symlink($tmp_file, $tmp_link);
+rename($tmp_link, $tmp_link2);
+
+clearstatcache();
+
+var_dump(readlink($tmp_link));
+var_dump(readlink($tmp_link2));
+var_dump(file_exists($tmp_file));
+
+@unlink($tmp_link);
+@unlink($tmp_link2);
+@unlink($tmp_file);
+
+echo "Done\n";
+?>
+--EXPECTF--
+Warning: readlink(): No such file or directory in %s on line %d
+bool(false)
+string(%d) "%srename_variation6.php.tmp"
+bool(true)
+Done
diff --git a/ext/standard/tests/file/rename_variation7-win32.phpt b/ext/standard/tests/file/rename_variation7-win32.phpt
new file mode 100644
index 0000000..369e8c2
--- /dev/null
+++ b/ext/standard/tests/file/rename_variation7-win32.phpt
@@ -0,0 +1,36 @@
+--TEST--
+Test rename() function: usage variations-8
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') die('skip.. for Windows');
+if (!function_exists("symlink")) die("skip symlinks are not supported");
+?>
+--FILE--
+<?php
+
+$tmp_link = __FILE__.".tmp.link";
+$tmp_link2 = __FILE__.".tmp.link2";
+
+if (symlink(dirname(__FILE__)."/there_is_no_such_file", $tmp_link)) {
+ rename($tmp_link, $tmp_link2);
+}
+
+clearstatcache();
+
+var_dump(readlink($tmp_link));
+var_dump(readlink($tmp_link2));
+
+@unlink($tmp_link);
+@unlink($tmp_link2);
+
+echo "Done\n";
+?>
+--EXPECTF--
+Warning: symlink(): Could not fetch file information(error 2) in %srename_variation7-win32.php on line %d
+
+Warning: readlink(): readlink failed to read the symbolic link (%srename_variation7-win32.php.tmp.link), error 2) in %srename_variation7-win32.php on line %d
+bool(false)
+
+Warning: readlink(): readlink failed to read the symbolic link (%srename_variation7-win32.php.tmp.link2), error 2) in %srename_variation7-win32.php on line %d
+bool(false)
+Done
diff --git a/ext/standard/tests/file/rename_variation7.phpt b/ext/standard/tests/file/rename_variation7.phpt
new file mode 100644
index 0000000..5b93772
--- /dev/null
+++ b/ext/standard/tests/file/rename_variation7.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Test rename() function: usage variations-8
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') die('skip.. not for Windows');
+if (!function_exists("symlink")) die("skip symlinks are not supported");
+?>
+--FILE--
+<?php
+
+$tmp_link = __FILE__.".tmp.link";
+$tmp_link2 = __FILE__.".tmp.link2";
+
+symlink(dirname(__FILE__)."/there_is_no_such_file", $tmp_link);
+rename($tmp_link, $tmp_link2);
+
+clearstatcache();
+
+var_dump(readlink($tmp_link));
+var_dump(readlink($tmp_link2));
+
+@unlink($tmp_link);
+@unlink($tmp_link2);
+
+echo "Done\n";
+?>
+--EXPECTF--
+Warning: readlink(): No such file or directory in %s on line %d
+bool(false)
+string(%d) "%sthere_is_no_such_file"
+Done
diff --git a/ext/standard/tests/file/rename_variation8-win32.phpt b/ext/standard/tests/file/rename_variation8-win32.phpt
new file mode 100644
index 0000000..1d25a12
--- /dev/null
+++ b/ext/standard/tests/file/rename_variation8-win32.phpt
@@ -0,0 +1,70 @@
+--TEST--
+Test rename() function: variation
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') die('skip.. for Windows');
+?>
+--FILE--
+<?php
+/* Prototype: bool rename ( string $oldname, string $newname [, resource $context] );
+ Description: Renames a file or directory
+*/
+
+echo "\n*** Testing rename() on non-existing file ***\n";
+$file_path = dirname(__FILE__);
+
+// try renaming a non existing file
+$src_name = $file_path."/non_existent_file.tmp";
+$dest_name = $file_path."/rename_variation8_new.tmp";
+var_dump( rename($src_name, $dest_name) );
+
+// ensure that $dest_name didn't get created
+var_dump( file_exists($src_name) ); // expecting false
+var_dump( file_exists($dest_name) ); // expecting false
+
+// rename a existing dir to new name
+echo "\n*** Testing rename() on existing directory ***\n";
+$dir_name = $file_path."/rename_basic_dir";
+mkdir($dir_name);
+$new_dir_name = $file_path."/rename_basic_dir1";
+var_dump( rename($dir_name, $new_dir_name) );
+//ensure that $new_dir_name got created
+var_dump( file_exists($dir_name) ); // expecting false
+var_dump( file_exists($new_dir_name) ); // expecting true
+
+// try to rename an non_existing dir
+echo "\n*** Testing rename() on non-existing directory ***\n";
+$non_existent_dir_name = $file_path."/non_existent_dir";
+$new_dir_name = "$file_path/rename_basic_dir2";
+var_dump( rename($non_existent_dir_name, $new_dir_name) );
+// ensure that $new_dir_name didn't get created
+var_dump( file_exists($non_existent_dir_name) ); // expecting flase
+var_dump( file_exists($new_dir_name) ); // expecting false
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+rmdir(dirname(__FILE__)."/rename_basic_dir1");
+?>
+--EXPECTF--
+*** Testing rename() on non-existing file ***
+
+Warning: rename(%s/non_existent_file.tmp,%s/rename_variation8_new.tmp): The system cannot find the file specified. (code: 2) in %s on line %d
+bool(false)
+bool(false)
+bool(false)
+
+*** Testing rename() on existing directory ***
+bool(true)
+bool(false)
+bool(true)
+
+*** Testing rename() on non-existing directory ***
+
+Warning: rename(%s/non_existent_dir,%s/rename_basic_dir2): The system cannot find the file specified. (code: 2) in %s on line %d
+bool(false)
+bool(false)
+bool(false)
+Done
+
diff --git a/ext/standard/tests/file/rename_variation8.phpt b/ext/standard/tests/file/rename_variation8.phpt
new file mode 100644
index 0000000..6e236c3
--- /dev/null
+++ b/ext/standard/tests/file/rename_variation8.phpt
@@ -0,0 +1,71 @@
+--TEST--
+Test rename() function: variation
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') die('skip.. not for Windows');
+?>
+--FILE--
+<?php
+/* Prototype: bool rename ( string $oldname, string $newname [, resource $context] );
+ Description: Renames a file or directory
+*/
+
+echo "\n*** Testing rename() on non-existing file ***\n";
+$file_path = dirname(__FILE__);
+
+// try renaming a non existing file
+$src_name = $file_path."/non_existent_file.tmp";
+$dest_name = $file_path."/rename_variation8_new.tmp";
+var_dump( rename($src_name, $dest_name) );
+
+// ensure that $dest_name didn't get created
+var_dump( file_exists($src_name) ); // expecting false
+var_dump( file_exists($dest_name) ); // expecting false
+
+// rename a existing dir to new name
+echo "\n*** Testing rename() on existing directory ***\n";
+$dir_name = $file_path."/rename_basic_dir";
+mkdir($dir_name);
+$new_dir_name = $file_path."/rename_basic_dir1";
+var_dump( rename($dir_name, $new_dir_name) );
+//ensure that $new_dir_name got created
+var_dump( file_exists($dir_name) ); // expecting false
+var_dump( file_exists($new_dir_name) ); // expecting true
+
+// try to rename an non_existing dir
+echo "\n*** Testing rename() on non-existing directory ***\n";
+$non_existent_dir_name = $file_path."/non_existent_dir";
+$new_dir_name = "$file_path/rename_basic_dir2";
+var_dump( rename($non_existent_dir_name, $new_dir_name) );
+// ensure that $new_dir_name didn't get created
+var_dump( file_exists($non_existent_dir_name) ); // expecting flase
+var_dump( file_exists($new_dir_name) ); // expecting false
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/rename_basic_new2.tmp");
+rmdir(dirname(__FILE__)."/rename_basic_dir1");
+?>
+--EXPECTF--
+*** Testing rename() on non-existing file ***
+
+Warning: rename(%s/non_existent_file.tmp,%s/rename_variation8_new.tmp): No such file or directory in %s on line %d
+bool(false)
+bool(false)
+bool(false)
+
+*** Testing rename() on existing directory ***
+bool(true)
+bool(false)
+bool(true)
+
+*** Testing rename() on non-existing directory ***
+
+Warning: rename(%s/non_existent_dir,%s/rename_basic_dir2): No such file or directory in %s on line %d
+bool(false)
+bool(false)
+bool(false)
+Done
+
diff --git a/ext/standard/tests/file/rename_variation9.phpt b/ext/standard/tests/file/rename_variation9.phpt
new file mode 100644
index 0000000..272fa94
--- /dev/null
+++ b/ext/standard/tests/file/rename_variation9.phpt
@@ -0,0 +1,53 @@
+--TEST--
+Test rename() function: basic functionality
+--FILE--
+<?php
+/* Prototype: bool rename ( string $oldname, string $newname [, resource $context] );
+ Description: Renames a file or directory
+*/
+
+echo "\n*** Testing rename() by giving stream context as third argument ***\n";
+$file_path = dirname(__FILE__);
+
+$context = stream_context_create();
+
+// on directory
+$dir_name = "$file_path/rename_variation_dir9";
+$new_dir_name = "$file_path/rename_variation_dir9_new";
+
+mkdir($dir_name);
+
+var_dump( rename($dir_name, $new_dir_name, $context) );
+var_dump( file_exists($dir_name) ); // expecting flase
+var_dump( file_exists($new_dir_name) ); // expecting true
+
+//on file
+$src_name = "$file_path/rename_variation9.tmp";
+$dest_name = "$file_path/rename_variation9_new.tmp";
+
+// create the file
+$fp = fopen($src_name, "w");
+$s1 = stat($src_name);
+fclose($fp);
+
+var_dump( rename($src_name, $dest_name, $context) );
+var_dump( file_exists($src_name) ); // expecting false
+var_dump( file_exists($dest_name) ); // expecting true
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/rename_variation9_new.tmp");
+rmdir(dirname(__FILE__)."/rename_variation_dir9_new");
+?>
+--EXPECT--
+*** Testing rename() by giving stream context as third argument ***
+bool(true)
+bool(false)
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+Done
+
diff --git a/ext/standard/tests/file/rmdir_variation1-win32.phpt b/ext/standard/tests/file/rmdir_variation1-win32.phpt
new file mode 100644
index 0000000..2516e61
--- /dev/null
+++ b/ext/standard/tests/file/rmdir_variation1-win32.phpt
@@ -0,0 +1,127 @@
+--TEST--
+Test rmdir() function : usage variation - invalid filenames
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+ die("skip Only valid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype : bool rmdir(string dirname[, resource context])
+ * Description: Remove a directory
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing rmdir() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase false' =>false,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+
+ // other
+ // php outputs Permission Denied, p8 outputs no suck file or dir
+ 'single space' => ' ',
+);
+
+// loop through each element of the array for dirname
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( rmdir($value) );
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing rmdir() : usage variation ***
+
+--uppercase NULL--
+Error: 2 - rmdir(): %s, %s(%d)
+bool(false)
+
+--lowercase null--
+Error: 2 - rmdir(): %s, %s(%d)
+bool(false)
+
+--lowercase false--
+Error: 2 - rmdir(): %s, %s(%d)
+bool(false)
+
+--uppercase FALSE--
+Error: 2 - rmdir(): %s, %s(%d)
+bool(false)
+
+--empty string DQ--
+Error: 2 - rmdir(): %s, %s(%d)
+bool(false)
+
+--empty string SQ--
+Error: 2 - rmdir(): %s, %s(%d)
+bool(false)
+
+--undefined var--
+Error: 2 - rmdir(): %s, %s(%d)
+bool(false)
+
+--unset var--
+Error: 2 - rmdir(): %s, %s(%d)
+bool(false)
+
+--single space--
+Error: 2 - rmdir( ): %s, %s(%d)
+bool(false)
+===DONE===
diff --git a/ext/standard/tests/file/rmdir_variation1.phpt b/ext/standard/tests/file/rmdir_variation1.phpt
new file mode 100644
index 0000000..04fee0e
--- /dev/null
+++ b/ext/standard/tests/file/rmdir_variation1.phpt
@@ -0,0 +1,127 @@
+--TEST--
+Test rmdir() function : usage variation - invalid file names
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+ die("skip Not valid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype : bool rmdir(string dirname[, resource context])
+ * Description: Remove a directory
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing rmdir() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase false' =>false,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+
+ // other
+ 'single space' => ' ',
+);
+
+// loop through each element of the array for dirname
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump(rmdir($value));
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing rmdir() : usage variation ***
+
+--uppercase NULL--
+Error: 2 - rmdir(): %s, %s(%d)
+bool(false)
+
+--lowercase null--
+Error: 2 - rmdir(): %s, %s(%d)
+bool(false)
+
+--lowercase false--
+Error: 2 - rmdir(): %s, %s(%d)
+bool(false)
+
+--uppercase FALSE--
+Error: 2 - rmdir(): %s, %s(%d)
+bool(false)
+
+--empty string DQ--
+Error: 2 - rmdir(): %s, %s(%d)
+bool(false)
+
+--empty string SQ--
+Error: 2 - rmdir(): %s, %s(%d)
+bool(false)
+
+--undefined var--
+Error: 2 - rmdir(): %s, %s(%d)
+bool(false)
+
+--unset var--
+Error: 2 - rmdir(): %s, %s(%d)
+bool(false)
+
+--single space--
+Error: 2 - rmdir( ): %s, %s(%d)
+bool(false)
+===DONE===
diff --git a/ext/standard/tests/file/rmdir_variation2.phpt b/ext/standard/tests/file/rmdir_variation2.phpt
new file mode 100644
index 0000000..2cee440
--- /dev/null
+++ b/ext/standard/tests/file/rmdir_variation2.phpt
@@ -0,0 +1,244 @@
+--TEST--
+Test rmdir() function : usage variation - different types for context
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : bool rmdir(string dirname[, resource context])
+ * Description: Remove a directory
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing rmdir() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$dirname = 'rmdirVar2.tmp';
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+$fileres = fopen(__FILE__, 'r');
+
+//array of values to iterate over
+$inputs = array(
+
+ // int data
+ 'int 0' => 0,
+ 'int 1' => 1,
+ 'int 12345' => 12345,
+ 'int -12345' => -2345,
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float -10.5' => -10.5,
+ 'float 12.3456789000e10' => 12.3456789000e10,
+ 'float -12.3456789000e10' => -12.3456789000e10,
+ 'float .5' => .5,
+
+ // array data
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // string data
+ 'string DQ' => "string",
+ 'string SQ' => 'string',
+ 'mixed case string' => "sTrInG",
+ 'heredoc' => $heredoc,
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+
+ // non stream context resource
+ $fileres,
+);
+
+// loop through each element of the array for context
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ @mkdir($dirname);
+ var_dump( rmdir($dirname, $value) );
+};
+
+@rmdir($dirname);
+fclose($fileres);
+?>
+===DONE===
+--EXPECTF--
+*** Testing rmdir() : usage variation ***
+
+--int 0--
+Error: 2 - rmdir() expects parameter 2 to be resource, integer given, %s(%d)
+bool(false)
+
+--int 1--
+Error: 2 - rmdir() expects parameter 2 to be resource, integer given, %s(%d)
+bool(false)
+
+--int 12345--
+Error: 2 - rmdir() expects parameter 2 to be resource, integer given, %s(%d)
+bool(false)
+
+--int -12345--
+Error: 2 - rmdir() expects parameter 2 to be resource, integer given, %s(%d)
+bool(false)
+
+--float 10.5--
+Error: 2 - rmdir() expects parameter 2 to be resource, double given, %s(%d)
+bool(false)
+
+--float -10.5--
+Error: 2 - rmdir() expects parameter 2 to be resource, double given, %s(%d)
+bool(false)
+
+--float 12.3456789000e10--
+Error: 2 - rmdir() expects parameter 2 to be resource, double given, %s(%d)
+bool(false)
+
+--float -12.3456789000e10--
+Error: 2 - rmdir() expects parameter 2 to be resource, double given, %s(%d)
+bool(false)
+
+--float .5--
+Error: 2 - rmdir() expects parameter 2 to be resource, double given, %s(%d)
+bool(false)
+
+--empty array--
+Error: 2 - rmdir() expects parameter 2 to be resource, array given, %s(%d)
+bool(false)
+
+--int indexed array--
+Error: 2 - rmdir() expects parameter 2 to be resource, array given, %s(%d)
+bool(false)
+
+--associative array--
+Error: 2 - rmdir() expects parameter 2 to be resource, array given, %s(%d)
+bool(false)
+
+--nested arrays--
+Error: 2 - rmdir() expects parameter 2 to be resource, array given, %s(%d)
+bool(false)
+
+--uppercase NULL--
+Error: 2 - rmdir() expects parameter 2 to be resource, null given, %s(%d)
+bool(false)
+
+--lowercase null--
+Error: 2 - rmdir() expects parameter 2 to be resource, null given, %s(%d)
+bool(false)
+
+--lowercase true--
+Error: 2 - rmdir() expects parameter 2 to be resource, boolean given, %s(%d)
+bool(false)
+
+--lowercase false--
+Error: 2 - rmdir() expects parameter 2 to be resource, boolean given, %s(%d)
+bool(false)
+
+--uppercase TRUE--
+Error: 2 - rmdir() expects parameter 2 to be resource, boolean given, %s(%d)
+bool(false)
+
+--uppercase FALSE--
+Error: 2 - rmdir() expects parameter 2 to be resource, boolean given, %s(%d)
+bool(false)
+
+--empty string DQ--
+Error: 2 - rmdir() expects parameter 2 to be resource, string given, %s(%d)
+bool(false)
+
+--empty string SQ--
+Error: 2 - rmdir() expects parameter 2 to be resource, string given, %s(%d)
+bool(false)
+
+--string DQ--
+Error: 2 - rmdir() expects parameter 2 to be resource, string given, %s(%d)
+bool(false)
+
+--string SQ--
+Error: 2 - rmdir() expects parameter 2 to be resource, string given, %s(%d)
+bool(false)
+
+--mixed case string--
+Error: 2 - rmdir() expects parameter 2 to be resource, string given, %s(%d)
+bool(false)
+
+--heredoc--
+Error: 2 - rmdir() expects parameter 2 to be resource, string given, %s(%d)
+bool(false)
+
+--instance of classWithToString--
+Error: 2 - rmdir() expects parameter 2 to be resource, object given, %s(%d)
+bool(false)
+
+--instance of classWithoutToString--
+Error: 2 - rmdir() expects parameter 2 to be resource, object given, %s(%d)
+bool(false)
+
+--undefined var--
+Error: 2 - rmdir() expects parameter 2 to be resource, null given, %s(%d)
+bool(false)
+
+--unset var--
+Error: 2 - rmdir() expects parameter 2 to be resource, null given, %s(%d)
+bool(false)
+
+--0--
+Error: 2 - rmdir(): supplied resource is not a valid Stream-Context resource, %s(%d)
+bool(true)
+===DONE===
diff --git a/ext/standard/tests/file/rmdir_variation3-win32.phpt b/ext/standard/tests/file/rmdir_variation3-win32.phpt
new file mode 100644
index 0000000..e6b3eaa
--- /dev/null
+++ b/ext/standard/tests/file/rmdir_variation3-win32.phpt
@@ -0,0 +1,108 @@
+--TEST--
+Test rmdir() function : variation: various valid and invalid paths
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+ die("skip Only valid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype : bool rmdir(string dirname[, resource context])
+ * Description: Remove a directory
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing rmdir() : variation ***\n";
+
+$workDir = "rmdirVar3.tmp";
+$subDir = "aSubDir";
+mkdir($workDir);
+$cwd = getcwd();
+
+$unixifiedDir = '/'.substr(str_replace('\\','/',$cwd).'/'.$workDir.'/'.$subDir, 3);
+
+$dirs = array(
+ // relative
+ $workDir.'\\'.$subDir,
+ '.\\'.$workDir.'\\'.$subDir,
+ $workDir.'\\..\\'.$workDir.'\\'.$subDir,
+
+ // relative bad path
+ $workDir.'\\..\\BADDIR\\'.$subDir,
+ 'BADDIR\\'.$subDir,
+
+ //absolute
+ $cwd.'\\'.$workDir.'\\'.$subDir,
+ $cwd.'\\.\\'.$workDir.'\\'.$subDir,
+ $cwd.'\\'.$workDir.'\\..\\'.$workDir.'\\'.$subDir,
+
+ //absolute bad path
+ $cwd.'\\BADDIR\\'.$subDir,
+
+ //trailing separators
+ $workDir.'\\'.$subDir.'\\',
+ $cwd.'\\'.$workDir.'\\'.$subDir.'\\',
+
+ // multiple separators
+ $workDir.'\\\\'.$subDir,
+ $cwd.'\\\\'.$workDir.'\\\\'.$subDir,
+
+ // Unixified Dir
+ $unixifiedDir,
+
+ );
+
+
+foreach($dirs as $dir) {
+ mkdir($workDir.'/'.$subDir);
+ echo "-- removing $dir --\n";
+ $res = rmdir($dir);
+ if ($res === true) {
+ echo "Directory removed\n";
+ }
+ else {
+ rmdir($workDir.'/'.$subDir);
+ }
+}
+
+rmdir($workDir);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing rmdir() : variation ***
+-- removing rmdirVar3.tmp\aSubDir --
+Directory removed
+-- removing .\rmdirVar3.tmp\aSubDir --
+Directory removed
+-- removing rmdirVar3.tmp\..\rmdirVar3.tmp\aSubDir --
+Directory removed
+-- removing rmdirVar3.tmp\..\BADDIR\aSubDir --
+
+Warning: rmdir(rmdirVar3.tmp\..\BADDIR\aSubDir): No such file or directory in %s on line %d
+-- removing BADDIR\aSubDir --
+
+Warning: rmdir(BADDIR\aSubDir): No such file or directory in %s on line %d
+-- removing %s\rmdirVar3.tmp\aSubDir --
+Directory removed
+-- removing %s\.\rmdirVar3.tmp\aSubDir --
+Directory removed
+-- removing %s\rmdirVar3.tmp\..\rmdirVar3.tmp\aSubDir --
+Directory removed
+-- removing %s\BADDIR\aSubDir --
+
+Warning: rmdir(%s\BADDIR\aSubDir): No such file or directory in %s on line %d
+-- removing rmdirVar3.tmp\aSubDir\ --
+Directory removed
+-- removing %s\rmdirVar3.tmp\aSubDir\ --
+Directory removed
+-- removing rmdirVar3.tmp\\aSubDir --
+Directory removed
+-- removing %s\\rmdirVar3.tmp\\aSubDir --
+Directory removed
+-- removing /%s/rmdirVar3.tmp/aSubDir --
+Directory removed
+===DONE=== \ No newline at end of file
diff --git a/ext/standard/tests/file/rmdir_variation3.phpt b/ext/standard/tests/file/rmdir_variation3.phpt
new file mode 100644
index 0000000..5848007
--- /dev/null
+++ b/ext/standard/tests/file/rmdir_variation3.phpt
@@ -0,0 +1,96 @@
+--TEST--
+Test rmdir() function : variation: various valid and invalid paths
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : bool rmdir(string dirname[, resource context])
+ * Description: Remove a directory
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing rmdir() : variation ***\n";
+
+$workDir = "rmdirVar3.tmp";
+$subDir = "aSubDir";
+mkdir($workDir);
+$cwd = getcwd();
+
+$dirs = array(
+ // relative
+ $workDir.'/'.$subDir,
+ './'.$workDir.'/'.$subDir,
+ $workDir.'/../'.$workDir.'/'.$subDir,
+
+ // relative bad path
+ $workDir.'/../BADDIR/'.$subDir,
+ 'BADDIR/'.$subDir,
+
+ //absolute
+ $cwd.'/'.$workDir.'/'.$subDir,
+ $cwd.'/./'.$workDir.'/'.$subDir,
+ $cwd.'/'.$workDir.'/../'.$workDir.'/'.$subDir,
+
+ //absolute bad path
+ $cwd.'/BADDIR/'.$subDir,
+
+ //trailing separators
+ $workDir.'/'.$subDir.'/',
+ $cwd.'/'.$workDir.'/'.$subDir.'/',
+
+ // multiple separators
+ $workDir.'//'.$subDir,
+ $cwd.'//'.$workDir.'//'.$subDir,
+
+ );
+
+
+foreach($dirs as $dir) {
+ mkdir($workDir.'/'.$subDir);
+ echo "-- removing $dir --\n";
+ $res = rmdir($dir);
+ if ($res === true) {
+ echo "Directory removed\n";
+ }
+ else {
+ rmdir($workDir.'/'.$subDir);
+ }
+}
+
+rmdir($workDir);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing rmdir() : variation ***
+-- removing rmdirVar3.tmp/aSubDir --
+Directory removed
+-- removing ./rmdirVar3.tmp/aSubDir --
+Directory removed
+-- removing rmdirVar3.tmp/../rmdirVar3.tmp/aSubDir --
+Directory removed
+-- removing rmdirVar3.tmp/../BADDIR/aSubDir --
+
+Warning: rmdir(rmdirVar3.tmp/../BADDIR/aSubDir): No such file or directory in %s on line %d
+-- removing BADDIR/aSubDir --
+
+Warning: rmdir(BADDIR/aSubDir): No such file or directory in %s on line %d
+-- removing %s/rmdirVar3.tmp/aSubDir --
+Directory removed
+-- removing %s/./rmdirVar3.tmp/aSubDir --
+Directory removed
+-- removing %s/rmdirVar3.tmp/../rmdirVar3.tmp/aSubDir --
+Directory removed
+-- removing %s/BADDIR/aSubDir --
+
+Warning: rmdir(%s/BADDIR/aSubDir): No such file or directory in %s on line %d
+-- removing rmdirVar3.tmp/aSubDir/ --
+Directory removed
+-- removing %s/rmdirVar3.tmp/aSubDir/ --
+Directory removed
+-- removing rmdirVar3.tmp//aSubDir --
+Directory removed
+-- removing %s//rmdirVar3.tmp//aSubDir --
+Directory removed
+===DONE=== \ No newline at end of file
diff --git a/ext/standard/tests/file/stat_basic-win32.phpt b/ext/standard/tests/file/stat_basic-win32.phpt
new file mode 100644
index 0000000..e3e7ea7
--- /dev/null
+++ b/ext/standard/tests/file/stat_basic-win32.phpt
@@ -0,0 +1,192 @@
+--TEST--
+Test stat() function: basic functionality
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip.. valid only for Windows');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: array stat ( string $filename );
+ Description: Gives information about a file
+*/
+
+$file_path = dirname(__FILE__);
+require("$file_path/file.inc");
+
+echo "*** Testing stat() : basic functionality ***\n";
+
+/* creating temp directory and file */
+
+// creating dir
+$dirname = "$file_path/stat_basic";
+mkdir($dirname);
+// stat of the dir created
+$dir_stat = stat($dirname);
+clearstatcache();
+sleep(2);
+
+// creating file
+$filename = "$dirname/stat_basic.tmp";
+$file_handle = fopen($filename, "w");
+fclose($file_handle);
+// stat of the file created
+$file_stat = stat($filename);
+sleep(2);
+
+// now new stat of the dir after file is created
+$new_dir_stat = stat($dirname);
+clearstatcache();
+
+// stat contains 13 different values stored twice, can be accessed using
+// numeric and named keys, compare them to see they are same
+echo "*** Testing stat(): validating the values stored in stat ***\n";
+// Initial stat values
+var_dump( compare_self_stat($file_stat) ); //expect true
+var_dump( compare_self_stat($dir_stat) ); //expect true
+
+// New stat values taken after creation of file
+var_dump( compare_self_stat($new_dir_stat) ); // expect true
+
+// compare the two stat values, initial stat and stat recorded after
+// creating file, also dump the value of stats
+echo "*** Testing stat(): comparing stats (recorded before and after file creation) ***\n";
+echo "-- comparing difference in dir stats before and after creating file in it --\n";
+$affected_elements = array( 9, 'mtime' );
+var_dump( compare_stats($dir_stat, $new_dir_stat, $affected_elements, '!=', true) ); // expect true
+
+echo "*** Testing stat(): for the return value ***\n";
+var_dump( is_array( stat($filename) ) );
+
+echo "\n---Done---";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink("$file_path/stat_basic/stat_basic.tmp");
+rmdir("$file_path/stat_basic");
+?>
+--EXPECTF--
+*** Testing stat() : basic functionality ***
+*** Testing stat(): validating the values stored in stat ***
+bool(true)
+bool(true)
+bool(true)
+*** Testing stat(): comparing stats (recorded before and after file creation) ***
+-- comparing difference in dir stats before and after creating file in it --
+array(26) {
+ [0]=>
+ int(%d)
+ [1]=>
+ int(0)
+ [2]=>
+ int(%d)
+ [3]=>
+ int(%d)
+ [4]=>
+ int(0)
+ [5]=>
+ int(0)
+ [6]=>
+ int(%d)
+ [7]=>
+ int(%d)
+ [8]=>
+ int(%d)
+ [9]=>
+ int(%d)
+ [10]=>
+ int(%d)
+ [11]=>
+ int(-1)
+ [12]=>
+ int(-1)
+ ["dev"]=>
+ int(%d)
+ ["ino"]=>
+ int(0)
+ ["mode"]=>
+ int(%d)
+ ["nlink"]=>
+ int(%d)
+ ["uid"]=>
+ int(0)
+ ["gid"]=>
+ int(0)
+ ["rdev"]=>
+ int(%d)
+ ["size"]=>
+ int(%d)
+ ["atime"]=>
+ int(%d)
+ ["mtime"]=>
+ int(%d)
+ ["ctime"]=>
+ int(%d)
+ ["blksize"]=>
+ int(-1)
+ ["blocks"]=>
+ int(-1)
+}
+array(26) {
+ [0]=>
+ int(%d)
+ [1]=>
+ int(%d)
+ [2]=>
+ int(%d)
+ [3]=>
+ int(%d)
+ [4]=>
+ int(%d)
+ [5]=>
+ int(%d)
+ [6]=>
+ int(%d)
+ [7]=>
+ int(%d)
+ [8]=>
+ int(%d)
+ [9]=>
+ int(%d)
+ [10]=>
+ int(%d)
+ [11]=>
+ int(-1)
+ [12]=>
+ int(-1)
+ ["dev"]=>
+ int(%d)
+ ["ino"]=>
+ int(%d)
+ ["mode"]=>
+ int(%d)
+ ["nlink"]=>
+ int(%d)
+ ["uid"]=>
+ int(%d)
+ ["gid"]=>
+ int(%d)
+ ["rdev"]=>
+ int(%d)
+ ["size"]=>
+ int(%d)
+ ["atime"]=>
+ int(%d)
+ ["mtime"]=>
+ int(%d)
+ ["ctime"]=>
+ int(%d)
+ ["blksize"]=>
+ int(-1)
+ ["blocks"]=>
+ int(-1)
+}
+bool(true)
+*** Testing stat(): for the return value ***
+bool(true)
+
+---Done---
+
diff --git a/ext/standard/tests/file/stat_error-win32.phpt b/ext/standard/tests/file/stat_error-win32.phpt
new file mode 100644
index 0000000..1b69da8
--- /dev/null
+++ b/ext/standard/tests/file/stat_error-win32.phpt
@@ -0,0 +1,55 @@
+--TEST--
+Test stat() function: error conditions
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip.. only for Windows');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: array stat ( string $filename );
+ Description: Gives information about a file
+*/
+
+$file_path = dirname(__FILE__);
+$arr = array(__FILE__);
+
+echo "\n*** Testing stat() for error conditions ***\n";
+var_dump( stat() ); // args < expected
+var_dump( stat(__FILE__, 2) ); // file, args > expected
+var_dump( stat(dirname(__FILE__), 2) ); //dir, args > expected
+
+var_dump( stat("$file_path/temp.tmp") ); // non existing file
+var_dump( stat("$file_path/temp/") ); // non existing dir
+var_dump( stat(22) ); // scalar argument
+var_dump( stat($arr) ); // array argument
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing stat() for error conditions ***
+
+Warning: stat() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: stat() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+
+Warning: stat() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+
+Warning: stat(): stat failed for %s in %s on line %d
+bool(false)
+
+Warning: stat(): stat failed for %s in %s on line %d
+bool(false)
+
+Warning: stat(): stat failed for 22 in %s on line %d
+bool(false)
+
+Warning: stat() expects parameter 1 to be a valid path, array given in %s on line %d
+NULL
+Done
+
diff --git a/ext/standard/tests/file/stat_variation1-win32.phpt b/ext/standard/tests/file/stat_variation1-win32.phpt
new file mode 100644
index 0000000..abbc88f
--- /dev/null
+++ b/ext/standard/tests/file/stat_variation1-win32.phpt
@@ -0,0 +1,94 @@
+--TEST--
+Test stat() functions: usage variations - effects of rename()
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip.. only for Windows');
+}
+?>
+--FILE--
+<?php
+
+/*
+ * Prototype: array stat ( string $filename );
+ * Description: Gives information about a file
+ */
+
+/* test the effects of rename() on stats of dir/file */
+
+$file_path = dirname(__FILE__);
+require "$file_path/file.inc";
+
+
+/* create temp file and directory */
+mkdir("$file_path/stat_variation1/"); // temp dir
+
+$file_handle = fopen("$file_path/stat_variation1.tmp", "w"); // temp file
+fclose($file_handle);
+
+
+echo "*** Testing stat(): on file and directory ater renaming them ***\n";
+
+// renaming a file
+echo "-- Testing stat() for files after being renamed --\n";
+$old_filename = "$file_path/stat_variation1.tmp";
+$new_filename = "$file_path/stat_variation1a.tmp";
+$old_stat = stat($old_filename);
+clearstatcache();
+sleep(2);
+var_dump( rename($old_filename, $new_filename) );
+$new_stat = stat($new_filename);
+
+// compare the self stat
+var_dump( compare_self_stat($old_stat) );
+var_dump( compare_self_stat($new_stat) );
+
+// compare the two stats
+var_dump( compare_stats($old_stat, $old_stat, $all_stat_keys) );
+// clear the cache
+clearstatcache();
+
+// renaming a directory
+echo "-- Testing stat() for directory after being renamed --\n";
+$old_dirname = "$file_path/stat_variation1";
+$new_dirname = "$file_path/stat_variation1a";
+$old_stat = stat($old_dirname);
+clearstatcache();
+sleep(2);
+var_dump( rename($old_dirname, $new_dirname) );
+$new_stat = stat($new_dirname);
+
+// compare self stats
+var_dump( compare_self_stat($old_stat) );
+var_dump( compare_self_stat($new_stat) );
+
+// compare the two stats
+var_dump( compare_stats($old_stat, $new_stat, $all_stat_keys) );
+// clear the cache
+clearstatcache();
+
+
+echo "\n*** Done ***";
+?>
+
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink("$file_path/stat_variation1a.tmp");
+rmdir("$file_path/stat_variation1a");
+?>
+--EXPECTF--
+*** Testing stat(): on file and directory ater renaming them ***
+-- Testing stat() for files after being renamed --
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+-- Testing stat() for directory after being renamed --
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/stat_variation2-win32.phpt b/ext/standard/tests/file/stat_variation2-win32.phpt
new file mode 100644
index 0000000..2bd9f80
--- /dev/null
+++ b/ext/standard/tests/file/stat_variation2-win32.phpt
@@ -0,0 +1,65 @@
+--TEST--
+Test stat() functions: usage variations - effects of writing to file
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip.. only for Windows');
+}
+?>
+--FILE--
+<?php
+
+/*
+ * Prototype: array stat ( string $filename );
+ * Description: Gives information about a file
+ */
+
+/* test the effects of writing to a file on the stats of the file */
+
+
+$file_path = dirname(__FILE__);
+require "$file_path/file.inc";
+
+
+$filename = "$file_path/stat_variation2.tmp";
+$file_handle = fopen($filename, "w"); // temp file
+fclose($file_handle);
+
+
+echo "*** Testing stat(): writing to a file ***\n";
+
+// writing to an empty file
+echo "-- Testing stat() on file after data is written in it --\n";
+$old_stat = stat($filename);
+clearstatcache();
+sleep(2);
+$file_handle = fopen($filename, "w"); // temp file
+fwrite($file_handle, "Hello World");
+fclose($file_handle);
+$new_stat = stat($filename);
+
+// compare self stats
+var_dump( compare_self_stat($old_stat) );
+var_dump( compare_self_stat($new_stat) );
+// compare the stats
+$comp_arr = array(7, 'size');
+var_dump(compare_stats($old_stat, $new_stat, $comp_arr, "<"));
+clearstatcache();
+
+echo "\n*** Done ***";
+?>
+
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink("$file_path/stat_variation2.tmp");
+?>
+--EXPECTF--
+*** Testing stat(): writing to a file ***
+-- Testing stat() on file after data is written in it --
+bool(true)
+bool(true)
+bool(true)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/stat_variation3-win32.phpt b/ext/standard/tests/file/stat_variation3-win32.phpt
new file mode 100644
index 0000000..e248116
--- /dev/null
+++ b/ext/standard/tests/file/stat_variation3-win32.phpt
@@ -0,0 +1,80 @@
+--TEST--
+Test stat() functions: usage variations - effects of creating/deleting the dir/file
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip.. only for Windows');
+}
+?>
+--FILE--
+<?php
+
+/*
+ * Prototype: array stat ( string $filename );
+ * Description: Gives information about a file
+ */
+
+/* test the effects of creating & deleting of subdir/file on the stats of dir/file */
+
+$file_path = dirname(__FILE__);
+require "$file_path/file.inc";
+
+
+/* create temp file and directory */
+mkdir("$file_path/stat_variation3/"); // temp dir
+
+echo "*** Testing stat(): with creating & deleting subdir/file ***\n";
+
+// creating and deleting subdir and files in the dir
+echo "-- Testing stat() on dir after subdir and file is created in it --\n";
+$dirname = "$file_path/stat_variation3";
+$old_stat = stat($dirname);
+clearstatcache();
+sleep(2);
+mkdir("$dirname/stat_variation3_subdir");
+$file_handle = fopen("$dirname/stat_variation3a.tmp", "w");
+fclose($file_handle);
+$new_stat = stat($dirname);
+
+// compare self stats
+var_dump( compare_self_stat($old_stat) );
+var_dump( compare_self_stat($new_stat) );
+// compare the stats
+$affected_members = array( 9, 'mtime');
+clearstatcache();
+sleep(2);
+var_dump(compare_stats($old_stat, $new_stat, $affected_members, "<"));
+unlink("$dirname/stat_variation3a.tmp");
+rmdir("$dirname/stat_variation3_subdir");
+clearstatcache();
+
+// comparing stats after the deletion of subdir and file
+echo "-- Testing stat() for comparing stats after the deletion of subdir and file --\n";
+$new_stat1 = stat($dirname);
+// compare self stats
+var_dump( compare_self_stat($new_stat1) );
+// compare the stats
+var_dump(compare_stats($new_stat, $new_stat1, $all_stat_keys, "="));
+clearstatcache();
+
+echo "\n*** Done ***";
+?>
+
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+rmdir("$file_path/stat_variation3");
+?>
+--EXPECTF--
+
+*** Testing stat(): with creating & deleting subdir/file ***
+-- Testing stat() on dir after subdir and file is created in it --
+bool(true)
+bool(true)
+bool(true)
+-- Testing stat() for comparing stats after the deletion of subdir and file --
+bool(true)
+bool(true)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/stat_variation4-win32.phpt b/ext/standard/tests/file/stat_variation4-win32.phpt
new file mode 100644
index 0000000..a0ffed2
--- /dev/null
+++ b/ext/standard/tests/file/stat_variation4-win32.phpt
@@ -0,0 +1,93 @@
+--TEST--
+Test stat() functions: usage variations - effects of is_dir() & is_file()
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip.. only for Windows');
+}
+?>
+--FILE--
+<?php
+
+/*
+ * Prototype: array stat ( string $filename );
+ * Description: Gives information about a file
+ */
+
+/* test the effects on the stats of dir/file for using is_dir() & is_file() on dir/file */
+
+$file_path = dirname(__FILE__);
+require "$file_path/file.inc";
+
+
+/* create temp file and directory */
+mkdir("$file_path/stat_variation4/"); // temp dir
+
+$file_handle = fopen("$file_path/stat_variation4.tmp", "w"); // temp file
+fclose($file_handle);
+
+
+echo "\n*** Testing stat(): on file and directory after accessing it
+ with is_dir() and is_file() functions ***\n";
+
+// is_dir() on a directory
+echo "-- Testing on Directory --\n";
+$old_dirname = "$file_path/stat_variation4";
+$old_stat = stat($old_dirname);
+// clear the cache
+clearstatcache();
+sleep(2);
+var_dump( is_dir($old_dirname) );
+$new_stat = stat($old_dirname);
+
+// compare self stats
+var_dump( compare_self_stat($old_stat) );
+var_dump( compare_self_stat($new_stat) );
+// compare the stat
+var_dump( compare_stats($old_stat, $new_stat, $all_stat_keys, "=") );
+// clear the stat
+clearstatcache();
+
+
+// is_file() on a file
+echo "-- Testing on file --\n";
+$old_filename = "$file_path/stat_variation4.tmp";
+$old_stat = stat($old_filename);
+// clear the stat
+clearstatcache();
+sleep(2);
+var_dump( is_file($old_filename) );
+$new_stat = stat($old_filename);
+// compare self stats
+var_dump( compare_self_stat($old_stat) );
+var_dump( compare_self_stat($new_stat) );
+// compare the stat
+var_dump( compare_stats($old_stat, $new_stat, $all_stat_keys, "=") );
+// clear the stat
+clearstatcache();
+
+echo "\n*** Done ***";
+?>
+
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink("$file_path/stat_variation4.tmp");
+rmdir("$file_path/stat_variation4");
+?>
+--EXPECTF--
+*** Testing stat(): on file and directory after accessing it
+ with is_dir() and is_file() functions ***
+-- Testing on Directory --
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+-- Testing on file --
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/stat_variation5-win32.phpt b/ext/standard/tests/file/stat_variation5-win32.phpt
new file mode 100644
index 0000000..038b9b6
--- /dev/null
+++ b/ext/standard/tests/file/stat_variation5-win32.phpt
@@ -0,0 +1,66 @@
+--TEST--
+Test stat() functions: usage variations - file opened in read/write mode
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip.. only for Windows');
+}
+?>
+--FILE--
+<?php
+
+/*
+ * Prototype: array stat ( string $filename );
+ * Description: Gives information about a file
+ */
+
+/* test the stats of file opened in write mode and then same in read mode */
+
+$file_path = dirname(__FILE__);
+require "$file_path/file.inc";
+
+
+$file_handle = fopen("$file_path/stat_variation5.tmp", "w"); // temp file
+fclose($file_handle);
+
+
+echo "\n*** Testing stat(): on a file with read/write permission ***\n";
+
+$filename = "$file_path/stat_variation5.tmp";
+$file_handle = fopen($filename, "w"); // create file
+fclose($file_handle);
+$old_stat = stat($filename);
+// clear the stat
+clearstatcache();
+sleep(2);
+// opening file again in read mode
+$file_handle = fopen($filename, "r"); // read file
+fclose($file_handle);
+$new_stat = stat($filename);
+// compare self stats
+var_dump( compare_self_stat($old_stat) );
+var_dump( compare_self_stat($new_stat) );
+// compare the stat
+$affected_members = array(10, 'ctime');
+var_dump( compare_stats($old_stat, $new_stat, $affected_members, "=") );
+// clear the stat
+clearstatcache();
+
+
+echo "\n*** Done ***";
+?>
+
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink("$file_path/stat_variation5.tmp");
+?>
+--EXPECTF--
+
+*** Testing stat(): on a file with read/write permission ***
+bool(true)
+bool(true)
+bool(true)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/stat_variation6-win32.phpt b/ext/standard/tests/file/stat_variation6-win32.phpt
new file mode 100644
index 0000000..3dae75b
--- /dev/null
+++ b/ext/standard/tests/file/stat_variation6-win32.phpt
@@ -0,0 +1,92 @@
+--TEST--
+Test stat() functions: usage variations - changing permissions of dir/file
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip.. only for Windows');
+}
+?>
+--FILE--
+<?php
+
+/*
+ * Prototype: array stat ( string $filename );
+ * Description: Gives information about a file
+ */
+
+/* test the effects on the stats of dir/file for changing permissions of dir/file */
+
+
+$file_path = dirname(__FILE__);
+require "$file_path/file.inc";
+
+
+/* create temp file and directory */
+$dirname = "$file_path/stat_variation6";
+mkdir($dirname); // temp dir
+
+$filename = "$file_path/stat_variation6.tmp";
+$file_handle = fopen($filename, "w"); // temp file
+fclose($file_handle);
+
+
+// checking stat() on file
+echo "\n*** Testing stat() on file with miscelleneous file permission and content ***\n";
+$old_stat = stat($filename);
+var_dump( chmod($filename, 0777) );
+// clear the stat
+clearstatcache();
+sleep(2);
+$new_stat = stat($filename);
+// compare self stats
+var_dump( compare_self_stat($old_stat) );
+var_dump( compare_self_stat($new_stat) );
+// compare the stat
+$affected_members = array( 10, 'ctime');
+var_dump( compare_stats($old_stat, $new_stat, $affected_members, "=") );
+// clear the stat
+clearstatcache(); // clear statement cache
+
+// checking stat() on directory
+echo "\n*** Testing stat() on directory with miscelleneous file permission ***\n";
+$old_stat = stat($dirname);
+var_dump( chmod($dirname, 0777) );
+// clear the stat
+clearstatcache();
+sleep(2);
+$new_stat = stat($dirname);
+// compare self stats
+var_dump( compare_self_stat($old_stat) );
+var_dump( compare_self_stat($new_stat) );
+// compare the stat
+$affected_members = array( 10, 'ctime');
+var_dump( compare_stats($old_stat, $new_stat, $affected_members, "=") );
+// clear the stat
+clearstatcache(); // clear statement cache
+
+
+echo "\n*** Done ***";
+?>
+
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink("$file_path/stat_variation6.tmp");
+rmdir("$file_path/stat_variation6");
+?>
+--EXPECTF--
+
+*** Testing stat() on file with miscelleneous file permission and content ***
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+
+*** Testing stat() on directory with miscelleneous file permission ***
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/stat_variation7-win32.phpt b/ext/standard/tests/file/stat_variation7-win32.phpt
new file mode 100644
index 0000000..d72305f
--- /dev/null
+++ b/ext/standard/tests/file/stat_variation7-win32.phpt
@@ -0,0 +1,298 @@
+--TEST--
+Test stat() functions: usage variations - names of dir/file stored in objects
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip.. only for Windows');
+}
+?>
+--FILE--
+<?php
+
+/*
+ * Prototype: array stat ( string $filename );
+ * Description: Gives information about a file
+ */
+
+/* test the stats of dir/file when their names are stored in objects */
+
+$file_path = dirname(__FILE__);
+require "$file_path/file.inc";
+
+
+/* create temp file and directory */
+mkdir("$file_path/stat_variation7/"); // temp dir
+
+$file_handle = fopen("$file_path/stat_variation7.tmp", "w"); // temp file
+fclose($file_handle);
+
+
+echo "\n*** Testing stat(): with filename
+ and directory name stored inside a object ***\n";
+
+// creating object with members as numeric and non-numeric filename and directory name
+class object_temp {
+public $var_name;
+public function object_temp($name) {
+$this->var_name = $name;
+ }
+}
+
+// directory as member
+$obj1 = new object_temp("$file_path/stat_variation7/");
+$obj2 = new object_temp("$file_path/stat_variation7a/");
+
+// file as member
+$obj3 = new object_temp("$file_path/stat_variation7.tmp");
+$obj4 = new object_temp("$file_path/stat_variation7a.tmp");
+
+echo "\n-- Testing stat() on filename stored inside an object --\n";
+var_dump( stat($obj3->var_name) );
+
+$file_handle = fopen("$file_path/stat_variation7a.tmp", "w");
+fclose($file_handle);
+var_dump( stat($obj4->var_name) );
+
+echo "\n-- Testing stat() on directory name stored inside an object --\n";
+var_dump( stat($obj1->var_name) );
+
+mkdir("$file_path/stat_variation7a/");
+var_dump( stat($obj2->var_name) );
+
+echo "\n*** Done ***";
+?>
+
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink("$file_path/stat_variation7.tmp");
+unlink("$file_path/stat_variation7a.tmp");
+rmdir("$file_path/stat_variation7");
+rmdir("$file_path/stat_variation7a");
+?>
+--EXPECTF--
+*** Testing stat(): with filename
+ and directory name stored inside a object ***
+
+-- Testing stat() on filename stored inside an object --
+array(26) {
+ [0]=>
+ int(%d)
+ [1]=>
+ int(%d)
+ [2]=>
+ int(%d)
+ [3]=>
+ int(%d)
+ [4]=>
+ int(%d)
+ [5]=>
+ int(%d)
+ [6]=>
+ int(%d)
+ [7]=>
+ int(%d)
+ [8]=>
+ int(%d)
+ [9]=>
+ int(%d)
+ [10]=>
+ int(%d)
+ [11]=>
+ int(-%d)
+ [12]=>
+ int(-%d)
+ ["dev"]=>
+ int(%d)
+ ["ino"]=>
+ int(%d)
+ ["mode"]=>
+ int(%d)
+ ["nlink"]=>
+ int(%d)
+ ["uid"]=>
+ int(%d)
+ ["gid"]=>
+ int(%d)
+ ["rdev"]=>
+ int(%d)
+ ["size"]=>
+ int(%d)
+ ["atime"]=>
+ int(%d)
+ ["mtime"]=>
+ int(%d)
+ ["ctime"]=>
+ int(%d)
+ ["blksize"]=>
+ int(-%d)
+ ["blocks"]=>
+ int(-%d)
+}
+array(26) {
+ [0]=>
+ int(%d)
+ [1]=>
+ int(%d)
+ [2]=>
+ int(%d)
+ [3]=>
+ int(%d)
+ [4]=>
+ int(%d)
+ [5]=>
+ int(%d)
+ [6]=>
+ int(%d)
+ [7]=>
+ int(%d)
+ [8]=>
+ int(%d)
+ [9]=>
+ int(%d)
+ [10]=>
+ int(%d)
+ [11]=>
+ int(-%d)
+ [12]=>
+ int(-%d)
+ ["dev"]=>
+ int(%d)
+ ["ino"]=>
+ int(%d)
+ ["mode"]=>
+ int(%d)
+ ["nlink"]=>
+ int(%d)
+ ["uid"]=>
+ int(%d)
+ ["gid"]=>
+ int(%d)
+ ["rdev"]=>
+ int(%d)
+ ["size"]=>
+ int(%d)
+ ["atime"]=>
+ int(%d)
+ ["mtime"]=>
+ int(%d)
+ ["ctime"]=>
+ int(%d)
+ ["blksize"]=>
+ int(-%d)
+ ["blocks"]=>
+ int(-%d)
+}
+
+-- Testing stat() on directory name stored inside an object --
+array(26) {
+ [0]=>
+ int(%d)
+ [1]=>
+ int(%d)
+ [2]=>
+ int(%d)
+ [3]=>
+ int(%d)
+ [4]=>
+ int(%d)
+ [5]=>
+ int(%d)
+ [6]=>
+ int(%d)
+ [7]=>
+ int(%d)
+ [8]=>
+ int(%d)
+ [9]=>
+ int(%d)
+ [10]=>
+ int(%d)
+ [11]=>
+ int(-%d)
+ [12]=>
+ int(-%d)
+ ["dev"]=>
+ int(%d)
+ ["ino"]=>
+ int(%d)
+ ["mode"]=>
+ int(%d)
+ ["nlink"]=>
+ int(%d)
+ ["uid"]=>
+ int(%d)
+ ["gid"]=>
+ int(%d)
+ ["rdev"]=>
+ int(%d)
+ ["size"]=>
+ int(%d)
+ ["atime"]=>
+ int(%d)
+ ["mtime"]=>
+ int(%d)
+ ["ctime"]=>
+ int(%d)
+ ["blksize"]=>
+ int(-%d)
+ ["blocks"]=>
+ int(-%d)
+}
+array(26) {
+ [0]=>
+ int(%d)
+ [1]=>
+ int(%d)
+ [2]=>
+ int(%d)
+ [3]=>
+ int(%d)
+ [4]=>
+ int(%d)
+ [5]=>
+ int(%d)
+ [6]=>
+ int(%d)
+ [7]=>
+ int(%d)
+ [8]=>
+ int(%d)
+ [9]=>
+ int(%d)
+ [10]=>
+ int(%d)
+ [11]=>
+ int(-%d)
+ [12]=>
+ int(-%d)
+ ["dev"]=>
+ int(%d)
+ ["ino"]=>
+ int(%d)
+ ["mode"]=>
+ int(%d)
+ ["nlink"]=>
+ int(%d)
+ ["uid"]=>
+ int(%d)
+ ["gid"]=>
+ int(%d)
+ ["rdev"]=>
+ int(%d)
+ ["size"]=>
+ int(%d)
+ ["atime"]=>
+ int(%d)
+ ["mtime"]=>
+ int(%d)
+ ["ctime"]=>
+ int(%d)
+ ["blksize"]=>
+ int(-%d)
+ ["blocks"]=>
+ int(-%d)
+}
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/stat_variation8-win32.phpt b/ext/standard/tests/file/stat_variation8-win32.phpt
new file mode 100644
index 0000000..079bd0d
--- /dev/null
+++ b/ext/standard/tests/file/stat_variation8-win32.phpt
@@ -0,0 +1,77 @@
+--TEST--
+Test stat() functions: usage variations - effects of truncate()
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip.. only for Windows');
+}
+?>
+--FILE--
+<?php
+
+/*
+ * Prototype: array stat ( string $filename );
+ * Description: Gives information about a file
+ */
+
+/* test the effects of truncate() on stats of file */
+
+
+$file_path = dirname(__FILE__);
+require "$file_path/file.inc";
+
+
+/* create temp file and directory */
+
+$filename = "$file_path/stat_variation8.tmp";
+$file_handle = fopen($filename, "w"); // temp file
+fclose($file_handle);
+
+
+echo "\n*** Testing stat(): on file by truncating it to given size ***\n";
+
+// create temp file
+$file_handle = fopen($filename, "w");
+fclose($file_handle);
+
+clearstatcache(true, $filename);
+$old_stat = stat($filename);
+// clear the cache
+sleep(2);
+
+// opening file in r/w mode
+$file_handle = fopen($filename, "r+");
+var_dump( ftruncate($file_handle, 512) ); // truncate it
+fclose($file_handle);
+
+clearstatcache(true, $filename);
+$new_stat = stat($filename);
+
+// compare self stats
+var_dump( compare_self_stat($old_stat) );
+var_dump( compare_self_stat($new_stat) );
+
+// compare the stat
+$affected_members = array(7, 9, 'size', 'mtime');
+var_dump( compare_stats($old_stat, $new_stat, $affected_members, '!=') );
+
+// clear the stat
+clearstatcache(true, $filename); // clear previous size value in cache
+
+echo "\n*** Done ***";
+?>
+
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink("$file_path/stat_variation8.tmp");
+?>
+--EXPECTF--
+*** Testing stat(): on file by truncating it to given size ***
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/statcache-corruption.phpt b/ext/standard/tests/file/statcache-corruption.phpt
new file mode 100644
index 0000000..7fa3916
--- /dev/null
+++ b/ext/standard/tests/file/statcache-corruption.phpt
@@ -0,0 +1,13 @@
+--TEST--
+statcache corruption
+--FILE--
+<?php
+$a = stat(__FILE__);
+is_link(__FILE__);
+$b = stat(__FILE__);
+print_r(array_diff($a, $b));
+?>
+--EXPECT--
+Array
+(
+)
diff --git a/ext/standard/tests/file/statpage.phpt b/ext/standard/tests/file/statpage.phpt
new file mode 100644
index 0000000..f11be97
--- /dev/null
+++ b/ext/standard/tests/file/statpage.phpt
@@ -0,0 +1,20 @@
+--TEST--
+getlastmod() and others
+--FILE--
+<?php
+
+var_dump(getlastmod());
+var_dump(getmyinode());
+var_dump(getmyuid());
+var_dump(getmypid());
+var_dump(getmygid());
+
+echo "Done\n";
+?>
+--EXPECTF--
+int(%d)
+int(%d)
+int(%d)
+int(%d)
+int(%d)
+Done
diff --git a/ext/standard/tests/file/stream_001.phpt b/ext/standard/tests/file/stream_001.phpt
new file mode 100644
index 0000000..eece30a
--- /dev/null
+++ b/ext/standard/tests/file/stream_001.phpt
@@ -0,0 +1,24 @@
+--TEST--
+stream_wrapper_unregister() & stream_wrapper_restore()
+--FILE--
+<?php
+
+var_dump(stream_wrapper_unregister('file'));
+var_dump(fopen("file://".__FILE__, "r"));
+var_dump(stream_wrapper_restore('file'));
+var_dump(fopen("file://".__FILE__, "r"));
+
+echo "Done\n";
+?>
+--EXPECTF--
+bool(true)
+
+Warning: fopen(): Unable to find the wrapper "file" - did you forget to enable it when you configured PHP? in %s on line %d
+
+Warning: fopen(): file:// wrapper is disabled in the server configuration in %s on line %d
+
+Warning: fopen(file://%s): failed to open stream: no suitable wrapper could be found in %s on line %d
+bool(false)
+bool(true)
+resource(%d) of type (stream)
+Done
diff --git a/ext/standard/tests/file/stream_002.phpt b/ext/standard/tests/file/stream_002.phpt
new file mode 100644
index 0000000..e982f70
--- /dev/null
+++ b/ext/standard/tests/file/stream_002.phpt
@@ -0,0 +1,53 @@
+--TEST--
+stream_socket_client() and invalid arguments
+--FILE--
+<?php
+
+$a = NULL;
+$b = NULL;
+var_dump(stream_socket_client("", $a, $b));
+var_dump($a, $b);
+var_dump(stream_socket_client("[", $a, $b));
+var_dump($a, $b);
+var_dump(stream_socket_client("[ ", $a, $b));
+var_dump($a, $b);
+var_dump(stream_socket_client(".", $a, $b));
+var_dump($a, $b);
+var_dump(stream_socket_client(1, $a, $b));
+var_dump($a, $b);
+var_dump(stream_socket_client(array(), $a, $b));
+var_dump($a, $b);
+
+echo "Done\n";
+?>
+--EXPECTF--
+Warning: stream_socket_client(): unable to connect to (Failed to parse address "") in %s on line %d
+bool(false)
+int(0)
+string(26) "Failed to parse address """
+
+Warning: stream_socket_client(): unable to connect to [ (Failed to parse address "[") in %s on line %d
+bool(false)
+int(0)
+string(27) "Failed to parse address "[""
+
+Warning: stream_socket_client(): unable to connect to [ (Failed to parse%saddress "[ ") in %s on line %d
+bool(false)
+int(0)
+string(%d) "Failed to parse%saddress "[ ""
+
+Warning: stream_socket_client(): unable to connect to . (Failed to parse address ".") in %s on line %d
+bool(false)
+int(0)
+string(27) "Failed to parse address ".""
+
+Warning: stream_socket_client(): unable to connect to 1 (Failed to parse address "1") in %s on line %d
+bool(false)
+int(0)
+string(27) "Failed to parse address "1""
+
+Warning: stream_socket_client() expects parameter 1 to be string, array given in %s on line %d
+bool(false)
+int(0)
+string(27) "Failed to parse address "1""
+Done
diff --git a/ext/standard/tests/file/stream_copy_to_stream.phpt b/ext/standard/tests/file/stream_copy_to_stream.phpt
new file mode 100644
index 0000000..716ae1f
--- /dev/null
+++ b/ext/standard/tests/file/stream_copy_to_stream.phpt
@@ -0,0 +1,154 @@
+--TEST--
+stream_copy_to_stream() tests
+--FILE--
+<?php
+define('WIN', substr(PHP_OS, 0, 3) == 'WIN');
+
+$initial_file = dirname(__FILE__).'/bug38086.txt';
+$new_file = dirname(__FILE__).'/bug38086_1.txt';
+
+$src = fopen($initial_file, 'r');
+stream_filter_append($src, "string.rot13", STREAM_FILTER_READ);
+
+$dest = fopen($new_file, 'w');
+var_dump(stream_copy_to_stream($src, $dest, 0));
+fclose($src); fclose($dest);
+
+var_dump(file_get_contents($new_file));
+unlink($new_file);
+
+/* --- */
+
+$src = fopen($initial_file, 'r');
+stream_filter_append($src, "string.rot13", STREAM_FILTER_READ);
+
+$dest = fopen($new_file, 'w');
+var_dump(stream_copy_to_stream($src, $dest, -1));
+fclose($src); fclose($dest);
+if (WIN) {
+ var_dump(str_replace("\r\n","\n", file_get_contents($new_file)));
+} else {
+ var_dump(file_get_contents($new_file));
+}
+unlink($new_file);
+
+/* --- */
+
+$src = fopen($initial_file, 'r');
+stream_filter_append($src, "string.rot13", STREAM_FILTER_READ);
+
+$dest = fopen($new_file, 'w');
+var_dump(stream_copy_to_stream($src, $dest));
+fclose($src); fclose($dest);
+
+if (WIN) {
+ var_dump(str_replace("\r\n","\n", file_get_contents($new_file)));
+} else {
+ var_dump(file_get_contents($new_file));
+}
+unlink($new_file);
+
+/* --- */
+
+$src = fopen($initial_file, 'r');
+
+$dest = fopen($new_file, 'w');
+var_dump(stream_copy_to_stream($src, $dest));
+fclose($src); fclose($dest);
+
+if (WIN) {
+ var_dump(str_replace("\r\n","\n", file_get_contents($new_file)));
+} else {
+ var_dump(file_get_contents($new_file));
+}
+unlink($new_file);
+
+/* --- */
+
+$src = fopen($initial_file, 'r');
+
+$dest = fopen($new_file, 'w');
+var_dump(stream_copy_to_stream($src, $dest, 1000000));
+fclose($src); fclose($dest);
+
+if (WIN) {
+ var_dump(str_replace("\r\n","\n", file_get_contents($new_file)));
+} else {
+ var_dump(file_get_contents($new_file));
+}
+
+unlink($new_file);
+
+/* --- */
+
+$src = fopen($initial_file, 'r');
+
+$dest = fopen($new_file, 'w');
+var_dump(stream_copy_to_stream($src, $dest, 10));
+fclose($src); fclose($dest);
+
+if (WIN) {
+ var_dump(str_replace("\r\n","\n", file_get_contents($new_file)));
+} else {
+ var_dump(file_get_contents($new_file));
+}
+unlink($new_file);
+
+/* --- */
+
+$src = fopen($initial_file, 'r');
+
+$dest = fopen($new_file, 'w');
+var_dump(stream_copy_to_stream($src, $dest, -1));
+fclose($src); fclose($dest);
+
+if (WIN) {
+ var_dump(str_replace("\r\n","\n", file_get_contents($new_file)));
+} else {
+ var_dump(file_get_contents($new_file));
+}
+unlink($new_file);
+
+echo "Done\n";
+?>
+--EXPECTF--
+int(0)
+string(0) ""
+int(%d)
+string(134) "Nabgure qnl
+Jura gur cnvaf bs yvsr jba'g one zl jnl
+V'yy oernx gurfr punvaf
+Gung ubyq zr qbja
+V'yy grne lbh qbja vagb zl cevingr uryy
+"
+int(%d)
+string(134) "Nabgure qnl
+Jura gur cnvaf bs yvsr jba'g one zl jnl
+V'yy oernx gurfr punvaf
+Gung ubyq zr qbja
+V'yy grne lbh qbja vagb zl cevingr uryy
+"
+int(%d)
+string(134) "Another day
+When the pains of life won't bar my way
+I'll break these chains
+That hold me down
+I'll tear you down into my private hell
+"
+int(%d)
+string(134) "Another day
+When the pains of life won't bar my way
+I'll break these chains
+That hold me down
+I'll tear you down into my private hell
+"
+int(%d)
+string(10) "Another da"
+int(%d)
+string(134) "Another day
+When the pains of life won't bar my way
+I'll break these chains
+That hold me down
+I'll tear you down into my private hell
+"
+Done
diff --git a/ext/standard/tests/file/stream_enclosed.phpt b/ext/standard/tests/file/stream_enclosed.phpt
new file mode 100644
index 0000000..9520ecc
--- /dev/null
+++ b/ext/standard/tests/file/stream_enclosed.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Unexposed/leaked stream encloses another stream
+--SKIPIF--
+<?php
+if (!function_exists('leak_variable')) die("skip only debug builds");
+--FILE--
+<?php
+$s = fopen('php://temp/maxmemory=1024','wb+');
+
+$t = fopen('php://temp/maxmemory=1024','wb+');
+
+/* force conversion of inner stream to STDIO. */
+$i = 0;
+while ($i++ < 5000) {
+ fwrite($t, str_repeat('a',1024));
+}
+
+leak_variable($s, true);
+leak_variable($t, true);
+--EXPECT--
diff --git a/ext/standard/tests/file/stream_get_line.phpt b/ext/standard/tests/file/stream_get_line.phpt
new file mode 100644
index 0000000..89798ef
--- /dev/null
+++ b/ext/standard/tests/file/stream_get_line.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Crash inside stream_get_line(), when length=0
+--FILE--
+<?php
+$path = dirname(__FILE__) . '/test.html';
+
+file_put_contents($path, b"foo<br>bar<br>foo");
+$fp = fopen($path, "r");
+while ($fp && !feof($fp)) {
+ echo stream_get_line($fp, 0, "<br>")."\n";
+}
+fclose($fp);
+@unlink($path);
+?>
+--EXPECT--
+foo
+bar
+foo
diff --git a/ext/standard/tests/file/stream_rfc2397_001.phpt b/ext/standard/tests/file/stream_rfc2397_001.phpt
new file mode 100644
index 0000000..040dc26
--- /dev/null
+++ b/ext/standard/tests/file/stream_rfc2397_001.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Stream: RFC2397 getting the data
+--INI--
+allow_url_fopen=1
+--FILE--
+<?php
+
+$data = 'data://,hello world';
+
+var_dump(file_get_contents($data));
+
+$file = fopen($data, 'r');
+unset($data);
+
+var_dump(stream_get_contents($file));
+
+?>
+===DONE===
+--EXPECT--
+string(11) "hello world"
+string(11) "hello world"
+===DONE=== \ No newline at end of file
diff --git a/ext/standard/tests/file/stream_rfc2397_002.phpt b/ext/standard/tests/file/stream_rfc2397_002.phpt
new file mode 100644
index 0000000..980863b
--- /dev/null
+++ b/ext/standard/tests/file/stream_rfc2397_002.phpt
@@ -0,0 +1,182 @@
+--TEST--
+Stream: RFC2397 getting meta data
+--INI--
+allow_url_fopen=1
+--FILE--
+<?php
+
+$streams = array(
+ 'data://,',
+ 'data://',
+ 'data://;base64,',
+ 'data://;base64',
+ 'data://foo,',
+ 'data://foo=bar,',
+ 'data://text/plain,',
+ 'data://text/plain;foo,',
+ 'data://text/plain;foo=bar,',
+ 'data://text/plain;foo=bar;bla,',
+ 'data://text/plain;foo=bar;base64,',
+ 'data://text/plain;foo=bar;bar=baz',
+ 'data://text/plain;foo=bar;bar=baz,',
+ );
+
+foreach($streams as $stream)
+{
+ $stream = fopen($stream, 'r');
+ $meta = @stream_get_meta_data($stream);
+ var_dump($meta);
+ var_dump(isset($meta['foo']) ? $meta['foo'] : null);
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+array(7) {
+ ["wrapper_type"]=>
+ string(7) "RFC2397"
+ ["stream_type"]=>
+ string(7) "RFC2397"
+ ["mode"]=>
+ string(1) "r"
+ ["unread_bytes"]=>
+ int(0)
+ ["seekable"]=>
+ bool(true)
+ ["uri"]=>
+ string(8) "data://,"
+ ["base64"]=>
+ bool(false)
+}
+NULL
+
+Warning: fopen(data://): failed to open stream: rfc2397: no comma in URL in %sstream_rfc2397_002.php on line %d
+NULL
+NULL
+array(7) {
+ ["wrapper_type"]=>
+ string(7) "RFC2397"
+ ["stream_type"]=>
+ string(7) "RFC2397"
+ ["mode"]=>
+ string(1) "r"
+ ["unread_bytes"]=>
+ int(0)
+ ["seekable"]=>
+ bool(true)
+ ["uri"]=>
+ string(15) "data://;base64,"
+ ["base64"]=>
+ bool(true)
+}
+NULL
+
+Warning: fopen(data://;base64): failed to open stream: rfc2397: no comma in URL in %sstream_rfc2397_002.php on line %d
+NULL
+NULL
+
+Warning: fopen(data://foo,): failed to open stream: rfc2397: illegal media type in %sstream_rfc2397_002.php on line %d
+NULL
+NULL
+
+Warning: fopen(data://foo=bar,): failed to open stream: rfc2397: illegal media type in %sstream_rfc2397_002.php on line %d
+NULL
+NULL
+array(8) {
+ ["wrapper_type"]=>
+ string(7) "RFC2397"
+ ["stream_type"]=>
+ string(7) "RFC2397"
+ ["mode"]=>
+ string(1) "r"
+ ["unread_bytes"]=>
+ int(0)
+ ["seekable"]=>
+ bool(true)
+ ["uri"]=>
+ string(18) "data://text/plain,"
+ ["mediatype"]=>
+ string(10) "text/plain"
+ ["base64"]=>
+ bool(false)
+}
+NULL
+
+Warning: fopen(data://text/plain;foo,): failed to open stream: rfc2397: illegal parameter in %sstream_rfc2397_002.php on line %d
+NULL
+NULL
+array(9) {
+ ["wrapper_type"]=>
+ string(7) "RFC2397"
+ ["stream_type"]=>
+ string(7) "RFC2397"
+ ["mode"]=>
+ string(1) "r"
+ ["unread_bytes"]=>
+ int(0)
+ ["seekable"]=>
+ bool(true)
+ ["uri"]=>
+ string(26) "data://text/plain;foo=bar,"
+ ["mediatype"]=>
+ string(10) "text/plain"
+ ["foo"]=>
+ string(3) "bar"
+ ["base64"]=>
+ bool(false)
+}
+string(3) "bar"
+
+Warning: fopen(data://text/plain;foo=bar;bla,): failed to open stream: rfc2397: illegal parameter in %sstream_rfc2397_002.php on line %d
+NULL
+NULL
+array(9) {
+ ["wrapper_type"]=>
+ string(7) "RFC2397"
+ ["stream_type"]=>
+ string(7) "RFC2397"
+ ["mode"]=>
+ string(1) "r"
+ ["unread_bytes"]=>
+ int(0)
+ ["seekable"]=>
+ bool(true)
+ ["uri"]=>
+ string(33) "data://text/plain;foo=bar;base64,"
+ ["mediatype"]=>
+ string(10) "text/plain"
+ ["foo"]=>
+ string(3) "bar"
+ ["base64"]=>
+ bool(true)
+}
+string(3) "bar"
+
+Warning: fopen(data://text/plain;foo=bar;bar=baz): failed to open stream: rfc2397: no comma in URL in %sstream_rfc2397_002.php on line %d
+NULL
+NULL
+array(10) {
+ ["wrapper_type"]=>
+ string(7) "RFC2397"
+ ["stream_type"]=>
+ string(7) "RFC2397"
+ ["mode"]=>
+ string(1) "r"
+ ["unread_bytes"]=>
+ int(0)
+ ["seekable"]=>
+ bool(true)
+ ["uri"]=>
+ string(34) "data://text/plain;foo=bar;bar=baz,"
+ ["mediatype"]=>
+ string(10) "text/plain"
+ ["foo"]=>
+ string(3) "bar"
+ ["bar"]=>
+ string(3) "baz"
+ ["base64"]=>
+ bool(false)
+}
+string(3) "bar"
+===DONE===
diff --git a/ext/standard/tests/file/stream_rfc2397_003.gif b/ext/standard/tests/file/stream_rfc2397_003.gif
new file mode 100755
index 0000000..3dc4fc6
--- /dev/null
+++ b/ext/standard/tests/file/stream_rfc2397_003.gif
Binary files differ
diff --git a/ext/standard/tests/file/stream_rfc2397_003.phpt b/ext/standard/tests/file/stream_rfc2397_003.phpt
new file mode 100644
index 0000000..7cc31fe
--- /dev/null
+++ b/ext/standard/tests/file/stream_rfc2397_003.phpt
@@ -0,0 +1,38 @@
+--TEST--
+Stream: RFC2397 decoding data
+--INI--
+allow_url_fopen=1
+--FILE--
+<?php
+
+$streams = array(
+ 'data://,A%20brief%20note',
+ 'data://application/vnd-xxx-query,select_vcount,fcol_from_fieldtable/local',
+ 'data://;base64,Zm9vYmFyIGZvb2Jhcg==',
+ 'stream_rfc2397_003.gif' => 'data://image/gif;base64,R0lGODdhMAAwAPAAAAAAAP///ywAAAAAMAAw
+AAAC8IyPqcvt3wCcDkiLc7C0qwyGHhSWpjQu5yqmCYsapyuvUUlvONmOZtfzgFz
+ByTB10QgxOR0TqBQejhRNzOfkVJ+5YiUqrXF5Y5lKh/DeuNcP5yLWGsEbtLiOSp
+a/TPg7JpJHxyendzWTBfX0cxOnKPjgBzi4diinWGdkF8kjdfnycQZXZeYGejmJl
+ZeGl9i2icVqaNVailT6F5iJ90m6mvuTS4OK05M0vDk0Q4XUtwvKOzrcd3iq9uis
+F81M1OIcR7lEewwcLp7tuNNkM3uNna3F2JQFo97Vriy/Xl4/f1cf5VWzXyym7PH
+hhx4dbgYKAAA7',
+ );
+
+foreach($streams as $original => $stream)
+{
+ if (is_string($original)) {
+ var_dump(file_get_contents(dirname(__FILE__) . '/' . $original) == file_get_contents($stream));
+ } else {
+ var_dump(file_get_contents($stream));
+ }
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+string(12) "A brief note"
+string(40) "select_vcount,fcol_from_fieldtable/local"
+string(13) "foobar foobar"
+bool(true)
+===DONE===
diff --git a/ext/standard/tests/file/stream_rfc2397_004.phpt b/ext/standard/tests/file/stream_rfc2397_004.phpt
new file mode 100644
index 0000000..1a8da93
--- /dev/null
+++ b/ext/standard/tests/file/stream_rfc2397_004.phpt
@@ -0,0 +1,32 @@
+--TEST--
+Stream: RFC2397 Mozilla tests
+--INI--
+allow_url_fopen=1
+--FILE--
+<?php
+
+$streams = array(
+ 'data://,;test',
+ 'data://text/plain,test',
+ 'data://text/plain;charset=US-ASCII,test',
+ 'data://;charset=UTF-8,Hello',
+ 'data://text/plain;charset=UTF-8,Hello',
+ 'data://,a,b',
+ );
+
+foreach($streams as $stream)
+{
+ var_dump(@file_get_contents($stream));
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+string(5) ";test"
+string(4) "test"
+string(4) "test"
+bool(false)
+string(5) "Hello"
+string(3) "a,b"
+===DONE=== \ No newline at end of file
diff --git a/ext/standard/tests/file/stream_rfc2397_005.phpt b/ext/standard/tests/file/stream_rfc2397_005.phpt
new file mode 100644
index 0000000..8fa1c16
--- /dev/null
+++ b/ext/standard/tests/file/stream_rfc2397_005.phpt
@@ -0,0 +1,38 @@
+--TEST--
+Stream: RFC2397 without //
+--INI--
+allow_url_fopen=1
+--FILE--
+<?php
+
+$streams = array(
+ 'data:,A%20brief%20note',
+ 'data:application/vnd-xxx-query,select_vcount,fcol_from_fieldtable/local',
+ 'data:;base64,Zm9vYmFyIGZvb2Jhcg==',
+ 'data:,;test',
+ 'data:text/plain,test',
+ 'data:text/plain;charset=US-ASCII,test',
+ 'data:;charset=UTF-8,Hello',
+ 'data:text/plain;charset=UTF-8,Hello',
+ 'data:,a,b',
+ );
+
+foreach($streams as $stream)
+{
+ var_dump(@file_get_contents($stream));
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+string(12) "A brief note"
+string(40) "select_vcount,fcol_from_fieldtable/local"
+string(13) "foobar foobar"
+string(5) ";test"
+string(4) "test"
+string(4) "test"
+bool(false)
+string(5) "Hello"
+string(3) "a,b"
+===DONE=== \ No newline at end of file
diff --git a/ext/standard/tests/file/stream_rfc2397_006.phpt b/ext/standard/tests/file/stream_rfc2397_006.phpt
new file mode 100644
index 0000000..e6694a2
--- /dev/null
+++ b/ext/standard/tests/file/stream_rfc2397_006.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Stream: RFC2397 with corrupt? payload
+--INI--
+allow_url_fopen=1
+--FILE--
+<?php
+
+$streams = array(
+ "data:;base64,\0Zm9vYmFyIGZvb2Jhcg==",
+ "data:;base64,Zm9vYmFy\0IGZvb2Jhcg==",
+ 'data:;base64,#Zm9vYmFyIGZvb2Jhcg==',
+ 'data:;base64,#Zm9vYmFyIGZvb2Jhc=',
+ );
+
+foreach($streams as $stream)
+{
+ var_dump(file_get_contents($stream));
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+Warning: file_get_contents() expects parameter 1 to be a valid path, string given in %s line %d
+NULL
+
+Warning: file_get_contents() expects parameter 1 to be a valid path, string given in %s line %d
+NULL
+string(13) "foobar foobar"
+
+Warning: file_get_contents(data:;base64,#Zm9vYmFyIGZvb2Jhc=): failed to open stream: rfc2397: unable to decode in %sstream_rfc2397_006.php on line %d
+bool(false)
+===DONE===
diff --git a/ext/standard/tests/file/stream_rfc2397_007.phpt b/ext/standard/tests/file/stream_rfc2397_007.phpt
new file mode 100644
index 0000000..8a6f315
--- /dev/null
+++ b/ext/standard/tests/file/stream_rfc2397_007.phpt
@@ -0,0 +1,143 @@
+--TEST--
+Stream: RFC2397 and seeking
+--INI--
+allow_url_fopen=1
+--FILE--
+<?php
+
+$streams = array(
+ "data:,012345",
+ );
+
+foreach($streams as $stream)
+{
+ echo "===$stream===\n";
+
+ $fp = fopen($stream, 'rb');
+
+ var_dump(ftell($fp));
+ var_dump(feof($fp));
+ echo "===S:4,S===\n";
+ var_dump(fseek($fp, 4));
+ var_dump(ftell($fp));
+ var_dump(feof($fp));
+ echo "===GETC===\n";
+ var_dump(fgetc($fp));
+ var_dump(ftell($fp));
+ var_dump(feof($fp));
+ echo "===GETC===\n";
+ var_dump(fgetc($fp));
+ var_dump(ftell($fp));
+ var_dump(feof($fp));
+ echo "===REWIND===\n";
+ var_dump(rewind($fp));
+ var_dump(ftell($fp));
+ var_dump(feof($fp));
+ echo "===GETC===\n";
+ var_dump(fgetc($fp));
+ var_dump(ftell($fp));
+ var_dump(feof($fp));
+ echo "===S:3,S===\n";
+ var_dump(fseek($fp, 3, SEEK_SET));
+ var_dump(ftell($fp));
+ var_dump(feof($fp));
+ echo "===S:1,C===\n";
+ var_dump(fseek($fp, 1, SEEK_CUR));
+ var_dump(ftell($fp));
+ var_dump(feof($fp));
+ echo "===S:-2,C===\n";
+ var_dump(fseek($fp, -2, SEEK_CUR));
+ var_dump(ftell($fp));
+ var_dump(feof($fp));
+ echo "===S:-10,C===\n";
+ var_dump(fseek($fp, -10, SEEK_CUR));
+ var_dump(ftell($fp));
+ var_dump(feof($fp));
+ echo "===S:3,S===\n";
+ var_dump(fseek($fp, 3, SEEK_SET));
+ var_dump(ftell($fp));
+ var_dump(feof($fp));
+ echo "===S:10,C===\n";
+ var_dump(fseek($fp, 10, SEEK_CUR));
+ var_dump(ftell($fp));
+ var_dump(feof($fp));
+ echo "===S:-1,E===\n";
+ var_dump(fseek($fp, -1, SEEK_END));
+ var_dump(ftell($fp));
+ var_dump(feof($fp));
+ echo "===S:0,E===\n";
+ var_dump(fseek($fp, 0, SEEK_END));
+ var_dump(ftell($fp));
+ var_dump(feof($fp));
+ echo "===S:1,E===\n";
+ var_dump(fseek($fp, 1, SEEK_END));
+ var_dump(ftell($fp));
+ var_dump(feof($fp));
+
+ fclose($fp);
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+===data:,012345===
+int(0)
+bool(false)
+===S:4,S===
+int(0)
+int(4)
+bool(false)
+===GETC===
+string(1) "4"
+int(5)
+bool(false)
+===GETC===
+string(1) "5"
+int(6)
+bool(true)
+===REWIND===
+bool(true)
+int(0)
+bool(false)
+===GETC===
+string(1) "0"
+int(1)
+bool(false)
+===S:3,S===
+int(0)
+int(3)
+bool(false)
+===S:1,C===
+int(0)
+int(4)
+bool(false)
+===S:-2,C===
+int(0)
+int(2)
+bool(false)
+===S:-10,C===
+int(-1)
+bool(false)
+bool(false)
+===S:3,S===
+int(0)
+int(3)
+bool(false)
+===S:10,C===
+int(-1)
+bool(false)
+bool(false)
+===S:-1,E===
+int(0)
+int(5)
+bool(false)
+===S:0,E===
+int(0)
+int(6)
+bool(false)
+===S:1,E===
+int(-1)
+bool(false)
+bool(false)
+===DONE===
diff --git a/ext/standard/tests/file/stream_supports_lock.phpt b/ext/standard/tests/file/stream_supports_lock.phpt
new file mode 100644
index 0000000..bbf3993
--- /dev/null
+++ b/ext/standard/tests/file/stream_supports_lock.phpt
@@ -0,0 +1,46 @@
+--TEST--
+stream_supports_lock
+--INI--
+allow_url_fopen=1
+--FILE--
+<?php
+$fp = fopen(__FILE__, "r");
+var_dump($fp);
+var_dump(stream_supports_lock($fp));
+fclose($fp);
+
+$fp = fopen("file://" . __FILE__, "r");
+var_dump($fp);
+var_dump(stream_supports_lock($fp));
+fclose($fp);
+
+$fp = fopen("php://memory", "r");
+var_dump($fp);
+var_dump(stream_supports_lock($fp));
+fclose($fp);
+
+$fp = fopen('data://text/plain,foobar', 'r');
+var_dump($fp);
+var_dump(stream_supports_lock($fp));
+fclose($fp);
+
+$sock = stream_context_create();
+var_dump($sock);
+var_dump(stream_supports_lock($sock));
+
+echo "Done\n";
+?>
+--EXPECTF--
+resource(%d) of type (stream)
+bool(true)
+resource(%d) of type (stream)
+bool(true)
+resource(%d) of type (stream)
+bool(false)
+resource(%d) of type (stream)
+bool(false)
+resource(%d) of type (stream-context)
+
+Warning: stream_supports_lock(): supplied resource is not a valid stream resource in %s on line %d
+bool(false)
+Done
diff --git a/ext/standard/tests/file/symlink.phpt b/ext/standard/tests/file/symlink.phpt
new file mode 100644
index 0000000..489c266
--- /dev/null
+++ b/ext/standard/tests/file/symlink.phpt
@@ -0,0 +1,78 @@
+--TEST--
+symlink() & friends
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip no symlinks on Windows');
+}
+?>
+--FILE--
+<?php
+
+$filename = dirname(__FILE__)."/symlink.dat";
+$link = dirname(__FILE__)."/symlink.link";
+
+var_dump(symlink($filename, $link));
+var_dump(readlink($link));
+var_dump(linkinfo($link));
+@unlink($link);
+
+var_dump(readlink($link));
+var_dump(linkinfo($link));
+
+touch($filename);
+var_dump(symlink($filename, dirname(__FILE__)));
+@unlink($link);
+
+var_dump(symlink($filename, $link));
+@unlink($link);
+
+touch($link);
+var_dump(symlink($filename, $link));
+@unlink($link);
+
+var_dump(link($filename, $link));
+@unlink($filename);
+
+var_dump(link($filename, $link));
+@unlink($link);
+
+var_dump(symlink(".", "."));
+var_dump(link(".", "."));
+var_dump(readlink("."));
+var_dump(linkinfo("."));
+
+echo "Done\n";
+?>
+--EXPECTF--
+bool(true)
+string(%d) "%ssymlink.dat"
+int(%d)
+
+Warning: readlink(): No such file or directory in %s on line %d
+bool(false)
+
+Warning: linkinfo(): No such file or directory in %s on line %d
+int(-1)
+
+Warning: symlink(): File exists in %s on line %d
+bool(false)
+bool(true)
+
+Warning: symlink(): File exists in %s on line %d
+bool(false)
+bool(true)
+
+Warning: link(): No such file or directory in %s on line %d
+bool(false)
+
+Warning: symlink(): %s in %s on line %d
+bool(false)
+
+Warning: link(): %s in %s on line %d
+bool(false)
+
+Warning: readlink(): Invalid argument in %s on line %d
+bool(false)
+int(%d)
+Done
diff --git a/ext/standard/tests/file/symlink_link_linkinfo_is_link_basic1.phpt b/ext/standard/tests/file/symlink_link_linkinfo_is_link_basic1.phpt
new file mode 100644
index 0000000..416e6ae
--- /dev/null
+++ b/ext/standard/tests/file/symlink_link_linkinfo_is_link_basic1.phpt
@@ -0,0 +1,114 @@
+--TEST--
+Test symlink(), linkinfo(), link() and is_link() functions: basic functionality - link to files
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip no symlinks on Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: bool symlink ( string $target, string $link );
+ Description: creates a symbolic link to the existing target with the specified name link
+
+ Prototype: bool is_link ( string $filename );
+ Description: Tells whether the given file is a symbolic link.
+
+ Prototype: bool link ( string $target, string $link );
+ Description: Create a hard link
+
+ Prototype: int linkinfo ( string $path );
+ Description: Gets information about a link
+*/
+
+$file_path = dirname(__FILE__);
+
+// temp dir created in present working directory
+$dirname = "symlink_link_linkinfo_is_link_basic1";
+mkdir("$file_path/$dirname"); // creating temp dir
+
+/* Creating soft/hard link to $filename created in temp directory $dirname
+ and checking linkinfo() and is_link() on the link created */
+
+echo "*** Testing symlink(), linkinfo(), link() and is_link() : basic functionality ***\n";
+
+// creating file in $dirname, links are created to the this file
+$filename = "$file_path/$dirname/symlink_link_linkinfo_is_link_basic1.tmp";
+$filename = fopen($filename, "w");
+fclose($filename);
+
+// name of the soft link created to $filename
+$sym_linkname = "$file_path/$dirname/symlink_link_linkinfo_is_link_softlink_basic1.tmp";
+
+// name of the hard link created to $filename
+$linkname = "$file_path/$dirname/symlink_link_linkinfo_is_link_hardlink_basic1.tmp";
+
+// filename stored in array with single and double slash notation in its path
+$files = array (
+ "$file_path/$dirname/symlink_link_linkinfo_is_link_basic1.tmp",
+ "$file_path//$dirname//symlink_link_linkinfo_is_link_basic1.tmp"
+);
+
+$counter = 1;
+/* create soft/hard link to the file
+ and check linkinfo() and is_link() on the link created */
+foreach($files as $file) {
+ echo "\n-- Iteration $counter --\n";
+ echo "-- Testing on soft links --\n";
+ // create soft link
+ var_dump( symlink($file, $sym_linkname) );
+ // checking information of link with linkinfo()
+ var_dump( linkinfo($sym_linkname) );
+ // checking if given file is soft link
+ var_dump( is_link($sym_linkname) );
+ // clear the cache
+ clearstatcache();
+
+ // testing on hard link
+ echo "-- Testing on hard links --\n";
+ // creating hard link
+ var_dump( link($file, $linkname) );
+ // checking information of link with linkinfo()
+ var_dump( linkinfo($linkname) );
+ // checking if given link is soft link; expected: false
+ var_dump( is_link($linkname) );
+ // clear the cache
+ clearstatcache();
+
+ // deleting the links
+ unlink($sym_linkname);
+ unlink($linkname);
+ $counter++;
+}
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+$dirname = dirname(__FILE__)."/symlink_link_linkinfo_is_link_basic1";
+unlink("$dirname/symlink_link_linkinfo_is_link_basic1.tmp");
+rmdir($dirname);
+?>
+--EXPECTF--
+*** Testing symlink(), linkinfo(), link() and is_link() : basic functionality ***
+
+-- Iteration 1 --
+-- Testing on soft links --
+bool(true)
+int(%d)
+bool(true)
+-- Testing on hard links --
+bool(true)
+int(%d)
+bool(false)
+
+-- Iteration 2 --
+-- Testing on soft links --
+bool(true)
+int(%d)
+bool(true)
+-- Testing on hard links --
+bool(true)
+int(%d)
+bool(false)
+Done
diff --git a/ext/standard/tests/file/symlink_link_linkinfo_is_link_basic2.phpt b/ext/standard/tests/file/symlink_link_linkinfo_is_link_basic2.phpt
new file mode 100644
index 0000000..4df4872
--- /dev/null
+++ b/ext/standard/tests/file/symlink_link_linkinfo_is_link_basic2.phpt
@@ -0,0 +1,90 @@
+--TEST--
+Test symlink(), linkinfo(), link() and is_link() functions: basic functionality - link to dirs
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip no symlinks on Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: bool symlink ( string $target, string $link );
+ Description: creates a symbolic link to the existing target with the specified name link
+
+ Prototype: bool is_link ( string $filename );
+ Description: Tells whether the given file is a symbolic link.
+
+ Prototype: bool link ( string $target, string $link );
+ Description: Create a hard link
+
+ Prototype: int linkinfo ( string $path );
+ Description: Gets information about a link
+*/
+
+$file_path = dirname(__FILE__);
+
+echo "*** Testing symlink(), linkinfo(), link() and is_link() : basic functionality ***\n";
+
+/* Creating soft/hard link to the temporary dir $dirname and checking
+ linkinfo() and is_link() on the link created to $dirname */
+
+$dirname = "symlink_link_linkinfo_is_link_basic2";
+mkdir($file_path."/".$dirname);
+
+echo "\n*** Testing symlink(), linkinfo(), link() and is_link() on directory ***\n";
+
+// name of the soft link created to $dirname
+$sym_linkname = "$file_path/$dirname/symlink_link_linkinfo_is_link_softlink_basic2.tmp";
+
+// name of the hard link created to $dirname
+$linkname = "$file_path/$dirname/symlink_link_linkinfo_is_link_hardlink_basic2.tmp";
+
+// testing on soft link
+echo "\n-- Testing on soft links --\n";
+// creating soft link to $dirname
+var_dump( symlink("$file_path/$dirname", $sym_linkname) ); // this works, expected true
+// gets information about soft link created to directory; expected: true
+var_dump( linkinfo($sym_linkname) );
+// checks if link created is soft link; expected: true
+var_dump( is_link($sym_linkname) );
+// clear the cache
+clearstatcache();
+
+// testing on hard link
+echo "\n-- Testing on hard links --\n";
+// creating hard link to $dirname; expected: false
+var_dump( link("$file_path/$dirname", $linkname) ); // this doesn't work, expected false
+var_dump( linkinfo($linkname) ); // link doesn't exists as not created, expected false
+var_dump( is_link($linkname) ); // link doesn't exists as not created, expected false
+// clear the cache
+clearstatcache();
+
+// deleting the links
+unlink($sym_linkname);
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+$dirname = dirname(__FILE__)."/symlink_link_linkinfo_is_link_basic2";
+rmdir($dirname);
+?>
+--EXPECTF--
+*** Testing symlink(), linkinfo(), link() and is_link() : basic functionality ***
+
+*** Testing symlink(), linkinfo(), link() and is_link() on directory ***
+
+-- Testing on soft links --
+bool(true)
+int(%d)
+bool(true)
+
+-- Testing on hard links --
+
+Warning: link(): %s in %s on line %d
+bool(false)
+
+Warning: linkinfo(): No such file or directory in %s on line %d
+int(-1)
+bool(false)
+Done
diff --git a/ext/standard/tests/file/symlink_link_linkinfo_is_link_error1.phpt b/ext/standard/tests/file/symlink_link_linkinfo_is_link_error1.phpt
new file mode 100644
index 0000000..8aae9b3
--- /dev/null
+++ b/ext/standard/tests/file/symlink_link_linkinfo_is_link_error1.phpt
@@ -0,0 +1,115 @@
+--TEST--
+Test symlink(), linkinfo(), link() and is_link() functions : error conditions - symlink & linkinfo
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip no symlinks on Windows');
+}
+if (substr(PHP_OS, 0, 3) == 'SUN') {
+ die('skip Not valid for Sun Solaris');
+}
+if (PHP_INT_SIZE != 4) {
+ die("skip this test is for 32bit platform only");
+}
+?>
+--FILE--
+<?php
+/* Prototype: bool symlink ( string $target, string $link );
+ Description: creates a symbolic link to the existing target with the specified name link
+
+ Prototype: bool is_link ( string $filename );
+ Description: Tells whether the given file is a symbolic link.
+
+ Prototype: bool link ( string $target, string $link );
+ Description: Create a hard link
+
+ Prototype: int linkinfo ( string $path );
+ Description: Gets information about a link
+*/
+
+// create temp $filename and create link $linkname to it
+$filename = dirname(__FILE__)."/symlink_link_linkinfo_is_link_error1.tmp";
+$fp = fopen($filename, "w"); // create temp file
+fclose($fp);
+
+// linkname used to create soft/hard link
+$linkname = dirname(__FILE__)."/symlink_link_linkinfo_is_link_link_error1.tmp";
+
+echo "*** Testing symlink() for error conditions ***\n";
+//zero arguments
+var_dump( symlink() );
+
+//more than expected
+var_dump( symlink($filename, $linkname, true) );
+
+//invalid arguments
+var_dump( symlink(NULL, $linkname) ); // NULL as filename
+var_dump( symlink('', $linkname) ); // empty string as filename
+var_dump( symlink(false, $linkname) ); // boolean false as filename
+var_dump( symlink($filename, NULL) ); // NULL as linkname
+var_dump( symlink($filename, '') ); // '' as linkname
+var_dump( symlink($filename, false) ); // false as linkname
+
+echo "\n*** Testing linkinfo() for error conditions ***\n";
+//zero arguments
+var_dump( linkinfo() );
+
+//more than expected
+var_dump( linkinfo($linkname, true) );
+
+//invalid arguments
+var_dump( linkinfo(NULL) ); // NULL as linkname
+var_dump( linkinfo('') ); // empty string as linkname
+var_dump( linkinfo(false) ); // boolean false as linkname
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/symlink_link_linkinfo_is_link_error1.tmp");
+@unlink(dirname(__FILE__)."/symlink_link_linkinfo_is_link_link_error1.tmp");
+?>
+--EXPECTF--
+*** Testing symlink() for error conditions ***
+
+Warning: symlink() expects exactly 2 parameters, 0 given in %s on line %d
+NULL
+
+Warning: symlink() expects exactly 2 parameters, 3 given in %s on line %d
+NULL
+
+Warning: symlink(): %s in %s on line %d
+bool(false)
+
+Warning: symlink(): %s in %s on line %d
+bool(false)
+
+Warning: symlink(): %s in %s on line %d
+bool(false)
+
+Warning: symlink(): %s in %s on line %d
+bool(false)
+
+Warning: symlink(): %s in %s on line %d
+bool(false)
+
+Warning: symlink(): %s in %s on line %d
+bool(false)
+
+*** Testing linkinfo() for error conditions ***
+
+Warning: linkinfo() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: linkinfo() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+
+Warning: linkinfo(): %s in %s on line %d
+int(-1)
+
+Warning: linkinfo(): %s in %s on line %d
+int(-1)
+
+Warning: linkinfo(): %s in %s on line %d
+int(-1)
+Done
diff --git a/ext/standard/tests/file/symlink_link_linkinfo_is_link_error2.phpt b/ext/standard/tests/file/symlink_link_linkinfo_is_link_error2.phpt
new file mode 100644
index 0000000..98ce621
--- /dev/null
+++ b/ext/standard/tests/file/symlink_link_linkinfo_is_link_error2.phpt
@@ -0,0 +1,114 @@
+--TEST--
+Test symlink(), linkinfo(), link() and is_link() functions : error conditions - link & is_link
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip no symlinks on Windows');
+}
+if (PHP_INT_SIZE != 4) {
+ die("skip this test is for 32bit platform only");
+}
+?>
+--FILE--
+<?php
+/* Prototype: bool symlink ( string $target, string $link );
+ Description: creates a symbolic link to the existing target with the specified name link
+
+ Prototype: bool is_link ( string $filename );
+ Description: Tells whether the given file is a symbolic link.
+
+ Prototype: bool link ( string $target, string $link );
+ Description: Create a hard link
+
+ Prototype: int linkinfo ( string $path );
+ Description: Gets information about a link
+*/
+
+// create temp $filename and create link $linkname to it
+$filename = dirname(__FILE__)."/symlink_link_linkinfo_is_link_error2.tmp";
+$fp = fopen($filename, "w"); // create temp file
+fclose($fp);
+
+// linkname used to create soft/hard link
+$linkname = dirname(__FILE__)."/symlink_link_linkinfo_is_link_link_error2.tmp";
+
+echo "*** Testing link() for error conditions ***\n";
+//zero arguments
+var_dump( link() );
+
+//more than expected
+var_dump( link($filename, $linkname, false) );
+
+//invalid arguments
+var_dump( link(NULL, $linkname) ); // NULL as filename
+var_dump( link('', $linkname) ); // empty string as filename
+var_dump( link(' ', $linkname) ); // space as filename
+var_dump( link(false, $linkname) ); // boolean false as filename
+var_dump( link($filename, NULL) ); // NULL as linkname
+var_dump( link($filename, '') ); // '' as linkname
+var_dump( link($filename, false) ); // false as linkname
+
+echo "\n*** Testing is_link() for error conditions ***\n";
+//zero arguments
+var_dump( is_link() );
+
+//more than expected
+var_dump( is_link($linkname, "/") );
+
+//invalid arguments
+var_dump( is_link(NULL) ); // NULL as linkname
+var_dump( is_link('') ); // empty string as linkname
+var_dump( is_link(' ') ); // space as linkname
+var_dump( is_link(false) ); // boolean false as linkname
+var_dump( is_link($filename) ); // file given to is_link
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/symlink_link_linkinfo_is_link_error2.tmp");
+?>
+--EXPECTF--
+*** Testing link() for error conditions ***
+
+Warning: link() expects exactly 2 parameters, 0 given in %s on line %d
+NULL
+
+Warning: link() expects exactly 2 parameters, 3 given in %s on line %d
+NULL
+
+Warning: link(): No such file or directory in %s on line %d
+bool(false)
+
+Warning: link(): No such file or directory in %s on line %d
+bool(false)
+
+Warning: link(): No such file or directory in %s on line %d
+bool(false)
+
+Warning: link(): No such file or directory in %s on line %d
+bool(false)
+
+Warning: link(): No such file or directory in %s on line %d
+bool(false)
+
+Warning: link(): No such file or directory in %s on line %d
+bool(false)
+
+Warning: link(): No such file or directory in %s on line %d
+bool(false)
+
+*** Testing is_link() for error conditions ***
+
+Warning: is_link() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: is_link() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+Done
+
diff --git a/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation1.phpt b/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation1.phpt
new file mode 100644
index 0000000..e3185c4
--- /dev/null
+++ b/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation1.phpt
@@ -0,0 +1,136 @@
+--TEST--
+Test symlink(), linkinfo(), link() and is_link() functions : usage variations - link name stored in an array/object
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip no symlinks on Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: bool symlink ( string $target, string $link );
+ Description: creates a symbolic link to the existing target with the specified name link
+
+ Prototype: bool is_link ( string $filename );
+ Description: Tells whether the given file is a symbolic link.
+
+ Prototype: bool link ( string $target, string $link );
+ Description: Create a hard link
+
+ Prototype: int linkinfo ( string $path );
+ Description: Gets information about a link
+*/
+
+/* Variation 1 : Creating links across directories where linkname is stored as an object and array member */
+
+// creating temp directory which will contain temp file and links created
+$file_path = dirname(__FILE__);
+$dirname = "$file_path/symlink_link_linkinfo_is_link_variation1/test/home";
+mkdir($dirname, 0777, true);
+
+// creating temp file; links are created to this file later on
+$filename = "$file_path/symlink_link_linkinfo_is_link_variation1/symlink_link_linkinfo_is_link_variation1.tmp";
+$fp = fopen($filename, "w");
+fclose($fp);
+
+echo "*** Testing symlink(), link(), linkinfo() and is_link() with linknames stored as members in an object ***\n";
+class object_temp {
+ var $linkname;
+ function object_temp($link) {
+ $this->linkname = $link;
+ }
+}
+
+$obj = new object_temp("$dirname/symlink_link_linkinfo_is_link_link.tmp");
+/* Testing on soft links */
+echo "\n-- Working with soft links --\n";
+// creating soft link
+var_dump( symlink($filename, $obj->linkname) );
+// check if the link exists
+var_dump( linkinfo($obj->linkname) );
+// check if link is soft link
+var_dump( is_link($obj->linkname) );
+// delete the link created
+unlink($obj->linkname);
+// clear the cache
+clearstatcache();
+
+/* Testing on hard links */
+echo "\n-- Working with hard links --\n";
+// creating hard link
+var_dump( link($filename, $obj->linkname) );
+// check if the link exists
+var_dump( linkinfo($obj->linkname) );
+// check if link is soft link; expected: false as the link is a hardlink
+var_dump( is_link($obj->linkname) );
+// delete the link created
+unlink($obj->linkname);
+// clear the cache
+clearstatcache();
+
+echo "\n*** Testing symlink(), link(), linkinfo() and is_link() with linknames stored as members of an array ***\n";
+
+$link_arr = array("$dirname/symlink_link_linkinfo_is_link_link.tmp");
+
+/* Testing on soft links */
+echo "\n-- Working with soft links --\n";
+// creating soft link
+var_dump( symlink($filename, $link_arr[0]) );
+// check if the link exist
+var_dump( linkinfo($link_arr[0]) );
+// check if link is soft link
+var_dump( is_link($link_arr[0]) );
+// delete the link created
+unlink($link_arr[0]);
+// clear the cache
+clearstatcache();
+
+/* Testing on hard links */
+echo "\n-- Working with hard links --\n";
+// creating hard link
+var_dump( link($filename, $link_arr[0]) );
+// check if the link exist
+var_dump( linkinfo($link_arr[0]) );
+// check if link is soft link; expected: false as this is a hardlink
+var_dump( is_link($link_arr[0]) );
+// delete the links created
+unlink($link_arr[0]);
+// clear the cache
+clearstatcache();
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$dirname = "$file_path/symlink_link_linkinfo_is_link_variation1";
+unlink("$dirname/symlink_link_linkinfo_is_link_variation1.tmp");
+rmdir("$dirname/test/home");
+rmdir("$dirname/test");
+rmdir($dirname);
+?>
+--EXPECTF--
+*** Testing symlink(), link(), linkinfo() and is_link() with linknames stored as members in an object ***
+
+-- Working with soft links --
+bool(true)
+int(%d)
+bool(true)
+
+-- Working with hard links --
+bool(true)
+int(%d)
+bool(false)
+
+*** Testing symlink(), link(), linkinfo() and is_link() with linknames stored as members of an array ***
+
+-- Working with soft links --
+bool(true)
+int(%d)
+bool(true)
+
+-- Working with hard links --
+bool(true)
+int(%d)
+bool(false)
+Done
diff --git a/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation2.phpt b/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation2.phpt
new file mode 100644
index 0000000..6ee6f12
--- /dev/null
+++ b/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation2.phpt
@@ -0,0 +1,51 @@
+--TEST--
+Test symlink(), linkinfo(), link() and is_link() functions : usage variations - hardlink to non-existent file
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip no symlinks on Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: bool symlink ( string $target, string $link );
+ Description: creates a symbolic link to the existing target with the specified name link
+
+ Prototype: bool is_link ( string $filename );
+ Description: Tells whether the given file is a symbolic link.
+
+ Prototype: bool link ( string $target, string $link );
+ Description: Create a hard link
+
+ Prototype: int linkinfo ( string $path );
+ Description: Gets information about a link
+*/
+
+/* Variation 2 : Create hard link to non-existent file */
+
+$file_path = dirname(__FILE__);
+// non-existing filename
+$non_existent_file = "$file_path/non_existent_file_variation2.tmp";
+// non-existing linkname
+$non_existent_linkname = "$file_path/non_existent_linkname_variation2.tmp";
+
+echo "*** Creating a hard link to a non-existent file ***\n";
+// creating hard link to non_existent file
+var_dump( link($non_existent_file, $non_existent_linkname) ); // expected false
+
+// checking linkinfo() and is_link() on the link; expected: false
+var_dump( linkinfo($non_existent_linkname) );
+var_dump( is_link($non_existent_linkname) );
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Creating a hard link to a non-existent file ***
+
+Warning: link(): No such file or directory in %s on line %d
+bool(false)
+
+Warning: linkinfo(): No such file or directory in %s on line %d
+int(-1)
+bool(false)
+Done
diff --git a/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation3.phpt b/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation3.phpt
new file mode 100644
index 0000000..21c9b57
--- /dev/null
+++ b/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation3.phpt
@@ -0,0 +1,146 @@
+--TEST--
+Test symlink(), linkinfo(), link() and is_link() functions : usage variations - access/update file through softlink
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip no symlinks on Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: bool symlink ( string $target, string $link );
+ Description: creates a symbolic link to the existing target with the specified name link
+
+ Prototype: bool is_link ( string $filename );
+ Description: Tells whether the given file is a symbolic link.
+
+ Prototype: bool link ( string $target, string $link );
+ Description: Create a hard link
+
+ Prototype: int linkinfo ( string $path );
+ Description: Gets information about a link
+*/
+
+/* Variation 3 : Create file and a soft link to the file
+ Access data of the file through the soft link
+ Update the file through soft link
+ Check size of file and soft link link
+*/
+
+$file_path = dirname(__FILE__);
+echo "*** Accessing and updating data of file through soft link ***\n";
+// Creating file and inserting data into it
+$filename = "$file_path/symlink_link_linkinfo_is_link_variation3.tmp";
+
+// create temp file
+$file = fopen($filename, "w");
+
+// create soft link to file
+$linkname = "$file_path/symlink_link_linkinfo_is_link_link_variation3.tmp";
+var_dump( symlink($filename, $linkname) );
+// storing size of symlink in a local variable
+$link_stat = lstat($linkname); // lstat of link
+$link_size = $link_stat[7]; // size of soft link
+
+// fill data into file
+fwrite($file, str_repeat("text", 20) );
+fclose($file);
+
+echo "\n-- Access data of the file through the soft link --\n";
+$data_from_link = file_get_contents($linkname); // data read from $filename
+var_dump( $data_from_link );
+
+echo "\n-- Check size of soft link and file --\n";
+var_dump( filesize($filename) );
+var_dump( filesize($linkname) );
+
+// taking lstat of symlink
+$stat = lstat($linkname);
+// checking that size of symlink remains same
+if ($link_size == $stat[7])
+ echo "\nSoft link size remains same \n";
+else
+ echo "\nWarning: Soft link size has changed \n";
+
+echo "\n-- Updating file with data through soft link --\n";
+// append link with data
+$fp = fopen($linkname, "a"); // open in append mode
+fwrite($fp, "Hello World");
+fclose($fp);
+
+// now check temp file for data; it should append "Hello World"
+$data_from_file = file_get_contents($filename);
+var_dump( $data_from_file );
+
+echo "\n-- Check size of soft link and file --\n";
+var_dump( filesize($filename) );
+var_dump( filesize($linkname) );
+
+// taking lstat of symlink
+$stat = lstat($linkname);
+// checking that size of symlink remains same
+if ($link_size == $stat[7])
+ echo "\nSoft link size remains same \n";
+else
+ echo "\nWarning: Soft link size has changed \n";
+
+echo "\n-- Updating file with data and check data through soft link --\n";
+// write to temp file
+$file = fopen($filename, "w");
+fwrite($file, "Hello World");
+fclose($file);
+
+// now check link for data; it should echo "Hello World"
+$data_from_link = file_get_contents($linkname);
+var_dump( $data_from_link );
+
+echo "\n-- Check size of soft link and file --\n";
+var_dump( filesize($filename) );
+var_dump( filesize($linkname) );
+
+// taking lstat of symlink
+$stat = lstat($linkname);
+// checking that size of symlink remains same
+if ($link_size == $stat[7])
+ echo "\nSoft link size remains same \n";
+else
+ echo "\nWarning: Soft link size has changed \n";
+
+// delete the link
+unlink($linkname);
+// delete the temporary file
+unlink($filename);
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Accessing and updating data of file through soft link ***
+bool(true)
+
+-- Access data of the file through the soft link --
+string(80) "texttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttext"
+
+-- Check size of soft link and file --
+int(80)
+int(80)
+
+Soft link size remains same
+
+-- Updating file with data through soft link --
+string(91) "texttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttextHello World"
+
+-- Check size of soft link and file --
+int(91)
+int(91)
+
+Soft link size remains same
+
+-- Updating file with data and check data through soft link --
+string(11) "Hello World"
+
+-- Check size of soft link and file --
+int(11)
+int(11)
+
+Soft link size remains same
+Done
diff --git a/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation4.phpt b/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation4.phpt
new file mode 100644
index 0000000..f58937c
--- /dev/null
+++ b/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation4.phpt
@@ -0,0 +1,120 @@
+--TEST--
+Test symlink(), linkinfo(), link() and is_link() functions : usage variations - access/update file through hard link
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip no symlinks on Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: bool symlink ( string $target, string $link );
+ Description: creates a symbolic link to the existing target with the specified name link
+
+ Prototype: bool is_link ( string $filename );
+ Description: Tells whether the given file is a symbolic link.
+
+ Prototype: bool link ( string $target, string $link );
+ Description: Create a hard link
+
+ Prototype: int linkinfo ( string $path );
+ Description: Gets information about a link
+*/
+
+/* Variation 4 : Create file and a hard link to the file
+ Access data of the file through the hard link
+ Update the file through hard link
+ Check size of file and hard link
+*/
+$file_path = dirname(__FILE__);
+
+echo "*** Accessing and updating data of file through hard link ***\n";
+// Creating file and inserting data into it
+$filename = "$file_path/symlink__link_linkinfo_is_link_variation4.tmp";
+// create temp file
+$file = fopen($filename, "w");
+// fill data into file
+fwrite($file, str_repeat("text", 20) );
+fclose($file);
+
+echo "\n-- Access data of the file through the hard link --\n";
+// create hard link to file
+$linkname = "$file_path/symlink_link_linkinfo_is_link_link_variation4.tmp";
+var_dump( link($filename, $linkname) );
+$data_from_link = file_get_contents($linkname); // data read from $filename
+var_dump( $data_from_link );
+
+echo "\n-- Check size of hard link and file --\n";
+if( filesize($filename) == filesize($linkname) )
+ echo "\nSize of file and hard link are same\n";
+else
+ echo "\nWarning: Size of file and hard link differ\n";
+
+echo "\n-- Updating file with data through hard link --\n";
+// append link with data
+$fp = fopen($linkname, "a"); // open in append mode
+fwrite($fp, "Hello World");
+fclose($fp);
+
+// now check temp file for data; it should append "Hello World"
+$data_from_file = file_get_contents($filename);
+var_dump( $data_from_file );
+
+echo "\n-- Check size of hard link and file --\n";
+if( filesize($filename) == filesize($linkname) )
+ echo "\nSize of file and hard link are same\n";
+else
+ echo "\nWarning: Size of file and hard link differ\n";
+
+echo "\n-- Updating file with data and check data through hard link --\n";
+// write to temp file
+$file = fopen($filename, "w");
+fwrite($file, "Hello World");
+fclose($file);
+
+// now check link for data; it should echo "Hello World"
+$data_from_link = file_get_contents($linkname);
+var_dump( $data_from_link );
+
+echo "\n-- Check size of hard link and file --\n";
+var_dump( filesize($filename) );
+var_dump( filesize($linkname) );
+if( filesize($filename) == filesize($linkname) )
+ echo "\nSize of file and hard link are same\n";
+else
+ echo "\nWarning: Size of file and hard link differ\n";
+
+// delete the link
+unlink($linkname);
+// delete the temporary file
+unlink($filename);
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Accessing and updating data of file through hard link ***
+
+-- Access data of the file through the hard link --
+bool(true)
+string(80) "texttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttext"
+
+-- Check size of hard link and file --
+
+Size of file and hard link are same
+
+-- Updating file with data through hard link --
+string(91) "texttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttextHello World"
+
+-- Check size of hard link and file --
+
+Size of file and hard link are same
+
+-- Updating file with data and check data through hard link --
+string(11) "Hello World"
+
+-- Check size of hard link and file --
+int(11)
+int(11)
+
+Size of file and hard link are same
+Done
diff --git a/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation5.phpt b/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation5.phpt
new file mode 100644
index 0000000..f7d2774
--- /dev/null
+++ b/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation5.phpt
@@ -0,0 +1,75 @@
+--TEST--
+Test symlink(), linkinfo(), link() and is_link() functions : usage variations - work on deleted link
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip no symlinks on Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: bool symlink ( string $target, string $link );
+ Description: creates a symbolic link to the existing target with the specified name link
+
+ Prototype: bool is_link ( string $filename );
+ Description: Tells whether the given file is a symbolic link.
+
+ Prototype: bool link ( string $target, string $link );
+ Description: Create a hard link
+
+ Prototype: int linkinfo ( string $path );
+ Description: Gets information about a link
+*/
+
+/* Variation 5 : Creating link, deleting it and checking linkinfo(), is_link() on it */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Testing linkinfo() and is_link() on deleted link ***\n";
+// link name used here
+$linkname = "$file_path/symlink_link_linkinfo_is_link_link_variation5.tmp";
+
+// create temp dir
+$dirname = "$file_path/symlink_link_linkinfo_is_link_variation5";
+mkdir($dirname);
+
+// filename used here
+$filename = "$dirname/symlink_link_linkinfo_is_link_variation5.tmp";
+// create the file
+$fp = fopen($filename, "w");
+$data = "Hello World";
+fwrite($fp, $data);
+fclose($fp);
+
+var_dump( symlink($filename, $linkname) ); // create link
+
+// delete the link
+var_dump( unlink($linkname) ); // delete the link
+
+// clear the cache
+clearstatcache();
+
+// try using linkinfo() & is_link() on deleted link; expected: false
+$deleted_link = $linkname;
+var_dump( linkinfo($deleted_link) );
+var_dump( is_link($deleted_link) );
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$dirname = "$file_path/symlink_link_linkinfo_is_link_variation5";
+$filename = "$dirname/symlink_link_linkinfo_is_link_variation5.tmp";
+unlink($filename);
+rmdir($dirname);
+?>
+--EXPECTF--
+*** Testing linkinfo() and is_link() on deleted link ***
+bool(true)
+bool(true)
+
+Warning: linkinfo(): No such file or directory in %s on line %d
+int(-1)
+bool(false)
+Done
diff --git a/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation6.phpt b/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation6.phpt
new file mode 100644
index 0000000..9b9afba
--- /dev/null
+++ b/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation6.phpt
@@ -0,0 +1,107 @@
+--TEST--
+Test symlink(), linkinfo(), link() and is_link() functions : usage variations - link & dir perms.
+--SKIPIF--
+<?php
+if ( substr(PHP_OS, 0, 3) == 'WIN' ) {
+ die('skip no symlinks on Windows');
+}
+if ( substr(PHP_OS, 0, 3) == 'MAC' ) {
+ die('skip Not valid for MacOS');
+}
+if (PHP_INT_SIZE != 4) {
+ die("skip this test is for 32bit platform only");
+}
+
+// Skip if being run by root (files are always readable, writeable and executable)
+$filename = dirname(__FILE__)."/symlink_link_linkinfo_is_link6_check_root.tmp";
+$fp = fopen($filename, 'w');
+fclose($fp);
+if(fileowner($filename) == 0) {
+ unlink ($filename);
+ die('skip cannot be run as root');
+}
+
+unlink($filename);
+?>
+--FILE--
+<?php
+/* Prototype: bool symlink ( string $target, string $link );
+ Description: creates a symbolic link to the existing target with the specified name link
+
+ Prototype: bool is_link ( string $filename );
+ Description: Tells whether the given file is a symbolic link.
+
+ Prototype: bool link ( string $target, string $link );
+ Description: Create a hard link
+
+ Prototype: int linkinfo ( string $path );
+ Description: Gets information about a link
+*/
+
+/* Variation 6 : Change permission of directory and try creating links inside that directory */
+$file_path = dirname(__FILE__);
+
+echo "*** Creating links in a directory without permission to allow the operation ***\n";
+// temp file used
+$dirname = "$file_path/symlink_link_linkinfo_is_link_variation6";
+mkdir($dirname);
+$filename = "$dirname/symlink_link_linkinfo_is_link_variation6.tmp";
+
+// remove all permissions from dir
+var_dump( chmod($dirname, 0000) );
+
+echo "\n-- Working with soft links --\n";
+$linkname = "$dirname/non_existent_link_variation5.tmp";
+
+// expected: false
+var_dump( symlink($filename, $linkname) ); // this link won't get created
+var_dump( linkinfo($linkname) );
+var_dump( is_link($linkname) );
+// clear the cache
+clearstatcache();
+
+echo "\n-- Working with hard links --\n";
+// expected: false
+var_dump( link($filename, $linkname) );
+var_dump( linkinfo($linkname) );
+var_dump( is_link($linkname) );
+// clear the cache
+clearstatcache();
+
+chmod($dirname, 0777); // to enable dir deletion
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$dirname = "$file_path/symlink_link_linkinfo_is_link_variation6";
+$filename = "$dirname/symlink_link_linkinfo_is_link_variation6.tmp";
+if(file_exists($filename)) {
+unlink($filename);
+}
+if(file_exists($dirname)) {
+rmdir($dirname);
+}
+?>
+--EXPECTF--
+*** Creating links in a directory without permission to allow the operation ***
+bool(true)
+
+-- Working with soft links --
+
+Warning: symlink(): Permission denied in %s on line %d
+bool(false)
+
+Warning: linkinfo(): Permission denied in %s on line %d
+int(-1)
+bool(false)
+
+-- Working with hard links --
+
+Warning: link(): Permission denied in %s on line %d
+bool(false)
+
+Warning: linkinfo(): Permission denied in %s on line %d
+int(-1)
+bool(false)
+Done
diff --git a/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation7.phpt b/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation7.phpt
new file mode 100644
index 0000000..82ca75b
--- /dev/null
+++ b/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation7.phpt
@@ -0,0 +1,94 @@
+--TEST--
+Test symlink(), linkinfo(), link() and is_link() functions : usage variations - try link to self
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip no symlinks on Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: bool symlink ( string $target, string $link );
+ Description: creates a symbolic link to the existing target with the specified name link
+
+ Prototype: bool is_link ( string $filename );
+ Description: Tells whether the given file is a symbolic link.
+
+ Prototype: bool link ( string $target, string $link );
+ Description: Create a hard link
+
+ Prototype: int linkinfo ( string $path );
+ Description: Gets information about a link
+*/
+
+/* Variation 7 : Create soft/hard link to itself */
+
+// temp file used
+$file_path = dirname(__FILE__);
+$dir = "$file_path/symlink_link_linkinfo_is_link_variation7";
+$filename = "$dir/symlink_link_linkinfo_is_link_variation7.tmp";
+// link name used
+$linkname = "$dir/symlink_link_linkinfo_is_link_link_variation7.tmp";
+// temp dirname used
+$dirname = "$dir/home/test";
+mkdir($dirname, 0755, true);
+
+// create file
+$fp = fopen($filename, "w");
+fclose($fp);
+
+echo "*** Create soft link to file and then to itself ***\n";
+// create soft link to $filename
+var_dump( symlink($filename, $linkname) );
+// create another link to $linkname
+var_dump( symlink($linkname, $linkname) );
+// delete link
+unlink($linkname);
+
+echo "\n*** Create soft link to directory and then to itself ***\n";
+// create soft link to $dirname
+var_dump( symlink($dirname, $linkname) );
+// create another link to $dirname
+var_dump( symlink($linkname, $linkname) );
+// delete link
+unlink($linkname);
+
+echo "\n*** Create hard link to file and then to itself ***\n";
+// create hard link to $filename
+var_dump( link($filename, $linkname) );
+// create another link to $linkname
+var_dump( link($linkname, $linkname) );
+// delete link
+unlink($linkname);
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$dir = "$file_path/symlink_link_linkinfo_is_link_variation7";
+$filename = "$dir/symlink_link_linkinfo_is_link_variation7.tmp";
+unlink($filename);
+rmdir("$dir/home/test");
+rmdir("$dir/home");
+rmdir($dir);
+?>
+--EXPECTF--
+*** Create soft link to file and then to itself ***
+bool(true)
+
+Warning: symlink(): File exists in %s on line %d
+bool(false)
+
+*** Create soft link to directory and then to itself ***
+bool(true)
+
+Warning: symlink(): File exists in %s on line %d
+bool(false)
+
+*** Create hard link to file and then to itself ***
+bool(true)
+
+Warning: link(): File exists in %s on line %d
+bool(false)
+Done
diff --git a/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation8.phpt b/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation8.phpt
new file mode 100644
index 0000000..27b8f58
--- /dev/null
+++ b/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation8.phpt
@@ -0,0 +1,83 @@
+--TEST--
+Test symlink(), linkinfo(), link() and is_link() functions : usage variations - try link with same name in diff. dir
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip no symlinks on Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: bool symlink ( string $target, string $link );
+ Description: creates a symbolic link to the existing target with the specified name link
+
+ Prototype: bool is_link ( string $filename );
+ Description: Tells whether the given file is a symbolic link.
+
+ Prototype: bool link ( string $target, string $link );
+ Description: Create a hard link
+
+ Prototype: int linkinfo ( string $path );
+ Description: Gets information about a link
+*/
+
+/* Variation 8 : Create soft/hard link to different directory */
+
+/* creating link to a file in different dir with the same name as the file */
+echo "\n*** Create hard link in different directory with same filename ***\n";
+// temp file used
+$file_path = dirname(__FILE__);
+$filename = "$file_path/symlink_link_linkinfo_is_link_variation8.tmp";
+// temp link name used
+$dirname = "$file_path/symlink_link_linkinfo_is_link1_variation8";
+mkdir($dirname);
+$linkname = "symlink_link_linkinfo_is_link_variation8.tmp";
+// create temp file
+$fp = fopen($filename, "w");
+fclose($fp);
+
+var_dump( link($filename, $dirname."/") ); // this fails indicating file exists
+// ok, creates "$file_path/symlink_link_linkinfo_is_link1_variation8/symlink_link_linkinfo_is_link_variation8.tmp" link
+var_dump( link($filename, $dirname."/".$linkname) ); // this works fine
+// delete link
+unlink($dirname."/".$linkname);
+// delete temp file
+unlink($filename);
+// delete temp dir
+rmdir($dirname);
+
+echo "\n*** Create soft link in different directory with same filename ***\n";
+$filename = "$file_path/symlink_link_linkinfo_is_link_variation8.tmp";
+// temp link name used
+$dirname = "$file_path/symlink_link_linkinfo_is_link1_variation8";
+mkdir($dirname);
+$linkname = "symlink_link_linkinfo_is_link_variation8.tmp";
+// create temp file
+$fp = fopen($filename, "w");
+fclose($fp);
+
+var_dump( symlink($filename, $dirname."/") ); // this fails indicating file exists
+// ok, creates "$file_path/symlink_link_linkinfo_is_link1_variation8/symlink_link_linkinfo_is_link_variation8.tmp" link
+var_dump( symlink($filename, $dirname."/".$linkname) ); // this works fine
+// delete link
+unlink($dirname."/".$linkname);
+// delete temp file
+unlink($filename);
+// delete temp dir
+rmdir($dirname);
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Create hard link in different directory with same filename ***
+
+Warning: link(): File exists in %s on line %d
+bool(false)
+bool(true)
+
+*** Create soft link in different directory with same filename ***
+
+Warning: symlink(): File exists in %s on line %d
+bool(false)
+bool(true)
+Done
diff --git a/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation9.phpt b/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation9.phpt
new file mode 100644
index 0000000..aacbcd4
--- /dev/null
+++ b/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation9.phpt
@@ -0,0 +1,121 @@
+--TEST--
+Test symlink(), linkinfo(), link() and is_link() functions : usage variations - link & lstat[dev] value
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip no symlinks on Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: bool symlink ( string $target, string $link );
+ Description: creates a symbolic link to the existing target with the specified name link
+
+ Prototype: bool is_link ( string $filename );
+ Description: Tells whether the given file is a symbolic link.
+
+ Prototype: bool link ( string $target, string $link );
+ Description: Create a hard link
+
+ Prototype: int linkinfo ( string $path );
+ Description: Gets information about a link
+*/
+
+/* Variation 9 : Check lstat of soft/hard link created
+ Check linkinfo() value with lstat['dev']
+*/
+// temp file used
+$file_path = dirname(__FILE__);
+$dirname = $file_path."/symlink_link_linkinfo_is_link_variation9";
+mkdir($dirname);
+$filename = "$dirname/symlink_link_linkinfo_is_link_variation9.tmp";
+// soft link name used
+$soft_link = "$dirname/symlink_link_linkinfo_is_link_softlink_variation9.tmp";
+// hard link name used
+$hard_link = "$dirname/symlink_link_linkinfo_is_link_hardlink_variation9.tmp";
+
+// create the file
+$fp = fopen($filename, "w");
+fclose($fp);
+
+echo "*** Checking lstat() on soft link ***\n";
+// create soft link
+var_dump( symlink($filename, $soft_link) );
+
+// confirming that linkinfo() = lstat['dev'] , this should always match
+$linkinfo = linkinfo($soft_link);
+$s1 = lstat($soft_link);
+echo "linkinfo() returns : $linkinfo\n";
+echo "lstat() returns lstat['dev'] as $s1[0]\n";
+if( $s1[0] == $linkinfo )
+ echo "\nlinkinfo() value matches lstat['dev']\n";
+else
+ echo "\nWarning: linkinfo() value doesnt match lstat['dev']\n";
+// delete link
+unlink($soft_link);
+
+echo "\n*** Checking lstat() on hard link ***\n";
+// create hard link
+var_dump( link($filename, $hard_link) );
+// confirming that linkinfo() = lstat['dev'] , this should always match
+$linkinfo = linkinfo($hard_link);
+$s1 = lstat($hard_link);
+echo "linkinfo() returns : $linkinfo\n";
+echo "lstat() returns lstat['dev'] as $s1[0]\n";
+if( $s1[0] == $linkinfo )
+ echo "\nlinkinfo() value matches lstat['dev']\n";
+else
+ echo "\nWarning: linkinfo() value doesnt match lstat['dev']\n";
+
+// delete link
+unlink($hard_link);
+
+echo "\n*** Checking lstat() on a soft link to directory ***\n";
+// create soft link
+var_dump( symlink($dirname, $soft_link) );
+
+// confirming that linkinfo() = lstat['dev'], this should always match
+$linkinfo = linkinfo($soft_link);
+$s1 = lstat($soft_link);
+echo "linkinfo() returns : $linkinfo\n";
+echo "lstat() returns lstat['dev'] as $s1[0]\n";
+if( $s1[0] == $linkinfo )
+ echo "\nlinkinfo() value matches lstat['dev']\n";
+else
+ echo "\nWarning: linkinfo() value doesnt match lstat['dev']\n";
+
+// delete link
+unlink($soft_link);
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$dirname = $file_path."/symlink_link_linkinfo_is_link_variation9";
+$filename = "$dirname/symlink_link_linkinfo_is_link_variation9.tmp";
+unlink($filename);
+rmdir($dirname);
+?>
+--EXPECTF--
+*** Checking lstat() on soft link ***
+bool(true)
+linkinfo() returns : %d
+lstat() returns lstat['dev'] as %d
+
+linkinfo() value matches lstat['dev']
+
+*** Checking lstat() on hard link ***
+bool(true)
+linkinfo() returns : %d
+lstat() returns lstat['dev'] as %d
+
+linkinfo() value matches lstat['dev']
+
+*** Checking lstat() on a soft link to directory ***
+bool(true)
+linkinfo() returns : %d
+lstat() returns lstat['dev'] as %d
+
+linkinfo() value matches lstat['dev']
+Done
diff --git a/ext/standard/tests/file/symlink_to_symlink.phpt b/ext/standard/tests/file/symlink_to_symlink.phpt
new file mode 100644
index 0000000..b7554f9
--- /dev/null
+++ b/ext/standard/tests/file/symlink_to_symlink.phpt
@@ -0,0 +1,50 @@
+--TEST--
+symlink() using a relative path, and symlink() to a symlink
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip no symlinks on Windows');
+}
+?>
+--FILE--
+<?php
+$prefix = __FILE__;
+
+touch($prefix . "_file");
+
+// symlink to a regular file using a relative dest
+symlink(basename($prefix . "_file"), $prefix . "_link1");
+
+// symlink to a symlink using a relative path
+symlink(basename($prefix . "_link1"), $prefix . "_link2");
+
+// symlink to a non-existent path
+@unlink($prefix . "_nonexistant");
+symlink(basename($prefix . "_nonexistant"), $prefix . "_link3");
+
+// symlink to a regular file using an absolute path
+symlink($prefix . "_file", $prefix . "_link4");
+
+// symlink to a symlink using an absolute path
+symlink($prefix . "_link4", $prefix . "_link5");
+
+var_dump(readlink($prefix . "_link1"));
+var_dump(readlink($prefix . "_link2"));
+var_dump(readlink($prefix . "_link3"));
+var_dump(readlink($prefix . "_link4"));
+var_dump(readlink($prefix . "_link5"));
+
+unlink($prefix . "_link5");
+unlink($prefix . "_link4");
+unlink($prefix . "_link3");
+unlink($prefix . "_link2");
+unlink($prefix . "_link1");
+unlink($prefix . "_file");
+
+?>
+--EXPECTF--
+%unicode|string%(%d) "symlink_to_symlink.php_file"
+%unicode|string%(%d) "symlink_to_symlink.php_link1"
+%unicode|string%(%d) "symlink_to_symlink.php_nonexistant"
+%unicode|string%(%d) "%s/symlink_to_symlink.php_file"
+%unicode|string%(%d) "%s/symlink_to_symlink.php_link4"
diff --git a/ext/standard/tests/file/tempnam_error.phpt b/ext/standard/tests/file/tempnam_error.phpt
new file mode 100644
index 0000000..91ca6a3
--- /dev/null
+++ b/ext/standard/tests/file/tempnam_error.phpt
@@ -0,0 +1,48 @@
+--TEST--
+Test tempnam() function: error conditions
+--FILE--
+<?php
+/* Prototype: string tempnam ( string $dir, string $prefix );
+ Description: Create file with unique file name.
+*/
+
+echo "*** Testing tempnam() error conditions ***\n";
+$file_path = dirname(__FILE__);
+
+/* More number of arguments than expected */
+var_dump( tempnam("$file_path", "tempnam_error.tmp", "") ); //Two Valid & One Invalid
+var_dump( tempnam("$file_path", "tempnam_error.tmp", TRUE) );
+
+/* Less number of arguments than expected */
+var_dump( tempnam("tempnam_error") ); //One Valid arg
+var_dump( tempnam("$file_path") ); //One Valid arg
+var_dump( tempnam("") ); //Empty string
+var_dump( tempnam(NULL) ); //NULL as arg
+var_dump( tempnam() ); //Zero args
+
+echo "*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing tempnam() error conditions ***
+
+Warning: tempnam() expects exactly 2 parameters, 3 given in %s on line %d
+NULL
+
+Warning: tempnam() expects exactly 2 parameters, 3 given in %s on line %d
+NULL
+
+Warning: tempnam() expects exactly 2 parameters, 1 given in %s on line %d
+NULL
+
+Warning: tempnam() expects exactly 2 parameters, 1 given in %s on line %d
+NULL
+
+Warning: tempnam() expects exactly 2 parameters, 1 given in %s on line %d
+NULL
+
+Warning: tempnam() expects exactly 2 parameters, 1 given in %s on line %d
+NULL
+
+Warning: tempnam() expects exactly 2 parameters, 0 given in %s on line %d
+NULL
+*** Done ***
diff --git a/ext/standard/tests/file/tempnam_variation1-win32.phpt b/ext/standard/tests/file/tempnam_variation1-win32.phpt
new file mode 100644
index 0000000..a3dd7e9
--- /dev/null
+++ b/ext/standard/tests/file/tempnam_variation1-win32.phpt
@@ -0,0 +1,103 @@
+--TEST--
+Test tempnam() function: usage variations - creating files
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+ die("skip Only valid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype: string tempnam ( string $dir, string $prefix );
+ Description: Create file with unique file name.
+*/
+
+/* Creating number of unique files by passing a file name as prefix */
+
+$file_path = dirname(__FILE__)."/tempnamVar1";
+mkdir($file_path);
+
+echo "*** Testing tempnam() in creation of unique files ***\n";
+for($i=1; $i<=10; $i++) {
+ echo "-- Iteration $i --\n";
+ $files[$i] = tempnam("$file_path", "tempnam_variation1.tmp");
+
+ if( file_exists($files[$i]) ) {
+
+ echo "File name is => ";
+ print($files[$i]);
+ echo "\n";
+
+ echo "File permissions are => ";
+ printf("%o", fileperms($files[$i]) );
+ echo "\n";
+ clearstatcache();
+
+ echo "File created in => ";
+ $file_dir = dirname($files[$i]);
+
+ if (realpath($file_dir) == realpath(sys_get_temp_dir()) || realpath($file_dir."\\") == realpath(sys_get_temp_dir())) {
+ echo "temp dir\n";
+ }
+ else if (realpath($file_dir) == realpath($file_path) || realpath($file_dir."\\") == realpath($file_path)) {
+ echo "directory specified\n";
+ }
+ else {
+ echo "unknown location\n";
+ }
+ clearstatcache();
+ }
+ else {
+ print("- File is not created -");
+ }
+}
+for($i=1; $i<=10; $i++) {
+ unlink($files[$i]);
+}
+rmdir($file_path);
+
+
+echo "*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing tempnam() in creation of unique files ***
+-- Iteration 1 --
+File name is => %s%et%s
+File permissions are => 100666
+File created in => directory specified
+-- Iteration 2 --
+File name is => %s%et%s
+File permissions are => 100666
+File created in => directory specified
+-- Iteration 3 --
+File name is => %s%et%s
+File permissions are => 100666
+File created in => directory specified
+-- Iteration 4 --
+File name is => %s%et%s
+File permissions are => 100666
+File created in => directory specified
+-- Iteration 5 --
+File name is => %s%et%s
+File permissions are => 100666
+File created in => directory specified
+-- Iteration 6 --
+File name is => %s%et%s
+File permissions are => 100666
+File created in => directory specified
+-- Iteration 7 --
+File name is => %s%et%s
+File permissions are => 100666
+File created in => directory specified
+-- Iteration 8 --
+File name is => %s%et%s
+File permissions are => 100666
+File created in => directory specified
+-- Iteration 9 --
+File name is => %s%et%s
+File permissions are => 100666
+File created in => directory specified
+-- Iteration 10 --
+File name is => %s%et%s
+File permissions are => 100666
+File created in => directory specified
+*** Done ***
diff --git a/ext/standard/tests/file/tempnam_variation1.phpt b/ext/standard/tests/file/tempnam_variation1.phpt
new file mode 100644
index 0000000..0745f53
--- /dev/null
+++ b/ext/standard/tests/file/tempnam_variation1.phpt
@@ -0,0 +1,116 @@
+--TEST--
+Test tempnam() function: usage variations - creating files
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+ die("skip Do not run on Windows");
+?>
+--FILE--
+<?php
+/* Prototype: string tempnam ( string $dir, string $prefix );
+ Description: Create file with unique file name.
+*/
+
+/* Creating number of unique files by passing a file name as prefix */
+
+$file_path = dirname(__FILE__)."/tempnamVar1";
+mkdir($file_path);
+
+echo "*** Testing tempnam() in creation of unique files ***\n";
+for($i=1; $i<=10; $i++) {
+ echo "-- Iteration $i --\n";
+ $files[$i] = tempnam("$file_path", "tempnam_variation1.tmp");
+
+ if( file_exists($files[$i]) ) {
+
+ echo "File name is => ";
+ print($files[$i]);
+ echo "\n";
+
+ echo "File permissions are => ";
+ printf("%o", fileperms($files[$i]) );
+ echo "\n";
+ clearstatcache();
+
+ echo "File inode is => ";
+ print_r( fileinode($files[$i]) ); //checking inodes
+ echo "\n";
+
+ echo "File created in => ";
+ $file_dir = dirname($files[$i]);
+
+ if ($file_dir == sys_get_temp_dir()) {
+ echo "temp dir\n";
+ }
+ else if ($file_dir == $file_path) {
+ echo "directory specified\n";
+ }
+ else {
+ echo "unknown location\n";
+ }
+ clearstatcache();
+ }
+ else {
+ print("- File is not created -");
+ }
+}
+for($i=1; $i<=10; $i++) {
+ unlink($files[$i]);
+}
+
+rmdir($file_path);
+echo "*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing tempnam() in creation of unique files ***
+-- Iteration 1 --
+File name is => %s%etempnam_variation1.tmp%s
+File permissions are => 100600
+File inode is => %d
+File created in => directory specified
+-- Iteration 2 --
+File name is => %s%etempnam_variation1.tmp%s
+File permissions are => 100600
+File inode is => %d
+File created in => directory specified
+-- Iteration 3 --
+File name is => %s%etempnam_variation1.tmp%s
+File permissions are => 100600
+File inode is => %d
+File created in => directory specified
+-- Iteration 4 --
+File name is => %s%etempnam_variation1.tmp%s
+File permissions are => 100600
+File inode is => %d
+File created in => directory specified
+-- Iteration 5 --
+File name is => %s%etempnam_variation1.tmp%s
+File permissions are => 100600
+File inode is => %d
+File created in => directory specified
+-- Iteration 6 --
+File name is => %s%etempnam_variation1.tmp%s
+File permissions are => 100600
+File inode is => %d
+File created in => directory specified
+-- Iteration 7 --
+File name is => %s%etempnam_variation1.tmp%s
+File permissions are => 100600
+File inode is => %d
+File created in => directory specified
+-- Iteration 8 --
+File name is => %s%etempnam_variation1.tmp%s
+File permissions are => 100600
+File inode is => %d
+File created in => directory specified
+-- Iteration 9 --
+File name is => %s%etempnam_variation1.tmp%s
+File permissions are => 100600
+File inode is => %d
+File created in => directory specified
+-- Iteration 10 --
+File name is => %s%etempnam_variation1.tmp%s
+File permissions are => 100600
+File inode is => %d
+File created in => directory specified
+*** Done ***
diff --git a/ext/standard/tests/file/tempnam_variation2-win32.phpt b/ext/standard/tests/file/tempnam_variation2-win32.phpt
new file mode 100644
index 0000000..4224966
--- /dev/null
+++ b/ext/standard/tests/file/tempnam_variation2-win32.phpt
@@ -0,0 +1,163 @@
+--TEST--
+Test tempnam() function: usage variations - various absolute and relative paths
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+ die("skip Only valid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype: string tempnam ( string $dir, string $prefix );
+ Description: Create file with unique file name.
+*/
+
+/* Creating unique files in various dirs by passing relative paths to $dir arg */
+
+echo "*** Testing tempnam() with absolute and relative paths ***\n";
+$dir_name = dirname(__FILE__)."/tempnam_variation2";
+mkdir($dir_name);
+$dir_path = $dir_name."/tempnam_variation2_sub";
+mkdir($dir_path);
+
+$old_dir_path = getcwd();
+chdir(dirname(__FILE__));
+
+$dir_paths = array(
+ // absolute paths
+ "$dir_path",
+ "$dir_path/",
+ "$dir_path/..",
+ "$dir_path//../",
+ "$dir_path/../.././tempnam_variation2",
+ "$dir_path/..///tempnam_variation2_sub//..//../tempnam_variation2",
+ "$dir_path/BADDIR",
+
+
+ // relative paths
+ ".",
+ "tempname_variation2",
+ "tempname_variation2/",
+ "tempnam_variation2/tempnam_variation2_sub",
+ "tempnam_variation2//tempnam_variation2_sub",
+ "./tempnam_variation2/../tempnam_variation2/tempnam_variation2_sub",
+ "BADDIR",
+);
+
+for($i = 0; $i<count($dir_paths); $i++) {
+ $j = $i+1;
+ echo "\n-- Iteration $j --\n";
+ $file_name = tempnam($dir_paths[$i], "tempnam_variation2.tmp");
+
+ if( file_exists($file_name) ){
+
+ echo "File name is => ";
+ print(realpath($file_name));
+ echo "\n";
+
+ echo "File permissions are => ";
+ printf("%o", fileperms($file_name) );
+ echo "\n";
+
+ echo "File created in => ";
+ $file_dir = dirname($file_name);
+ $dir_req = $dir_paths[$i];
+
+ if (realpath($file_dir) == realpath(sys_get_temp_dir()) || realpath($file_dir."\\") == realpath(sys_get_temp_dir())) {
+ echo "temp dir\n";
+ }
+ else if (realpath($file_dir) == realpath($dir_req) || realpath($file_dir."\\") == realpath($dir_req)) {
+ echo "directory specified\n";
+ }
+ else {
+ echo "unknown location\n";
+ }
+
+
+ }
+ else {
+ echo "-- File is not created --";
+ }
+
+ unlink($file_name);
+}
+
+chdir($old_dir_path);
+rmdir($dir_path);
+rmdir($dir_name);
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing tempnam() with absolute and relative paths ***
+
+-- Iteration 1 --
+File name is => %s\tempnam_variation2\tempnam_variation2_sub\t%s
+File permissions are => 100666
+File created in => directory specified
+
+-- Iteration 2 --
+File name is => %s\tempnam_variation2\tempnam_variation2_sub\t%s
+File permissions are => 100666
+File created in => directory specified
+
+-- Iteration 3 --
+File name is => %s\tempnam_variation2\t%s
+File permissions are => 100666
+File created in => directory specified
+
+-- Iteration 4 --
+File name is => %s\tempnam_variation2\t%s
+File permissions are => 100666
+File created in => directory specified
+
+-- Iteration 5 --
+File name is => %s\tempnam_variation2\t%s
+File permissions are => 100666
+File created in => directory specified
+
+-- Iteration 6 --
+File name is => %s\tempnam_variation2\t%s
+File permissions are => 100666
+File created in => directory specified
+
+-- Iteration 7 --
+File name is => %s\t%s
+File permissions are => 100666
+File created in => temp dir
+
+-- Iteration 8 --
+File name is => %s\t%s
+File permissions are => 100666
+File created in => directory specified
+
+-- Iteration 9 --
+File name is => %s\t%s
+File permissions are => 100666
+File created in => temp dir
+
+-- Iteration 10 --
+File name is => %s\t%s
+File permissions are => 100666
+File created in => temp dir
+
+-- Iteration 11 --
+File name is => %s\tempnam_variation2\tempnam_variation2_sub\t%s
+File permissions are => 100666
+File created in => directory specified
+
+-- Iteration 12 --
+File name is => %s\tempnam_variation2\tempnam_variation2_sub\t%s
+File permissions are => 100666
+File created in => directory specified
+
+-- Iteration 13 --
+File name is => %s\tempnam_variation2\tempnam_variation2_sub\t%s
+File permissions are => 100666
+File created in => directory specified
+
+-- Iteration 14 --
+File name is => %s\t%s
+File permissions are => 100666
+File created in => temp dir
+
+*** Done *** \ No newline at end of file
diff --git a/ext/standard/tests/file/tempnam_variation2.phpt b/ext/standard/tests/file/tempnam_variation2.phpt
new file mode 100644
index 0000000..b7e5cdc
--- /dev/null
+++ b/ext/standard/tests/file/tempnam_variation2.phpt
@@ -0,0 +1,163 @@
+--TEST--
+Test tempnam() function: usage variations - various absolute and relative paths
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+ die("skip Do not run on Windows");
+?>
+--FILE--
+<?php
+/* Prototype: string tempnam ( string $dir, string $prefix );
+ Description: Create file with unique file name.
+*/
+
+/* Creating unique files in various dirs by passing relative paths to $dir arg */
+
+echo "*** Testing tempnam() with absolute and relative paths ***\n";
+$dir_name = dirname(__FILE__)."/tempnam_variation2";
+mkdir($dir_name);
+$dir_path = $dir_name."/tempnam_variation2_sub";
+mkdir($dir_path);
+
+$old_dir_path = getcwd();
+chdir(dirname(__FILE__));
+
+$dir_paths = array(
+ // absolute paths
+ "$dir_path",
+ "$dir_path/",
+ "$dir_path/..",
+ "$dir_path//../",
+ "$dir_path/../.././tempnam_variation2",
+ "$dir_path/..///tempnam_variation2_sub//..//../tempnam_variation2",
+ "$dir_path/BADDIR",
+
+
+ // relative paths
+ ".",
+ "tempname_variation2",
+ "tempname_variation2/",
+ "tempnam_variation2/tempnam_variation2_sub",
+ "tempnam_variation2//tempnam_variation2_sub",
+ "./tempnam_variation2/../tempnam_variation2/tempnam_variation2_sub",
+ "BADDIR",
+);
+
+for($i = 0; $i<count($dir_paths); $i++) {
+ $j = $i+1;
+ echo "\n-- Iteration $j --\n";
+ $file_name = tempnam($dir_paths[$i], "tempnam_variation2.tmp");
+
+ if( file_exists($file_name) ){
+
+ echo "File name is => ";
+ print(realpath($file_name));
+ echo "\n";
+
+ echo "File permissions are => ";
+ printf("%o", fileperms($file_name) );
+ echo "\n";
+
+ echo "File created in => ";
+ $file_dir = dirname($file_name);
+ $dir_req = $dir_paths[$i];
+
+ if (realpath($file_dir) == realpath(sys_get_temp_dir())) {
+ echo "temp dir\n";
+ }
+ else if ($file_dir == realpath($dir_req)) {
+ echo "directory specified\n";
+ }
+ else {
+ echo "unknown location\n";
+ }
+
+
+ }
+ else {
+ echo "-- File is not created --";
+ }
+
+ unlink($file_name);
+}
+
+chdir($old_dir_path);
+rmdir($dir_path);
+rmdir($dir_name);
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing tempnam() with absolute and relative paths ***
+
+-- Iteration 1 --
+File name is => %s/tempnam_variation2/tempnam_variation2_sub/tempnam_variation2.tmp%s
+File permissions are => 100600
+File created in => directory specified
+
+-- Iteration 2 --
+File name is => %s/tempnam_variation2/tempnam_variation2_sub/tempnam_variation2.tmp%s
+File permissions are => 100600
+File created in => directory specified
+
+-- Iteration 3 --
+File name is => %s/tempnam_variation2/tempnam_variation2.tmp%s
+File permissions are => 100600
+File created in => directory specified
+
+-- Iteration 4 --
+File name is => %s/tempnam_variation2/tempnam_variation2.tmp%s
+File permissions are => 100600
+File created in => directory specified
+
+-- Iteration 5 --
+File name is => %s/tempnam_variation2/tempnam_variation2.tmp%s
+File permissions are => 100600
+File created in => directory specified
+
+-- Iteration 6 --
+File name is => %s/tempnam_variation2/tempnam_variation2.tmp%s
+File permissions are => 100600
+File created in => directory specified
+
+-- Iteration 7 --
+File name is => %s/tempnam_variation2.tmp%s
+File permissions are => 100600
+File created in => temp dir
+
+-- Iteration 8 --
+File name is => %s/tempnam_variation2.tmp%s
+File permissions are => 100600
+File created in => directory specified
+
+-- Iteration 9 --
+File name is => %s/tempnam_variation2.tmp%s
+File permissions are => 100600
+File created in => temp dir
+
+-- Iteration 10 --
+File name is => %s/tempnam_variation2.tmp%s
+File permissions are => 100600
+File created in => temp dir
+
+-- Iteration 11 --
+File name is => %s/tempnam_variation2/tempnam_variation2_sub/tempnam_variation2.tmp%s
+File permissions are => 100600
+File created in => directory specified
+
+-- Iteration 12 --
+File name is => %s/tempnam_variation2/tempnam_variation2_sub/tempnam_variation2.tmp%s
+File permissions are => 100600
+File created in => directory specified
+
+-- Iteration 13 --
+File name is => %s/tempnam_variation2/tempnam_variation2_sub/tempnam_variation2.tmp%s
+File permissions are => 100600
+File created in => directory specified
+
+-- Iteration 14 --
+File name is => %s/tempnam_variation2.tmp%s
+File permissions are => 100600
+File created in => temp dir
+
+*** Done *** \ No newline at end of file
diff --git a/ext/standard/tests/file/tempnam_variation3-win32.phpt b/ext/standard/tests/file/tempnam_variation3-win32.phpt
new file mode 100644
index 0000000..fb457cb
--- /dev/null
+++ b/ext/standard/tests/file/tempnam_variation3-win32.phpt
@@ -0,0 +1,115 @@
+--TEST--
+Test tempnam() function: usage variations - obscure prefixes
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+ die("skip run only on Windows");
+?>
+--FILE--
+<?php
+/* Prototype: string tempnam ( string $dir, string $prefix );
+ Description: Create file with unique file name.
+*/
+
+/* Passing invalid/non-existing args for $prefix */
+
+echo "*** Testing tempnam() with obscure prefixes ***\n";
+$file_path = dirname(__FILE__)."/tempnamVar3";
+if (!mkdir($file_path)) {
+ echo "Failed, cannot create temp dir $filepath\n";
+ exit(1);
+}
+
+$file_path = realpath($file_path);
+
+/* An array of prefixes */
+$names_arr = array(
+ /* Valid args (casting)*/
+ -1,
+ TRUE,
+ FALSE,
+ NULL,
+ "",
+ " ",
+ "\0",
+ /* Invalid args */
+ array(),
+
+ /* Valid args*/
+ /* prefix with path separator of a non existing directory*/
+ "/no/such/file/dir",
+ "php/php"
+);
+
+$res_arr = array(
+ /* Invalid args */
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ true,
+ false,
+
+ /* prefix with path separator of a non existing directory*/
+ true,
+ true
+);
+
+for( $i=0; $i<count($names_arr); $i++ ) {
+ echo "-- Iteration $i --\n";
+ $file_name = tempnam($file_path, $names_arr[$i]);
+
+ /* creating the files in existing dir */
+ if (file_exists($file_name) && !$res_arr[$i]) {
+ echo "Failed\n";
+ }
+ if ($res_arr[$i]) {
+ $file_dir = dirname($file_name);
+ if (realpath($file_dir) == $file_path || realpath($file_dir . "\\") == $file_path) {
+ echo "OK\n";
+ } else {
+ echo "Failed, not created in the correct directory " . realpath($file_dir) . ' vs ' . $file_path ."\n";
+ }
+
+ if (!is_writable($file_name)) {
+ printf("%o\n", fileperms($file_name) );
+
+ }
+ } else {
+ echo "OK\n";
+ }
+ @unlink($file_name);
+}
+
+rmdir($file_path);
+echo "\n*** Done. ***\n";
+?>
+--EXPECTF--
+*** Testing tempnam() with obscure prefixes ***
+-- Iteration 0 --
+OK
+-- Iteration 1 --
+OK
+-- Iteration 2 --
+OK
+-- Iteration 3 --
+OK
+-- Iteration 4 --
+OK
+-- Iteration 5 --
+Failed, not created in the correct directory %s vs %s
+0
+-- Iteration 6 --
+OK
+-- Iteration 7 --
+
+Warning: tempnam() expects parameter 2 to be string, array given in %s\ext\standard\tests\file\tempnam_variation3-win32.php on line %d
+OK
+-- Iteration 8 --
+OK
+-- Iteration 9 --
+OK
+
+*** Done. ***
diff --git a/ext/standard/tests/file/tempnam_variation3.phpt b/ext/standard/tests/file/tempnam_variation3.phpt
new file mode 100644
index 0000000..69ab16c
--- /dev/null
+++ b/ext/standard/tests/file/tempnam_variation3.phpt
@@ -0,0 +1,122 @@
+--TEST--
+Test tempnam() function: usage variations - obscure prefixes
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+ die("skip Do not run on Windows");
+?>
+--FILE--
+<?php
+/* Prototype: string tempnam ( string $dir, string $prefix );
+ Description: Create file with unique file name.
+*/
+
+/* Passing invalid/non-existing args for $prefix */
+
+echo "*** Testing tempnam() with obscure prefixes ***\n";
+$file_path = dirname(__FILE__)."/tempnamVar3";
+mkdir($file_path);
+
+/* An array of prefixes */
+$names_arr = array(
+ /* Invalid args */
+ -1,
+ TRUE,
+ FALSE,
+ NULL,
+ "",
+ " ",
+ "\0",
+ array(),
+
+ /* prefix with path separator of a non existing directory*/
+ "/no/such/file/dir",
+ "php/php"
+
+);
+
+for( $i=0; $i<count($names_arr); $i++ ) {
+ echo "-- Iteration $i --\n";
+ $file_name = tempnam("$file_path", $names_arr[$i]);
+
+ /* creating the files in existing dir */
+ if( file_exists($file_name) ) {
+ echo "File name is => ";
+ print($file_name);
+ echo "\n";
+
+ echo "File permissions are => ";
+ printf("%o", fileperms($file_name) );
+ echo "\n";
+
+ echo "File created in => ";
+ $file_dir = dirname($file_name);
+
+ if ($file_dir == sys_get_temp_dir()) {
+ echo "temp dir\n";
+ }
+ else if ($file_dir == $file_path) {
+ echo "directory specified\n";
+ }
+ else {
+ echo "unknown location\n";
+ }
+
+ }
+ else {
+ echo "-- File is not created --\n";
+ }
+
+ unlink($file_name);
+}
+
+rmdir($file_path);
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing tempnam() with obscure prefixes ***
+-- Iteration 0 --
+File name is => %s/%s
+File permissions are => 100600
+File created in => directory specified
+-- Iteration 1 --
+File name is => %s/%s
+File permissions are => 100600
+File created in => directory specified
+-- Iteration 2 --
+File name is => %s/%s
+File permissions are => 100600
+File created in => directory specified
+-- Iteration 3 --
+File name is => %s/%s
+File permissions are => 100600
+File created in => directory specified
+-- Iteration 4 --
+File name is => %s/%s
+File permissions are => 100600
+File created in => directory specified
+-- Iteration 5 --
+File name is => %s/%s
+File permissions are => 100600
+File created in => directory specified
+-- Iteration 6 --
+File name is => %s/%s
+File permissions are => 100600
+File created in => directory specified
+-- Iteration 7 --
+
+Warning: tempnam() expects parameter 2 to be string, array given in %s on line %d
+-- File is not created --
+
+Warning: unlink(): %s in %s on line %d
+-- Iteration 8 --
+File name is => %s/dir%s
+File permissions are => 100600
+File created in => directory specified
+-- Iteration 9 --
+File name is => %s/php%s
+File permissions are => 100600
+File created in => directory specified
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/tempnam_variation4.phpt b/ext/standard/tests/file/tempnam_variation4.phpt
new file mode 100644
index 0000000..4ce1c7e
--- /dev/null
+++ b/ext/standard/tests/file/tempnam_variation4.phpt
@@ -0,0 +1,1092 @@
+--TEST--
+Test tempnam() function: usage variations - permissions(0000 to 0777) of dir
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip Not valid for Windows');
+}
+// Skip if being run by root
+$filename = dirname(__FILE__)."/is_readable_root_check.tmp";
+$fp = fopen($filename, 'w');
+fclose($fp);
+if(fileowner($filename) == 0) {
+ unlink ($filename);
+ die('skip cannot be run as root');
+}
+unlink($filename);
+?>
+--FILE--
+<?php
+/* Prototype: string tempnam ( string $dir, string $prefix );
+ Description: Create file with unique file name.
+*/
+
+/* Trying to create the file in a dir with permissions from 0000 to 0777,
+ Allowable permissions: files are expected to be created in the input dir
+ Non-allowable permissions: files are expected to be created in '/tmp' dir
+*/
+
+echo "*** Testing tempnam() with dir of permissions from 0000 to 0777 ***\n";
+$file_path = dirname(__FILE__);
+$dir_name = $file_path."/tempnam_variation4";
+$prefix = "tempnamVar4.";
+
+mkdir($dir_name);
+
+for($mode = 0000; $mode <= 0777; $mode++) {
+ echo "-- dir perms ";
+ printf("%o", $mode);
+ echo " --\n";
+ chmod($dir_name, $mode);
+ $file_name = tempnam($dir_name, $prefix);
+
+ if(file_exists($file_name) ) {
+ if (realpath(dirname($file_name)) == realpath(sys_get_temp_dir())) {
+ $msg = " created in temp dir ";
+ }
+ else if (dirname($file_name) == $dir_name) {
+ $msg = " created in requested dir";
+ }
+ else {
+ $msg = " created in unexpected dir";
+ }
+
+ echo $msg."\n";
+ unlink($file_name);
+ }
+ else {
+ print("FAILED: File is not created\n");
+ }
+}
+
+rmdir($dir_name);
+
+echo "*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing tempnam() with dir of permissions from 0000 to 0777 ***
+-- dir perms 0 --
+ created in temp dir
+-- dir perms 1 --
+ created in temp dir
+-- dir perms 2 --
+ created in temp dir
+-- dir perms 3 --
+ created in temp dir
+-- dir perms 4 --
+ created in temp dir
+-- dir perms 5 --
+ created in temp dir
+-- dir perms 6 --
+ created in temp dir
+-- dir perms 7 --
+ created in temp dir
+-- dir perms 10 --
+ created in temp dir
+-- dir perms 11 --
+ created in temp dir
+-- dir perms 12 --
+ created in temp dir
+-- dir perms 13 --
+ created in temp dir
+-- dir perms 14 --
+ created in temp dir
+-- dir perms 15 --
+ created in temp dir
+-- dir perms 16 --
+ created in temp dir
+-- dir perms 17 --
+ created in temp dir
+-- dir perms 20 --
+ created in temp dir
+-- dir perms 21 --
+ created in temp dir
+-- dir perms 22 --
+ created in temp dir
+-- dir perms 23 --
+ created in temp dir
+-- dir perms 24 --
+ created in temp dir
+-- dir perms 25 --
+ created in temp dir
+-- dir perms 26 --
+ created in temp dir
+-- dir perms 27 --
+ created in temp dir
+-- dir perms 30 --
+ created in temp dir
+-- dir perms 31 --
+ created in temp dir
+-- dir perms 32 --
+ created in temp dir
+-- dir perms 33 --
+ created in temp dir
+-- dir perms 34 --
+ created in temp dir
+-- dir perms 35 --
+ created in temp dir
+-- dir perms 36 --
+ created in temp dir
+-- dir perms 37 --
+ created in temp dir
+-- dir perms 40 --
+ created in temp dir
+-- dir perms 41 --
+ created in temp dir
+-- dir perms 42 --
+ created in temp dir
+-- dir perms 43 --
+ created in temp dir
+-- dir perms 44 --
+ created in temp dir
+-- dir perms 45 --
+ created in temp dir
+-- dir perms 46 --
+ created in temp dir
+-- dir perms 47 --
+ created in temp dir
+-- dir perms 50 --
+ created in temp dir
+-- dir perms 51 --
+ created in temp dir
+-- dir perms 52 --
+ created in temp dir
+-- dir perms 53 --
+ created in temp dir
+-- dir perms 54 --
+ created in temp dir
+-- dir perms 55 --
+ created in temp dir
+-- dir perms 56 --
+ created in temp dir
+-- dir perms 57 --
+ created in temp dir
+-- dir perms 60 --
+ created in temp dir
+-- dir perms 61 --
+ created in temp dir
+-- dir perms 62 --
+ created in temp dir
+-- dir perms 63 --
+ created in temp dir
+-- dir perms 64 --
+ created in temp dir
+-- dir perms 65 --
+ created in temp dir
+-- dir perms 66 --
+ created in temp dir
+-- dir perms 67 --
+ created in temp dir
+-- dir perms 70 --
+ created in temp dir
+-- dir perms 71 --
+ created in temp dir
+-- dir perms 72 --
+ created in temp dir
+-- dir perms 73 --
+ created in temp dir
+-- dir perms 74 --
+ created in temp dir
+-- dir perms 75 --
+ created in temp dir
+-- dir perms 76 --
+ created in temp dir
+-- dir perms 77 --
+ created in temp dir
+-- dir perms 100 --
+ created in temp dir
+-- dir perms 101 --
+ created in temp dir
+-- dir perms 102 --
+ created in temp dir
+-- dir perms 103 --
+ created in temp dir
+-- dir perms 104 --
+ created in temp dir
+-- dir perms 105 --
+ created in temp dir
+-- dir perms 106 --
+ created in temp dir
+-- dir perms 107 --
+ created in temp dir
+-- dir perms 110 --
+ created in temp dir
+-- dir perms 111 --
+ created in temp dir
+-- dir perms 112 --
+ created in temp dir
+-- dir perms 113 --
+ created in temp dir
+-- dir perms 114 --
+ created in temp dir
+-- dir perms 115 --
+ created in temp dir
+-- dir perms 116 --
+ created in temp dir
+-- dir perms 117 --
+ created in temp dir
+-- dir perms 120 --
+ created in temp dir
+-- dir perms 121 --
+ created in temp dir
+-- dir perms 122 --
+ created in temp dir
+-- dir perms 123 --
+ created in temp dir
+-- dir perms 124 --
+ created in temp dir
+-- dir perms 125 --
+ created in temp dir
+-- dir perms 126 --
+ created in temp dir
+-- dir perms 127 --
+ created in temp dir
+-- dir perms 130 --
+ created in temp dir
+-- dir perms 131 --
+ created in temp dir
+-- dir perms 132 --
+ created in temp dir
+-- dir perms 133 --
+ created in temp dir
+-- dir perms 134 --
+ created in temp dir
+-- dir perms 135 --
+ created in temp dir
+-- dir perms 136 --
+ created in temp dir
+-- dir perms 137 --
+ created in temp dir
+-- dir perms 140 --
+ created in temp dir
+-- dir perms 141 --
+ created in temp dir
+-- dir perms 142 --
+ created in temp dir
+-- dir perms 143 --
+ created in temp dir
+-- dir perms 144 --
+ created in temp dir
+-- dir perms 145 --
+ created in temp dir
+-- dir perms 146 --
+ created in temp dir
+-- dir perms 147 --
+ created in temp dir
+-- dir perms 150 --
+ created in temp dir
+-- dir perms 151 --
+ created in temp dir
+-- dir perms 152 --
+ created in temp dir
+-- dir perms 153 --
+ created in temp dir
+-- dir perms 154 --
+ created in temp dir
+-- dir perms 155 --
+ created in temp dir
+-- dir perms 156 --
+ created in temp dir
+-- dir perms 157 --
+ created in temp dir
+-- dir perms 160 --
+ created in temp dir
+-- dir perms 161 --
+ created in temp dir
+-- dir perms 162 --
+ created in temp dir
+-- dir perms 163 --
+ created in temp dir
+-- dir perms 164 --
+ created in temp dir
+-- dir perms 165 --
+ created in temp dir
+-- dir perms 166 --
+ created in temp dir
+-- dir perms 167 --
+ created in temp dir
+-- dir perms 170 --
+ created in temp dir
+-- dir perms 171 --
+ created in temp dir
+-- dir perms 172 --
+ created in temp dir
+-- dir perms 173 --
+ created in temp dir
+-- dir perms 174 --
+ created in temp dir
+-- dir perms 175 --
+ created in temp dir
+-- dir perms 176 --
+ created in temp dir
+-- dir perms 177 --
+ created in temp dir
+-- dir perms 200 --
+ created in temp dir
+-- dir perms 201 --
+ created in temp dir
+-- dir perms 202 --
+ created in temp dir
+-- dir perms 203 --
+ created in temp dir
+-- dir perms 204 --
+ created in temp dir
+-- dir perms 205 --
+ created in temp dir
+-- dir perms 206 --
+ created in temp dir
+-- dir perms 207 --
+ created in temp dir
+-- dir perms 210 --
+ created in temp dir
+-- dir perms 211 --
+ created in temp dir
+-- dir perms 212 --
+ created in temp dir
+-- dir perms 213 --
+ created in temp dir
+-- dir perms 214 --
+ created in temp dir
+-- dir perms 215 --
+ created in temp dir
+-- dir perms 216 --
+ created in temp dir
+-- dir perms 217 --
+ created in temp dir
+-- dir perms 220 --
+ created in temp dir
+-- dir perms 221 --
+ created in temp dir
+-- dir perms 222 --
+ created in temp dir
+-- dir perms 223 --
+ created in temp dir
+-- dir perms 224 --
+ created in temp dir
+-- dir perms 225 --
+ created in temp dir
+-- dir perms 226 --
+ created in temp dir
+-- dir perms 227 --
+ created in temp dir
+-- dir perms 230 --
+ created in temp dir
+-- dir perms 231 --
+ created in temp dir
+-- dir perms 232 --
+ created in temp dir
+-- dir perms 233 --
+ created in temp dir
+-- dir perms 234 --
+ created in temp dir
+-- dir perms 235 --
+ created in temp dir
+-- dir perms 236 --
+ created in temp dir
+-- dir perms 237 --
+ created in temp dir
+-- dir perms 240 --
+ created in temp dir
+-- dir perms 241 --
+ created in temp dir
+-- dir perms 242 --
+ created in temp dir
+-- dir perms 243 --
+ created in temp dir
+-- dir perms 244 --
+ created in temp dir
+-- dir perms 245 --
+ created in temp dir
+-- dir perms 246 --
+ created in temp dir
+-- dir perms 247 --
+ created in temp dir
+-- dir perms 250 --
+ created in temp dir
+-- dir perms 251 --
+ created in temp dir
+-- dir perms 252 --
+ created in temp dir
+-- dir perms 253 --
+ created in temp dir
+-- dir perms 254 --
+ created in temp dir
+-- dir perms 255 --
+ created in temp dir
+-- dir perms 256 --
+ created in temp dir
+-- dir perms 257 --
+ created in temp dir
+-- dir perms 260 --
+ created in temp dir
+-- dir perms 261 --
+ created in temp dir
+-- dir perms 262 --
+ created in temp dir
+-- dir perms 263 --
+ created in temp dir
+-- dir perms 264 --
+ created in temp dir
+-- dir perms 265 --
+ created in temp dir
+-- dir perms 266 --
+ created in temp dir
+-- dir perms 267 --
+ created in temp dir
+-- dir perms 270 --
+ created in temp dir
+-- dir perms 271 --
+ created in temp dir
+-- dir perms 272 --
+ created in temp dir
+-- dir perms 273 --
+ created in temp dir
+-- dir perms 274 --
+ created in temp dir
+-- dir perms 275 --
+ created in temp dir
+-- dir perms 276 --
+ created in temp dir
+-- dir perms 277 --
+ created in temp dir
+-- dir perms 300 --
+ created in requested dir
+-- dir perms 301 --
+ created in requested dir
+-- dir perms 302 --
+ created in requested dir
+-- dir perms 303 --
+ created in requested dir
+-- dir perms 304 --
+ created in requested dir
+-- dir perms 305 --
+ created in requested dir
+-- dir perms 306 --
+ created in requested dir
+-- dir perms 307 --
+ created in requested dir
+-- dir perms 310 --
+ created in requested dir
+-- dir perms 311 --
+ created in requested dir
+-- dir perms 312 --
+ created in requested dir
+-- dir perms 313 --
+ created in requested dir
+-- dir perms 314 --
+ created in requested dir
+-- dir perms 315 --
+ created in requested dir
+-- dir perms 316 --
+ created in requested dir
+-- dir perms 317 --
+ created in requested dir
+-- dir perms 320 --
+ created in requested dir
+-- dir perms 321 --
+ created in requested dir
+-- dir perms 322 --
+ created in requested dir
+-- dir perms 323 --
+ created in requested dir
+-- dir perms 324 --
+ created in requested dir
+-- dir perms 325 --
+ created in requested dir
+-- dir perms 326 --
+ created in requested dir
+-- dir perms 327 --
+ created in requested dir
+-- dir perms 330 --
+ created in requested dir
+-- dir perms 331 --
+ created in requested dir
+-- dir perms 332 --
+ created in requested dir
+-- dir perms 333 --
+ created in requested dir
+-- dir perms 334 --
+ created in requested dir
+-- dir perms 335 --
+ created in requested dir
+-- dir perms 336 --
+ created in requested dir
+-- dir perms 337 --
+ created in requested dir
+-- dir perms 340 --
+ created in requested dir
+-- dir perms 341 --
+ created in requested dir
+-- dir perms 342 --
+ created in requested dir
+-- dir perms 343 --
+ created in requested dir
+-- dir perms 344 --
+ created in requested dir
+-- dir perms 345 --
+ created in requested dir
+-- dir perms 346 --
+ created in requested dir
+-- dir perms 347 --
+ created in requested dir
+-- dir perms 350 --
+ created in requested dir
+-- dir perms 351 --
+ created in requested dir
+-- dir perms 352 --
+ created in requested dir
+-- dir perms 353 --
+ created in requested dir
+-- dir perms 354 --
+ created in requested dir
+-- dir perms 355 --
+ created in requested dir
+-- dir perms 356 --
+ created in requested dir
+-- dir perms 357 --
+ created in requested dir
+-- dir perms 360 --
+ created in requested dir
+-- dir perms 361 --
+ created in requested dir
+-- dir perms 362 --
+ created in requested dir
+-- dir perms 363 --
+ created in requested dir
+-- dir perms 364 --
+ created in requested dir
+-- dir perms 365 --
+ created in requested dir
+-- dir perms 366 --
+ created in requested dir
+-- dir perms 367 --
+ created in requested dir
+-- dir perms 370 --
+ created in requested dir
+-- dir perms 371 --
+ created in requested dir
+-- dir perms 372 --
+ created in requested dir
+-- dir perms 373 --
+ created in requested dir
+-- dir perms 374 --
+ created in requested dir
+-- dir perms 375 --
+ created in requested dir
+-- dir perms 376 --
+ created in requested dir
+-- dir perms 377 --
+ created in requested dir
+-- dir perms 400 --
+ created in temp dir
+-- dir perms 401 --
+ created in temp dir
+-- dir perms 402 --
+ created in temp dir
+-- dir perms 403 --
+ created in temp dir
+-- dir perms 404 --
+ created in temp dir
+-- dir perms 405 --
+ created in temp dir
+-- dir perms 406 --
+ created in temp dir
+-- dir perms 407 --
+ created in temp dir
+-- dir perms 410 --
+ created in temp dir
+-- dir perms 411 --
+ created in temp dir
+-- dir perms 412 --
+ created in temp dir
+-- dir perms 413 --
+ created in temp dir
+-- dir perms 414 --
+ created in temp dir
+-- dir perms 415 --
+ created in temp dir
+-- dir perms 416 --
+ created in temp dir
+-- dir perms 417 --
+ created in temp dir
+-- dir perms 420 --
+ created in temp dir
+-- dir perms 421 --
+ created in temp dir
+-- dir perms 422 --
+ created in temp dir
+-- dir perms 423 --
+ created in temp dir
+-- dir perms 424 --
+ created in temp dir
+-- dir perms 425 --
+ created in temp dir
+-- dir perms 426 --
+ created in temp dir
+-- dir perms 427 --
+ created in temp dir
+-- dir perms 430 --
+ created in temp dir
+-- dir perms 431 --
+ created in temp dir
+-- dir perms 432 --
+ created in temp dir
+-- dir perms 433 --
+ created in temp dir
+-- dir perms 434 --
+ created in temp dir
+-- dir perms 435 --
+ created in temp dir
+-- dir perms 436 --
+ created in temp dir
+-- dir perms 437 --
+ created in temp dir
+-- dir perms 440 --
+ created in temp dir
+-- dir perms 441 --
+ created in temp dir
+-- dir perms 442 --
+ created in temp dir
+-- dir perms 443 --
+ created in temp dir
+-- dir perms 444 --
+ created in temp dir
+-- dir perms 445 --
+ created in temp dir
+-- dir perms 446 --
+ created in temp dir
+-- dir perms 447 --
+ created in temp dir
+-- dir perms 450 --
+ created in temp dir
+-- dir perms 451 --
+ created in temp dir
+-- dir perms 452 --
+ created in temp dir
+-- dir perms 453 --
+ created in temp dir
+-- dir perms 454 --
+ created in temp dir
+-- dir perms 455 --
+ created in temp dir
+-- dir perms 456 --
+ created in temp dir
+-- dir perms 457 --
+ created in temp dir
+-- dir perms 460 --
+ created in temp dir
+-- dir perms 461 --
+ created in temp dir
+-- dir perms 462 --
+ created in temp dir
+-- dir perms 463 --
+ created in temp dir
+-- dir perms 464 --
+ created in temp dir
+-- dir perms 465 --
+ created in temp dir
+-- dir perms 466 --
+ created in temp dir
+-- dir perms 467 --
+ created in temp dir
+-- dir perms 470 --
+ created in temp dir
+-- dir perms 471 --
+ created in temp dir
+-- dir perms 472 --
+ created in temp dir
+-- dir perms 473 --
+ created in temp dir
+-- dir perms 474 --
+ created in temp dir
+-- dir perms 475 --
+ created in temp dir
+-- dir perms 476 --
+ created in temp dir
+-- dir perms 477 --
+ created in temp dir
+-- dir perms 500 --
+ created in temp dir
+-- dir perms 501 --
+ created in temp dir
+-- dir perms 502 --
+ created in temp dir
+-- dir perms 503 --
+ created in temp dir
+-- dir perms 504 --
+ created in temp dir
+-- dir perms 505 --
+ created in temp dir
+-- dir perms 506 --
+ created in temp dir
+-- dir perms 507 --
+ created in temp dir
+-- dir perms 510 --
+ created in temp dir
+-- dir perms 511 --
+ created in temp dir
+-- dir perms 512 --
+ created in temp dir
+-- dir perms 513 --
+ created in temp dir
+-- dir perms 514 --
+ created in temp dir
+-- dir perms 515 --
+ created in temp dir
+-- dir perms 516 --
+ created in temp dir
+-- dir perms 517 --
+ created in temp dir
+-- dir perms 520 --
+ created in temp dir
+-- dir perms 521 --
+ created in temp dir
+-- dir perms 522 --
+ created in temp dir
+-- dir perms 523 --
+ created in temp dir
+-- dir perms 524 --
+ created in temp dir
+-- dir perms 525 --
+ created in temp dir
+-- dir perms 526 --
+ created in temp dir
+-- dir perms 527 --
+ created in temp dir
+-- dir perms 530 --
+ created in temp dir
+-- dir perms 531 --
+ created in temp dir
+-- dir perms 532 --
+ created in temp dir
+-- dir perms 533 --
+ created in temp dir
+-- dir perms 534 --
+ created in temp dir
+-- dir perms 535 --
+ created in temp dir
+-- dir perms 536 --
+ created in temp dir
+-- dir perms 537 --
+ created in temp dir
+-- dir perms 540 --
+ created in temp dir
+-- dir perms 541 --
+ created in temp dir
+-- dir perms 542 --
+ created in temp dir
+-- dir perms 543 --
+ created in temp dir
+-- dir perms 544 --
+ created in temp dir
+-- dir perms 545 --
+ created in temp dir
+-- dir perms 546 --
+ created in temp dir
+-- dir perms 547 --
+ created in temp dir
+-- dir perms 550 --
+ created in temp dir
+-- dir perms 551 --
+ created in temp dir
+-- dir perms 552 --
+ created in temp dir
+-- dir perms 553 --
+ created in temp dir
+-- dir perms 554 --
+ created in temp dir
+-- dir perms 555 --
+ created in temp dir
+-- dir perms 556 --
+ created in temp dir
+-- dir perms 557 --
+ created in temp dir
+-- dir perms 560 --
+ created in temp dir
+-- dir perms 561 --
+ created in temp dir
+-- dir perms 562 --
+ created in temp dir
+-- dir perms 563 --
+ created in temp dir
+-- dir perms 564 --
+ created in temp dir
+-- dir perms 565 --
+ created in temp dir
+-- dir perms 566 --
+ created in temp dir
+-- dir perms 567 --
+ created in temp dir
+-- dir perms 570 --
+ created in temp dir
+-- dir perms 571 --
+ created in temp dir
+-- dir perms 572 --
+ created in temp dir
+-- dir perms 573 --
+ created in temp dir
+-- dir perms 574 --
+ created in temp dir
+-- dir perms 575 --
+ created in temp dir
+-- dir perms 576 --
+ created in temp dir
+-- dir perms 577 --
+ created in temp dir
+-- dir perms 600 --
+ created in temp dir
+-- dir perms 601 --
+ created in temp dir
+-- dir perms 602 --
+ created in temp dir
+-- dir perms 603 --
+ created in temp dir
+-- dir perms 604 --
+ created in temp dir
+-- dir perms 605 --
+ created in temp dir
+-- dir perms 606 --
+ created in temp dir
+-- dir perms 607 --
+ created in temp dir
+-- dir perms 610 --
+ created in temp dir
+-- dir perms 611 --
+ created in temp dir
+-- dir perms 612 --
+ created in temp dir
+-- dir perms 613 --
+ created in temp dir
+-- dir perms 614 --
+ created in temp dir
+-- dir perms 615 --
+ created in temp dir
+-- dir perms 616 --
+ created in temp dir
+-- dir perms 617 --
+ created in temp dir
+-- dir perms 620 --
+ created in temp dir
+-- dir perms 621 --
+ created in temp dir
+-- dir perms 622 --
+ created in temp dir
+-- dir perms 623 --
+ created in temp dir
+-- dir perms 624 --
+ created in temp dir
+-- dir perms 625 --
+ created in temp dir
+-- dir perms 626 --
+ created in temp dir
+-- dir perms 627 --
+ created in temp dir
+-- dir perms 630 --
+ created in temp dir
+-- dir perms 631 --
+ created in temp dir
+-- dir perms 632 --
+ created in temp dir
+-- dir perms 633 --
+ created in temp dir
+-- dir perms 634 --
+ created in temp dir
+-- dir perms 635 --
+ created in temp dir
+-- dir perms 636 --
+ created in temp dir
+-- dir perms 637 --
+ created in temp dir
+-- dir perms 640 --
+ created in temp dir
+-- dir perms 641 --
+ created in temp dir
+-- dir perms 642 --
+ created in temp dir
+-- dir perms 643 --
+ created in temp dir
+-- dir perms 644 --
+ created in temp dir
+-- dir perms 645 --
+ created in temp dir
+-- dir perms 646 --
+ created in temp dir
+-- dir perms 647 --
+ created in temp dir
+-- dir perms 650 --
+ created in temp dir
+-- dir perms 651 --
+ created in temp dir
+-- dir perms 652 --
+ created in temp dir
+-- dir perms 653 --
+ created in temp dir
+-- dir perms 654 --
+ created in temp dir
+-- dir perms 655 --
+ created in temp dir
+-- dir perms 656 --
+ created in temp dir
+-- dir perms 657 --
+ created in temp dir
+-- dir perms 660 --
+ created in temp dir
+-- dir perms 661 --
+ created in temp dir
+-- dir perms 662 --
+ created in temp dir
+-- dir perms 663 --
+ created in temp dir
+-- dir perms 664 --
+ created in temp dir
+-- dir perms 665 --
+ created in temp dir
+-- dir perms 666 --
+ created in temp dir
+-- dir perms 667 --
+ created in temp dir
+-- dir perms 670 --
+ created in temp dir
+-- dir perms 671 --
+ created in temp dir
+-- dir perms 672 --
+ created in temp dir
+-- dir perms 673 --
+ created in temp dir
+-- dir perms 674 --
+ created in temp dir
+-- dir perms 675 --
+ created in temp dir
+-- dir perms 676 --
+ created in temp dir
+-- dir perms 677 --
+ created in temp dir
+-- dir perms 700 --
+ created in requested dir
+-- dir perms 701 --
+ created in requested dir
+-- dir perms 702 --
+ created in requested dir
+-- dir perms 703 --
+ created in requested dir
+-- dir perms 704 --
+ created in requested dir
+-- dir perms 705 --
+ created in requested dir
+-- dir perms 706 --
+ created in requested dir
+-- dir perms 707 --
+ created in requested dir
+-- dir perms 710 --
+ created in requested dir
+-- dir perms 711 --
+ created in requested dir
+-- dir perms 712 --
+ created in requested dir
+-- dir perms 713 --
+ created in requested dir
+-- dir perms 714 --
+ created in requested dir
+-- dir perms 715 --
+ created in requested dir
+-- dir perms 716 --
+ created in requested dir
+-- dir perms 717 --
+ created in requested dir
+-- dir perms 720 --
+ created in requested dir
+-- dir perms 721 --
+ created in requested dir
+-- dir perms 722 --
+ created in requested dir
+-- dir perms 723 --
+ created in requested dir
+-- dir perms 724 --
+ created in requested dir
+-- dir perms 725 --
+ created in requested dir
+-- dir perms 726 --
+ created in requested dir
+-- dir perms 727 --
+ created in requested dir
+-- dir perms 730 --
+ created in requested dir
+-- dir perms 731 --
+ created in requested dir
+-- dir perms 732 --
+ created in requested dir
+-- dir perms 733 --
+ created in requested dir
+-- dir perms 734 --
+ created in requested dir
+-- dir perms 735 --
+ created in requested dir
+-- dir perms 736 --
+ created in requested dir
+-- dir perms 737 --
+ created in requested dir
+-- dir perms 740 --
+ created in requested dir
+-- dir perms 741 --
+ created in requested dir
+-- dir perms 742 --
+ created in requested dir
+-- dir perms 743 --
+ created in requested dir
+-- dir perms 744 --
+ created in requested dir
+-- dir perms 745 --
+ created in requested dir
+-- dir perms 746 --
+ created in requested dir
+-- dir perms 747 --
+ created in requested dir
+-- dir perms 750 --
+ created in requested dir
+-- dir perms 751 --
+ created in requested dir
+-- dir perms 752 --
+ created in requested dir
+-- dir perms 753 --
+ created in requested dir
+-- dir perms 754 --
+ created in requested dir
+-- dir perms 755 --
+ created in requested dir
+-- dir perms 756 --
+ created in requested dir
+-- dir perms 757 --
+ created in requested dir
+-- dir perms 760 --
+ created in requested dir
+-- dir perms 761 --
+ created in requested dir
+-- dir perms 762 --
+ created in requested dir
+-- dir perms 763 --
+ created in requested dir
+-- dir perms 764 --
+ created in requested dir
+-- dir perms 765 --
+ created in requested dir
+-- dir perms 766 --
+ created in requested dir
+-- dir perms 767 --
+ created in requested dir
+-- dir perms 770 --
+ created in requested dir
+-- dir perms 771 --
+ created in requested dir
+-- dir perms 772 --
+ created in requested dir
+-- dir perms 773 --
+ created in requested dir
+-- dir perms 774 --
+ created in requested dir
+-- dir perms 775 --
+ created in requested dir
+-- dir perms 776 --
+ created in requested dir
+-- dir perms 777 --
+ created in requested dir
+*** Done ***
diff --git a/ext/standard/tests/file/tempnam_variation5-win32.phpt b/ext/standard/tests/file/tempnam_variation5-win32.phpt
new file mode 100644
index 0000000..3e39352
--- /dev/null
+++ b/ext/standard/tests/file/tempnam_variation5-win32.phpt
@@ -0,0 +1,54 @@
+--TEST--
+Test tempnam() function: usage variations - existing file
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+ die("skip Windows only");
+?>
+--FILE--
+<?php
+/* Prototype: string tempnam ( string $dir, string $prefix );
+ Description: Create file with unique file name.
+*/
+
+/* Passing an existing file as $prefix for tempnam() fn */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test tempnam() function: by passing an existing filename as prefix ***\n";
+$dir_name = $file_path."/tempnam_variation6";
+mkdir($dir_name);
+$h = fopen($dir_name."/tempnam_variation6.tmp", "w");
+
+for($i=1; $i<=3; $i++) {
+ echo "-- Iteration $i --\n";
+ $created_file = tempnam("$dir_name", "tempnam_variation6.tmp");
+
+ if( file_exists($created_file) ) {
+ echo "File name is => ";
+ print($created_file);
+ echo "\n";
+ }
+ else
+ print("File is not created");
+
+ unlink($created_file);
+}
+fclose($h);
+unlink($dir_name."/tempnam_variation6.tmp");
+rmdir($dir_name);
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Test tempnam() function: by passing an existing filename as prefix ***
+-- Iteration 1 --
+File name is => %stempnam_variation6%et%s
+-- Iteration 2 --
+File name is => %stempnam_variation6%et%s
+-- Iteration 3 --
+File name is => %stempnam_variation6%et%s
+
+*** Done ***
diff --git a/ext/standard/tests/file/tempnam_variation5.phpt b/ext/standard/tests/file/tempnam_variation5.phpt
new file mode 100644
index 0000000..26c3f91
--- /dev/null
+++ b/ext/standard/tests/file/tempnam_variation5.phpt
@@ -0,0 +1,52 @@
+--TEST--
+Test tempnam() function: usage variations - existing file
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+ die("skip Do not run on Windows");
+?>
+--FILE--
+<?php
+/* Prototype: string tempnam ( string $dir, string $prefix );
+ Description: Create file with unique file name.
+*/
+
+/* Passing an existing file as $prefix for tempnam() fn */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Test tempnam() function: by passing an existing filename as prefix ***\n";
+$dir_name = $file_path."/tempnam_variation6";
+mkdir($dir_name);
+$h = fopen($dir_name."/tempnam_variation6.tmp", "w");
+
+for($i=1; $i<=3; $i++) {
+ echo "-- Iteration $i --\n";
+ $created_file = tempnam("$dir_name", "tempnam_variation6.tmp");
+
+ if( file_exists($created_file) ) {
+ echo "File name is => ";
+ print($created_file);
+ echo "\n";
+ }
+ else
+ print("File is not created");
+
+ unlink($created_file);
+}
+fclose($h);
+unlink($dir_name."/tempnam_variation6.tmp");
+rmdir($dir_name);
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Test tempnam() function: by passing an existing filename as prefix ***
+-- Iteration 1 --
+File name is => %stempnam_variation6%etempnam_variation6.tmp%s
+-- Iteration 2 --
+File name is => %stempnam_variation6%etempnam_variation6.tmp%s
+-- Iteration 3 --
+File name is => %stempnam_variation6%etempnam_variation6.tmp%s
+
+*** Done ***
diff --git a/ext/standard/tests/file/tempnam_variation6-win32.phpt b/ext/standard/tests/file/tempnam_variation6-win32.phpt
new file mode 100644
index 0000000..efe7e86
--- /dev/null
+++ b/ext/standard/tests/file/tempnam_variation6-win32.phpt
@@ -0,0 +1,62 @@
+--TEST--
+Test tempnam() function: usage variations - Using previous unique filename
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+ die("skip Windows Only");
+?>
+--FILE--
+<?php
+/* Prototype: string tempnam ( string $dir, string $prefix );
+ Description: Create file with unique file name.
+*/
+
+/* Trying to create unique files by passing previously created unique file name as prefix */
+
+$file_path = dirname(__FILE__);
+
+echo "\n*** Test tempnam(): by passing previously created filenames ***\n";
+$file_name = "tempnam_variation6.tmp";
+for($i=1; $i<=3; $i++) {
+ echo "-- Iteration $i --\n";
+ $file_name = tempnam("$file_path", $file_name);
+
+ if( file_exists($file_name) ) {
+ echo "File name is => ";
+ print($file_name);
+ echo "\n";
+
+ echo "File created in => ";
+ $file_dir = dirname($file_name);
+
+ if ($file_dir == sys_get_temp_dir()) {
+ echo "temp dir\n";
+ }
+ else if ($file_dir == $file_path) {
+ echo "directory specified\n";
+ }
+ else {
+ echo "unknown location\n";
+ }
+ }
+
+ unlink($file_name);
+}
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Test tempnam(): by passing previously created filenames ***
+-- Iteration 1 --
+File name is => %s%et%s
+File created in => directory specified
+-- Iteration 2 --
+File name is => %s%et%s
+File created in => directory specified
+-- Iteration 3 --
+File name is => %s%et%s
+File created in => directory specified
+
+*** Done ***
diff --git a/ext/standard/tests/file/tempnam_variation6.phpt b/ext/standard/tests/file/tempnam_variation6.phpt
new file mode 100644
index 0000000..5eb6e6f
--- /dev/null
+++ b/ext/standard/tests/file/tempnam_variation6.phpt
@@ -0,0 +1,60 @@
+--TEST--
+Test tempnam() function: usage variations - Using previous unique filename
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+ die("skip Do not run on Windows");
+?>
+--FILE--
+<?php
+/* Prototype: string tempnam ( string $dir, string $prefix );
+ Description: Create file with unique file name.
+*/
+
+/* Trying to create unique files by passing previously created unique file name as prefix */
+
+$file_path = dirname(__FILE__);
+
+echo "\n*** Test tempnam(): by passing previously created filenames ***\n";
+$file_name = "tempnam_variation6.tmp";
+for($i=1; $i<=3; $i++) {
+ echo "-- Iteration $i --\n";
+ $file_name = tempnam("$file_path", $file_name);
+
+ if( file_exists($file_name) ) {
+ echo "File name is => ";
+ print($file_name);
+ echo "\n";
+
+ echo "File created in => ";
+ $file_dir = dirname($file_name);
+
+ if ($file_dir == sys_get_temp_dir()) {
+ echo "temp dir\n";
+ }
+ else if ($file_dir == $file_path) {
+ echo "directory specified\n";
+ }
+ else {
+ echo "unknown location\n";
+ }
+ }
+
+ unlink($file_name);
+}
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Test tempnam(): by passing previously created filenames ***
+-- Iteration 1 --
+File name is => %s%etempnam_variation6.tmp%s
+File created in => directory specified
+-- Iteration 2 --
+File name is => %s%etempnam_variation6.tmp%s
+File created in => directory specified
+-- Iteration 3 --
+File name is => %s%etempnam_variation6.tmp%s
+File created in => directory specified
+
+*** Done ***
diff --git a/ext/standard/tests/file/tempnam_variation7-win32.phpt b/ext/standard/tests/file/tempnam_variation7-win32.phpt
new file mode 100644
index 0000000..0c8caca
--- /dev/null
+++ b/ext/standard/tests/file/tempnam_variation7-win32.phpt
@@ -0,0 +1,113 @@
+--TEST--
+Test tempnam() function: usage variations - invalid/non-existing dir
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+ die("skip Only run on Windows");
+?>
+--FILE--
+<?php
+/* Prototype: string tempnam ( string $dir, string $prefix );
+ Description: Create file with unique file name.
+*/
+
+/* Passing invalid/non-existing args for $dir,
+ hence the unique files will be created in temporary dir */
+
+echo "*** Testing tempnam() with invalid/non-existing directory names ***\n";
+/* An array of names, which will be passed as a dir name */
+$names_arr = array(
+ /* Invalid args */
+ -1,
+ TRUE,
+ FALSE,
+ NULL,
+ "",
+ " ",
+ "\0",
+ array(),
+
+ /* Non-existing dirs */
+ "/no/such/file/dir",
+ "php"
+);
+
+for( $i=0; $i<count($names_arr); $i++ ) {
+ echo "-- Iteration $i --\n";
+ $file_name = tempnam($names_arr[$i], "tempnam_variation3.tmp");
+
+ if( file_exists($file_name) ){
+
+ echo "File name is => ";
+ print($file_name);
+ echo "\n";
+
+ echo "File permissions are => ";
+ printf("%o", fileperms($file_name) );
+ echo "\n";
+
+ echo "File created in => ";
+ $file_dir = dirname($file_name);
+ if (realpath($file_dir) == realpath(sys_get_temp_dir()) || realpath($file_dir."\\") == realpath(sys_get_temp_dir())) {
+ echo "temp dir\n";
+ } else {
+ echo "unknown location\n";
+ }
+ } else {
+ echo "-- File is not created --\n";
+ }
+
+ unlink($file_name);
+}
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing tempnam() with invalid/non-existing directory names ***
+-- Iteration 0 --
+File name is => %s%et%s
+File permissions are => 100666
+File created in => temp dir
+-- Iteration 1 --
+File name is => %s%et%s
+File permissions are => 100666
+File created in => temp dir
+-- Iteration 2 --
+File name is => %s%et%s
+File permissions are => 100666
+File created in => temp dir
+-- Iteration 3 --
+File name is => %s%et%s
+File permissions are => 100666
+File created in => temp dir
+-- Iteration 4 --
+File name is => %s%et%s
+File permissions are => 100666
+File created in => temp dir
+-- Iteration 5 --
+File name is => %s%et%s
+File permissions are => 100666
+File created in => temp dir
+-- Iteration 6 --
+
+Warning: tempnam() expects parameter 1 to be a valid path, string given in %stempnam_variation7-win32.php on line %d
+-- File is not created --
+
+Warning: unlink(): %r(Invalid argument|No such file or directory)%r in %s on line %d
+-- Iteration 7 --
+
+Warning: tempnam() expects parameter 1 to be a valid path, array given in %s on line %d
+-- File is not created --
+
+Warning: unlink(): %r(Invalid argument|No such file or directory)%r in %s on line %d
+-- Iteration 8 --
+File name is => %s%et%s
+File permissions are => 100666
+File created in => temp dir
+-- Iteration 9 --
+File name is => %s%et%s
+File permissions are => 100666
+File created in => temp dir
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/tempnam_variation7.phpt b/ext/standard/tests/file/tempnam_variation7.phpt
new file mode 100644
index 0000000..b6f81ca
--- /dev/null
+++ b/ext/standard/tests/file/tempnam_variation7.phpt
@@ -0,0 +1,118 @@
+--TEST--
+Test tempnam() function: usage variations - invalid/non-existing dir
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+ die("skip Do not run on Windows");
+?>
+--FILE--
+<?php
+/* Prototype: string tempnam ( string $dir, string $prefix );
+ Description: Create file with unique file name.
+*/
+
+/* Passing invalid/non-existing args for $dir,
+ hence the unique files will be created in temporary dir */
+
+echo "*** Testing tempnam() with invalid/non-existing directory names ***\n";
+/* An array of names, which will be passed as a dir name */
+$names_arr = array(
+ /* Invalid args */
+ -1,
+ TRUE,
+ FALSE,
+ NULL,
+ "",
+ " ",
+ "\0",
+ array(),
+
+ /* Non-existing dirs */
+ "/no/such/file/dir",
+ "php"
+
+);
+
+for( $i=0; $i<count($names_arr); $i++ ) {
+ echo "-- Iteration $i --\n";
+ $file_name = tempnam($names_arr[$i], "tempnam_variation3.tmp");
+
+ if( file_exists($file_name) ){
+
+ echo "File name is => ";
+ print($file_name);
+ echo "\n";
+
+ echo "File permissions are => ";
+ printf("%o", fileperms($file_name) );
+ echo "\n";
+
+ echo "File created in => ";
+ $file_dir = dirname($file_name);
+
+ if (realpath($file_dir) == realpath(sys_get_temp_dir())) {
+ echo "temp dir\n";
+ }
+ else {
+ echo "unknown location\n";
+ }
+
+ }
+ else {
+ echo "-- File is not created --\n";
+ }
+
+ unlink($file_name);
+}
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing tempnam() with invalid/non-existing directory names ***
+-- Iteration 0 --
+File name is => %s%etempnam_variation3.tmp%s
+File permissions are => 100600
+File created in => temp dir
+-- Iteration 1 --
+File name is => %s%etempnam_variation3.tmp%s
+File permissions are => 100600
+File created in => temp dir
+-- Iteration 2 --
+File name is => %s%etempnam_variation3.tmp%s
+File permissions are => 100600
+File created in => temp dir
+-- Iteration 3 --
+File name is => %s%etempnam_variation3.tmp%s
+File permissions are => 100600
+File created in => temp dir
+-- Iteration 4 --
+File name is => %s%etempnam_variation3.tmp%s
+File permissions are => 100600
+File created in => temp dir
+-- Iteration 5 --
+File name is => %s%etempnam_variation3.tmp%s
+File permissions are => 100600
+File created in => temp dir
+-- Iteration 6 --
+
+Warning: tempnam() expects parameter 1 to be a valid path, string given in %s on line %d
+-- File is not created --
+
+Warning: unlink(): %s in %s on line %d
+-- Iteration 7 --
+
+Warning: tempnam() expects parameter 1 to be a valid path, array given in %s on line %d
+-- File is not created --
+
+Warning: unlink(): %s in %s on line %d
+-- Iteration 8 --
+File name is => %s/tempnam_variation3.tmp%s
+File permissions are => 100600
+File created in => temp dir
+-- Iteration 9 --
+File name is => %s/tempnam_variation3.tmp%s
+File permissions are => 100600
+File created in => temp dir
+
+*** Done ***
+
diff --git a/ext/standard/tests/file/tempnam_variation8-win32.phpt b/ext/standard/tests/file/tempnam_variation8-win32.phpt
new file mode 100644
index 0000000..8df67b6
--- /dev/null
+++ b/ext/standard/tests/file/tempnam_variation8-win32.phpt
@@ -0,0 +1,147 @@
+--TEST--
+Test tempnam() function: usage variations - various absolute and relative paths
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != "WIN")
+ die("skip Only valid for Windows");
+?>
+--FILE--
+<?php
+/* Prototype: string tempnam ( string $dir, string $prefix );
+ Description: Create file with unique file name.
+*/
+
+/* Creating unique files in various dirs by passing relative paths to $dir arg */
+
+echo "*** Testing tempnam() with absolute and relative paths ***\n";
+$dir_name = dirname(__FILE__)."\\tempnam_variation2";
+mkdir($dir_name);
+$dir_path = $dir_name."/tempnam_variation2_sub";
+mkdir($dir_path);
+
+$old_dir_path = getcwd();
+chdir(dirname(__FILE__));
+
+$dir_paths = array(
+ // absolute paths
+ "$dir_path\\",
+ "$dir_path\\..",
+ "$dir_path\\\\..\\",
+ "$dir_path\\..\\..\\.\\tempnam_variation2",
+ "$dir_path\\..\\\\\\tempnam_variation2_sub\\\\..\\\\..\\tempnam_variation2",
+ "$dir_path\\BADDIR",
+
+
+ // relative paths
+ "tempname_variation2\\",
+ "tempnam_variation2\\tempnam_variation2_sub",
+ "tempnam_variation2\\\\tempnam_variation2_sub",
+ ".\\tempnam_variation2\\..\\tempnam_variation2\\tempnam_variation2_sub",
+ "BADDIR",
+);
+
+for($i = 0; $i<count($dir_paths); $i++) {
+ $j = $i+1;
+ echo "\n-- Iteration $j --\n";
+ $file_name = tempnam($dir_paths[$i], "tempnam_variation2.tmp");
+
+ if( file_exists($file_name) ){
+
+ echo "File name is => ";
+ print(realpath($file_name));
+ echo "\n";
+
+ echo "File permissions are => ";
+ printf("%o", fileperms($file_name) );
+ echo "\n";
+
+ echo "File created in => ";
+ $file_dir = dirname($file_name);
+ $dir_req = $dir_paths[$i];
+
+ if (realpath($file_dir) == realpath(sys_get_temp_dir()) || realpath($file_dir."\\") == realpath(sys_get_temp_dir())) {
+ echo "temp dir\n";
+ }
+ else if (realpath($file_dir) == realpath($dir_req) || realpath($file_dir."\\") == realpath($dir_req)) {
+ echo "directory specified\n";
+ }
+ else {
+ echo "unknown location\n";
+ }
+
+
+ }
+ else {
+ echo "-- File is not created --";
+ }
+
+ unlink($file_name);
+}
+
+chdir($old_dir_path);
+rmdir($dir_path);
+rmdir($dir_name);
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing tempnam() with absolute and relative paths ***
+
+-- Iteration 1 --
+File name is => %s\tempnam_variation2\tempnam_variation2_sub\t%s
+File permissions are => 100666
+File created in => directory specified
+
+-- Iteration 2 --
+File name is => %s\tempnam_variation2\t%s
+File permissions are => 100666
+File created in => directory specified
+
+-- Iteration 3 --
+File name is => %s\tempnam_variation2\t%s
+File permissions are => 100666
+File created in => directory specified
+
+-- Iteration 4 --
+File name is => %s\tempnam_variation2\t%s
+File permissions are => 100666
+File created in => directory specified
+
+-- Iteration 5 --
+File name is => %s\tempnam_variation2\t%s
+File permissions are => 100666
+File created in => directory specified
+
+-- Iteration 6 --
+File name is => %s\t%s
+File permissions are => 100666
+File created in => temp dir
+
+-- Iteration 7 --
+File name is => %s\t%s
+File permissions are => 100666
+File created in => temp dir
+
+-- Iteration 8 --
+File name is => %s\tempnam_variation2\tempnam_variation2_sub\t%s
+File permissions are => 100666
+File created in => directory specified
+
+-- Iteration 9 --
+File name is => %s\tempnam_variation2\tempnam_variation2_sub\t%s
+File permissions are => 100666
+File created in => directory specified
+
+-- Iteration 10 --
+File name is => %s\tempnam_variation2\tempnam_variation2_sub\t%s
+File permissions are => 100666
+File created in => directory specified
+
+-- Iteration 11 --
+File name is => %s\t%s
+File permissions are => 100666
+File created in => temp dir
+
+*** Done ***
diff --git a/ext/standard/tests/file/test.csv b/ext/standard/tests/file/test.csv
new file mode 100644
index 0000000..d99984c
--- /dev/null
+++ b/ext/standard/tests/file/test.csv
@@ -0,0 +1,17 @@
+6,7,8,line1
+1,2,3,"line2
+2,4,5,line3
+2,4,5,line3
+2,4,5,line3
+2,4,5,line3
+2,4,5,line3
+2,4,5,line3
+2,4,5,line3
+2,4,5,line3
+2,4,5,line3
+2,4,5,line3
+2,4,5,line3
+2,4,5,line3
+2,4,5,line3
+2,4,5,line3
+2,4,5,line3
diff --git a/ext/standard/tests/file/test2.csv b/ext/standard/tests/file/test2.csv
new file mode 100644
index 0000000..d816464
--- /dev/null
+++ b/ext/standard/tests/file/test2.csv
@@ -0,0 +1 @@
+"One","\"Two\"","Three\"","Four","\\","\\\\\\\\\\\\\\\\\\\\\\\"\\\\"
diff --git a/ext/standard/tests/file/test3.csv b/ext/standard/tests/file/test3.csv
new file mode 100644
index 0000000..63f0903
--- /dev/null
+++ b/ext/standard/tests/file/test3.csv
Binary files differ
diff --git a/ext/standard/tests/file/touch.phpt b/ext/standard/tests/file/touch.phpt
new file mode 100644
index 0000000..c6c270d
--- /dev/null
+++ b/ext/standard/tests/file/touch.phpt
@@ -0,0 +1,58 @@
+--TEST--
+touch() tests
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. only for Non Windows.');
+}
+?>
+--FILE--
+<?php
+
+// This doesn't work for windows, time, atime usage results in very different
+// output to linux. This could be a php.net bug on windows or a windows querk.
+$filename = dirname(__FILE__)."/touch.dat";
+
+var_dump(touch());
+var_dump(touch($filename));
+var_dump(filemtime($filename));
+@unlink($filename);
+var_dump(touch($filename, 101));
+var_dump(filemtime($filename));
+
+@unlink($filename);
+var_dump(touch($filename, -1));
+var_dump(filemtime($filename));
+
+@unlink($filename);
+var_dump(touch($filename, 100, 100));
+var_dump(filemtime($filename));
+
+@unlink($filename);
+var_dump(touch($filename, 100, -100));
+var_dump(filemtime($filename));
+
+var_dump(touch("/no/such/file/or/directory"));
+
+@unlink($filename);
+
+echo "Done\n";
+?>
+--EXPECTF--
+Warning: touch() expects at least 1 parameter, 0 given in %s on line %d
+NULL
+bool(true)
+int(%d)
+bool(true)
+int(101)
+bool(true)
+int(%i)
+bool(true)
+int(100)
+bool(true)
+int(100)
+
+Warning: touch(): Unable to create file /no/such/file/or/directory because %s in %s on line %d
+bool(false)
+Done
+
diff --git a/ext/standard/tests/file/touch_basic-win32.phpt b/ext/standard/tests/file/touch_basic-win32.phpt
new file mode 100644
index 0000000..b4ad29f
--- /dev/null
+++ b/ext/standard/tests/file/touch_basic-win32.phpt
@@ -0,0 +1,96 @@
+--TEST--
+Test touch() function : basic functionality
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip.. only for Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto bool touch(string filename [, int time [, int atime]])
+ * Description: Set modification time of file
+ * Source code: ext/standard/filestat.c
+ * Alias to functions:
+ */
+
+echo "*** Testing touch() : basic functionality ***\n";
+
+$filename = dirname(__FILE__)."/touch.dat";
+
+echo "\n--- testing touch creates a file ---\n";
+@unlink($filename);
+if (file_exists($filename)) {
+ die("touch_basic failed");
+}
+var_dump( touch($filename) );
+if (file_exists($filename) == false) {
+ die("touch_basic failed");
+}
+
+echo "\n --- testing touch doesn't alter file contents ---\n";
+$testln = "Here is a test line";
+$h = fopen($filename, "wb");
+fwrite($h, $testln);
+fclose($h);
+touch($filename);
+$h = fopen($filename, "rb");
+echo fgets($h);
+fclose($h);
+
+echo "\n\n --- testing touch alters the correct file metadata ---\n";
+$init_meta = stat($filename);
+clearstatcache();
+sleep(1);
+touch($filename);
+$next_meta = stat($filename);
+$type = array("dev", "ino", "mode", "nlink", "uid", "gid",
+ "rdev", "size", "atime", "mtime", "ctime",
+ "blksize", "blocks");
+
+for ($i = 0; $i < count($type); $i++) {
+ if ($init_meta[$i] != $next_meta[$i]) {
+ echo "stat data differs at $type[$i]\n";
+ }
+}
+
+
+// Initialise all required variables
+$time = 10000;
+$atime = 20470;
+
+// Calling touch() with all possible arguments
+echo "\n --- testing touch using all parameters ---\n";
+var_dump( touch($filename, $time, $atime) );
+clearstatcache();
+$init_meta = stat($filename);
+echo "ctime=".$init_meta['ctime']."\n";
+echo "mtime=".$init_meta['mtime']."\n";
+echo "atime=".$init_meta['atime']."\n";
+
+unlink($filename);
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing touch() : basic functionality ***
+
+--- testing touch creates a file ---
+bool(true)
+
+ --- testing touch doesn't alter file contents ---
+Here is a test line
+
+ --- testing touch alters the correct file metadata ---
+stat data differs at atime
+stat data differs at mtime
+
+ --- testing touch using all parameters ---
+bool(true)
+ctime=%d
+mtime=10000
+atime=20470
+Done
+
diff --git a/ext/standard/tests/file/touch_basic.phpt b/ext/standard/tests/file/touch_basic.phpt
new file mode 100644
index 0000000..c41fdf1
--- /dev/null
+++ b/ext/standard/tests/file/touch_basic.phpt
@@ -0,0 +1,97 @@
+--TEST--
+Test touch() function : basic functionality
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. only for Non Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype : proto bool touch(string filename [, int time [, int atime]])
+ * Description: Set modification time of file
+ * Source code: ext/standard/filestat.c
+ * Alias to functions:
+ */
+
+echo "*** Testing touch() : basic functionality ***\n";
+
+$filename = dirname(__FILE__)."/touch.dat";
+
+echo "\n--- testing touch creates a file ---\n";
+@unlink($filename);
+if (file_exists($filename)) {
+ die("touch_basic failed");
+}
+var_dump( touch($filename) );
+if (file_exists($filename) == false) {
+ die("touch_basic failed");
+}
+
+echo "\n --- testing touch doesn't alter file contents ---\n";
+$testln = "Here is a test line";
+$h = fopen($filename, "wb");
+fwrite($h, $testln);
+fclose($h);
+touch($filename);
+$h = fopen($filename, "rb");
+echo fgets($h);
+fclose($h);
+
+echo "\n\n --- testing touch alters the correct file metadata ---\n";
+$init_meta = stat($filename);
+clearstatcache();
+sleep(1);
+touch($filename);
+$next_meta = stat($filename);
+$type = array("dev", "ino", "mode", "nlink", "uid", "gid",
+ "rdev", "size", "atime", "mtime", "ctime",
+ "blksize", "blocks");
+
+for ($i = 0; $i < count($type); $i++) {
+ if ($init_meta[$i] != $next_meta[$i]) {
+ echo "stat data differs at $type[$i]\n";
+ }
+}
+
+
+// Initialise all required variables
+$time = 10000;
+$atime = 20470;
+
+// Calling touch() with all possible arguments
+echo "\n --- testing touch using all parameters ---\n";
+var_dump( touch($filename, $time, $atime) );
+clearstatcache();
+$init_meta = stat($filename);
+echo "ctime=".$init_meta['ctime']."\n";
+echo "mtime=".$init_meta['mtime']."\n";
+echo "atime=".$init_meta['atime']."\n";
+
+unlink($filename);
+
+echo "Done";
+?>
+--EXPECTF--
+*** Testing touch() : basic functionality ***
+
+--- testing touch creates a file ---
+bool(true)
+
+ --- testing touch doesn't alter file contents ---
+Here is a test line
+
+ --- testing touch alters the correct file metadata ---
+stat data differs at atime
+stat data differs at mtime
+stat data differs at ctime
+
+ --- testing touch using all parameters ---
+bool(true)
+ctime=%d
+mtime=10000
+atime=20470
+Done
diff --git a/ext/standard/tests/file/touch_error.phpt b/ext/standard/tests/file/touch_error.phpt
new file mode 100644
index 0000000..ec58fee
--- /dev/null
+++ b/ext/standard/tests/file/touch_error.phpt
@@ -0,0 +1,22 @@
+--TEST--
+touch() error tests
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+
+var_dump(touch());
+var_dump(touch(1, 2, 3, 4));
+var_dump(touch("/no/such/file/or/directory"));
+
+?>
+--EXPECTF--
+Warning: touch() expects at least 1 parameter, 0 given in %s on line %d
+NULL
+
+Warning: touch() expects at most 3 parameters, 4 given in %s on line %d
+NULL
+
+Warning: touch(): Unable to create file /no/such/file/or/directory because No such file or directory in %s on line %d
+bool(false)
+
diff --git a/ext/standard/tests/file/touch_variation1.phpt b/ext/standard/tests/file/touch_variation1.phpt
new file mode 100644
index 0000000..dba41a6
--- /dev/null
+++ b/ext/standard/tests/file/touch_variation1.phpt
@@ -0,0 +1,39 @@
+--TEST--
+touch() with times
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. Not valid for Windows');
+}
+?>
+--FILE--
+<?php
+
+$filename = dirname(__FILE__)."/touch.dat";
+
+
+var_dump(touch($filename, 101));
+var_dump(filemtime($filename));
+var_dump(fileatime($filename));
+
+@unlink($filename);
+
+@unlink($filename);
+var_dump(touch($filename, 100, 102));
+var_dump(filemtime($filename));
+var_dump(fileatime($filename));
+
+@unlink($filename);
+echo "Done\n";
+
+?>
+--EXPECTF--
+bool(true)
+int(101)
+int(101)
+bool(true)
+int(100)
+int(102)
+Done \ No newline at end of file
diff --git a/ext/standard/tests/file/touch_variation2.phpt b/ext/standard/tests/file/touch_variation2.phpt
new file mode 100644
index 0000000..9ccb90c
--- /dev/null
+++ b/ext/standard/tests/file/touch_variation2.phpt
@@ -0,0 +1,24 @@
+--TEST--
+touch() - ensure touch does not delete existing file.
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+
+
+$filename = dirname(__FILE__)."/touch.dat";
+$fp=fopen($filename,"w");
+fwrite ($fp,"mydata");
+fclose($fp);
+
+var_dump(touch($filename, 101));
+var_dump(file_get_contents($filename));
+
+@unlink($filename);
+echo "Done\n";
+
+?>
+--EXPECT--
+bool(true)
+string(6) "mydata"
+Done
diff --git a/ext/standard/tests/file/touch_variation3-win32.phpt b/ext/standard/tests/file/touch_variation3-win32.phpt
new file mode 100644
index 0000000..43556b8
--- /dev/null
+++ b/ext/standard/tests/file/touch_variation3-win32.phpt
@@ -0,0 +1,199 @@
+--TEST--
+Test touch() function : usage variation - different types for time
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip.. only for Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype : bool touch(string filename [, int time [, int atime]])
+ * Description: Set modification time of file
+ * Source code: ext/standard/filestat.c
+ * Alias to functions:
+ */
+
+echo "*** Testing touch() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$filename = 'touchVar2.tmp';
+$atime = 10;
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float 12.3456789000e10' => 12.3456789000e10,
+ 'float .5' => .5,
+
+ // array data
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // string data
+ 'string DQ' => "string",
+ 'string SQ' => 'string',
+ 'mixed case string' => "sTrInG",
+ 'heredoc' => $heredoc,
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for time
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( touch($filename, $value, $atime) );
+};
+
+unlink($filename);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing touch() : usage variation ***
+
+--float 10.5--
+bool(true)
+
+--float 12.3456789000e10--
+bool(true)
+
+--float .5--
+bool(true)
+
+--empty array--
+Error: 2 - touch() expects parameter 2 to be long, array given, %s(%d)
+NULL
+
+--int indexed array--
+Error: 2 - touch() expects parameter 2 to be long, array given, %s(%d)
+NULL
+
+--associative array--
+Error: 2 - touch() expects parameter 2 to be long, array given, %s(%d)
+NULL
+
+--nested arrays--
+Error: 2 - touch() expects parameter 2 to be long, array given, %s(%d)
+NULL
+
+--uppercase NULL--
+bool(true)
+
+--lowercase null--
+bool(true)
+
+--lowercase true--
+bool(true)
+
+--lowercase false--
+bool(true)
+
+--uppercase TRUE--
+bool(true)
+
+--uppercase FALSE--
+bool(true)
+
+--empty string DQ--
+Error: 2 - touch() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--empty string SQ--
+Error: 2 - touch() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--string DQ--
+Error: 2 - touch() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--string SQ--
+Error: 2 - touch() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--mixed case string--
+Error: 2 - touch() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--heredoc--
+Error: 2 - touch() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--instance of classWithToString--
+Error: 2 - touch() expects parameter 2 to be long, object given, %s(%d)
+NULL
+
+--instance of classWithoutToString--
+Error: 2 - touch() expects parameter 2 to be long, object given, %s(%d)
+NULL
+
+--undefined var--
+bool(true)
+
+--unset var--
+bool(true)
+===DONE===
+
diff --git a/ext/standard/tests/file/touch_variation3.phpt b/ext/standard/tests/file/touch_variation3.phpt
new file mode 100644
index 0000000..810cd71
--- /dev/null
+++ b/ext/standard/tests/file/touch_variation3.phpt
@@ -0,0 +1,199 @@
+--TEST--
+Test touch() function : usage variation - different types for time
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. Not for Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype : bool touch(string filename [, int time [, int atime]])
+ * Description: Set modification time of file
+ * Source code: ext/standard/filestat.c
+ * Alias to functions:
+ */
+
+echo "*** Testing touch() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$filename = 'touchVar2.tmp';
+$atime = 10;
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float 12.3456789000e10' => 12.3456789000e10,
+ 'float .5' => .5,
+
+ // array data
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // string data
+ 'string DQ' => "string",
+ 'string SQ' => 'string',
+ 'mixed case string' => "sTrInG",
+ 'heredoc' => $heredoc,
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for time
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( touch($filename, $value, $atime) );
+};
+
+unlink($filename);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing touch() : usage variation ***
+
+--float 10.5--
+bool(true)
+
+--float 12.3456789000e10--
+bool(true)
+
+--float .5--
+bool(true)
+
+--empty array--
+Error: 2 - touch() expects parameter 2 to be long, array given, %s(%d)
+NULL
+
+--int indexed array--
+Error: 2 - touch() expects parameter 2 to be long, array given, %s(%d)
+NULL
+
+--associative array--
+Error: 2 - touch() expects parameter 2 to be long, array given, %s(%d)
+NULL
+
+--nested arrays--
+Error: 2 - touch() expects parameter 2 to be long, array given, %s(%d)
+NULL
+
+--uppercase NULL--
+bool(true)
+
+--lowercase null--
+bool(true)
+
+--lowercase true--
+bool(true)
+
+--lowercase false--
+bool(true)
+
+--uppercase TRUE--
+bool(true)
+
+--uppercase FALSE--
+bool(true)
+
+--empty string DQ--
+Error: 2 - touch() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--empty string SQ--
+Error: 2 - touch() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--string DQ--
+Error: 2 - touch() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--string SQ--
+Error: 2 - touch() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--mixed case string--
+Error: 2 - touch() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--heredoc--
+Error: 2 - touch() expects parameter 2 to be long, string given, %s(%d)
+NULL
+
+--instance of classWithToString--
+Error: 2 - touch() expects parameter 2 to be long, object given, %s(%d)
+NULL
+
+--instance of classWithoutToString--
+Error: 2 - touch() expects parameter 2 to be long, object given, %s(%d)
+NULL
+
+--undefined var--
+bool(true)
+
+--unset var--
+bool(true)
+===DONE===
+
diff --git a/ext/standard/tests/file/touch_variation4-win32.phpt b/ext/standard/tests/file/touch_variation4-win32.phpt
new file mode 100644
index 0000000..ee2639a
--- /dev/null
+++ b/ext/standard/tests/file/touch_variation4-win32.phpt
@@ -0,0 +1,199 @@
+--TEST--
+Test touch() function : usage variation - different types for atime
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip.. only for Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype : bool touch(string filename [, int time [, int atime]])
+ * Description: Set modification time of file
+ * Source code: ext/standard/filestat.c
+ * Alias to functions:
+ */
+
+echo "*** Testing touch() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$filename = 'touchVar3.tmp';
+$time = 10;
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float 12.3456789000e10' => 12.3456789000e10,
+ 'float .5' => .5,
+
+ // array data
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // string data
+ 'string DQ' => "string",
+ 'string SQ' => 'string',
+ 'mixed case string' => "sTrInG",
+ 'heredoc' => $heredoc,
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for atime
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( touch($filename, $time, $value) );
+};
+
+unlink($filename);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing touch() : usage variation ***
+
+--float 10.5--
+bool(true)
+
+--float 12.3456789000e10--
+bool(true)
+
+--float .5--
+bool(true)
+
+--empty array--
+Error: 2 - touch() expects parameter 3 to be long, array given, %s(%d)
+NULL
+
+--int indexed array--
+Error: 2 - touch() expects parameter 3 to be long, array given, %s(%d)
+NULL
+
+--associative array--
+Error: 2 - touch() expects parameter 3 to be long, array given, %s(%d)
+NULL
+
+--nested arrays--
+Error: 2 - touch() expects parameter 3 to be long, array given, %s(%d)
+NULL
+
+--uppercase NULL--
+bool(true)
+
+--lowercase null--
+bool(true)
+
+--lowercase true--
+bool(true)
+
+--lowercase false--
+bool(true)
+
+--uppercase TRUE--
+bool(true)
+
+--uppercase FALSE--
+bool(true)
+
+--empty string DQ--
+Error: 2 - touch() expects parameter 3 to be long, string given, %s(%d)
+NULL
+
+--empty string SQ--
+Error: 2 - touch() expects parameter 3 to be long, string given, %s(%d)
+NULL
+
+--string DQ--
+Error: 2 - touch() expects parameter 3 to be long, string given, %s(%d)
+NULL
+
+--string SQ--
+Error: 2 - touch() expects parameter 3 to be long, string given, %s(%d)
+NULL
+
+--mixed case string--
+Error: 2 - touch() expects parameter 3 to be long, string given, %s(%d)
+NULL
+
+--heredoc--
+Error: 2 - touch() expects parameter 3 to be long, string given, %s(%d)
+NULL
+
+--instance of classWithToString--
+Error: 2 - touch() expects parameter 3 to be long, object given, %s(%d)
+NULL
+
+--instance of classWithoutToString--
+Error: 2 - touch() expects parameter 3 to be long, object given, %s(%d)
+NULL
+
+--undefined var--
+bool(true)
+
+--unset var--
+bool(true)
+===DONE===
+
diff --git a/ext/standard/tests/file/touch_variation4.phpt b/ext/standard/tests/file/touch_variation4.phpt
new file mode 100644
index 0000000..b0238b1
--- /dev/null
+++ b/ext/standard/tests/file/touch_variation4.phpt
@@ -0,0 +1,199 @@
+--TEST--
+Test touch() function : usage variation - different types for atime
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. Not for Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype : bool touch(string filename [, int time [, int atime]])
+ * Description: Set modification time of file
+ * Source code: ext/standard/filestat.c
+ * Alias to functions:
+ */
+
+echo "*** Testing touch() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$filename = 'touchVar3.tmp';
+$time = 10;
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float 12.3456789000e10' => 12.3456789000e10,
+ 'float .5' => .5,
+
+ // array data
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // string data
+ 'string DQ' => "string",
+ 'string SQ' => 'string',
+ 'mixed case string' => "sTrInG",
+ 'heredoc' => $heredoc,
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for atime
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ var_dump( touch($filename, $time, $value) );
+};
+
+unlink($filename);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing touch() : usage variation ***
+
+--float 10.5--
+bool(true)
+
+--float 12.3456789000e10--
+bool(true)
+
+--float .5--
+bool(true)
+
+--empty array--
+Error: 2 - touch() expects parameter 3 to be long, array given, %s(%d)
+NULL
+
+--int indexed array--
+Error: 2 - touch() expects parameter 3 to be long, array given, %s(%d)
+NULL
+
+--associative array--
+Error: 2 - touch() expects parameter 3 to be long, array given, %s(%d)
+NULL
+
+--nested arrays--
+Error: 2 - touch() expects parameter 3 to be long, array given, %s(%d)
+NULL
+
+--uppercase NULL--
+bool(true)
+
+--lowercase null--
+bool(true)
+
+--lowercase true--
+bool(true)
+
+--lowercase false--
+bool(true)
+
+--uppercase TRUE--
+bool(true)
+
+--uppercase FALSE--
+bool(true)
+
+--empty string DQ--
+Error: 2 - touch() expects parameter 3 to be long, string given, %s(%d)
+NULL
+
+--empty string SQ--
+Error: 2 - touch() expects parameter 3 to be long, string given, %s(%d)
+NULL
+
+--string DQ--
+Error: 2 - touch() expects parameter 3 to be long, string given, %s(%d)
+NULL
+
+--string SQ--
+Error: 2 - touch() expects parameter 3 to be long, string given, %s(%d)
+NULL
+
+--mixed case string--
+Error: 2 - touch() expects parameter 3 to be long, string given, %s(%d)
+NULL
+
+--heredoc--
+Error: 2 - touch() expects parameter 3 to be long, string given, %s(%d)
+NULL
+
+--instance of classWithToString--
+Error: 2 - touch() expects parameter 3 to be long, object given, %s(%d)
+NULL
+
+--instance of classWithoutToString--
+Error: 2 - touch() expects parameter 3 to be long, object given, %s(%d)
+NULL
+
+--undefined var--
+bool(true)
+
+--unset var--
+bool(true)
+===DONE===
+
diff --git a/ext/standard/tests/file/touch_variation5-win32.phpt b/ext/standard/tests/file/touch_variation5-win32.phpt
new file mode 100644
index 0000000..92bd8b7
--- /dev/null
+++ b/ext/standard/tests/file/touch_variation5-win32.phpt
@@ -0,0 +1,230 @@
+--TEST--
+Test touch() function : variation: various valid and invalid paths
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip.. only for Windows');
+}
+--FILE--
+<?php
+/* Prototype : bool touch(string filename [, int time [, int atime]])
+ * Description: Set modification time of file
+ * Source code: ext/standard/filestat.c
+ * Alias to functions:
+ */
+
+$workDir = "touchVar5.tmp";
+$subDirOrFile = "aSubDirOrFile";
+$cwd = __DIR__;
+chdir($cwd);
+if (!mkdir($cwd . '/' . $workDir)) die("cannot create directory $workDir");
+
+$paths = array(
+ // relative
+ $workDir.'/'.$subDirOrFile,
+ './'.$workDir.'/'.$subDirOrFile,
+ $workDir.'/../'.$workDir.'/'.$subDirOrFile,
+
+ // relative bad path (note p8 msgs differ)
+ $workDir.'/../BADDIR/'.$subDirOrFile,
+ 'BADDIR/'.$subDirOrFile,
+
+ //absolute
+ $cwd.'/'.$workDir.'/'.$subDirOrFile,
+ $cwd.'/./'.$workDir.'/'.$subDirOrFile,
+ $cwd.'/'.$workDir.'/../'.$workDir.'/'.$subDirOrFile,
+
+ //absolute bad path (note p8 msgs differ)
+ $cwd.'/BADDIR/'.$subDirOrFile,
+
+ //trailing separators
+ $workDir.'/'.$subDirOrFile.'/',
+ $cwd.'/'.$workDir.'/'.$subDirOrFile.'/',
+
+ // multiple separators
+ $workDir.'//'.$subDirOrFile,
+ $cwd.'//'.$workDir.'//'.$subDirOrFile,
+
+ );
+
+echo "*** Testing touch() : variation ***\n";
+
+echo "\n*** testing nonexisting paths ***\n";
+test_nonexisting($paths);
+
+echo "\n*** testing existing files ***\n";
+test_existing($paths, false);
+
+echo "\n*** testing existing directories ***\n";
+test_existing($paths, true);
+
+
+rmdir($workDir);
+
+
+
+function test_nonexisting($paths) {
+ foreach($paths as $path) {
+ echo "--- testing $path ---\n";
+
+ if (is_dir($path) || is_file($path)) {
+ echo "FAILED: $path - exists\n";
+ }
+ else {
+ $res = touch($path);
+ if ($res === true) {
+ // something was created
+ if (file_exists($path)) {
+ // something found
+ if (is_dir($path)) {
+ echo "FAILED: $path - unexpected directory\n";
+ }
+ else {
+ echo "PASSED: $path - created\n";
+ unlink($path);
+ }
+ }
+ else {
+ // nothing found
+ echo "FAILED: $path - touch returned true, nothing there\n";
+ }
+ }
+ else {
+ // nothing created
+ if (file_exists($path)) {
+ //something found
+ echo "FAILED: $path - touch returned false, something there\n";
+ if (is_dir($path)) {
+ rmdir($path);
+ }
+ else {
+ unlink($path);
+ }
+ }
+ }
+ }
+ }
+}
+
+function test_existing($paths, $are_dirs) {
+ foreach($paths as $path) {
+ if ($are_dirs) {
+ $res = @mkdir($path);
+ if ($res == true) {
+ test_path($path);
+ rmdir($path);
+ }
+ }
+ else {
+ $h = @fopen($path,"w");
+ if ($h !== false) {
+ fclose($h);
+ test_path($path);
+ unlink($path);
+ }
+ }
+ }
+}
+
+
+function test_path($path) {
+ echo "--- testing $path ---\n";
+ $org_atime = get_atime($path);
+ clearstatcache();
+ $res = touch($path,0,0);
+ $next_atime = get_atime($path);
+ if ($next_atime == $org_atime) {
+ echo "FAILED: $path - access time not changed\n";
+ }
+ else {
+ echo "PASSED: $path - touched\n";
+ }
+}
+
+function get_atime($path) {
+ $temp = stat($path);
+ return $temp['atime'];
+}
+
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing touch() : variation ***
+
+*** testing nonexisting paths ***
+--- testing touchVar5.tmp/aSubDirOrFile ---
+PASSED: touchVar5.tmp/aSubDirOrFile - created
+--- testing ./touchVar5.tmp/aSubDirOrFile ---
+PASSED: ./touchVar5.tmp/aSubDirOrFile - created
+--- testing touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile ---
+PASSED: touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile - created
+--- testing touchVar5.tmp/../BADDIR/aSubDirOrFile ---
+
+Warning: touch(): Unable to create file touchVar5.tmp/../BADDIR/aSubDirOrFile because %s in %s on line %d
+--- testing BADDIR/aSubDirOrFile ---
+
+Warning: touch(): Unable to create file BADDIR/aSubDirOrFile because %s in %s on line %d
+--- testing %s/touchVar5.tmp/aSubDirOrFile ---
+PASSED: %s/touchVar5.tmp/aSubDirOrFile - created
+--- testing %s/./touchVar5.tmp/aSubDirOrFile ---
+PASSED: %s/./touchVar5.tmp/aSubDirOrFile - created
+--- testing %s/touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile ---
+PASSED: %s/touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile - created
+--- testing %s/BADDIR/aSubDirOrFile ---
+
+Warning: touch(): Unable to create file %s/BADDIR/aSubDirOrFile because %s in %s on line %d
+--- testing touchVar5.tmp/aSubDirOrFile/ ---
+
+Warning: touch(): Unable to create file touchVar5.tmp/aSubDirOrFile/ because Invalid argument in %s on line %d
+--- testing %s/touchVar5.tmp/aSubDirOrFile/ ---
+
+Warning: touch(): Unable to create file %s/touchVar5.tmp/aSubDirOrFile/ because Invalid argument in %s on line %d
+--- testing touchVar5.tmp//aSubDirOrFile ---
+PASSED: touchVar5.tmp//aSubDirOrFile - created
+--- testing %s//touchVar5.tmp//aSubDirOrFile ---
+PASSED: %s//touchVar5.tmp//aSubDirOrFile - created
+
+*** testing existing files ***
+--- testing touchVar5.tmp/aSubDirOrFile ---
+PASSED: touchVar5.tmp/aSubDirOrFile - touched
+--- testing ./touchVar5.tmp/aSubDirOrFile ---
+PASSED: ./touchVar5.tmp/aSubDirOrFile - touched
+--- testing touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile ---
+PASSED: touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile - touched
+--- testing %s/touchVar5.tmp/aSubDirOrFile ---
+PASSED: %s/touchVar5.tmp/aSubDirOrFile - touched
+--- testing %s/./touchVar5.tmp/aSubDirOrFile ---
+PASSED: %s/./touchVar5.tmp/aSubDirOrFile - touched
+--- testing %s/touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile ---
+PASSED: %s/touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile - touched
+--- testing touchVar5.tmp//aSubDirOrFile ---
+PASSED: touchVar5.tmp//aSubDirOrFile - touched
+--- testing %s//touchVar5.tmp//aSubDirOrFile ---
+PASSED: %s//touchVar5.tmp//aSubDirOrFile - touched
+
+*** testing existing directories ***
+--- testing touchVar5.tmp/aSubDirOrFile ---
+PASSED: touchVar5.tmp/aSubDirOrFile - touched
+--- testing ./touchVar5.tmp/aSubDirOrFile ---
+PASSED: ./touchVar5.tmp/aSubDirOrFile - touched
+--- testing touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile ---
+PASSED: touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile - touched
+--- testing %s/touchVar5.tmp/aSubDirOrFile ---
+PASSED: %s/touchVar5.tmp/aSubDirOrFile - touched
+--- testing %s/./touchVar5.tmp/aSubDirOrFile ---
+PASSED: %s/./touchVar5.tmp/aSubDirOrFile - touched
+--- testing %s/touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile ---
+PASSED: %s/touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile - touched
+--- testing touchVar5.tmp/aSubDirOrFile/ ---
+PASSED: touchVar5.tmp/aSubDirOrFile/ - touched
+--- testing %s/touchVar5.tmp/aSubDirOrFile/ ---
+PASSED: %s/touchVar5.tmp/aSubDirOrFile/ - touched
+--- testing touchVar5.tmp//aSubDirOrFile ---
+PASSED: touchVar5.tmp//aSubDirOrFile - touched
+--- testing %s//touchVar5.tmp//aSubDirOrFile ---
+PASSED: %s//touchVar5.tmp//aSubDirOrFile - touched
+===DONE===
+
diff --git a/ext/standard/tests/file/touch_variation5.phpt b/ext/standard/tests/file/touch_variation5.phpt
new file mode 100644
index 0000000..a448db3
--- /dev/null
+++ b/ext/standard/tests/file/touch_variation5.phpt
@@ -0,0 +1,230 @@
+--TEST--
+Test touch() function : variation: various valid and invalid paths
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. Not for Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype : bool touch(string filename [, int time [, int atime]])
+ * Description: Set modification time of file
+ * Source code: ext/standard/filestat.c
+ * Alias to functions:
+ */
+
+$workDir = "touchVar5.tmp";
+$subDirOrFile = "aSubDirOrFile";
+mkdir($workDir);
+$cwd = getcwd();
+
+$paths = array(
+ // relative
+ $workDir.'/'.$subDirOrFile,
+ './'.$workDir.'/'.$subDirOrFile,
+ $workDir.'/../'.$workDir.'/'.$subDirOrFile,
+
+ // relative bad path
+ $workDir.'/../BADDIR/'.$subDirOrFile,
+ 'BADDIR/'.$subDirOrFile,
+
+ //absolute
+ $cwd.'/'.$workDir.'/'.$subDirOrFile,
+ $cwd.'/./'.$workDir.'/'.$subDirOrFile,
+ $cwd.'/'.$workDir.'/../'.$workDir.'/'.$subDirOrFile,
+
+ //absolute bad path
+ $cwd.'/BADDIR/'.$subDirOrFile,
+
+ //trailing separators
+ $workDir.'/'.$subDirOrFile.'/',
+ $cwd.'/'.$workDir.'/'.$subDirOrFile.'/',
+
+ // multiple separators
+ $workDir.'//'.$subDirOrFile,
+ $cwd.'//'.$workDir.'//'.$subDirOrFile,
+
+ );
+
+echo "*** Testing touch() : variation ***\n";
+
+echo "\n*** testing nonexisting paths ***\n";
+test_nonexisting($paths);
+
+echo "\n*** testing existing files ***\n";
+test_existing($paths, false);
+
+echo "\n*** testing existing directories ***\n";
+test_existing($paths, true);
+
+
+rmdir($workDir);
+
+
+
+function test_nonexisting($paths) {
+ foreach($paths as $path) {
+ echo "--- testing $path ---\n";
+
+ if (is_dir($path) || is_file($path)) {
+ echo "FAILED: $path - exists\n";
+ }
+ else {
+ $res = touch($path);
+ if ($res === true) {
+ // something was created
+ if (file_exists($path)) {
+ // something found
+ if (is_dir($path)) {
+ echo "FAILED: $path - unexpected directory\n";
+ }
+ else {
+ echo "PASSED: $path - created\n";
+ unlink($path);
+ }
+ }
+ else {
+ // nothing found
+ echo "FAILED: $path - touch returned true, nothing there\n";
+ }
+ }
+ else {
+ // nothing created
+ if (file_exists($path)) {
+ //something found
+ echo "FAILED: $path - touch returned false, something there\n";
+ if (is_dir($path)) {
+ rmdir($path);
+ }
+ else {
+ unlink($path);
+ }
+ }
+ }
+ }
+ }
+}
+
+function test_existing($paths, $are_dirs) {
+ foreach($paths as $path) {
+ if ($are_dirs) {
+ $res = @mkdir($path);
+ if ($res == true) {
+ test_path($path);
+ rmdir($path);
+ }
+ }
+ else {
+ $h = @fopen($path,"w");
+ if ($h !== false) {
+ fclose($h);
+ test_path($path);
+ unlink($path);
+ }
+ }
+ }
+}
+
+
+function test_path($path) {
+ echo "--- testing $path ---\n";
+ $org_atime = get_atime($path);
+ clearstatcache();
+ $res = touch($path,0,0);
+ $next_atime = get_atime($path);
+ if ($next_atime == $org_atime) {
+ echo "FAILED: $path - access time not changed\n";
+ }
+ else {
+ echo "PASSED: $path - touched\n";
+ }
+}
+
+function get_atime($path) {
+ $temp = stat($path);
+ return $temp['atime'];
+}
+
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing touch() : variation ***
+
+*** testing nonexisting paths ***
+--- testing touchVar5.tmp/aSubDirOrFile ---
+PASSED: touchVar5.tmp/aSubDirOrFile - created
+--- testing ./touchVar5.tmp/aSubDirOrFile ---
+PASSED: ./touchVar5.tmp/aSubDirOrFile - created
+--- testing touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile ---
+PASSED: touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile - created
+--- testing touchVar5.tmp/../BADDIR/aSubDirOrFile ---
+
+Warning: touch(): Unable to create file touchVar5.tmp/../BADDIR/aSubDirOrFile because %s in %s on line %d
+--- testing BADDIR/aSubDirOrFile ---
+
+Warning: touch(): Unable to create file BADDIR/aSubDirOrFile because %s in %s on line %d
+--- testing /%s/touchVar5.tmp/aSubDirOrFile ---
+PASSED: /%s/touchVar5.tmp/aSubDirOrFile - created
+--- testing /%s/./touchVar5.tmp/aSubDirOrFile ---
+PASSED: /%s/./touchVar5.tmp/aSubDirOrFile - created
+--- testing /%s/touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile ---
+PASSED: /%s/touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile - created
+--- testing /%s/BADDIR/aSubDirOrFile ---
+
+Warning: touch(): Unable to create file /%s/BADDIR/aSubDirOrFile because %s in %s on line %d
+--- testing touchVar5.tmp/aSubDirOrFile/ ---
+
+Warning: touch(): Unable to create file touchVar5.tmp/aSubDirOrFile/ because %s in %s on line %d
+--- testing /%s/touchVar5.tmp/aSubDirOrFile/ ---
+
+Warning: touch(): Unable to create file /%s/touchVar5.tmp/aSubDirOrFile/ because %s in %s on line %d
+--- testing touchVar5.tmp//aSubDirOrFile ---
+PASSED: touchVar5.tmp//aSubDirOrFile - created
+--- testing /%s//touchVar5.tmp//aSubDirOrFile ---
+PASSED: /%s//touchVar5.tmp//aSubDirOrFile - created
+
+*** testing existing files ***
+--- testing touchVar5.tmp/aSubDirOrFile ---
+PASSED: touchVar5.tmp/aSubDirOrFile - touched
+--- testing ./touchVar5.tmp/aSubDirOrFile ---
+PASSED: ./touchVar5.tmp/aSubDirOrFile - touched
+--- testing touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile ---
+PASSED: touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile - touched
+--- testing /%s/touchVar5.tmp/aSubDirOrFile ---
+PASSED: /%s/touchVar5.tmp/aSubDirOrFile - touched
+--- testing /%s/./touchVar5.tmp/aSubDirOrFile ---
+PASSED: /%s/./touchVar5.tmp/aSubDirOrFile - touched
+--- testing /%s/touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile ---
+PASSED: /%s/touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile - touched
+--- testing touchVar5.tmp//aSubDirOrFile ---
+PASSED: touchVar5.tmp//aSubDirOrFile - touched
+--- testing /%s//touchVar5.tmp//aSubDirOrFile ---
+PASSED: /%s//touchVar5.tmp//aSubDirOrFile - touched
+
+*** testing existing directories ***
+--- testing touchVar5.tmp/aSubDirOrFile ---
+PASSED: touchVar5.tmp/aSubDirOrFile - touched
+--- testing ./touchVar5.tmp/aSubDirOrFile ---
+PASSED: ./touchVar5.tmp/aSubDirOrFile - touched
+--- testing touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile ---
+PASSED: touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile - touched
+--- testing /%s/touchVar5.tmp/aSubDirOrFile ---
+PASSED: /%s/touchVar5.tmp/aSubDirOrFile - touched
+--- testing /%s/./touchVar5.tmp/aSubDirOrFile ---
+PASSED: /%s/./touchVar5.tmp/aSubDirOrFile - touched
+--- testing /%s/touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile ---
+PASSED: /%s/touchVar5.tmp/../touchVar5.tmp/aSubDirOrFile - touched
+--- testing touchVar5.tmp/aSubDirOrFile/ ---
+PASSED: touchVar5.tmp/aSubDirOrFile/ - touched
+--- testing /%s/touchVar5.tmp/aSubDirOrFile/ ---
+PASSED: /%s/touchVar5.tmp/aSubDirOrFile/ - touched
+--- testing touchVar5.tmp//aSubDirOrFile ---
+PASSED: touchVar5.tmp//aSubDirOrFile - touched
+--- testing /%s//touchVar5.tmp//aSubDirOrFile ---
+PASSED: /%s//touchVar5.tmp//aSubDirOrFile - touched
+===DONE===
+
diff --git a/ext/standard/tests/file/touch_variation6-win32.phpt b/ext/standard/tests/file/touch_variation6-win32.phpt
new file mode 100644
index 0000000..625e571
--- /dev/null
+++ b/ext/standard/tests/file/touch_variation6-win32.phpt
@@ -0,0 +1,242 @@
+--TEST--
+Test touch() function : variation: various valid and invalid paths
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip.. only for Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype : bool touch(string filename [, int time [, int atime]])
+ * Description: Set modification time of file
+ * Source code: ext/standard/filestat.c
+ * Alias to functions:
+ */
+
+$workDir = "touchVar5.tmp";
+$subDirOrFile = "aSubDirOrFile";
+chdir(__DIR__);
+mkdir($workDir);
+$cwd = getcwd();
+
+$unixifiedDirOrFile = '/'.substr(str_replace('\\','/',$cwd).'/'.$workDir.'/'.$subDirOrFile, 3);
+
+$paths = array(
+ // relative
+ $workDir.'\\'.$subDirOrFile,
+ '.\\'.$workDir.'\\'.$subDirOrFile,
+ $workDir.'\\..\\'.$workDir.'\\'.$subDirOrFile,
+
+ // relative bad path (note p8 msgs differ)
+ $workDir.'\\..\\BADDIR\\'.$subDirOrFile,
+ 'BADDIR\\'.$subDirOrFile,
+
+ //absolute
+ $cwd.'\\'.$workDir.'\\'.$subDirOrFile,
+ $cwd.'\\.\\'.$workDir.'\\'.$subDirOrFile,
+ $cwd.'\\'.$workDir.'\\..\\'.$workDir.'\\'.$subDirOrFile,
+
+ //absolute bad path (note p8 msgs differ)
+ $cwd.'\\BADDIR\\'.$subDirOrFile,
+
+ //trailing separators
+ $workDir.'\\'.$subDirOrFile.'\\',
+ $cwd.'\\'.$workDir.'\\'.$subDirOrFile.'\\',
+
+ // multiple separators
+ $workDir.'\\\\'.$subDirOrFile,
+ $cwd.'\\\\'.$workDir.'\\\\'.$subDirOrFile,
+
+ // Unixified Dir Or File
+ $unixifiedDirOrFile,
+
+ );
+
+echo "*** Testing touch() : variation ***\n";
+
+echo "\n*** testing nonexisting paths ***\n";
+test_nonexisting($paths);
+
+echo "\n*** testing existing files ***\n";
+test_existing($paths, false);
+
+echo "\n*** testing existing directories ***\n";
+test_existing($paths, true);
+
+
+rmdir($workDir);
+
+
+
+function test_nonexisting($paths) {
+ foreach($paths as $path) {
+ echo "--- testing $path ---\n";
+
+ if (is_dir($path) || is_file($path)) {
+ echo "FAILED: $path - exists\n";
+ }
+ else {
+ $res = touch($path);
+ if ($res === true) {
+ // something was created
+ if (file_exists($path)) {
+ // something found
+ if (is_dir($path)) {
+ echo "FAILED: $path - unexpected directory\n";
+ }
+ else {
+ echo "PASSED: $path - created\n";
+ unlink($path);
+ }
+ }
+ else {
+ // nothing found
+ echo "FAILED: $path - touch returned true, nothing there\n";
+ }
+ }
+ else {
+ // nothing created
+ if (file_exists($path)) {
+ //something found
+ echo "FAILED: $path - touch returned false, something there\n";
+ if (is_dir($path)) {
+ rmdir($path);
+ }
+ else {
+ unlink($path);
+ }
+ }
+ }
+ }
+ }
+}
+
+function test_existing($paths, $are_dirs) {
+ foreach($paths as $path) {
+ if ($are_dirs) {
+ $res = @mkdir($path);
+ if ($res == true) {
+ test_path($path);
+ rmdir($path);
+ }
+ }
+ else {
+ $h = @fopen($path,"w");
+ if ($h !== false) {
+ fclose($h);
+ test_path($path);
+ unlink($path);
+ }
+ }
+ }
+}
+
+
+function test_path($path) {
+ echo "--- testing $path ---\n";
+ $org_atime = get_atime($path);
+ clearstatcache();
+ $res = touch($path,0,0);
+ $next_atime = get_atime($path);
+ if ($next_atime == $org_atime) {
+ echo "FAILED: $path - access time not changed\n";
+ }
+ else {
+ echo "PASSED: $path - touched\n";
+ }
+}
+
+function get_atime($path) {
+ $temp = stat($path);
+ return $temp['atime'];
+}
+
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing touch() : variation ***
+
+*** testing nonexisting paths ***
+--- testing touchVar5.tmp\aSubDirOrFile ---
+PASSED: touchVar5.tmp\aSubDirOrFile - created
+--- testing .\touchVar5.tmp\aSubDirOrFile ---
+PASSED: .\touchVar5.tmp\aSubDirOrFile - created
+--- testing touchVar5.tmp\..\touchVar5.tmp\aSubDirOrFile ---
+PASSED: touchVar5.tmp\..\touchVar5.tmp\aSubDirOrFile - created
+--- testing touchVar5.tmp\..\BADDIR\aSubDirOrFile ---
+
+Warning: touch(): Unable to create file touchVar5.tmp\..\BADDIR\aSubDirOrFile because %s in %s on line %d
+--- testing BADDIR\aSubDirOrFile ---
+
+Warning: touch(): Unable to create file BADDIR\aSubDirOrFile because %s in %s on line %d
+--- testing %s\touchVar5.tmp\aSubDirOrFile ---
+PASSED: %s\touchVar5.tmp\aSubDirOrFile - created
+--- testing %s\.\touchVar5.tmp\aSubDirOrFile ---
+PASSED: %s\.\touchVar5.tmp\aSubDirOrFile - created
+--- testing %s\touchVar5.tmp\..\touchVar5.tmp\aSubDirOrFile ---
+PASSED: %s\touchVar5.tmp\..\touchVar5.tmp\aSubDirOrFile - created
+--- testing %s\BADDIR\aSubDirOrFile ---
+
+Warning: touch(): Unable to create file %s\BADDIR\aSubDirOrFile because %s in %s on line %d
+--- testing touchVar5.tmp\aSubDirOrFile\ ---
+
+Warning: touch(): Unable to create file touchVar5.tmp\aSubDirOrFile\ because Invalid argument in %s on line %d
+--- testing %s\touchVar5.tmp\aSubDirOrFile\ ---
+
+Warning: touch(): Unable to create file %s\touchVar5.tmp\aSubDirOrFile\ because Invalid argument in %s on line %d
+--- testing touchVar5.tmp\\aSubDirOrFile ---
+PASSED: touchVar5.tmp\\aSubDirOrFile - created
+--- testing %s\\touchVar5.tmp\\aSubDirOrFile ---
+PASSED: %s\\touchVar5.tmp\\aSubDirOrFile - created
+--- testing /%s/touchVar5.tmp/aSubDirOrFile ---
+PASSED: /%s/touchVar5.tmp/aSubDirOrFile - created
+
+*** testing existing files ***
+--- testing touchVar5.tmp\aSubDirOrFile ---
+PASSED: touchVar5.tmp\aSubDirOrFile - touched
+--- testing .\touchVar5.tmp\aSubDirOrFile ---
+PASSED: .\touchVar5.tmp\aSubDirOrFile - touched
+--- testing touchVar5.tmp\..\touchVar5.tmp\aSubDirOrFile ---
+PASSED: touchVar5.tmp\..\touchVar5.tmp\aSubDirOrFile - touched
+--- testing %s\touchVar5.tmp\aSubDirOrFile ---
+PASSED: %s\touchVar5.tmp\aSubDirOrFile - touched
+--- testing %s\.\touchVar5.tmp\aSubDirOrFile ---
+PASSED: %s\.\touchVar5.tmp\aSubDirOrFile - touched
+--- testing %s\touchVar5.tmp\..\touchVar5.tmp\aSubDirOrFile ---
+PASSED: %s\touchVar5.tmp\..\touchVar5.tmp\aSubDirOrFile - touched
+--- testing touchVar5.tmp\\aSubDirOrFile ---
+PASSED: touchVar5.tmp\\aSubDirOrFile - touched
+--- testing %s\\touchVar5.tmp\\aSubDirOrFile ---
+PASSED: %s\\touchVar5.tmp\\aSubDirOrFile - touched
+--- testing /%s/touchVar5.tmp/aSubDirOrFile ---
+PASSED: /%s/touchVar5.tmp/aSubDirOrFile - touched
+
+*** testing existing directories ***
+--- testing touchVar5.tmp\aSubDirOrFile ---
+PASSED: touchVar5.tmp\aSubDirOrFile - touched
+--- testing .\touchVar5.tmp\aSubDirOrFile ---
+PASSED: .\touchVar5.tmp\aSubDirOrFile - touched
+--- testing touchVar5.tmp\..\touchVar5.tmp\aSubDirOrFile ---
+PASSED: touchVar5.tmp\..\touchVar5.tmp\aSubDirOrFile - touched
+--- testing %s\touchVar5.tmp\aSubDirOrFile ---
+PASSED: %s\touchVar5.tmp\aSubDirOrFile - touched
+--- testing %s\.\touchVar5.tmp\aSubDirOrFile ---
+PASSED: %s\.\touchVar5.tmp\aSubDirOrFile - touched
+--- testing %s\touchVar5.tmp\..\touchVar5.tmp\aSubDirOrFile ---
+PASSED: %s\touchVar5.tmp\..\touchVar5.tmp\aSubDirOrFile - touched
+--- testing touchVar5.tmp\aSubDirOrFile\ ---
+PASSED: touchVar5.tmp\aSubDirOrFile\ - touched
+--- testing %s\touchVar5.tmp\aSubDirOrFile\ ---
+PASSED: %s\touchVar5.tmp\aSubDirOrFile\ - touched
+--- testing touchVar5.tmp\\aSubDirOrFile ---
+PASSED: touchVar5.tmp\\aSubDirOrFile - touched
+--- testing %s\\touchVar5.tmp\\aSubDirOrFile ---
+PASSED: %s\\touchVar5.tmp\\aSubDirOrFile - touched
+--- testing /%s/touchVar5.tmp/aSubDirOrFile ---
+PASSED: /%s/touchVar5.tmp/aSubDirOrFile - touched
+===DONE===
+
diff --git a/ext/standard/tests/file/umask_basic.phpt b/ext/standard/tests/file/umask_basic.phpt
new file mode 100644
index 0000000..761df97
--- /dev/null
+++ b/ext/standard/tests/file/umask_basic.phpt
@@ -0,0 +1,2079 @@
+--TEST--
+Test umask() function: basic functionality
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. only for Linux');
+}
+?>
+--FILE--
+<?php
+/* Prototype: int umask ( [int $mask] );
+ Description: Changes the current umask
+*/
+
+echo "*** Testing umask() : basic functionality ***\n";
+// checking umask() on all the modes
+for($mask = 0000; $mask <= 0777; $mask++) {
+ echo "-- Setting umask to $mask --\n";
+ var_dump( umask($mask) );
+ var_dump( umask() );
+ echo "\n";
+ if ($mask != umask()) {
+ die('An error occurred while changing back the umask');
+ }
+}
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing umask() : basic functionality ***
+-- Setting umask to 0 --
+int(%d)
+int(0)
+
+-- Setting umask to 1 --
+int(0)
+int(1)
+
+-- Setting umask to 2 --
+int(1)
+int(2)
+
+-- Setting umask to 3 --
+int(2)
+int(3)
+
+-- Setting umask to 4 --
+int(3)
+int(4)
+
+-- Setting umask to 5 --
+int(4)
+int(5)
+
+-- Setting umask to 6 --
+int(5)
+int(6)
+
+-- Setting umask to 7 --
+int(6)
+int(7)
+
+-- Setting umask to 8 --
+int(7)
+int(8)
+
+-- Setting umask to 9 --
+int(8)
+int(9)
+
+-- Setting umask to 10 --
+int(9)
+int(10)
+
+-- Setting umask to 11 --
+int(10)
+int(11)
+
+-- Setting umask to 12 --
+int(11)
+int(12)
+
+-- Setting umask to 13 --
+int(12)
+int(13)
+
+-- Setting umask to 14 --
+int(13)
+int(14)
+
+-- Setting umask to 15 --
+int(14)
+int(15)
+
+-- Setting umask to 16 --
+int(15)
+int(16)
+
+-- Setting umask to 17 --
+int(16)
+int(17)
+
+-- Setting umask to 18 --
+int(17)
+int(18)
+
+-- Setting umask to 19 --
+int(18)
+int(19)
+
+-- Setting umask to 20 --
+int(19)
+int(20)
+
+-- Setting umask to 21 --
+int(20)
+int(21)
+
+-- Setting umask to 22 --
+int(21)
+int(22)
+
+-- Setting umask to 23 --
+int(22)
+int(23)
+
+-- Setting umask to 24 --
+int(23)
+int(24)
+
+-- Setting umask to 25 --
+int(24)
+int(25)
+
+-- Setting umask to 26 --
+int(25)
+int(26)
+
+-- Setting umask to 27 --
+int(26)
+int(27)
+
+-- Setting umask to 28 --
+int(27)
+int(28)
+
+-- Setting umask to 29 --
+int(28)
+int(29)
+
+-- Setting umask to 30 --
+int(29)
+int(30)
+
+-- Setting umask to 31 --
+int(30)
+int(31)
+
+-- Setting umask to 32 --
+int(31)
+int(32)
+
+-- Setting umask to 33 --
+int(32)
+int(33)
+
+-- Setting umask to 34 --
+int(33)
+int(34)
+
+-- Setting umask to 35 --
+int(34)
+int(35)
+
+-- Setting umask to 36 --
+int(35)
+int(36)
+
+-- Setting umask to 37 --
+int(36)
+int(37)
+
+-- Setting umask to 38 --
+int(37)
+int(38)
+
+-- Setting umask to 39 --
+int(38)
+int(39)
+
+-- Setting umask to 40 --
+int(39)
+int(40)
+
+-- Setting umask to 41 --
+int(40)
+int(41)
+
+-- Setting umask to 42 --
+int(41)
+int(42)
+
+-- Setting umask to 43 --
+int(42)
+int(43)
+
+-- Setting umask to 44 --
+int(43)
+int(44)
+
+-- Setting umask to 45 --
+int(44)
+int(45)
+
+-- Setting umask to 46 --
+int(45)
+int(46)
+
+-- Setting umask to 47 --
+int(46)
+int(47)
+
+-- Setting umask to 48 --
+int(47)
+int(48)
+
+-- Setting umask to 49 --
+int(48)
+int(49)
+
+-- Setting umask to 50 --
+int(49)
+int(50)
+
+-- Setting umask to 51 --
+int(50)
+int(51)
+
+-- Setting umask to 52 --
+int(51)
+int(52)
+
+-- Setting umask to 53 --
+int(52)
+int(53)
+
+-- Setting umask to 54 --
+int(53)
+int(54)
+
+-- Setting umask to 55 --
+int(54)
+int(55)
+
+-- Setting umask to 56 --
+int(55)
+int(56)
+
+-- Setting umask to 57 --
+int(56)
+int(57)
+
+-- Setting umask to 58 --
+int(57)
+int(58)
+
+-- Setting umask to 59 --
+int(58)
+int(59)
+
+-- Setting umask to 60 --
+int(59)
+int(60)
+
+-- Setting umask to 61 --
+int(60)
+int(61)
+
+-- Setting umask to 62 --
+int(61)
+int(62)
+
+-- Setting umask to 63 --
+int(62)
+int(63)
+
+-- Setting umask to 64 --
+int(63)
+int(64)
+
+-- Setting umask to 65 --
+int(64)
+int(65)
+
+-- Setting umask to 66 --
+int(65)
+int(66)
+
+-- Setting umask to 67 --
+int(66)
+int(67)
+
+-- Setting umask to 68 --
+int(67)
+int(68)
+
+-- Setting umask to 69 --
+int(68)
+int(69)
+
+-- Setting umask to 70 --
+int(69)
+int(70)
+
+-- Setting umask to 71 --
+int(70)
+int(71)
+
+-- Setting umask to 72 --
+int(71)
+int(72)
+
+-- Setting umask to 73 --
+int(72)
+int(73)
+
+-- Setting umask to 74 --
+int(73)
+int(74)
+
+-- Setting umask to 75 --
+int(74)
+int(75)
+
+-- Setting umask to 76 --
+int(75)
+int(76)
+
+-- Setting umask to 77 --
+int(76)
+int(77)
+
+-- Setting umask to 78 --
+int(77)
+int(78)
+
+-- Setting umask to 79 --
+int(78)
+int(79)
+
+-- Setting umask to 80 --
+int(79)
+int(80)
+
+-- Setting umask to 81 --
+int(80)
+int(81)
+
+-- Setting umask to 82 --
+int(81)
+int(82)
+
+-- Setting umask to 83 --
+int(82)
+int(83)
+
+-- Setting umask to 84 --
+int(83)
+int(84)
+
+-- Setting umask to 85 --
+int(84)
+int(85)
+
+-- Setting umask to 86 --
+int(85)
+int(86)
+
+-- Setting umask to 87 --
+int(86)
+int(87)
+
+-- Setting umask to 88 --
+int(87)
+int(88)
+
+-- Setting umask to 89 --
+int(88)
+int(89)
+
+-- Setting umask to 90 --
+int(89)
+int(90)
+
+-- Setting umask to 91 --
+int(90)
+int(91)
+
+-- Setting umask to 92 --
+int(91)
+int(92)
+
+-- Setting umask to 93 --
+int(92)
+int(93)
+
+-- Setting umask to 94 --
+int(93)
+int(94)
+
+-- Setting umask to 95 --
+int(94)
+int(95)
+
+-- Setting umask to 96 --
+int(95)
+int(96)
+
+-- Setting umask to 97 --
+int(96)
+int(97)
+
+-- Setting umask to 98 --
+int(97)
+int(98)
+
+-- Setting umask to 99 --
+int(98)
+int(99)
+
+-- Setting umask to 100 --
+int(99)
+int(100)
+
+-- Setting umask to 101 --
+int(100)
+int(101)
+
+-- Setting umask to 102 --
+int(101)
+int(102)
+
+-- Setting umask to 103 --
+int(102)
+int(103)
+
+-- Setting umask to 104 --
+int(103)
+int(104)
+
+-- Setting umask to 105 --
+int(104)
+int(105)
+
+-- Setting umask to 106 --
+int(105)
+int(106)
+
+-- Setting umask to 107 --
+int(106)
+int(107)
+
+-- Setting umask to 108 --
+int(107)
+int(108)
+
+-- Setting umask to 109 --
+int(108)
+int(109)
+
+-- Setting umask to 110 --
+int(109)
+int(110)
+
+-- Setting umask to 111 --
+int(110)
+int(111)
+
+-- Setting umask to 112 --
+int(111)
+int(112)
+
+-- Setting umask to 113 --
+int(112)
+int(113)
+
+-- Setting umask to 114 --
+int(113)
+int(114)
+
+-- Setting umask to 115 --
+int(114)
+int(115)
+
+-- Setting umask to 116 --
+int(115)
+int(116)
+
+-- Setting umask to 117 --
+int(116)
+int(117)
+
+-- Setting umask to 118 --
+int(117)
+int(118)
+
+-- Setting umask to 119 --
+int(118)
+int(119)
+
+-- Setting umask to 120 --
+int(119)
+int(120)
+
+-- Setting umask to 121 --
+int(120)
+int(121)
+
+-- Setting umask to 122 --
+int(121)
+int(122)
+
+-- Setting umask to 123 --
+int(122)
+int(123)
+
+-- Setting umask to 124 --
+int(123)
+int(124)
+
+-- Setting umask to 125 --
+int(124)
+int(125)
+
+-- Setting umask to 126 --
+int(125)
+int(126)
+
+-- Setting umask to 127 --
+int(126)
+int(127)
+
+-- Setting umask to 128 --
+int(127)
+int(128)
+
+-- Setting umask to 129 --
+int(128)
+int(129)
+
+-- Setting umask to 130 --
+int(129)
+int(130)
+
+-- Setting umask to 131 --
+int(130)
+int(131)
+
+-- Setting umask to 132 --
+int(131)
+int(132)
+
+-- Setting umask to 133 --
+int(132)
+int(133)
+
+-- Setting umask to 134 --
+int(133)
+int(134)
+
+-- Setting umask to 135 --
+int(134)
+int(135)
+
+-- Setting umask to 136 --
+int(135)
+int(136)
+
+-- Setting umask to 137 --
+int(136)
+int(137)
+
+-- Setting umask to 138 --
+int(137)
+int(138)
+
+-- Setting umask to 139 --
+int(138)
+int(139)
+
+-- Setting umask to 140 --
+int(139)
+int(140)
+
+-- Setting umask to 141 --
+int(140)
+int(141)
+
+-- Setting umask to 142 --
+int(141)
+int(142)
+
+-- Setting umask to 143 --
+int(142)
+int(143)
+
+-- Setting umask to 144 --
+int(143)
+int(144)
+
+-- Setting umask to 145 --
+int(144)
+int(145)
+
+-- Setting umask to 146 --
+int(145)
+int(146)
+
+-- Setting umask to 147 --
+int(146)
+int(147)
+
+-- Setting umask to 148 --
+int(147)
+int(148)
+
+-- Setting umask to 149 --
+int(148)
+int(149)
+
+-- Setting umask to 150 --
+int(149)
+int(150)
+
+-- Setting umask to 151 --
+int(150)
+int(151)
+
+-- Setting umask to 152 --
+int(151)
+int(152)
+
+-- Setting umask to 153 --
+int(152)
+int(153)
+
+-- Setting umask to 154 --
+int(153)
+int(154)
+
+-- Setting umask to 155 --
+int(154)
+int(155)
+
+-- Setting umask to 156 --
+int(155)
+int(156)
+
+-- Setting umask to 157 --
+int(156)
+int(157)
+
+-- Setting umask to 158 --
+int(157)
+int(158)
+
+-- Setting umask to 159 --
+int(158)
+int(159)
+
+-- Setting umask to 160 --
+int(159)
+int(160)
+
+-- Setting umask to 161 --
+int(160)
+int(161)
+
+-- Setting umask to 162 --
+int(161)
+int(162)
+
+-- Setting umask to 163 --
+int(162)
+int(163)
+
+-- Setting umask to 164 --
+int(163)
+int(164)
+
+-- Setting umask to 165 --
+int(164)
+int(165)
+
+-- Setting umask to 166 --
+int(165)
+int(166)
+
+-- Setting umask to 167 --
+int(166)
+int(167)
+
+-- Setting umask to 168 --
+int(167)
+int(168)
+
+-- Setting umask to 169 --
+int(168)
+int(169)
+
+-- Setting umask to 170 --
+int(169)
+int(170)
+
+-- Setting umask to 171 --
+int(170)
+int(171)
+
+-- Setting umask to 172 --
+int(171)
+int(172)
+
+-- Setting umask to 173 --
+int(172)
+int(173)
+
+-- Setting umask to 174 --
+int(173)
+int(174)
+
+-- Setting umask to 175 --
+int(174)
+int(175)
+
+-- Setting umask to 176 --
+int(175)
+int(176)
+
+-- Setting umask to 177 --
+int(176)
+int(177)
+
+-- Setting umask to 178 --
+int(177)
+int(178)
+
+-- Setting umask to 179 --
+int(178)
+int(179)
+
+-- Setting umask to 180 --
+int(179)
+int(180)
+
+-- Setting umask to 181 --
+int(180)
+int(181)
+
+-- Setting umask to 182 --
+int(181)
+int(182)
+
+-- Setting umask to 183 --
+int(182)
+int(183)
+
+-- Setting umask to 184 --
+int(183)
+int(184)
+
+-- Setting umask to 185 --
+int(184)
+int(185)
+
+-- Setting umask to 186 --
+int(185)
+int(186)
+
+-- Setting umask to 187 --
+int(186)
+int(187)
+
+-- Setting umask to 188 --
+int(187)
+int(188)
+
+-- Setting umask to 189 --
+int(188)
+int(189)
+
+-- Setting umask to 190 --
+int(189)
+int(190)
+
+-- Setting umask to 191 --
+int(190)
+int(191)
+
+-- Setting umask to 192 --
+int(191)
+int(192)
+
+-- Setting umask to 193 --
+int(192)
+int(193)
+
+-- Setting umask to 194 --
+int(193)
+int(194)
+
+-- Setting umask to 195 --
+int(194)
+int(195)
+
+-- Setting umask to 196 --
+int(195)
+int(196)
+
+-- Setting umask to 197 --
+int(196)
+int(197)
+
+-- Setting umask to 198 --
+int(197)
+int(198)
+
+-- Setting umask to 199 --
+int(198)
+int(199)
+
+-- Setting umask to 200 --
+int(199)
+int(200)
+
+-- Setting umask to 201 --
+int(200)
+int(201)
+
+-- Setting umask to 202 --
+int(201)
+int(202)
+
+-- Setting umask to 203 --
+int(202)
+int(203)
+
+-- Setting umask to 204 --
+int(203)
+int(204)
+
+-- Setting umask to 205 --
+int(204)
+int(205)
+
+-- Setting umask to 206 --
+int(205)
+int(206)
+
+-- Setting umask to 207 --
+int(206)
+int(207)
+
+-- Setting umask to 208 --
+int(207)
+int(208)
+
+-- Setting umask to 209 --
+int(208)
+int(209)
+
+-- Setting umask to 210 --
+int(209)
+int(210)
+
+-- Setting umask to 211 --
+int(210)
+int(211)
+
+-- Setting umask to 212 --
+int(211)
+int(212)
+
+-- Setting umask to 213 --
+int(212)
+int(213)
+
+-- Setting umask to 214 --
+int(213)
+int(214)
+
+-- Setting umask to 215 --
+int(214)
+int(215)
+
+-- Setting umask to 216 --
+int(215)
+int(216)
+
+-- Setting umask to 217 --
+int(216)
+int(217)
+
+-- Setting umask to 218 --
+int(217)
+int(218)
+
+-- Setting umask to 219 --
+int(218)
+int(219)
+
+-- Setting umask to 220 --
+int(219)
+int(220)
+
+-- Setting umask to 221 --
+int(220)
+int(221)
+
+-- Setting umask to 222 --
+int(221)
+int(222)
+
+-- Setting umask to 223 --
+int(222)
+int(223)
+
+-- Setting umask to 224 --
+int(223)
+int(224)
+
+-- Setting umask to 225 --
+int(224)
+int(225)
+
+-- Setting umask to 226 --
+int(225)
+int(226)
+
+-- Setting umask to 227 --
+int(226)
+int(227)
+
+-- Setting umask to 228 --
+int(227)
+int(228)
+
+-- Setting umask to 229 --
+int(228)
+int(229)
+
+-- Setting umask to 230 --
+int(229)
+int(230)
+
+-- Setting umask to 231 --
+int(230)
+int(231)
+
+-- Setting umask to 232 --
+int(231)
+int(232)
+
+-- Setting umask to 233 --
+int(232)
+int(233)
+
+-- Setting umask to 234 --
+int(233)
+int(234)
+
+-- Setting umask to 235 --
+int(234)
+int(235)
+
+-- Setting umask to 236 --
+int(235)
+int(236)
+
+-- Setting umask to 237 --
+int(236)
+int(237)
+
+-- Setting umask to 238 --
+int(237)
+int(238)
+
+-- Setting umask to 239 --
+int(238)
+int(239)
+
+-- Setting umask to 240 --
+int(239)
+int(240)
+
+-- Setting umask to 241 --
+int(240)
+int(241)
+
+-- Setting umask to 242 --
+int(241)
+int(242)
+
+-- Setting umask to 243 --
+int(242)
+int(243)
+
+-- Setting umask to 244 --
+int(243)
+int(244)
+
+-- Setting umask to 245 --
+int(244)
+int(245)
+
+-- Setting umask to 246 --
+int(245)
+int(246)
+
+-- Setting umask to 247 --
+int(246)
+int(247)
+
+-- Setting umask to 248 --
+int(247)
+int(248)
+
+-- Setting umask to 249 --
+int(248)
+int(249)
+
+-- Setting umask to 250 --
+int(249)
+int(250)
+
+-- Setting umask to 251 --
+int(250)
+int(251)
+
+-- Setting umask to 252 --
+int(251)
+int(252)
+
+-- Setting umask to 253 --
+int(252)
+int(253)
+
+-- Setting umask to 254 --
+int(253)
+int(254)
+
+-- Setting umask to 255 --
+int(254)
+int(255)
+
+-- Setting umask to 256 --
+int(255)
+int(256)
+
+-- Setting umask to 257 --
+int(256)
+int(257)
+
+-- Setting umask to 258 --
+int(257)
+int(258)
+
+-- Setting umask to 259 --
+int(258)
+int(259)
+
+-- Setting umask to 260 --
+int(259)
+int(260)
+
+-- Setting umask to 261 --
+int(260)
+int(261)
+
+-- Setting umask to 262 --
+int(261)
+int(262)
+
+-- Setting umask to 263 --
+int(262)
+int(263)
+
+-- Setting umask to 264 --
+int(263)
+int(264)
+
+-- Setting umask to 265 --
+int(264)
+int(265)
+
+-- Setting umask to 266 --
+int(265)
+int(266)
+
+-- Setting umask to 267 --
+int(266)
+int(267)
+
+-- Setting umask to 268 --
+int(267)
+int(268)
+
+-- Setting umask to 269 --
+int(268)
+int(269)
+
+-- Setting umask to 270 --
+int(269)
+int(270)
+
+-- Setting umask to 271 --
+int(270)
+int(271)
+
+-- Setting umask to 272 --
+int(271)
+int(272)
+
+-- Setting umask to 273 --
+int(272)
+int(273)
+
+-- Setting umask to 274 --
+int(273)
+int(274)
+
+-- Setting umask to 275 --
+int(274)
+int(275)
+
+-- Setting umask to 276 --
+int(275)
+int(276)
+
+-- Setting umask to 277 --
+int(276)
+int(277)
+
+-- Setting umask to 278 --
+int(277)
+int(278)
+
+-- Setting umask to 279 --
+int(278)
+int(279)
+
+-- Setting umask to 280 --
+int(279)
+int(280)
+
+-- Setting umask to 281 --
+int(280)
+int(281)
+
+-- Setting umask to 282 --
+int(281)
+int(282)
+
+-- Setting umask to 283 --
+int(282)
+int(283)
+
+-- Setting umask to 284 --
+int(283)
+int(284)
+
+-- Setting umask to 285 --
+int(284)
+int(285)
+
+-- Setting umask to 286 --
+int(285)
+int(286)
+
+-- Setting umask to 287 --
+int(286)
+int(287)
+
+-- Setting umask to 288 --
+int(287)
+int(288)
+
+-- Setting umask to 289 --
+int(288)
+int(289)
+
+-- Setting umask to 290 --
+int(289)
+int(290)
+
+-- Setting umask to 291 --
+int(290)
+int(291)
+
+-- Setting umask to 292 --
+int(291)
+int(292)
+
+-- Setting umask to 293 --
+int(292)
+int(293)
+
+-- Setting umask to 294 --
+int(293)
+int(294)
+
+-- Setting umask to 295 --
+int(294)
+int(295)
+
+-- Setting umask to 296 --
+int(295)
+int(296)
+
+-- Setting umask to 297 --
+int(296)
+int(297)
+
+-- Setting umask to 298 --
+int(297)
+int(298)
+
+-- Setting umask to 299 --
+int(298)
+int(299)
+
+-- Setting umask to 300 --
+int(299)
+int(300)
+
+-- Setting umask to 301 --
+int(300)
+int(301)
+
+-- Setting umask to 302 --
+int(301)
+int(302)
+
+-- Setting umask to 303 --
+int(302)
+int(303)
+
+-- Setting umask to 304 --
+int(303)
+int(304)
+
+-- Setting umask to 305 --
+int(304)
+int(305)
+
+-- Setting umask to 306 --
+int(305)
+int(306)
+
+-- Setting umask to 307 --
+int(306)
+int(307)
+
+-- Setting umask to 308 --
+int(307)
+int(308)
+
+-- Setting umask to 309 --
+int(308)
+int(309)
+
+-- Setting umask to 310 --
+int(309)
+int(310)
+
+-- Setting umask to 311 --
+int(310)
+int(311)
+
+-- Setting umask to 312 --
+int(311)
+int(312)
+
+-- Setting umask to 313 --
+int(312)
+int(313)
+
+-- Setting umask to 314 --
+int(313)
+int(314)
+
+-- Setting umask to 315 --
+int(314)
+int(315)
+
+-- Setting umask to 316 --
+int(315)
+int(316)
+
+-- Setting umask to 317 --
+int(316)
+int(317)
+
+-- Setting umask to 318 --
+int(317)
+int(318)
+
+-- Setting umask to 319 --
+int(318)
+int(319)
+
+-- Setting umask to 320 --
+int(319)
+int(320)
+
+-- Setting umask to 321 --
+int(320)
+int(321)
+
+-- Setting umask to 322 --
+int(321)
+int(322)
+
+-- Setting umask to 323 --
+int(322)
+int(323)
+
+-- Setting umask to 324 --
+int(323)
+int(324)
+
+-- Setting umask to 325 --
+int(324)
+int(325)
+
+-- Setting umask to 326 --
+int(325)
+int(326)
+
+-- Setting umask to 327 --
+int(326)
+int(327)
+
+-- Setting umask to 328 --
+int(327)
+int(328)
+
+-- Setting umask to 329 --
+int(328)
+int(329)
+
+-- Setting umask to 330 --
+int(329)
+int(330)
+
+-- Setting umask to 331 --
+int(330)
+int(331)
+
+-- Setting umask to 332 --
+int(331)
+int(332)
+
+-- Setting umask to 333 --
+int(332)
+int(333)
+
+-- Setting umask to 334 --
+int(333)
+int(334)
+
+-- Setting umask to 335 --
+int(334)
+int(335)
+
+-- Setting umask to 336 --
+int(335)
+int(336)
+
+-- Setting umask to 337 --
+int(336)
+int(337)
+
+-- Setting umask to 338 --
+int(337)
+int(338)
+
+-- Setting umask to 339 --
+int(338)
+int(339)
+
+-- Setting umask to 340 --
+int(339)
+int(340)
+
+-- Setting umask to 341 --
+int(340)
+int(341)
+
+-- Setting umask to 342 --
+int(341)
+int(342)
+
+-- Setting umask to 343 --
+int(342)
+int(343)
+
+-- Setting umask to 344 --
+int(343)
+int(344)
+
+-- Setting umask to 345 --
+int(344)
+int(345)
+
+-- Setting umask to 346 --
+int(345)
+int(346)
+
+-- Setting umask to 347 --
+int(346)
+int(347)
+
+-- Setting umask to 348 --
+int(347)
+int(348)
+
+-- Setting umask to 349 --
+int(348)
+int(349)
+
+-- Setting umask to 350 --
+int(349)
+int(350)
+
+-- Setting umask to 351 --
+int(350)
+int(351)
+
+-- Setting umask to 352 --
+int(351)
+int(352)
+
+-- Setting umask to 353 --
+int(352)
+int(353)
+
+-- Setting umask to 354 --
+int(353)
+int(354)
+
+-- Setting umask to 355 --
+int(354)
+int(355)
+
+-- Setting umask to 356 --
+int(355)
+int(356)
+
+-- Setting umask to 357 --
+int(356)
+int(357)
+
+-- Setting umask to 358 --
+int(357)
+int(358)
+
+-- Setting umask to 359 --
+int(358)
+int(359)
+
+-- Setting umask to 360 --
+int(359)
+int(360)
+
+-- Setting umask to 361 --
+int(360)
+int(361)
+
+-- Setting umask to 362 --
+int(361)
+int(362)
+
+-- Setting umask to 363 --
+int(362)
+int(363)
+
+-- Setting umask to 364 --
+int(363)
+int(364)
+
+-- Setting umask to 365 --
+int(364)
+int(365)
+
+-- Setting umask to 366 --
+int(365)
+int(366)
+
+-- Setting umask to 367 --
+int(366)
+int(367)
+
+-- Setting umask to 368 --
+int(367)
+int(368)
+
+-- Setting umask to 369 --
+int(368)
+int(369)
+
+-- Setting umask to 370 --
+int(369)
+int(370)
+
+-- Setting umask to 371 --
+int(370)
+int(371)
+
+-- Setting umask to 372 --
+int(371)
+int(372)
+
+-- Setting umask to 373 --
+int(372)
+int(373)
+
+-- Setting umask to 374 --
+int(373)
+int(374)
+
+-- Setting umask to 375 --
+int(374)
+int(375)
+
+-- Setting umask to 376 --
+int(375)
+int(376)
+
+-- Setting umask to 377 --
+int(376)
+int(377)
+
+-- Setting umask to 378 --
+int(377)
+int(378)
+
+-- Setting umask to 379 --
+int(378)
+int(379)
+
+-- Setting umask to 380 --
+int(379)
+int(380)
+
+-- Setting umask to 381 --
+int(380)
+int(381)
+
+-- Setting umask to 382 --
+int(381)
+int(382)
+
+-- Setting umask to 383 --
+int(382)
+int(383)
+
+-- Setting umask to 384 --
+int(383)
+int(384)
+
+-- Setting umask to 385 --
+int(384)
+int(385)
+
+-- Setting umask to 386 --
+int(385)
+int(386)
+
+-- Setting umask to 387 --
+int(386)
+int(387)
+
+-- Setting umask to 388 --
+int(387)
+int(388)
+
+-- Setting umask to 389 --
+int(388)
+int(389)
+
+-- Setting umask to 390 --
+int(389)
+int(390)
+
+-- Setting umask to 391 --
+int(390)
+int(391)
+
+-- Setting umask to 392 --
+int(391)
+int(392)
+
+-- Setting umask to 393 --
+int(392)
+int(393)
+
+-- Setting umask to 394 --
+int(393)
+int(394)
+
+-- Setting umask to 395 --
+int(394)
+int(395)
+
+-- Setting umask to 396 --
+int(395)
+int(396)
+
+-- Setting umask to 397 --
+int(396)
+int(397)
+
+-- Setting umask to 398 --
+int(397)
+int(398)
+
+-- Setting umask to 399 --
+int(398)
+int(399)
+
+-- Setting umask to 400 --
+int(399)
+int(400)
+
+-- Setting umask to 401 --
+int(400)
+int(401)
+
+-- Setting umask to 402 --
+int(401)
+int(402)
+
+-- Setting umask to 403 --
+int(402)
+int(403)
+
+-- Setting umask to 404 --
+int(403)
+int(404)
+
+-- Setting umask to 405 --
+int(404)
+int(405)
+
+-- Setting umask to 406 --
+int(405)
+int(406)
+
+-- Setting umask to 407 --
+int(406)
+int(407)
+
+-- Setting umask to 408 --
+int(407)
+int(408)
+
+-- Setting umask to 409 --
+int(408)
+int(409)
+
+-- Setting umask to 410 --
+int(409)
+int(410)
+
+-- Setting umask to 411 --
+int(410)
+int(411)
+
+-- Setting umask to 412 --
+int(411)
+int(412)
+
+-- Setting umask to 413 --
+int(412)
+int(413)
+
+-- Setting umask to 414 --
+int(413)
+int(414)
+
+-- Setting umask to 415 --
+int(414)
+int(415)
+
+-- Setting umask to 416 --
+int(415)
+int(416)
+
+-- Setting umask to 417 --
+int(416)
+int(417)
+
+-- Setting umask to 418 --
+int(417)
+int(418)
+
+-- Setting umask to 419 --
+int(418)
+int(419)
+
+-- Setting umask to 420 --
+int(419)
+int(420)
+
+-- Setting umask to 421 --
+int(420)
+int(421)
+
+-- Setting umask to 422 --
+int(421)
+int(422)
+
+-- Setting umask to 423 --
+int(422)
+int(423)
+
+-- Setting umask to 424 --
+int(423)
+int(424)
+
+-- Setting umask to 425 --
+int(424)
+int(425)
+
+-- Setting umask to 426 --
+int(425)
+int(426)
+
+-- Setting umask to 427 --
+int(426)
+int(427)
+
+-- Setting umask to 428 --
+int(427)
+int(428)
+
+-- Setting umask to 429 --
+int(428)
+int(429)
+
+-- Setting umask to 430 --
+int(429)
+int(430)
+
+-- Setting umask to 431 --
+int(430)
+int(431)
+
+-- Setting umask to 432 --
+int(431)
+int(432)
+
+-- Setting umask to 433 --
+int(432)
+int(433)
+
+-- Setting umask to 434 --
+int(433)
+int(434)
+
+-- Setting umask to 435 --
+int(434)
+int(435)
+
+-- Setting umask to 436 --
+int(435)
+int(436)
+
+-- Setting umask to 437 --
+int(436)
+int(437)
+
+-- Setting umask to 438 --
+int(437)
+int(438)
+
+-- Setting umask to 439 --
+int(438)
+int(439)
+
+-- Setting umask to 440 --
+int(439)
+int(440)
+
+-- Setting umask to 441 --
+int(440)
+int(441)
+
+-- Setting umask to 442 --
+int(441)
+int(442)
+
+-- Setting umask to 443 --
+int(442)
+int(443)
+
+-- Setting umask to 444 --
+int(443)
+int(444)
+
+-- Setting umask to 445 --
+int(444)
+int(445)
+
+-- Setting umask to 446 --
+int(445)
+int(446)
+
+-- Setting umask to 447 --
+int(446)
+int(447)
+
+-- Setting umask to 448 --
+int(447)
+int(448)
+
+-- Setting umask to 449 --
+int(448)
+int(449)
+
+-- Setting umask to 450 --
+int(449)
+int(450)
+
+-- Setting umask to 451 --
+int(450)
+int(451)
+
+-- Setting umask to 452 --
+int(451)
+int(452)
+
+-- Setting umask to 453 --
+int(452)
+int(453)
+
+-- Setting umask to 454 --
+int(453)
+int(454)
+
+-- Setting umask to 455 --
+int(454)
+int(455)
+
+-- Setting umask to 456 --
+int(455)
+int(456)
+
+-- Setting umask to 457 --
+int(456)
+int(457)
+
+-- Setting umask to 458 --
+int(457)
+int(458)
+
+-- Setting umask to 459 --
+int(458)
+int(459)
+
+-- Setting umask to 460 --
+int(459)
+int(460)
+
+-- Setting umask to 461 --
+int(460)
+int(461)
+
+-- Setting umask to 462 --
+int(461)
+int(462)
+
+-- Setting umask to 463 --
+int(462)
+int(463)
+
+-- Setting umask to 464 --
+int(463)
+int(464)
+
+-- Setting umask to 465 --
+int(464)
+int(465)
+
+-- Setting umask to 466 --
+int(465)
+int(466)
+
+-- Setting umask to 467 --
+int(466)
+int(467)
+
+-- Setting umask to 468 --
+int(467)
+int(468)
+
+-- Setting umask to 469 --
+int(468)
+int(469)
+
+-- Setting umask to 470 --
+int(469)
+int(470)
+
+-- Setting umask to 471 --
+int(470)
+int(471)
+
+-- Setting umask to 472 --
+int(471)
+int(472)
+
+-- Setting umask to 473 --
+int(472)
+int(473)
+
+-- Setting umask to 474 --
+int(473)
+int(474)
+
+-- Setting umask to 475 --
+int(474)
+int(475)
+
+-- Setting umask to 476 --
+int(475)
+int(476)
+
+-- Setting umask to 477 --
+int(476)
+int(477)
+
+-- Setting umask to 478 --
+int(477)
+int(478)
+
+-- Setting umask to 479 --
+int(478)
+int(479)
+
+-- Setting umask to 480 --
+int(479)
+int(480)
+
+-- Setting umask to 481 --
+int(480)
+int(481)
+
+-- Setting umask to 482 --
+int(481)
+int(482)
+
+-- Setting umask to 483 --
+int(482)
+int(483)
+
+-- Setting umask to 484 --
+int(483)
+int(484)
+
+-- Setting umask to 485 --
+int(484)
+int(485)
+
+-- Setting umask to 486 --
+int(485)
+int(486)
+
+-- Setting umask to 487 --
+int(486)
+int(487)
+
+-- Setting umask to 488 --
+int(487)
+int(488)
+
+-- Setting umask to 489 --
+int(488)
+int(489)
+
+-- Setting umask to 490 --
+int(489)
+int(490)
+
+-- Setting umask to 491 --
+int(490)
+int(491)
+
+-- Setting umask to 492 --
+int(491)
+int(492)
+
+-- Setting umask to 493 --
+int(492)
+int(493)
+
+-- Setting umask to 494 --
+int(493)
+int(494)
+
+-- Setting umask to 495 --
+int(494)
+int(495)
+
+-- Setting umask to 496 --
+int(495)
+int(496)
+
+-- Setting umask to 497 --
+int(496)
+int(497)
+
+-- Setting umask to 498 --
+int(497)
+int(498)
+
+-- Setting umask to 499 --
+int(498)
+int(499)
+
+-- Setting umask to 500 --
+int(499)
+int(500)
+
+-- Setting umask to 501 --
+int(500)
+int(501)
+
+-- Setting umask to 502 --
+int(501)
+int(502)
+
+-- Setting umask to 503 --
+int(502)
+int(503)
+
+-- Setting umask to 504 --
+int(503)
+int(504)
+
+-- Setting umask to 505 --
+int(504)
+int(505)
+
+-- Setting umask to 506 --
+int(505)
+int(506)
+
+-- Setting umask to 507 --
+int(506)
+int(507)
+
+-- Setting umask to 508 --
+int(507)
+int(508)
+
+-- Setting umask to 509 --
+int(508)
+int(509)
+
+-- Setting umask to 510 --
+int(509)
+int(510)
+
+-- Setting umask to 511 --
+int(510)
+int(511)
+
+Done
diff --git a/ext/standard/tests/file/umask_error.phpt b/ext/standard/tests/file/umask_error.phpt
new file mode 100644
index 0000000..ddf60ab
--- /dev/null
+++ b/ext/standard/tests/file/umask_error.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Test umask() function: error conditions
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. only for Linux');
+}
+?>
+--FILE--
+<?php
+/* Prototype: int umask ( [int $mask] );
+ Description: Changes the current umask
+*/
+
+echo "*** Testing umask() : error conditions ***\n";
+
+var_dump( umask(0000, true) ); // args > expected
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing umask() : error conditions ***
+
+Warning: umask() expects at most 1 parameter, 2 given in %s on line %d
+bool(false)
+Done
diff --git a/ext/standard/tests/file/umask_variation1.phpt b/ext/standard/tests/file/umask_variation1.phpt
new file mode 100644
index 0000000..29fe92e
--- /dev/null
+++ b/ext/standard/tests/file/umask_variation1.phpt
@@ -0,0 +1,761 @@
+--TEST--
+Test umask() function: usage variations - perms from 0000 to 0350
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. only on Linux');
+}
+?>
+--FILE--
+<?php
+/* Prototype: int umask ( [int $mask] );
+ Description: Changes the current umask
+*/
+
+$file_path = dirname(__FILE__);
+
+/* Check umask() on file/dir */
+
+echo "*** Testing umask() on file and directory ***\n";
+// temp filename used
+$filename = "$file_path/umask_variation1.tmp";
+// temp dir used
+$dirname = "$file_path/umask_variation1";
+
+for($mask = 0000; $mask <= 0350; $mask++) {
+ echo "-- Setting umask to ";
+ echo sprintf('%03o', $mask);
+ echo " --\n";
+ // setting umask
+ umask($mask);
+
+ /* umasking file */
+ // creating temp file
+ $fp = fopen($filename, "w");
+ fclose($fp);
+ echo "File permission : ";
+ // check file permission
+ echo substr(sprintf('%o', fileperms($filename)), -3);
+ echo "\n";
+ // chmod file to 0777 to enable deletion
+ chmod($filename, 0777);
+ // delete temp file created here
+ unlink($filename);
+
+ /* umasking directory */
+ // create temp dir
+ mkdir($dirname);
+ echo "Directory permission : ";
+ // check $dirname permission
+ echo substr(sprintf('%o', fileperms($dirname)), -3);
+ echo "\n";
+ // chmod 0777 to enable deletion
+ chmod($dirname, 0777);
+ // delete temp dir created
+ rmdir($dirname);
+}
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing umask() on file and directory ***
+-- Setting umask to 000 --
+File permission : 666
+Directory permission : 777
+-- Setting umask to 001 --
+File permission : 666
+Directory permission : 776
+-- Setting umask to 002 --
+File permission : 664
+Directory permission : 775
+-- Setting umask to 003 --
+File permission : 664
+Directory permission : 774
+-- Setting umask to 004 --
+File permission : 662
+Directory permission : 773
+-- Setting umask to 005 --
+File permission : 662
+Directory permission : 772
+-- Setting umask to 006 --
+File permission : 660
+Directory permission : 771
+-- Setting umask to 007 --
+File permission : 660
+Directory permission : 770
+-- Setting umask to 010 --
+File permission : 666
+Directory permission : 767
+-- Setting umask to 011 --
+File permission : 666
+Directory permission : 766
+-- Setting umask to 012 --
+File permission : 664
+Directory permission : 765
+-- Setting umask to 013 --
+File permission : 664
+Directory permission : 764
+-- Setting umask to 014 --
+File permission : 662
+Directory permission : 763
+-- Setting umask to 015 --
+File permission : 662
+Directory permission : 762
+-- Setting umask to 016 --
+File permission : 660
+Directory permission : 761
+-- Setting umask to 017 --
+File permission : 660
+Directory permission : 760
+-- Setting umask to 020 --
+File permission : 646
+Directory permission : 757
+-- Setting umask to 021 --
+File permission : 646
+Directory permission : 756
+-- Setting umask to 022 --
+File permission : 644
+Directory permission : 755
+-- Setting umask to 023 --
+File permission : 644
+Directory permission : 754
+-- Setting umask to 024 --
+File permission : 642
+Directory permission : 753
+-- Setting umask to 025 --
+File permission : 642
+Directory permission : 752
+-- Setting umask to 026 --
+File permission : 640
+Directory permission : 751
+-- Setting umask to 027 --
+File permission : 640
+Directory permission : 750
+-- Setting umask to 030 --
+File permission : 646
+Directory permission : 747
+-- Setting umask to 031 --
+File permission : 646
+Directory permission : 746
+-- Setting umask to 032 --
+File permission : 644
+Directory permission : 745
+-- Setting umask to 033 --
+File permission : 644
+Directory permission : 744
+-- Setting umask to 034 --
+File permission : 642
+Directory permission : 743
+-- Setting umask to 035 --
+File permission : 642
+Directory permission : 742
+-- Setting umask to 036 --
+File permission : 640
+Directory permission : 741
+-- Setting umask to 037 --
+File permission : 640
+Directory permission : 740
+-- Setting umask to 040 --
+File permission : 626
+Directory permission : 737
+-- Setting umask to 041 --
+File permission : 626
+Directory permission : 736
+-- Setting umask to 042 --
+File permission : 624
+Directory permission : 735
+-- Setting umask to 043 --
+File permission : 624
+Directory permission : 734
+-- Setting umask to 044 --
+File permission : 622
+Directory permission : 733
+-- Setting umask to 045 --
+File permission : 622
+Directory permission : 732
+-- Setting umask to 046 --
+File permission : 620
+Directory permission : 731
+-- Setting umask to 047 --
+File permission : 620
+Directory permission : 730
+-- Setting umask to 050 --
+File permission : 626
+Directory permission : 727
+-- Setting umask to 051 --
+File permission : 626
+Directory permission : 726
+-- Setting umask to 052 --
+File permission : 624
+Directory permission : 725
+-- Setting umask to 053 --
+File permission : 624
+Directory permission : 724
+-- Setting umask to 054 --
+File permission : 622
+Directory permission : 723
+-- Setting umask to 055 --
+File permission : 622
+Directory permission : 722
+-- Setting umask to 056 --
+File permission : 620
+Directory permission : 721
+-- Setting umask to 057 --
+File permission : 620
+Directory permission : 720
+-- Setting umask to 060 --
+File permission : 606
+Directory permission : 717
+-- Setting umask to 061 --
+File permission : 606
+Directory permission : 716
+-- Setting umask to 062 --
+File permission : 604
+Directory permission : 715
+-- Setting umask to 063 --
+File permission : 604
+Directory permission : 714
+-- Setting umask to 064 --
+File permission : 602
+Directory permission : 713
+-- Setting umask to 065 --
+File permission : 602
+Directory permission : 712
+-- Setting umask to 066 --
+File permission : 600
+Directory permission : 711
+-- Setting umask to 067 --
+File permission : 600
+Directory permission : 710
+-- Setting umask to 070 --
+File permission : 606
+Directory permission : 707
+-- Setting umask to 071 --
+File permission : 606
+Directory permission : 706
+-- Setting umask to 072 --
+File permission : 604
+Directory permission : 705
+-- Setting umask to 073 --
+File permission : 604
+Directory permission : 704
+-- Setting umask to 074 --
+File permission : 602
+Directory permission : 703
+-- Setting umask to 075 --
+File permission : 602
+Directory permission : 702
+-- Setting umask to 076 --
+File permission : 600
+Directory permission : 701
+-- Setting umask to 077 --
+File permission : 600
+Directory permission : 700
+-- Setting umask to 100 --
+File permission : 666
+Directory permission : 677
+-- Setting umask to 101 --
+File permission : 666
+Directory permission : 676
+-- Setting umask to 102 --
+File permission : 664
+Directory permission : 675
+-- Setting umask to 103 --
+File permission : 664
+Directory permission : 674
+-- Setting umask to 104 --
+File permission : 662
+Directory permission : 673
+-- Setting umask to 105 --
+File permission : 662
+Directory permission : 672
+-- Setting umask to 106 --
+File permission : 660
+Directory permission : 671
+-- Setting umask to 107 --
+File permission : 660
+Directory permission : 670
+-- Setting umask to 110 --
+File permission : 666
+Directory permission : 667
+-- Setting umask to 111 --
+File permission : 666
+Directory permission : 666
+-- Setting umask to 112 --
+File permission : 664
+Directory permission : 665
+-- Setting umask to 113 --
+File permission : 664
+Directory permission : 664
+-- Setting umask to 114 --
+File permission : 662
+Directory permission : 663
+-- Setting umask to 115 --
+File permission : 662
+Directory permission : 662
+-- Setting umask to 116 --
+File permission : 660
+Directory permission : 661
+-- Setting umask to 117 --
+File permission : 660
+Directory permission : 660
+-- Setting umask to 120 --
+File permission : 646
+Directory permission : 657
+-- Setting umask to 121 --
+File permission : 646
+Directory permission : 656
+-- Setting umask to 122 --
+File permission : 644
+Directory permission : 655
+-- Setting umask to 123 --
+File permission : 644
+Directory permission : 654
+-- Setting umask to 124 --
+File permission : 642
+Directory permission : 653
+-- Setting umask to 125 --
+File permission : 642
+Directory permission : 652
+-- Setting umask to 126 --
+File permission : 640
+Directory permission : 651
+-- Setting umask to 127 --
+File permission : 640
+Directory permission : 650
+-- Setting umask to 130 --
+File permission : 646
+Directory permission : 647
+-- Setting umask to 131 --
+File permission : 646
+Directory permission : 646
+-- Setting umask to 132 --
+File permission : 644
+Directory permission : 645
+-- Setting umask to 133 --
+File permission : 644
+Directory permission : 644
+-- Setting umask to 134 --
+File permission : 642
+Directory permission : 643
+-- Setting umask to 135 --
+File permission : 642
+Directory permission : 642
+-- Setting umask to 136 --
+File permission : 640
+Directory permission : 641
+-- Setting umask to 137 --
+File permission : 640
+Directory permission : 640
+-- Setting umask to 140 --
+File permission : 626
+Directory permission : 637
+-- Setting umask to 141 --
+File permission : 626
+Directory permission : 636
+-- Setting umask to 142 --
+File permission : 624
+Directory permission : 635
+-- Setting umask to 143 --
+File permission : 624
+Directory permission : 634
+-- Setting umask to 144 --
+File permission : 622
+Directory permission : 633
+-- Setting umask to 145 --
+File permission : 622
+Directory permission : 632
+-- Setting umask to 146 --
+File permission : 620
+Directory permission : 631
+-- Setting umask to 147 --
+File permission : 620
+Directory permission : 630
+-- Setting umask to 150 --
+File permission : 626
+Directory permission : 627
+-- Setting umask to 151 --
+File permission : 626
+Directory permission : 626
+-- Setting umask to 152 --
+File permission : 624
+Directory permission : 625
+-- Setting umask to 153 --
+File permission : 624
+Directory permission : 624
+-- Setting umask to 154 --
+File permission : 622
+Directory permission : 623
+-- Setting umask to 155 --
+File permission : 622
+Directory permission : 622
+-- Setting umask to 156 --
+File permission : 620
+Directory permission : 621
+-- Setting umask to 157 --
+File permission : 620
+Directory permission : 620
+-- Setting umask to 160 --
+File permission : 606
+Directory permission : 617
+-- Setting umask to 161 --
+File permission : 606
+Directory permission : 616
+-- Setting umask to 162 --
+File permission : 604
+Directory permission : 615
+-- Setting umask to 163 --
+File permission : 604
+Directory permission : 614
+-- Setting umask to 164 --
+File permission : 602
+Directory permission : 613
+-- Setting umask to 165 --
+File permission : 602
+Directory permission : 612
+-- Setting umask to 166 --
+File permission : 600
+Directory permission : 611
+-- Setting umask to 167 --
+File permission : 600
+Directory permission : 610
+-- Setting umask to 170 --
+File permission : 606
+Directory permission : 607
+-- Setting umask to 171 --
+File permission : 606
+Directory permission : 606
+-- Setting umask to 172 --
+File permission : 604
+Directory permission : 605
+-- Setting umask to 173 --
+File permission : 604
+Directory permission : 604
+-- Setting umask to 174 --
+File permission : 602
+Directory permission : 603
+-- Setting umask to 175 --
+File permission : 602
+Directory permission : 602
+-- Setting umask to 176 --
+File permission : 600
+Directory permission : 601
+-- Setting umask to 177 --
+File permission : 600
+Directory permission : 600
+-- Setting umask to 200 --
+File permission : 466
+Directory permission : 577
+-- Setting umask to 201 --
+File permission : 466
+Directory permission : 576
+-- Setting umask to 202 --
+File permission : 464
+Directory permission : 575
+-- Setting umask to 203 --
+File permission : 464
+Directory permission : 574
+-- Setting umask to 204 --
+File permission : 462
+Directory permission : 573
+-- Setting umask to 205 --
+File permission : 462
+Directory permission : 572
+-- Setting umask to 206 --
+File permission : 460
+Directory permission : 571
+-- Setting umask to 207 --
+File permission : 460
+Directory permission : 570
+-- Setting umask to 210 --
+File permission : 466
+Directory permission : 567
+-- Setting umask to 211 --
+File permission : 466
+Directory permission : 566
+-- Setting umask to 212 --
+File permission : 464
+Directory permission : 565
+-- Setting umask to 213 --
+File permission : 464
+Directory permission : 564
+-- Setting umask to 214 --
+File permission : 462
+Directory permission : 563
+-- Setting umask to 215 --
+File permission : 462
+Directory permission : 562
+-- Setting umask to 216 --
+File permission : 460
+Directory permission : 561
+-- Setting umask to 217 --
+File permission : 460
+Directory permission : 560
+-- Setting umask to 220 --
+File permission : 446
+Directory permission : 557
+-- Setting umask to 221 --
+File permission : 446
+Directory permission : 556
+-- Setting umask to 222 --
+File permission : 444
+Directory permission : 555
+-- Setting umask to 223 --
+File permission : 444
+Directory permission : 554
+-- Setting umask to 224 --
+File permission : 442
+Directory permission : 553
+-- Setting umask to 225 --
+File permission : 442
+Directory permission : 552
+-- Setting umask to 226 --
+File permission : 440
+Directory permission : 551
+-- Setting umask to 227 --
+File permission : 440
+Directory permission : 550
+-- Setting umask to 230 --
+File permission : 446
+Directory permission : 547
+-- Setting umask to 231 --
+File permission : 446
+Directory permission : 546
+-- Setting umask to 232 --
+File permission : 444
+Directory permission : 545
+-- Setting umask to 233 --
+File permission : 444
+Directory permission : 544
+-- Setting umask to 234 --
+File permission : 442
+Directory permission : 543
+-- Setting umask to 235 --
+File permission : 442
+Directory permission : 542
+-- Setting umask to 236 --
+File permission : 440
+Directory permission : 541
+-- Setting umask to 237 --
+File permission : 440
+Directory permission : 540
+-- Setting umask to 240 --
+File permission : 426
+Directory permission : 537
+-- Setting umask to 241 --
+File permission : 426
+Directory permission : 536
+-- Setting umask to 242 --
+File permission : 424
+Directory permission : 535
+-- Setting umask to 243 --
+File permission : 424
+Directory permission : 534
+-- Setting umask to 244 --
+File permission : 422
+Directory permission : 533
+-- Setting umask to 245 --
+File permission : 422
+Directory permission : 532
+-- Setting umask to 246 --
+File permission : 420
+Directory permission : 531
+-- Setting umask to 247 --
+File permission : 420
+Directory permission : 530
+-- Setting umask to 250 --
+File permission : 426
+Directory permission : 527
+-- Setting umask to 251 --
+File permission : 426
+Directory permission : 526
+-- Setting umask to 252 --
+File permission : 424
+Directory permission : 525
+-- Setting umask to 253 --
+File permission : 424
+Directory permission : 524
+-- Setting umask to 254 --
+File permission : 422
+Directory permission : 523
+-- Setting umask to 255 --
+File permission : 422
+Directory permission : 522
+-- Setting umask to 256 --
+File permission : 420
+Directory permission : 521
+-- Setting umask to 257 --
+File permission : 420
+Directory permission : 520
+-- Setting umask to 260 --
+File permission : 406
+Directory permission : 517
+-- Setting umask to 261 --
+File permission : 406
+Directory permission : 516
+-- Setting umask to 262 --
+File permission : 404
+Directory permission : 515
+-- Setting umask to 263 --
+File permission : 404
+Directory permission : 514
+-- Setting umask to 264 --
+File permission : 402
+Directory permission : 513
+-- Setting umask to 265 --
+File permission : 402
+Directory permission : 512
+-- Setting umask to 266 --
+File permission : 400
+Directory permission : 511
+-- Setting umask to 267 --
+File permission : 400
+Directory permission : 510
+-- Setting umask to 270 --
+File permission : 406
+Directory permission : 507
+-- Setting umask to 271 --
+File permission : 406
+Directory permission : 506
+-- Setting umask to 272 --
+File permission : 404
+Directory permission : 505
+-- Setting umask to 273 --
+File permission : 404
+Directory permission : 504
+-- Setting umask to 274 --
+File permission : 402
+Directory permission : 503
+-- Setting umask to 275 --
+File permission : 402
+Directory permission : 502
+-- Setting umask to 276 --
+File permission : 400
+Directory permission : 501
+-- Setting umask to 277 --
+File permission : 400
+Directory permission : 500
+-- Setting umask to 300 --
+File permission : 466
+Directory permission : 477
+-- Setting umask to 301 --
+File permission : 466
+Directory permission : 476
+-- Setting umask to 302 --
+File permission : 464
+Directory permission : 475
+-- Setting umask to 303 --
+File permission : 464
+Directory permission : 474
+-- Setting umask to 304 --
+File permission : 462
+Directory permission : 473
+-- Setting umask to 305 --
+File permission : 462
+Directory permission : 472
+-- Setting umask to 306 --
+File permission : 460
+Directory permission : 471
+-- Setting umask to 307 --
+File permission : 460
+Directory permission : 470
+-- Setting umask to 310 --
+File permission : 466
+Directory permission : 467
+-- Setting umask to 311 --
+File permission : 466
+Directory permission : 466
+-- Setting umask to 312 --
+File permission : 464
+Directory permission : 465
+-- Setting umask to 313 --
+File permission : 464
+Directory permission : 464
+-- Setting umask to 314 --
+File permission : 462
+Directory permission : 463
+-- Setting umask to 315 --
+File permission : 462
+Directory permission : 462
+-- Setting umask to 316 --
+File permission : 460
+Directory permission : 461
+-- Setting umask to 317 --
+File permission : 460
+Directory permission : 460
+-- Setting umask to 320 --
+File permission : 446
+Directory permission : 457
+-- Setting umask to 321 --
+File permission : 446
+Directory permission : 456
+-- Setting umask to 322 --
+File permission : 444
+Directory permission : 455
+-- Setting umask to 323 --
+File permission : 444
+Directory permission : 454
+-- Setting umask to 324 --
+File permission : 442
+Directory permission : 453
+-- Setting umask to 325 --
+File permission : 442
+Directory permission : 452
+-- Setting umask to 326 --
+File permission : 440
+Directory permission : 451
+-- Setting umask to 327 --
+File permission : 440
+Directory permission : 450
+-- Setting umask to 330 --
+File permission : 446
+Directory permission : 447
+-- Setting umask to 331 --
+File permission : 446
+Directory permission : 446
+-- Setting umask to 332 --
+File permission : 444
+Directory permission : 445
+-- Setting umask to 333 --
+File permission : 444
+Directory permission : 444
+-- Setting umask to 334 --
+File permission : 442
+Directory permission : 443
+-- Setting umask to 335 --
+File permission : 442
+Directory permission : 442
+-- Setting umask to 336 --
+File permission : 440
+Directory permission : 441
+-- Setting umask to 337 --
+File permission : 440
+Directory permission : 440
+-- Setting umask to 340 --
+File permission : 426
+Directory permission : 437
+-- Setting umask to 341 --
+File permission : 426
+Directory permission : 436
+-- Setting umask to 342 --
+File permission : 424
+Directory permission : 435
+-- Setting umask to 343 --
+File permission : 424
+Directory permission : 434
+-- Setting umask to 344 --
+File permission : 422
+Directory permission : 433
+-- Setting umask to 345 --
+File permission : 422
+Directory permission : 432
+-- Setting umask to 346 --
+File permission : 420
+Directory permission : 431
+-- Setting umask to 347 --
+File permission : 420
+Directory permission : 430
+-- Setting umask to 350 --
+File permission : 426
+Directory permission : 427
+Done
diff --git a/ext/standard/tests/file/umask_variation2.phpt b/ext/standard/tests/file/umask_variation2.phpt
new file mode 100644
index 0000000..85b1a67
--- /dev/null
+++ b/ext/standard/tests/file/umask_variation2.phpt
@@ -0,0 +1,899 @@
+--TEST--
+Test umask() function: usage variations - perms from 0351 to 0777
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. only on Linux');
+}
+?>
+--FILE--
+<?php
+/* Prototype: int umask ( [int $mask] );
+ Description: Changes the current umask
+*/
+
+$file_path = dirname(__FILE__);
+
+/* Check umask() on file/dir */
+
+echo "*** Testing umask() on file and directory ***\n";
+// temp filename used
+$filename = "$file_path/umask_variation2.tmp";
+// temp dir used
+$dirname = "$file_path/umask_variation2";
+
+for($mask = 0351; $mask <= 0777; $mask++) {
+ echo "-- Setting umask to ";
+ echo sprintf('%03o', $mask);
+ echo " --\n";
+ // setting umask
+ umask($mask);
+
+ /* umasking file */
+ // creating temp file
+ $fp = fopen($filename, "w");
+ fclose($fp);
+ echo "File permission : ";
+ // check file permission
+ echo substr(sprintf('%o', fileperms($filename)), -3);
+ echo "\n";
+ // chmod file to 0777 to enable deletion
+ chmod($filename, 0777);
+ // delete temp file created here
+ unlink($filename);
+
+ /* umasking directory */
+ // create temp dir
+ mkdir($dirname);
+ echo "Directory permission : ";
+ // check $dirname permission
+ echo substr(sprintf('%o', fileperms($dirname)), -3);
+ echo "\n";
+ // chmod 0777 to enable deletion
+ chmod($dirname, 0777);
+ // delete temp dir created
+ rmdir($dirname);
+}
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing umask() on file and directory ***
+-- Setting umask to 351 --
+File permission : 426
+Directory permission : 426
+-- Setting umask to 352 --
+File permission : 424
+Directory permission : 425
+-- Setting umask to 353 --
+File permission : 424
+Directory permission : 424
+-- Setting umask to 354 --
+File permission : 422
+Directory permission : 423
+-- Setting umask to 355 --
+File permission : 422
+Directory permission : 422
+-- Setting umask to 356 --
+File permission : 420
+Directory permission : 421
+-- Setting umask to 357 --
+File permission : 420
+Directory permission : 420
+-- Setting umask to 360 --
+File permission : 406
+Directory permission : 417
+-- Setting umask to 361 --
+File permission : 406
+Directory permission : 416
+-- Setting umask to 362 --
+File permission : 404
+Directory permission : 415
+-- Setting umask to 363 --
+File permission : 404
+Directory permission : 414
+-- Setting umask to 364 --
+File permission : 402
+Directory permission : 413
+-- Setting umask to 365 --
+File permission : 402
+Directory permission : 412
+-- Setting umask to 366 --
+File permission : 400
+Directory permission : 411
+-- Setting umask to 367 --
+File permission : 400
+Directory permission : 410
+-- Setting umask to 370 --
+File permission : 406
+Directory permission : 407
+-- Setting umask to 371 --
+File permission : 406
+Directory permission : 406
+-- Setting umask to 372 --
+File permission : 404
+Directory permission : 405
+-- Setting umask to 373 --
+File permission : 404
+Directory permission : 404
+-- Setting umask to 374 --
+File permission : 402
+Directory permission : 403
+-- Setting umask to 375 --
+File permission : 402
+Directory permission : 402
+-- Setting umask to 376 --
+File permission : 400
+Directory permission : 401
+-- Setting umask to 377 --
+File permission : 400
+Directory permission : 400
+-- Setting umask to 400 --
+File permission : 266
+Directory permission : 377
+-- Setting umask to 401 --
+File permission : 266
+Directory permission : 376
+-- Setting umask to 402 --
+File permission : 264
+Directory permission : 375
+-- Setting umask to 403 --
+File permission : 264
+Directory permission : 374
+-- Setting umask to 404 --
+File permission : 262
+Directory permission : 373
+-- Setting umask to 405 --
+File permission : 262
+Directory permission : 372
+-- Setting umask to 406 --
+File permission : 260
+Directory permission : 371
+-- Setting umask to 407 --
+File permission : 260
+Directory permission : 370
+-- Setting umask to 410 --
+File permission : 266
+Directory permission : 367
+-- Setting umask to 411 --
+File permission : 266
+Directory permission : 366
+-- Setting umask to 412 --
+File permission : 264
+Directory permission : 365
+-- Setting umask to 413 --
+File permission : 264
+Directory permission : 364
+-- Setting umask to 414 --
+File permission : 262
+Directory permission : 363
+-- Setting umask to 415 --
+File permission : 262
+Directory permission : 362
+-- Setting umask to 416 --
+File permission : 260
+Directory permission : 361
+-- Setting umask to 417 --
+File permission : 260
+Directory permission : 360
+-- Setting umask to 420 --
+File permission : 246
+Directory permission : 357
+-- Setting umask to 421 --
+File permission : 246
+Directory permission : 356
+-- Setting umask to 422 --
+File permission : 244
+Directory permission : 355
+-- Setting umask to 423 --
+File permission : 244
+Directory permission : 354
+-- Setting umask to 424 --
+File permission : 242
+Directory permission : 353
+-- Setting umask to 425 --
+File permission : 242
+Directory permission : 352
+-- Setting umask to 426 --
+File permission : 240
+Directory permission : 351
+-- Setting umask to 427 --
+File permission : 240
+Directory permission : 350
+-- Setting umask to 430 --
+File permission : 246
+Directory permission : 347
+-- Setting umask to 431 --
+File permission : 246
+Directory permission : 346
+-- Setting umask to 432 --
+File permission : 244
+Directory permission : 345
+-- Setting umask to 433 --
+File permission : 244
+Directory permission : 344
+-- Setting umask to 434 --
+File permission : 242
+Directory permission : 343
+-- Setting umask to 435 --
+File permission : 242
+Directory permission : 342
+-- Setting umask to 436 --
+File permission : 240
+Directory permission : 341
+-- Setting umask to 437 --
+File permission : 240
+Directory permission : 340
+-- Setting umask to 440 --
+File permission : 226
+Directory permission : 337
+-- Setting umask to 441 --
+File permission : 226
+Directory permission : 336
+-- Setting umask to 442 --
+File permission : 224
+Directory permission : 335
+-- Setting umask to 443 --
+File permission : 224
+Directory permission : 334
+-- Setting umask to 444 --
+File permission : 222
+Directory permission : 333
+-- Setting umask to 445 --
+File permission : 222
+Directory permission : 332
+-- Setting umask to 446 --
+File permission : 220
+Directory permission : 331
+-- Setting umask to 447 --
+File permission : 220
+Directory permission : 330
+-- Setting umask to 450 --
+File permission : 226
+Directory permission : 327
+-- Setting umask to 451 --
+File permission : 226
+Directory permission : 326
+-- Setting umask to 452 --
+File permission : 224
+Directory permission : 325
+-- Setting umask to 453 --
+File permission : 224
+Directory permission : 324
+-- Setting umask to 454 --
+File permission : 222
+Directory permission : 323
+-- Setting umask to 455 --
+File permission : 222
+Directory permission : 322
+-- Setting umask to 456 --
+File permission : 220
+Directory permission : 321
+-- Setting umask to 457 --
+File permission : 220
+Directory permission : 320
+-- Setting umask to 460 --
+File permission : 206
+Directory permission : 317
+-- Setting umask to 461 --
+File permission : 206
+Directory permission : 316
+-- Setting umask to 462 --
+File permission : 204
+Directory permission : 315
+-- Setting umask to 463 --
+File permission : 204
+Directory permission : 314
+-- Setting umask to 464 --
+File permission : 202
+Directory permission : 313
+-- Setting umask to 465 --
+File permission : 202
+Directory permission : 312
+-- Setting umask to 466 --
+File permission : 200
+Directory permission : 311
+-- Setting umask to 467 --
+File permission : 200
+Directory permission : 310
+-- Setting umask to 470 --
+File permission : 206
+Directory permission : 307
+-- Setting umask to 471 --
+File permission : 206
+Directory permission : 306
+-- Setting umask to 472 --
+File permission : 204
+Directory permission : 305
+-- Setting umask to 473 --
+File permission : 204
+Directory permission : 304
+-- Setting umask to 474 --
+File permission : 202
+Directory permission : 303
+-- Setting umask to 475 --
+File permission : 202
+Directory permission : 302
+-- Setting umask to 476 --
+File permission : 200
+Directory permission : 301
+-- Setting umask to 477 --
+File permission : 200
+Directory permission : 300
+-- Setting umask to 500 --
+File permission : 266
+Directory permission : 277
+-- Setting umask to 501 --
+File permission : 266
+Directory permission : 276
+-- Setting umask to 502 --
+File permission : 264
+Directory permission : 275
+-- Setting umask to 503 --
+File permission : 264
+Directory permission : 274
+-- Setting umask to 504 --
+File permission : 262
+Directory permission : 273
+-- Setting umask to 505 --
+File permission : 262
+Directory permission : 272
+-- Setting umask to 506 --
+File permission : 260
+Directory permission : 271
+-- Setting umask to 507 --
+File permission : 260
+Directory permission : 270
+-- Setting umask to 510 --
+File permission : 266
+Directory permission : 267
+-- Setting umask to 511 --
+File permission : 266
+Directory permission : 266
+-- Setting umask to 512 --
+File permission : 264
+Directory permission : 265
+-- Setting umask to 513 --
+File permission : 264
+Directory permission : 264
+-- Setting umask to 514 --
+File permission : 262
+Directory permission : 263
+-- Setting umask to 515 --
+File permission : 262
+Directory permission : 262
+-- Setting umask to 516 --
+File permission : 260
+Directory permission : 261
+-- Setting umask to 517 --
+File permission : 260
+Directory permission : 260
+-- Setting umask to 520 --
+File permission : 246
+Directory permission : 257
+-- Setting umask to 521 --
+File permission : 246
+Directory permission : 256
+-- Setting umask to 522 --
+File permission : 244
+Directory permission : 255
+-- Setting umask to 523 --
+File permission : 244
+Directory permission : 254
+-- Setting umask to 524 --
+File permission : 242
+Directory permission : 253
+-- Setting umask to 525 --
+File permission : 242
+Directory permission : 252
+-- Setting umask to 526 --
+File permission : 240
+Directory permission : 251
+-- Setting umask to 527 --
+File permission : 240
+Directory permission : 250
+-- Setting umask to 530 --
+File permission : 246
+Directory permission : 247
+-- Setting umask to 531 --
+File permission : 246
+Directory permission : 246
+-- Setting umask to 532 --
+File permission : 244
+Directory permission : 245
+-- Setting umask to 533 --
+File permission : 244
+Directory permission : 244
+-- Setting umask to 534 --
+File permission : 242
+Directory permission : 243
+-- Setting umask to 535 --
+File permission : 242
+Directory permission : 242
+-- Setting umask to 536 --
+File permission : 240
+Directory permission : 241
+-- Setting umask to 537 --
+File permission : 240
+Directory permission : 240
+-- Setting umask to 540 --
+File permission : 226
+Directory permission : 237
+-- Setting umask to 541 --
+File permission : 226
+Directory permission : 236
+-- Setting umask to 542 --
+File permission : 224
+Directory permission : 235
+-- Setting umask to 543 --
+File permission : 224
+Directory permission : 234
+-- Setting umask to 544 --
+File permission : 222
+Directory permission : 233
+-- Setting umask to 545 --
+File permission : 222
+Directory permission : 232
+-- Setting umask to 546 --
+File permission : 220
+Directory permission : 231
+-- Setting umask to 547 --
+File permission : 220
+Directory permission : 230
+-- Setting umask to 550 --
+File permission : 226
+Directory permission : 227
+-- Setting umask to 551 --
+File permission : 226
+Directory permission : 226
+-- Setting umask to 552 --
+File permission : 224
+Directory permission : 225
+-- Setting umask to 553 --
+File permission : 224
+Directory permission : 224
+-- Setting umask to 554 --
+File permission : 222
+Directory permission : 223
+-- Setting umask to 555 --
+File permission : 222
+Directory permission : 222
+-- Setting umask to 556 --
+File permission : 220
+Directory permission : 221
+-- Setting umask to 557 --
+File permission : 220
+Directory permission : 220
+-- Setting umask to 560 --
+File permission : 206
+Directory permission : 217
+-- Setting umask to 561 --
+File permission : 206
+Directory permission : 216
+-- Setting umask to 562 --
+File permission : 204
+Directory permission : 215
+-- Setting umask to 563 --
+File permission : 204
+Directory permission : 214
+-- Setting umask to 564 --
+File permission : 202
+Directory permission : 213
+-- Setting umask to 565 --
+File permission : 202
+Directory permission : 212
+-- Setting umask to 566 --
+File permission : 200
+Directory permission : 211
+-- Setting umask to 567 --
+File permission : 200
+Directory permission : 210
+-- Setting umask to 570 --
+File permission : 206
+Directory permission : 207
+-- Setting umask to 571 --
+File permission : 206
+Directory permission : 206
+-- Setting umask to 572 --
+File permission : 204
+Directory permission : 205
+-- Setting umask to 573 --
+File permission : 204
+Directory permission : 204
+-- Setting umask to 574 --
+File permission : 202
+Directory permission : 203
+-- Setting umask to 575 --
+File permission : 202
+Directory permission : 202
+-- Setting umask to 576 --
+File permission : 200
+Directory permission : 201
+-- Setting umask to 577 --
+File permission : 200
+Directory permission : 200
+-- Setting umask to 600 --
+File permission : 066
+Directory permission : 177
+-- Setting umask to 601 --
+File permission : 066
+Directory permission : 176
+-- Setting umask to 602 --
+File permission : 064
+Directory permission : 175
+-- Setting umask to 603 --
+File permission : 064
+Directory permission : 174
+-- Setting umask to 604 --
+File permission : 062
+Directory permission : 173
+-- Setting umask to 605 --
+File permission : 062
+Directory permission : 172
+-- Setting umask to 606 --
+File permission : 060
+Directory permission : 171
+-- Setting umask to 607 --
+File permission : 060
+Directory permission : 170
+-- Setting umask to 610 --
+File permission : 066
+Directory permission : 167
+-- Setting umask to 611 --
+File permission : 066
+Directory permission : 166
+-- Setting umask to 612 --
+File permission : 064
+Directory permission : 165
+-- Setting umask to 613 --
+File permission : 064
+Directory permission : 164
+-- Setting umask to 614 --
+File permission : 062
+Directory permission : 163
+-- Setting umask to 615 --
+File permission : 062
+Directory permission : 162
+-- Setting umask to 616 --
+File permission : 060
+Directory permission : 161
+-- Setting umask to 617 --
+File permission : 060
+Directory permission : 160
+-- Setting umask to 620 --
+File permission : 046
+Directory permission : 157
+-- Setting umask to 621 --
+File permission : 046
+Directory permission : 156
+-- Setting umask to 622 --
+File permission : 044
+Directory permission : 155
+-- Setting umask to 623 --
+File permission : 044
+Directory permission : 154
+-- Setting umask to 624 --
+File permission : 042
+Directory permission : 153
+-- Setting umask to 625 --
+File permission : 042
+Directory permission : 152
+-- Setting umask to 626 --
+File permission : 040
+Directory permission : 151
+-- Setting umask to 627 --
+File permission : 040
+Directory permission : 150
+-- Setting umask to 630 --
+File permission : 046
+Directory permission : 147
+-- Setting umask to 631 --
+File permission : 046
+Directory permission : 146
+-- Setting umask to 632 --
+File permission : 044
+Directory permission : 145
+-- Setting umask to 633 --
+File permission : 044
+Directory permission : 144
+-- Setting umask to 634 --
+File permission : 042
+Directory permission : 143
+-- Setting umask to 635 --
+File permission : 042
+Directory permission : 142
+-- Setting umask to 636 --
+File permission : 040
+Directory permission : 141
+-- Setting umask to 637 --
+File permission : 040
+Directory permission : 140
+-- Setting umask to 640 --
+File permission : 026
+Directory permission : 137
+-- Setting umask to 641 --
+File permission : 026
+Directory permission : 136
+-- Setting umask to 642 --
+File permission : 024
+Directory permission : 135
+-- Setting umask to 643 --
+File permission : 024
+Directory permission : 134
+-- Setting umask to 644 --
+File permission : 022
+Directory permission : 133
+-- Setting umask to 645 --
+File permission : 022
+Directory permission : 132
+-- Setting umask to 646 --
+File permission : 020
+Directory permission : 131
+-- Setting umask to 647 --
+File permission : 020
+Directory permission : 130
+-- Setting umask to 650 --
+File permission : 026
+Directory permission : 127
+-- Setting umask to 651 --
+File permission : 026
+Directory permission : 126
+-- Setting umask to 652 --
+File permission : 024
+Directory permission : 125
+-- Setting umask to 653 --
+File permission : 024
+Directory permission : 124
+-- Setting umask to 654 --
+File permission : 022
+Directory permission : 123
+-- Setting umask to 655 --
+File permission : 022
+Directory permission : 122
+-- Setting umask to 656 --
+File permission : 020
+Directory permission : 121
+-- Setting umask to 657 --
+File permission : 020
+Directory permission : 120
+-- Setting umask to 660 --
+File permission : 006
+Directory permission : 117
+-- Setting umask to 661 --
+File permission : 006
+Directory permission : 116
+-- Setting umask to 662 --
+File permission : 004
+Directory permission : 115
+-- Setting umask to 663 --
+File permission : 004
+Directory permission : 114
+-- Setting umask to 664 --
+File permission : 002
+Directory permission : 113
+-- Setting umask to 665 --
+File permission : 002
+Directory permission : 112
+-- Setting umask to 666 --
+File permission : 000
+Directory permission : 111
+-- Setting umask to 667 --
+File permission : 000
+Directory permission : 110
+-- Setting umask to 670 --
+File permission : 006
+Directory permission : 107
+-- Setting umask to 671 --
+File permission : 006
+Directory permission : 106
+-- Setting umask to 672 --
+File permission : 004
+Directory permission : 105
+-- Setting umask to 673 --
+File permission : 004
+Directory permission : 104
+-- Setting umask to 674 --
+File permission : 002
+Directory permission : 103
+-- Setting umask to 675 --
+File permission : 002
+Directory permission : 102
+-- Setting umask to 676 --
+File permission : 000
+Directory permission : 101
+-- Setting umask to 677 --
+File permission : 000
+Directory permission : 100
+-- Setting umask to 700 --
+File permission : 066
+Directory permission : 077
+-- Setting umask to 701 --
+File permission : 066
+Directory permission : 076
+-- Setting umask to 702 --
+File permission : 064
+Directory permission : 075
+-- Setting umask to 703 --
+File permission : 064
+Directory permission : 074
+-- Setting umask to 704 --
+File permission : 062
+Directory permission : 073
+-- Setting umask to 705 --
+File permission : 062
+Directory permission : 072
+-- Setting umask to 706 --
+File permission : 060
+Directory permission : 071
+-- Setting umask to 707 --
+File permission : 060
+Directory permission : 070
+-- Setting umask to 710 --
+File permission : 066
+Directory permission : 067
+-- Setting umask to 711 --
+File permission : 066
+Directory permission : 066
+-- Setting umask to 712 --
+File permission : 064
+Directory permission : 065
+-- Setting umask to 713 --
+File permission : 064
+Directory permission : 064
+-- Setting umask to 714 --
+File permission : 062
+Directory permission : 063
+-- Setting umask to 715 --
+File permission : 062
+Directory permission : 062
+-- Setting umask to 716 --
+File permission : 060
+Directory permission : 061
+-- Setting umask to 717 --
+File permission : 060
+Directory permission : 060
+-- Setting umask to 720 --
+File permission : 046
+Directory permission : 057
+-- Setting umask to 721 --
+File permission : 046
+Directory permission : 056
+-- Setting umask to 722 --
+File permission : 044
+Directory permission : 055
+-- Setting umask to 723 --
+File permission : 044
+Directory permission : 054
+-- Setting umask to 724 --
+File permission : 042
+Directory permission : 053
+-- Setting umask to 725 --
+File permission : 042
+Directory permission : 052
+-- Setting umask to 726 --
+File permission : 040
+Directory permission : 051
+-- Setting umask to 727 --
+File permission : 040
+Directory permission : 050
+-- Setting umask to 730 --
+File permission : 046
+Directory permission : 047
+-- Setting umask to 731 --
+File permission : 046
+Directory permission : 046
+-- Setting umask to 732 --
+File permission : 044
+Directory permission : 045
+-- Setting umask to 733 --
+File permission : 044
+Directory permission : 044
+-- Setting umask to 734 --
+File permission : 042
+Directory permission : 043
+-- Setting umask to 735 --
+File permission : 042
+Directory permission : 042
+-- Setting umask to 736 --
+File permission : 040
+Directory permission : 041
+-- Setting umask to 737 --
+File permission : 040
+Directory permission : 040
+-- Setting umask to 740 --
+File permission : 026
+Directory permission : 037
+-- Setting umask to 741 --
+File permission : 026
+Directory permission : 036
+-- Setting umask to 742 --
+File permission : 024
+Directory permission : 035
+-- Setting umask to 743 --
+File permission : 024
+Directory permission : 034
+-- Setting umask to 744 --
+File permission : 022
+Directory permission : 033
+-- Setting umask to 745 --
+File permission : 022
+Directory permission : 032
+-- Setting umask to 746 --
+File permission : 020
+Directory permission : 031
+-- Setting umask to 747 --
+File permission : 020
+Directory permission : 030
+-- Setting umask to 750 --
+File permission : 026
+Directory permission : 027
+-- Setting umask to 751 --
+File permission : 026
+Directory permission : 026
+-- Setting umask to 752 --
+File permission : 024
+Directory permission : 025
+-- Setting umask to 753 --
+File permission : 024
+Directory permission : 024
+-- Setting umask to 754 --
+File permission : 022
+Directory permission : 023
+-- Setting umask to 755 --
+File permission : 022
+Directory permission : 022
+-- Setting umask to 756 --
+File permission : 020
+Directory permission : 021
+-- Setting umask to 757 --
+File permission : 020
+Directory permission : 020
+-- Setting umask to 760 --
+File permission : 006
+Directory permission : 017
+-- Setting umask to 761 --
+File permission : 006
+Directory permission : 016
+-- Setting umask to 762 --
+File permission : 004
+Directory permission : 015
+-- Setting umask to 763 --
+File permission : 004
+Directory permission : 014
+-- Setting umask to 764 --
+File permission : 002
+Directory permission : 013
+-- Setting umask to 765 --
+File permission : 002
+Directory permission : 012
+-- Setting umask to 766 --
+File permission : 000
+Directory permission : 011
+-- Setting umask to 767 --
+File permission : 000
+Directory permission : 010
+-- Setting umask to 770 --
+File permission : 006
+Directory permission : 007
+-- Setting umask to 771 --
+File permission : 006
+Directory permission : 006
+-- Setting umask to 772 --
+File permission : 004
+Directory permission : 005
+-- Setting umask to 773 --
+File permission : 004
+Directory permission : 004
+-- Setting umask to 774 --
+File permission : 002
+Directory permission : 003
+-- Setting umask to 775 --
+File permission : 002
+Directory permission : 002
+-- Setting umask to 776 --
+File permission : 000
+Directory permission : 001
+-- Setting umask to 777 --
+File permission : 000
+Directory permission : 000
+Done
diff --git a/ext/standard/tests/file/umask_variation3.phpt b/ext/standard/tests/file/umask_variation3.phpt
new file mode 100644
index 0000000..c666c32
--- /dev/null
+++ b/ext/standard/tests/file/umask_variation3.phpt
@@ -0,0 +1,237 @@
+--TEST--
+Test umask() function : usage variation
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. only for Non Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype : int umask([int mask])
+ * Description: Return or change the umask
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing umask() : usage variation ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+ //out of boundary integers
+ 'int -100' => -100,
+ 'int 99999' => 99999,
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float -10.5' => -10.5,
+ 'float 12.3456789000e10' => 12.3456789000e10,
+ //'float -12.3456789000e10' => -12.3456789000e10, different in p8
+ 'float .5' => .5,
+
+ // array data
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // string data
+ 'string DQ' => "string",
+ 'string SQ' => 'string',
+ 'mixed case string' => "sTrInG",
+ 'heredoc' => $heredoc,
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+);
+
+// loop through each element of the array for mask
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ umask(0);
+ var_dump(umask($value));
+ var_dump( umask() & 0777);
+};
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing umask() : usage variation ***
+
+--int -100--
+int(0)
+int(412)
+
+--int 99999--
+int(0)
+int(159)
+
+--float 10.5--
+int(0)
+int(10)
+
+--float -10.5--
+int(0)
+int(502)
+
+--float 12.3456789000e10--
+int(0)
+int(%d)
+
+--float .5--
+int(0)
+int(0)
+
+--empty array--
+Error: 2 - umask() expects parameter 1 to be long, array given, %s(%d)
+bool(false)
+int(63)
+
+--int indexed array--
+Error: 2 - umask() expects parameter 1 to be long, array given, %s(%d)
+bool(false)
+int(63)
+
+--associative array--
+Error: 2 - umask() expects parameter 1 to be long, array given, %s(%d)
+bool(false)
+int(63)
+
+--nested arrays--
+Error: 2 - umask() expects parameter 1 to be long, array given, %s(%d)
+bool(false)
+int(63)
+
+--uppercase NULL--
+int(0)
+int(0)
+
+--lowercase null--
+int(0)
+int(0)
+
+--lowercase true--
+int(0)
+int(1)
+
+--lowercase false--
+int(0)
+int(0)
+
+--uppercase TRUE--
+int(0)
+int(1)
+
+--uppercase FALSE--
+int(0)
+int(0)
+
+--empty string DQ--
+Error: 2 - umask() expects parameter 1 to be long, string given, %s(%d)
+bool(false)
+int(63)
+
+--empty string SQ--
+Error: 2 - umask() expects parameter 1 to be long, string given, %s(%d)
+bool(false)
+int(63)
+
+--string DQ--
+Error: 2 - umask() expects parameter 1 to be long, string given, %s(%d)
+bool(false)
+int(63)
+
+--string SQ--
+Error: 2 - umask() expects parameter 1 to be long, string given, %s(%d)
+bool(false)
+int(63)
+
+--mixed case string--
+Error: 2 - umask() expects parameter 1 to be long, string given, %s(%d)
+bool(false)
+int(63)
+
+--heredoc--
+Error: 2 - umask() expects parameter 1 to be long, string given, %s(%d)
+bool(false)
+int(63)
+
+--instance of classWithToString--
+Error: 2 - umask() expects parameter 1 to be long, object given, %s(%d)
+bool(false)
+int(63)
+
+--instance of classWithoutToString--
+Error: 2 - umask() expects parameter 1 to be long, object given, %s(%d)
+bool(false)
+int(63)
+
+--undefined var--
+int(0)
+int(0)
+
+--unset var--
+int(0)
+int(0)
+===DONE===
+
diff --git a/ext/standard/tests/file/unlink_basic.phpt b/ext/standard/tests/file/unlink_basic.phpt
new file mode 100644
index 0000000..97e6aa6
--- /dev/null
+++ b/ext/standard/tests/file/unlink_basic.phpt
@@ -0,0 +1,43 @@
+--TEST--
+Testing unlink() function : basic functionality
+--FILE--
+<?php
+/* Prototype : bool unlink ( string $filename [, resource $context] );
+ Description : Deletes filename
+*/
+
+$file_path = dirname(__FILE__);
+
+echo "*** Testing unlink() on a file ***\n";
+$filename = "$file_path/unlink_basic.tmp"; // temp file name used here
+$fp = fopen($filename, "w"); // create file
+fwrite($fp, "Hello World");
+fclose($fp);
+
+// delete file
+var_dump( unlink($filename) );
+var_dump( file_exists($filename) ); // confirm file doesnt exist
+
+echo "\n*** Testing unlink() : checking second argument ***\n";
+// creating a context
+$context = stream_context_create();
+// temp file name used here
+$filename = "$file_path/unlink_basic.tmp";
+$fp = fopen($filename, "w"); // create file
+fclose($fp);
+
+// delete file
+var_dump( unlink($filename, $context) ); // using $context in second argument
+var_dump( file_exists($filename) ); // confirm file doesnt exist
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing unlink() on a file ***
+bool(true)
+bool(false)
+
+*** Testing unlink() : checking second argument ***
+bool(true)
+bool(false)
+Done
diff --git a/ext/standard/tests/file/unlink_error-win32.phpt b/ext/standard/tests/file/unlink_error-win32.phpt
new file mode 100644
index 0000000..e55f6ed
--- /dev/null
+++ b/ext/standard/tests/file/unlink_error-win32.phpt
@@ -0,0 +1,110 @@
+--TEST--
+Testing unlink() function : error conditions
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip.. only on Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype : bool unlink ( string $filename [, resource $context] );
+ Description : Deletes filename
+*/
+
+$file_path = dirname(__FILE__);
+
+$filename = "$file_path/unlink_error.tmp"; // temp file name used here
+$fp = fopen($filename, "w"); // create file
+fclose($fp);
+
+// creating a context
+$context = stream_context_create();
+
+echo "*** Testing unlink() : error conditions ***\n";
+
+echo "-- Testing unlink() on unexpected no. of arguments --\n";
+// arg < expected
+var_dump( unlink() );
+// args > expected
+var_dump( unlink($filename, $context, true) );
+var_dump( file_exists($filename) ); // expected: true
+
+echo "\n-- Testing unlink() on invalid arguments --\n";
+// invalid arguments
+var_dump( unlink('') ); // $filename as empty string
+var_dump( file_exists('') ); // confirm file doesnt exist
+
+var_dump( unlink(NULL) ); // $filename as NULL
+var_dump( file_exists(NULL) ); // confirm file doesnt exist
+
+var_dump( unlink(false) ); // $filename as boolean false
+var_dump( file_exists(false) ); // confirm file doesnt exist
+
+var_dump( unlink($filename, '') ); // $context as empty string
+var_dump( unlink($filename, false) ); // $context as boolean false
+var_dump( unlink($filename, NULL) ); // $context as NULL
+
+
+echo "\n-- Testing unlink() on non-existent file --\n";
+var_dump( unlink(dirname(__FILE__)."/non_existent_file.tmp") );
+
+echo "\n-- Testing unlink() on directory --\n";
+// temp directory used here
+$dirname = "$file_path/unlink_error";
+// create temp dir
+mkdir($dirname);
+// unlinking directory
+var_dump( unlink($dirname) ); // expected: false as unlink() does not work on dir
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/unlink_error.tmp");
+rmdir(dirname(__FILE__)."/unlink_error");
+?>
+--EXPECTF--
+*** Testing unlink() : error conditions ***
+-- Testing unlink() on unexpected no. of arguments --
+
+Warning: unlink() expects at least 1 parameter, 0 given in %s on line %d
+bool(false)
+
+Warning: unlink() expects at most 2 parameters, 3 given in %s on line %d
+bool(false)
+bool(true)
+
+-- Testing unlink() on invalid arguments --
+
+Warning: unlink(): %s in %s on line %d
+bool(false)
+bool(false)
+
+Warning: unlink(): %s in %s on line %d
+bool(false)
+bool(false)
+
+Warning: unlink(): %s in %s on line %d
+bool(false)
+bool(false)
+
+Warning: unlink() expects parameter 2 to be resource, string given in %s on line %d
+bool(false)
+
+Warning: unlink() expects parameter 2 to be resource, boolean given in %s on line %d
+bool(false)
+
+Warning: unlink() expects parameter 2 to be resource, null given in %s on line %d
+bool(false)
+
+-- Testing unlink() on non-existent file --
+
+Warning: unlink(%s/non_existent_file.tmp): No such file or directory in %s on line %d
+bool(false)
+
+-- Testing unlink() on directory --
+
+Warning: unlink(%s/unlink_error): Permission denied in %s on line %d
+bool(false)
+Done
diff --git a/ext/standard/tests/file/unlink_error.phpt b/ext/standard/tests/file/unlink_error.phpt
new file mode 100644
index 0000000..9571784
--- /dev/null
+++ b/ext/standard/tests/file/unlink_error.phpt
@@ -0,0 +1,110 @@
+--TEST--
+Testing unlink() function : error conditions
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. only on Linux');
+}
+?>
+--FILE--
+<?php
+/* Prototype : bool unlink ( string $filename [, resource $context] );
+ Description : Deletes filename
+*/
+
+$file_path = dirname(__FILE__);
+
+$filename = "$file_path/unlink_error.tmp"; // temp file name used here
+$fp = fopen($filename, "w"); // create file
+fclose($fp);
+
+// creating a context
+$context = stream_context_create();
+
+echo "*** Testing unlink() : error conditions ***\n";
+
+echo "-- Testing unlink() on unexpected no. of arguments --\n";
+// arg < expected
+var_dump( unlink() );
+// args > expected
+var_dump( unlink($filename, $context, true) );
+var_dump( file_exists($filename) ); // expected true
+
+echo "\n-- Testing unlink() on invalid arguments --\n";
+// invalid arguments
+var_dump( unlink('') ); // $filename as empty string
+var_dump( file_exists('') ); // confirm file doesnt exist
+
+var_dump( unlink(NULL) ); // $filename as NULL
+var_dump( file_exists(NULL) ); // confirm file doesnt exist
+
+var_dump( unlink(false) ); // $filename as boolean false
+var_dump( file_exists(false) ); // confirm file doesnt exist
+
+var_dump( unlink($filename, '') ); // $context as empty string
+var_dump( unlink($filename, false) ); // $context as boolean false
+var_dump( unlink($filename, NULL) ); // $context as NULL
+
+
+echo "\n-- Testing unlink() on non-existent file --\n";
+var_dump( unlink(dirname(__FILE__)."/non_existent_file.tmp") );
+
+echo "\n-- Testing unlink() on directory --\n";
+// temp directory used here
+$dirname = "$file_path/unlink_error";
+// create temp dir
+mkdir($dirname);
+// unlinking directory
+var_dump( unlink($dirname) ); // expected: false as unlink() does not work on dir
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/unlink_error.tmp");
+rmdir(dirname(__FILE__)."/unlink_error");
+?>
+--EXPECTF--
+*** Testing unlink() : error conditions ***
+-- Testing unlink() on unexpected no. of arguments --
+
+Warning: unlink() expects at least 1 parameter, 0 given in %s on line %d
+bool(false)
+
+Warning: unlink() expects at most 2 parameters, 3 given in %s on line %d
+bool(false)
+bool(true)
+
+-- Testing unlink() on invalid arguments --
+
+Warning: unlink(): %s in %s on line %d
+bool(false)
+bool(false)
+
+Warning: unlink(): %s in %s on line %d
+bool(false)
+bool(false)
+
+Warning: unlink(): %s in %s on line %d
+bool(false)
+bool(false)
+
+Warning: unlink() expects parameter 2 to be resource, %unicode_string_optional% given in %s on line %d
+bool(false)
+
+Warning: unlink() expects parameter 2 to be resource, boolean given in %s on line %d
+bool(false)
+
+Warning: unlink() expects parameter 2 to be resource, null given in %s on line %d
+bool(false)
+
+-- Testing unlink() on non-existent file --
+
+Warning: unlink(%s/non_existent_file.tmp): No such file or directory in %s on line %d
+bool(false)
+
+-- Testing unlink() on directory --
+
+Warning: unlink(%s/unlink_error): %s in %s on line %d
+bool(false)
+Done
diff --git a/ext/standard/tests/file/unlink_variation1-win32.phpt b/ext/standard/tests/file/unlink_variation1-win32.phpt
new file mode 100644
index 0000000..b00e546
--- /dev/null
+++ b/ext/standard/tests/file/unlink_variation1-win32.phpt
@@ -0,0 +1,85 @@
+--TEST--
+Test unlink() function : usage variations - unlinking file in a directory
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip only on Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype : bool unlink ( string $filename [, resource $context] );
+ Description : Deletes filename
+*/
+
+/* Delete file having default permission but its dir having readonly permission
+ Delete file having readonly permission but dir having default permission
+*/
+
+
+$file_path = dirname(__FILE__);
+
+// temp dir name used here
+$dirname = "$file_path/unlink_variation1";
+// temp filename used here
+$filename = "$dirname/unlink_variation1-win32.tmp";
+
+echo "\n*** Testing unlink() on file inside a directory ***\n";
+// create temp dir
+mkdir($dirname);
+// create temp file inside $dirname
+$fp = fopen($filename, "w");
+fclose($fp);
+
+echo "-- Unlink file having default permission and its dir having read only permission --\n";
+// remove write permission of $dirname
+// on windows dir permission is not respected
+var_dump( chmod($dirname, 0444) );
+// now try deleting $filename
+var_dump( unlink($filename) ); // expected: true
+var_dump( file_exists($filename) ); // confirm file is deleted
+
+// remove the dir
+var_dump( chmod($dirname, 0777) );
+rmdir($dirname);
+
+echo "\n-- Unlinking file without write permission, its dir having default permission --\n";
+// create the temp dir
+mkdir($dirname);
+
+// create the temp file
+$fp = fopen($filename, "w");
+fclose($fp);
+
+// remove write permission from file
+var_dump( chmod($filename, 0444) );
+
+// now try deleting temp file inside $dirname
+var_dump( unlink($filename) ); // expected: false
+
+// reassign write permission to temp file
+chmod($filename, 0777);
+// delete temp file
+var_dump( unlink($filename) );
+var_dump( file_exists($filename) ); // confirm file is deleted
+// remove temp dir
+rmdir($dirname);
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing unlink() on file inside a directory ***
+-- Unlink file having default permission and its dir having read only permission --
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+
+-- Unlinking file without write permission, its dir having default permission --
+bool(true)
+
+Warning: unlink(%s/unlink_variation1/unlink_variation1-win32.tmp): Permission denied in %s on line %d
+bool(false)
+bool(true)
+bool(false)
+Done
diff --git a/ext/standard/tests/file/unlink_variation1.phpt b/ext/standard/tests/file/unlink_variation1.phpt
new file mode 100644
index 0000000..c27c13d
--- /dev/null
+++ b/ext/standard/tests/file/unlink_variation1.phpt
@@ -0,0 +1,92 @@
+--TEST--
+Test unlink() function : usage variations - unlinking file in a directory
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip only on Linux');
+}
+// Skip if being run by root (files are always readable, writeable and executable)
+$filename = dirname(__FILE__)."/unlink_root_check.tmp";
+$fp = fopen($filename, 'w');
+fclose($fp);
+if(fileowner($filename) == 0) {
+ unlink ($filename);
+ die('skip cannot be run as root');
+}
+
+unlink($filename);
+?>
+--FILE--
+<?php
+/* Prototype : bool unlink ( string $filename [, resource $context] );
+ Description : Deletes filename
+*/
+
+/* Delete file having default permission but its dir having readonly permission
+ Delete file having readonly permission but dir having default permission
+*/
+
+
+$file_path = dirname(__FILE__);
+
+// temp dir name used here
+$dirname = "$file_path/unlink_variation1";
+// temp filename used here
+$filename = "$dirname/unlink_variation1.tmp";
+
+echo "\n*** Testing unlink() on file inside a directory ***\n";
+// create temp dir
+mkdir($dirname);
+// create temp file inside $dirname
+$fp = fopen($filename, "w");
+fclose($fp);
+
+echo "-- Unlink file having default permission and its dir having read only permission --\n";
+// remove write permission of $dirname
+var_dump( chmod($dirname, 0444) );
+// now try deleting $filename
+var_dump( unlink($filename) ); // expected false
+var_dump( file_exists($filename) ); // confirm file is deleted
+
+// remove the dir
+var_dump( chmod($dirname, 0777) );
+var_dump( unlink($filename) ); // expected true
+var_dump( rmdir($dirname) );
+
+echo "\n-- Unlinking file without write permission, its dir having default permission --\n";
+// create the temp dir
+var_dump( mkdir($dirname) );
+// create the temp file
+$fp = fopen($filename, "w");
+fclose($fp);
+
+// remove write permission from file
+var_dump( chmod($filename, 0444) );
+// now try deleting temp file inside $dirname
+var_dump( unlink($filename) ); // expected: true
+var_dump( file_exists($filename) ); // expected: false
+
+// remove temp dir
+var_dump( rmdir($dirname) );
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing unlink() on file inside a directory ***
+-- Unlink file having default permission and its dir having read only permission --
+bool(true)
+
+Warning: unlink(%s): %s in %s on line %d
+bool(false)
+bool(false)
+bool(true)
+bool(true)
+bool(true)
+
+-- Unlinking file without write permission, its dir having default permission --
+bool(true)
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+Done \ No newline at end of file
diff --git a/ext/standard/tests/file/unlink_variation10.phpt b/ext/standard/tests/file/unlink_variation10.phpt
new file mode 100644
index 0000000..e0c92ca
--- /dev/null
+++ b/ext/standard/tests/file/unlink_variation10.phpt
@@ -0,0 +1,106 @@
+--TEST--
+Test unlink() function : variation: unlinking directories
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. Not for Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype : bool unlink(string filename[, context context])
+ * Description: Delete a file
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing unlink() : variation ***\n";
+
+$workDir = "unlinkVar8.tmp";
+$tmpDir = "subDir.tmp";
+$dirToLinkTo = $workDir.'/'."linkme.tmp";
+
+mkdir($workDir);
+$cwd = getcwd();
+mkdir($dirToLinkTo);
+
+$dirs = array(
+ // relative
+ $workDir.'/'.$tmpDir,
+ './'.$workDir.'/'.$tmpDir,
+ $workDir.'/../'.$workDir.'/'.$tmpDir,
+
+ //absolute
+ $cwd.'/'.$workDir.'/'.$tmpDir,
+ $cwd.'/./'.$workDir.'/'.$tmpDir,
+ $cwd.'/'.$workDir.'/../'.$workDir.'/'.$tmpDir,
+
+ // multiple separators
+ $workDir.'//'.$tmpDir,
+ $cwd.'//'.$workDir.'//'.$tmpDir,
+
+ );
+
+
+foreach($dirs as $dirToUnlink) {
+ test_link($workDir.'/'.$tmpDir, $dirToLinkTo, $dirToUnlink, true); //soft link
+ //cannot test hard links unless you are root.
+}
+
+echo "\n--- try to unlink a directory ---\n";
+unlink($dirToLinkTo);
+rmdir($dirToLinkTo);
+rmdir($workDir);
+
+function test_link($linkedDir, $toLinkTo, $tounlink, $softlink) {
+ if ($softlink == true) {
+ symlink($toLinkTo, $linkedDir);
+ $msg = "soft link";
+ }
+ else {
+ link($toLinkTo, $linkedDir);
+ $msg = "hard link";
+ }
+ echo "-- unlinking $msg $tounlink --\n";
+ $res = unlink($tounlink);
+ if ($res === true) {
+ if (is_link($tounlink) === false) {
+ echo "directory unlinked\n";
+ }
+ else {
+ echo "FAILED: directory not unlinked\n";
+ }
+ }
+ else {
+ unlink($linkedDir);
+ }
+}
+
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing unlink() : variation ***
+-- unlinking soft link unlinkVar8.tmp/subDir.tmp --
+directory unlinked
+-- unlinking soft link ./unlinkVar8.tmp/subDir.tmp --
+directory unlinked
+-- unlinking soft link unlinkVar8.tmp/../unlinkVar8.tmp/subDir.tmp --
+directory unlinked
+-- unlinking soft link /%s/unlinkVar8.tmp/subDir.tmp --
+directory unlinked
+-- unlinking soft link /%s/./unlinkVar8.tmp/subDir.tmp --
+directory unlinked
+-- unlinking soft link /%s/unlinkVar8.tmp/../unlinkVar8.tmp/subDir.tmp --
+directory unlinked
+-- unlinking soft link unlinkVar8.tmp//subDir.tmp --
+directory unlinked
+-- unlinking soft link /%s//unlinkVar8.tmp//subDir.tmp --
+directory unlinked
+
+--- try to unlink a directory ---
+
+Warning: unlink(unlinkVar8.tmp/linkme.tmp): %s in %s on line %d
+===DONE=== \ No newline at end of file
diff --git a/ext/standard/tests/file/unlink_variation2-win32.phpt b/ext/standard/tests/file/unlink_variation2-win32.phpt
new file mode 100644
index 0000000..af7b381
--- /dev/null
+++ b/ext/standard/tests/file/unlink_variation2-win32.phpt
@@ -0,0 +1,43 @@
+--TEST--
+Test unlink() function : usage variations - unlink file in use
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip only on Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype : bool unlink ( string $filename [, resource $context] );
+ Description : Deletes filename
+*/
+
+/* Try to unlink file when file handle is still in use */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Testing unlink() on a file when file handle is open ***\n";
+// temp file name used here
+$filename = "$file_path/unlink_variation2-win32.tmp";
+
+// create file
+$fp = fopen($filename, "w");
+// try unlink() on $filename
+var_dump( unlink($filename) ); // expected: false as file handle is still open
+// now close file handle
+fclose($fp);
+
+// now unlink file
+var_dump( unlink($filename) ); // expected: true
+var_dump( file_exists($filename) ); // confirm file is deleted
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing unlink() on a file when file handle is open ***
+
+Warning: unlink(%s): %s in %s on line %d
+bool(false)
+bool(true)
+bool(false)
+Done
diff --git a/ext/standard/tests/file/unlink_variation2.phpt b/ext/standard/tests/file/unlink_variation2.phpt
new file mode 100644
index 0000000..071a657
--- /dev/null
+++ b/ext/standard/tests/file/unlink_variation2.phpt
@@ -0,0 +1,37 @@
+--TEST--
+Test unlink() function : usage variations - unlink file in use
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip only on Linux');
+}
+?>
+--FILE--
+<?php
+/* Prototype : bool unlink ( string $filename [, resource $context] );
+ Description : Deletes filename
+*/
+
+/* Try to unlink file when file handle is still in use */
+
+$file_path = dirname(__FILE__);
+
+echo "*** Testing unlink() on a file which is in use ***\n";
+// temp file name used here
+$filename = "$file_path/unlink_variation2.tmp";
+
+// create file
+$fp = fopen($filename, "w");
+// try unlink() on $filename
+var_dump( unlink($filename) ); // expected: true on linux
+var_dump( file_exists($filename) ); // confirm file is deleted
+// now close file handle
+fclose($fp);
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing unlink() on a file which is in use ***
+bool(true)
+bool(false)
+Done
diff --git a/ext/standard/tests/file/unlink_variation3.phpt b/ext/standard/tests/file/unlink_variation3.phpt
new file mode 100644
index 0000000..96f21b2
--- /dev/null
+++ b/ext/standard/tests/file/unlink_variation3.phpt
@@ -0,0 +1,60 @@
+--TEST--
+Test unlink() function : usage variations - unlink links
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip only on Linux');
+}
+?>
+--FILE--
+<?php
+/* Prototype : bool unlink ( string $filename [, resource $context] );
+ Description : Deletes filename
+*/
+
+/* Delete link files - soft and hard links */
+
+$file_path = dirname(__FILE__);
+// temp file used
+$filename = "$file_path/unlink_variation3.tmp";
+
+echo "*** Testing unlink() on soft and hard links ***\n";
+// create temp file
+$fp = fopen($filename, "w");
+fclose($fp);
+// link name used here
+$linkname = "$file_path/unlink_variation3_link.tmp";
+
+echo "-- Testing unlink() on soft link --\n";
+// create soft link
+var_dump( symlink($filename, $linkname) ); // expected: true
+// unlink soft link
+var_dump( unlink($linkname) ); // expected: true
+var_dump( file_exists($linkname) ); // confirm link is deleted
+
+echo "-- Testing unlink() on hard link --\n";
+// create hard link
+var_dump( link($filename, $linkname) ); // expected: true
+// delete hard link
+var_dump( unlink($linkname) ); // expected: true
+var_dump( file_exists($linkname) ); // confirm link is deleted
+
+// delete temp file
+var_dump( unlink($filename) );
+var_dump( file_exists($filename) ); // confirm file is deleted
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing unlink() on soft and hard links ***
+-- Testing unlink() on soft link --
+bool(true)
+bool(true)
+bool(false)
+-- Testing unlink() on hard link --
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+bool(false)
+Done
diff --git a/ext/standard/tests/file/unlink_variation4.phpt b/ext/standard/tests/file/unlink_variation4.phpt
new file mode 100644
index 0000000..746cfd3
--- /dev/null
+++ b/ext/standard/tests/file/unlink_variation4.phpt
@@ -0,0 +1,37 @@
+--TEST--
+Test unlink() function : usage variations - unlink deleted file
+--FILE--
+<?php
+/* Prototype : bool unlink ( string $filename [, resource $context] );
+ Description : Deletes filename
+*/
+
+/* Try deleting a file which is already deleted */
+
+$file_path = dirname(__FILE__);
+
+// temp file used
+$filename = "$file_path/unlink_variation4.tmp";
+
+echo "*** Testing unlink() on deleted file ***\n";
+// create temp file
+$fp = fopen($filename, "w");
+fclose($fp);
+
+// delete temp file
+var_dump( unlink($filename) ); // expected: true
+var_dump( file_exists($filename) ); // confirm file deleted
+
+// delete deleted file
+var_dump( unlink($filename) ); // expected: false
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing unlink() on deleted file ***
+bool(true)
+bool(false)
+
+Warning: unlink(%s/unlink_variation4.tmp): %s in %s on line %d
+bool(false)
+Done
diff --git a/ext/standard/tests/file/unlink_variation5.phpt b/ext/standard/tests/file/unlink_variation5.phpt
new file mode 100644
index 0000000..51bb2c7
--- /dev/null
+++ b/ext/standard/tests/file/unlink_variation5.phpt
@@ -0,0 +1,2087 @@
+--TEST--
+Test unlink() function : usage variations - files with diff. file permissions
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip only on Linux');
+}
+?>
+--FILE--
+<?php
+/* Prototype : bool unlink ( string $filename [, resource $context] );
+ Description : Deletes filename
+*/
+
+/* delete files with different file permission(0000 to 0777) */
+
+$file_path = dirname(__FILE__);
+
+// temp file used
+$filename = "$file_path/unlink_variation5.tmp";
+
+echo "*** Testing unlink() on a file ***\n";
+
+for($mode = 0000; $mode <= 0777; $mode++ ) {
+ // create temp file
+ $fp = fopen($filename, "w");
+ fclose($fp);
+ // changing mode of file
+ echo "File permission : $mode\n";
+ var_dump( chmod($filename, $mode) );
+ var_dump( unlink($filename) ); // deleting file
+ var_dump( file_exists($filename) ); // confirm file deleted
+}
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing unlink() on a file ***
+File permission : 0
+bool(true)
+bool(true)
+bool(false)
+File permission : 1
+bool(true)
+bool(true)
+bool(false)
+File permission : 2
+bool(true)
+bool(true)
+bool(false)
+File permission : 3
+bool(true)
+bool(true)
+bool(false)
+File permission : 4
+bool(true)
+bool(true)
+bool(false)
+File permission : 5
+bool(true)
+bool(true)
+bool(false)
+File permission : 6
+bool(true)
+bool(true)
+bool(false)
+File permission : 7
+bool(true)
+bool(true)
+bool(false)
+File permission : 8
+bool(true)
+bool(true)
+bool(false)
+File permission : 9
+bool(true)
+bool(true)
+bool(false)
+File permission : 10
+bool(true)
+bool(true)
+bool(false)
+File permission : 11
+bool(true)
+bool(true)
+bool(false)
+File permission : 12
+bool(true)
+bool(true)
+bool(false)
+File permission : 13
+bool(true)
+bool(true)
+bool(false)
+File permission : 14
+bool(true)
+bool(true)
+bool(false)
+File permission : 15
+bool(true)
+bool(true)
+bool(false)
+File permission : 16
+bool(true)
+bool(true)
+bool(false)
+File permission : 17
+bool(true)
+bool(true)
+bool(false)
+File permission : 18
+bool(true)
+bool(true)
+bool(false)
+File permission : 19
+bool(true)
+bool(true)
+bool(false)
+File permission : 20
+bool(true)
+bool(true)
+bool(false)
+File permission : 21
+bool(true)
+bool(true)
+bool(false)
+File permission : 22
+bool(true)
+bool(true)
+bool(false)
+File permission : 23
+bool(true)
+bool(true)
+bool(false)
+File permission : 24
+bool(true)
+bool(true)
+bool(false)
+File permission : 25
+bool(true)
+bool(true)
+bool(false)
+File permission : 26
+bool(true)
+bool(true)
+bool(false)
+File permission : 27
+bool(true)
+bool(true)
+bool(false)
+File permission : 28
+bool(true)
+bool(true)
+bool(false)
+File permission : 29
+bool(true)
+bool(true)
+bool(false)
+File permission : 30
+bool(true)
+bool(true)
+bool(false)
+File permission : 31
+bool(true)
+bool(true)
+bool(false)
+File permission : 32
+bool(true)
+bool(true)
+bool(false)
+File permission : 33
+bool(true)
+bool(true)
+bool(false)
+File permission : 34
+bool(true)
+bool(true)
+bool(false)
+File permission : 35
+bool(true)
+bool(true)
+bool(false)
+File permission : 36
+bool(true)
+bool(true)
+bool(false)
+File permission : 37
+bool(true)
+bool(true)
+bool(false)
+File permission : 38
+bool(true)
+bool(true)
+bool(false)
+File permission : 39
+bool(true)
+bool(true)
+bool(false)
+File permission : 40
+bool(true)
+bool(true)
+bool(false)
+File permission : 41
+bool(true)
+bool(true)
+bool(false)
+File permission : 42
+bool(true)
+bool(true)
+bool(false)
+File permission : 43
+bool(true)
+bool(true)
+bool(false)
+File permission : 44
+bool(true)
+bool(true)
+bool(false)
+File permission : 45
+bool(true)
+bool(true)
+bool(false)
+File permission : 46
+bool(true)
+bool(true)
+bool(false)
+File permission : 47
+bool(true)
+bool(true)
+bool(false)
+File permission : 48
+bool(true)
+bool(true)
+bool(false)
+File permission : 49
+bool(true)
+bool(true)
+bool(false)
+File permission : 50
+bool(true)
+bool(true)
+bool(false)
+File permission : 51
+bool(true)
+bool(true)
+bool(false)
+File permission : 52
+bool(true)
+bool(true)
+bool(false)
+File permission : 53
+bool(true)
+bool(true)
+bool(false)
+File permission : 54
+bool(true)
+bool(true)
+bool(false)
+File permission : 55
+bool(true)
+bool(true)
+bool(false)
+File permission : 56
+bool(true)
+bool(true)
+bool(false)
+File permission : 57
+bool(true)
+bool(true)
+bool(false)
+File permission : 58
+bool(true)
+bool(true)
+bool(false)
+File permission : 59
+bool(true)
+bool(true)
+bool(false)
+File permission : 60
+bool(true)
+bool(true)
+bool(false)
+File permission : 61
+bool(true)
+bool(true)
+bool(false)
+File permission : 62
+bool(true)
+bool(true)
+bool(false)
+File permission : 63
+bool(true)
+bool(true)
+bool(false)
+File permission : 64
+bool(true)
+bool(true)
+bool(false)
+File permission : 65
+bool(true)
+bool(true)
+bool(false)
+File permission : 66
+bool(true)
+bool(true)
+bool(false)
+File permission : 67
+bool(true)
+bool(true)
+bool(false)
+File permission : 68
+bool(true)
+bool(true)
+bool(false)
+File permission : 69
+bool(true)
+bool(true)
+bool(false)
+File permission : 70
+bool(true)
+bool(true)
+bool(false)
+File permission : 71
+bool(true)
+bool(true)
+bool(false)
+File permission : 72
+bool(true)
+bool(true)
+bool(false)
+File permission : 73
+bool(true)
+bool(true)
+bool(false)
+File permission : 74
+bool(true)
+bool(true)
+bool(false)
+File permission : 75
+bool(true)
+bool(true)
+bool(false)
+File permission : 76
+bool(true)
+bool(true)
+bool(false)
+File permission : 77
+bool(true)
+bool(true)
+bool(false)
+File permission : 78
+bool(true)
+bool(true)
+bool(false)
+File permission : 79
+bool(true)
+bool(true)
+bool(false)
+File permission : 80
+bool(true)
+bool(true)
+bool(false)
+File permission : 81
+bool(true)
+bool(true)
+bool(false)
+File permission : 82
+bool(true)
+bool(true)
+bool(false)
+File permission : 83
+bool(true)
+bool(true)
+bool(false)
+File permission : 84
+bool(true)
+bool(true)
+bool(false)
+File permission : 85
+bool(true)
+bool(true)
+bool(false)
+File permission : 86
+bool(true)
+bool(true)
+bool(false)
+File permission : 87
+bool(true)
+bool(true)
+bool(false)
+File permission : 88
+bool(true)
+bool(true)
+bool(false)
+File permission : 89
+bool(true)
+bool(true)
+bool(false)
+File permission : 90
+bool(true)
+bool(true)
+bool(false)
+File permission : 91
+bool(true)
+bool(true)
+bool(false)
+File permission : 92
+bool(true)
+bool(true)
+bool(false)
+File permission : 93
+bool(true)
+bool(true)
+bool(false)
+File permission : 94
+bool(true)
+bool(true)
+bool(false)
+File permission : 95
+bool(true)
+bool(true)
+bool(false)
+File permission : 96
+bool(true)
+bool(true)
+bool(false)
+File permission : 97
+bool(true)
+bool(true)
+bool(false)
+File permission : 98
+bool(true)
+bool(true)
+bool(false)
+File permission : 99
+bool(true)
+bool(true)
+bool(false)
+File permission : 100
+bool(true)
+bool(true)
+bool(false)
+File permission : 101
+bool(true)
+bool(true)
+bool(false)
+File permission : 102
+bool(true)
+bool(true)
+bool(false)
+File permission : 103
+bool(true)
+bool(true)
+bool(false)
+File permission : 104
+bool(true)
+bool(true)
+bool(false)
+File permission : 105
+bool(true)
+bool(true)
+bool(false)
+File permission : 106
+bool(true)
+bool(true)
+bool(false)
+File permission : 107
+bool(true)
+bool(true)
+bool(false)
+File permission : 108
+bool(true)
+bool(true)
+bool(false)
+File permission : 109
+bool(true)
+bool(true)
+bool(false)
+File permission : 110
+bool(true)
+bool(true)
+bool(false)
+File permission : 111
+bool(true)
+bool(true)
+bool(false)
+File permission : 112
+bool(true)
+bool(true)
+bool(false)
+File permission : 113
+bool(true)
+bool(true)
+bool(false)
+File permission : 114
+bool(true)
+bool(true)
+bool(false)
+File permission : 115
+bool(true)
+bool(true)
+bool(false)
+File permission : 116
+bool(true)
+bool(true)
+bool(false)
+File permission : 117
+bool(true)
+bool(true)
+bool(false)
+File permission : 118
+bool(true)
+bool(true)
+bool(false)
+File permission : 119
+bool(true)
+bool(true)
+bool(false)
+File permission : 120
+bool(true)
+bool(true)
+bool(false)
+File permission : 121
+bool(true)
+bool(true)
+bool(false)
+File permission : 122
+bool(true)
+bool(true)
+bool(false)
+File permission : 123
+bool(true)
+bool(true)
+bool(false)
+File permission : 124
+bool(true)
+bool(true)
+bool(false)
+File permission : 125
+bool(true)
+bool(true)
+bool(false)
+File permission : 126
+bool(true)
+bool(true)
+bool(false)
+File permission : 127
+bool(true)
+bool(true)
+bool(false)
+File permission : 128
+bool(true)
+bool(true)
+bool(false)
+File permission : 129
+bool(true)
+bool(true)
+bool(false)
+File permission : 130
+bool(true)
+bool(true)
+bool(false)
+File permission : 131
+bool(true)
+bool(true)
+bool(false)
+File permission : 132
+bool(true)
+bool(true)
+bool(false)
+File permission : 133
+bool(true)
+bool(true)
+bool(false)
+File permission : 134
+bool(true)
+bool(true)
+bool(false)
+File permission : 135
+bool(true)
+bool(true)
+bool(false)
+File permission : 136
+bool(true)
+bool(true)
+bool(false)
+File permission : 137
+bool(true)
+bool(true)
+bool(false)
+File permission : 138
+bool(true)
+bool(true)
+bool(false)
+File permission : 139
+bool(true)
+bool(true)
+bool(false)
+File permission : 140
+bool(true)
+bool(true)
+bool(false)
+File permission : 141
+bool(true)
+bool(true)
+bool(false)
+File permission : 142
+bool(true)
+bool(true)
+bool(false)
+File permission : 143
+bool(true)
+bool(true)
+bool(false)
+File permission : 144
+bool(true)
+bool(true)
+bool(false)
+File permission : 145
+bool(true)
+bool(true)
+bool(false)
+File permission : 146
+bool(true)
+bool(true)
+bool(false)
+File permission : 147
+bool(true)
+bool(true)
+bool(false)
+File permission : 148
+bool(true)
+bool(true)
+bool(false)
+File permission : 149
+bool(true)
+bool(true)
+bool(false)
+File permission : 150
+bool(true)
+bool(true)
+bool(false)
+File permission : 151
+bool(true)
+bool(true)
+bool(false)
+File permission : 152
+bool(true)
+bool(true)
+bool(false)
+File permission : 153
+bool(true)
+bool(true)
+bool(false)
+File permission : 154
+bool(true)
+bool(true)
+bool(false)
+File permission : 155
+bool(true)
+bool(true)
+bool(false)
+File permission : 156
+bool(true)
+bool(true)
+bool(false)
+File permission : 157
+bool(true)
+bool(true)
+bool(false)
+File permission : 158
+bool(true)
+bool(true)
+bool(false)
+File permission : 159
+bool(true)
+bool(true)
+bool(false)
+File permission : 160
+bool(true)
+bool(true)
+bool(false)
+File permission : 161
+bool(true)
+bool(true)
+bool(false)
+File permission : 162
+bool(true)
+bool(true)
+bool(false)
+File permission : 163
+bool(true)
+bool(true)
+bool(false)
+File permission : 164
+bool(true)
+bool(true)
+bool(false)
+File permission : 165
+bool(true)
+bool(true)
+bool(false)
+File permission : 166
+bool(true)
+bool(true)
+bool(false)
+File permission : 167
+bool(true)
+bool(true)
+bool(false)
+File permission : 168
+bool(true)
+bool(true)
+bool(false)
+File permission : 169
+bool(true)
+bool(true)
+bool(false)
+File permission : 170
+bool(true)
+bool(true)
+bool(false)
+File permission : 171
+bool(true)
+bool(true)
+bool(false)
+File permission : 172
+bool(true)
+bool(true)
+bool(false)
+File permission : 173
+bool(true)
+bool(true)
+bool(false)
+File permission : 174
+bool(true)
+bool(true)
+bool(false)
+File permission : 175
+bool(true)
+bool(true)
+bool(false)
+File permission : 176
+bool(true)
+bool(true)
+bool(false)
+File permission : 177
+bool(true)
+bool(true)
+bool(false)
+File permission : 178
+bool(true)
+bool(true)
+bool(false)
+File permission : 179
+bool(true)
+bool(true)
+bool(false)
+File permission : 180
+bool(true)
+bool(true)
+bool(false)
+File permission : 181
+bool(true)
+bool(true)
+bool(false)
+File permission : 182
+bool(true)
+bool(true)
+bool(false)
+File permission : 183
+bool(true)
+bool(true)
+bool(false)
+File permission : 184
+bool(true)
+bool(true)
+bool(false)
+File permission : 185
+bool(true)
+bool(true)
+bool(false)
+File permission : 186
+bool(true)
+bool(true)
+bool(false)
+File permission : 187
+bool(true)
+bool(true)
+bool(false)
+File permission : 188
+bool(true)
+bool(true)
+bool(false)
+File permission : 189
+bool(true)
+bool(true)
+bool(false)
+File permission : 190
+bool(true)
+bool(true)
+bool(false)
+File permission : 191
+bool(true)
+bool(true)
+bool(false)
+File permission : 192
+bool(true)
+bool(true)
+bool(false)
+File permission : 193
+bool(true)
+bool(true)
+bool(false)
+File permission : 194
+bool(true)
+bool(true)
+bool(false)
+File permission : 195
+bool(true)
+bool(true)
+bool(false)
+File permission : 196
+bool(true)
+bool(true)
+bool(false)
+File permission : 197
+bool(true)
+bool(true)
+bool(false)
+File permission : 198
+bool(true)
+bool(true)
+bool(false)
+File permission : 199
+bool(true)
+bool(true)
+bool(false)
+File permission : 200
+bool(true)
+bool(true)
+bool(false)
+File permission : 201
+bool(true)
+bool(true)
+bool(false)
+File permission : 202
+bool(true)
+bool(true)
+bool(false)
+File permission : 203
+bool(true)
+bool(true)
+bool(false)
+File permission : 204
+bool(true)
+bool(true)
+bool(false)
+File permission : 205
+bool(true)
+bool(true)
+bool(false)
+File permission : 206
+bool(true)
+bool(true)
+bool(false)
+File permission : 207
+bool(true)
+bool(true)
+bool(false)
+File permission : 208
+bool(true)
+bool(true)
+bool(false)
+File permission : 209
+bool(true)
+bool(true)
+bool(false)
+File permission : 210
+bool(true)
+bool(true)
+bool(false)
+File permission : 211
+bool(true)
+bool(true)
+bool(false)
+File permission : 212
+bool(true)
+bool(true)
+bool(false)
+File permission : 213
+bool(true)
+bool(true)
+bool(false)
+File permission : 214
+bool(true)
+bool(true)
+bool(false)
+File permission : 215
+bool(true)
+bool(true)
+bool(false)
+File permission : 216
+bool(true)
+bool(true)
+bool(false)
+File permission : 217
+bool(true)
+bool(true)
+bool(false)
+File permission : 218
+bool(true)
+bool(true)
+bool(false)
+File permission : 219
+bool(true)
+bool(true)
+bool(false)
+File permission : 220
+bool(true)
+bool(true)
+bool(false)
+File permission : 221
+bool(true)
+bool(true)
+bool(false)
+File permission : 222
+bool(true)
+bool(true)
+bool(false)
+File permission : 223
+bool(true)
+bool(true)
+bool(false)
+File permission : 224
+bool(true)
+bool(true)
+bool(false)
+File permission : 225
+bool(true)
+bool(true)
+bool(false)
+File permission : 226
+bool(true)
+bool(true)
+bool(false)
+File permission : 227
+bool(true)
+bool(true)
+bool(false)
+File permission : 228
+bool(true)
+bool(true)
+bool(false)
+File permission : 229
+bool(true)
+bool(true)
+bool(false)
+File permission : 230
+bool(true)
+bool(true)
+bool(false)
+File permission : 231
+bool(true)
+bool(true)
+bool(false)
+File permission : 232
+bool(true)
+bool(true)
+bool(false)
+File permission : 233
+bool(true)
+bool(true)
+bool(false)
+File permission : 234
+bool(true)
+bool(true)
+bool(false)
+File permission : 235
+bool(true)
+bool(true)
+bool(false)
+File permission : 236
+bool(true)
+bool(true)
+bool(false)
+File permission : 237
+bool(true)
+bool(true)
+bool(false)
+File permission : 238
+bool(true)
+bool(true)
+bool(false)
+File permission : 239
+bool(true)
+bool(true)
+bool(false)
+File permission : 240
+bool(true)
+bool(true)
+bool(false)
+File permission : 241
+bool(true)
+bool(true)
+bool(false)
+File permission : 242
+bool(true)
+bool(true)
+bool(false)
+File permission : 243
+bool(true)
+bool(true)
+bool(false)
+File permission : 244
+bool(true)
+bool(true)
+bool(false)
+File permission : 245
+bool(true)
+bool(true)
+bool(false)
+File permission : 246
+bool(true)
+bool(true)
+bool(false)
+File permission : 247
+bool(true)
+bool(true)
+bool(false)
+File permission : 248
+bool(true)
+bool(true)
+bool(false)
+File permission : 249
+bool(true)
+bool(true)
+bool(false)
+File permission : 250
+bool(true)
+bool(true)
+bool(false)
+File permission : 251
+bool(true)
+bool(true)
+bool(false)
+File permission : 252
+bool(true)
+bool(true)
+bool(false)
+File permission : 253
+bool(true)
+bool(true)
+bool(false)
+File permission : 254
+bool(true)
+bool(true)
+bool(false)
+File permission : 255
+bool(true)
+bool(true)
+bool(false)
+File permission : 256
+bool(true)
+bool(true)
+bool(false)
+File permission : 257
+bool(true)
+bool(true)
+bool(false)
+File permission : 258
+bool(true)
+bool(true)
+bool(false)
+File permission : 259
+bool(true)
+bool(true)
+bool(false)
+File permission : 260
+bool(true)
+bool(true)
+bool(false)
+File permission : 261
+bool(true)
+bool(true)
+bool(false)
+File permission : 262
+bool(true)
+bool(true)
+bool(false)
+File permission : 263
+bool(true)
+bool(true)
+bool(false)
+File permission : 264
+bool(true)
+bool(true)
+bool(false)
+File permission : 265
+bool(true)
+bool(true)
+bool(false)
+File permission : 266
+bool(true)
+bool(true)
+bool(false)
+File permission : 267
+bool(true)
+bool(true)
+bool(false)
+File permission : 268
+bool(true)
+bool(true)
+bool(false)
+File permission : 269
+bool(true)
+bool(true)
+bool(false)
+File permission : 270
+bool(true)
+bool(true)
+bool(false)
+File permission : 271
+bool(true)
+bool(true)
+bool(false)
+File permission : 272
+bool(true)
+bool(true)
+bool(false)
+File permission : 273
+bool(true)
+bool(true)
+bool(false)
+File permission : 274
+bool(true)
+bool(true)
+bool(false)
+File permission : 275
+bool(true)
+bool(true)
+bool(false)
+File permission : 276
+bool(true)
+bool(true)
+bool(false)
+File permission : 277
+bool(true)
+bool(true)
+bool(false)
+File permission : 278
+bool(true)
+bool(true)
+bool(false)
+File permission : 279
+bool(true)
+bool(true)
+bool(false)
+File permission : 280
+bool(true)
+bool(true)
+bool(false)
+File permission : 281
+bool(true)
+bool(true)
+bool(false)
+File permission : 282
+bool(true)
+bool(true)
+bool(false)
+File permission : 283
+bool(true)
+bool(true)
+bool(false)
+File permission : 284
+bool(true)
+bool(true)
+bool(false)
+File permission : 285
+bool(true)
+bool(true)
+bool(false)
+File permission : 286
+bool(true)
+bool(true)
+bool(false)
+File permission : 287
+bool(true)
+bool(true)
+bool(false)
+File permission : 288
+bool(true)
+bool(true)
+bool(false)
+File permission : 289
+bool(true)
+bool(true)
+bool(false)
+File permission : 290
+bool(true)
+bool(true)
+bool(false)
+File permission : 291
+bool(true)
+bool(true)
+bool(false)
+File permission : 292
+bool(true)
+bool(true)
+bool(false)
+File permission : 293
+bool(true)
+bool(true)
+bool(false)
+File permission : 294
+bool(true)
+bool(true)
+bool(false)
+File permission : 295
+bool(true)
+bool(true)
+bool(false)
+File permission : 296
+bool(true)
+bool(true)
+bool(false)
+File permission : 297
+bool(true)
+bool(true)
+bool(false)
+File permission : 298
+bool(true)
+bool(true)
+bool(false)
+File permission : 299
+bool(true)
+bool(true)
+bool(false)
+File permission : 300
+bool(true)
+bool(true)
+bool(false)
+File permission : 301
+bool(true)
+bool(true)
+bool(false)
+File permission : 302
+bool(true)
+bool(true)
+bool(false)
+File permission : 303
+bool(true)
+bool(true)
+bool(false)
+File permission : 304
+bool(true)
+bool(true)
+bool(false)
+File permission : 305
+bool(true)
+bool(true)
+bool(false)
+File permission : 306
+bool(true)
+bool(true)
+bool(false)
+File permission : 307
+bool(true)
+bool(true)
+bool(false)
+File permission : 308
+bool(true)
+bool(true)
+bool(false)
+File permission : 309
+bool(true)
+bool(true)
+bool(false)
+File permission : 310
+bool(true)
+bool(true)
+bool(false)
+File permission : 311
+bool(true)
+bool(true)
+bool(false)
+File permission : 312
+bool(true)
+bool(true)
+bool(false)
+File permission : 313
+bool(true)
+bool(true)
+bool(false)
+File permission : 314
+bool(true)
+bool(true)
+bool(false)
+File permission : 315
+bool(true)
+bool(true)
+bool(false)
+File permission : 316
+bool(true)
+bool(true)
+bool(false)
+File permission : 317
+bool(true)
+bool(true)
+bool(false)
+File permission : 318
+bool(true)
+bool(true)
+bool(false)
+File permission : 319
+bool(true)
+bool(true)
+bool(false)
+File permission : 320
+bool(true)
+bool(true)
+bool(false)
+File permission : 321
+bool(true)
+bool(true)
+bool(false)
+File permission : 322
+bool(true)
+bool(true)
+bool(false)
+File permission : 323
+bool(true)
+bool(true)
+bool(false)
+File permission : 324
+bool(true)
+bool(true)
+bool(false)
+File permission : 325
+bool(true)
+bool(true)
+bool(false)
+File permission : 326
+bool(true)
+bool(true)
+bool(false)
+File permission : 327
+bool(true)
+bool(true)
+bool(false)
+File permission : 328
+bool(true)
+bool(true)
+bool(false)
+File permission : 329
+bool(true)
+bool(true)
+bool(false)
+File permission : 330
+bool(true)
+bool(true)
+bool(false)
+File permission : 331
+bool(true)
+bool(true)
+bool(false)
+File permission : 332
+bool(true)
+bool(true)
+bool(false)
+File permission : 333
+bool(true)
+bool(true)
+bool(false)
+File permission : 334
+bool(true)
+bool(true)
+bool(false)
+File permission : 335
+bool(true)
+bool(true)
+bool(false)
+File permission : 336
+bool(true)
+bool(true)
+bool(false)
+File permission : 337
+bool(true)
+bool(true)
+bool(false)
+File permission : 338
+bool(true)
+bool(true)
+bool(false)
+File permission : 339
+bool(true)
+bool(true)
+bool(false)
+File permission : 340
+bool(true)
+bool(true)
+bool(false)
+File permission : 341
+bool(true)
+bool(true)
+bool(false)
+File permission : 342
+bool(true)
+bool(true)
+bool(false)
+File permission : 343
+bool(true)
+bool(true)
+bool(false)
+File permission : 344
+bool(true)
+bool(true)
+bool(false)
+File permission : 345
+bool(true)
+bool(true)
+bool(false)
+File permission : 346
+bool(true)
+bool(true)
+bool(false)
+File permission : 347
+bool(true)
+bool(true)
+bool(false)
+File permission : 348
+bool(true)
+bool(true)
+bool(false)
+File permission : 349
+bool(true)
+bool(true)
+bool(false)
+File permission : 350
+bool(true)
+bool(true)
+bool(false)
+File permission : 351
+bool(true)
+bool(true)
+bool(false)
+File permission : 352
+bool(true)
+bool(true)
+bool(false)
+File permission : 353
+bool(true)
+bool(true)
+bool(false)
+File permission : 354
+bool(true)
+bool(true)
+bool(false)
+File permission : 355
+bool(true)
+bool(true)
+bool(false)
+File permission : 356
+bool(true)
+bool(true)
+bool(false)
+File permission : 357
+bool(true)
+bool(true)
+bool(false)
+File permission : 358
+bool(true)
+bool(true)
+bool(false)
+File permission : 359
+bool(true)
+bool(true)
+bool(false)
+File permission : 360
+bool(true)
+bool(true)
+bool(false)
+File permission : 361
+bool(true)
+bool(true)
+bool(false)
+File permission : 362
+bool(true)
+bool(true)
+bool(false)
+File permission : 363
+bool(true)
+bool(true)
+bool(false)
+File permission : 364
+bool(true)
+bool(true)
+bool(false)
+File permission : 365
+bool(true)
+bool(true)
+bool(false)
+File permission : 366
+bool(true)
+bool(true)
+bool(false)
+File permission : 367
+bool(true)
+bool(true)
+bool(false)
+File permission : 368
+bool(true)
+bool(true)
+bool(false)
+File permission : 369
+bool(true)
+bool(true)
+bool(false)
+File permission : 370
+bool(true)
+bool(true)
+bool(false)
+File permission : 371
+bool(true)
+bool(true)
+bool(false)
+File permission : 372
+bool(true)
+bool(true)
+bool(false)
+File permission : 373
+bool(true)
+bool(true)
+bool(false)
+File permission : 374
+bool(true)
+bool(true)
+bool(false)
+File permission : 375
+bool(true)
+bool(true)
+bool(false)
+File permission : 376
+bool(true)
+bool(true)
+bool(false)
+File permission : 377
+bool(true)
+bool(true)
+bool(false)
+File permission : 378
+bool(true)
+bool(true)
+bool(false)
+File permission : 379
+bool(true)
+bool(true)
+bool(false)
+File permission : 380
+bool(true)
+bool(true)
+bool(false)
+File permission : 381
+bool(true)
+bool(true)
+bool(false)
+File permission : 382
+bool(true)
+bool(true)
+bool(false)
+File permission : 383
+bool(true)
+bool(true)
+bool(false)
+File permission : 384
+bool(true)
+bool(true)
+bool(false)
+File permission : 385
+bool(true)
+bool(true)
+bool(false)
+File permission : 386
+bool(true)
+bool(true)
+bool(false)
+File permission : 387
+bool(true)
+bool(true)
+bool(false)
+File permission : 388
+bool(true)
+bool(true)
+bool(false)
+File permission : 389
+bool(true)
+bool(true)
+bool(false)
+File permission : 390
+bool(true)
+bool(true)
+bool(false)
+File permission : 391
+bool(true)
+bool(true)
+bool(false)
+File permission : 392
+bool(true)
+bool(true)
+bool(false)
+File permission : 393
+bool(true)
+bool(true)
+bool(false)
+File permission : 394
+bool(true)
+bool(true)
+bool(false)
+File permission : 395
+bool(true)
+bool(true)
+bool(false)
+File permission : 396
+bool(true)
+bool(true)
+bool(false)
+File permission : 397
+bool(true)
+bool(true)
+bool(false)
+File permission : 398
+bool(true)
+bool(true)
+bool(false)
+File permission : 399
+bool(true)
+bool(true)
+bool(false)
+File permission : 400
+bool(true)
+bool(true)
+bool(false)
+File permission : 401
+bool(true)
+bool(true)
+bool(false)
+File permission : 402
+bool(true)
+bool(true)
+bool(false)
+File permission : 403
+bool(true)
+bool(true)
+bool(false)
+File permission : 404
+bool(true)
+bool(true)
+bool(false)
+File permission : 405
+bool(true)
+bool(true)
+bool(false)
+File permission : 406
+bool(true)
+bool(true)
+bool(false)
+File permission : 407
+bool(true)
+bool(true)
+bool(false)
+File permission : 408
+bool(true)
+bool(true)
+bool(false)
+File permission : 409
+bool(true)
+bool(true)
+bool(false)
+File permission : 410
+bool(true)
+bool(true)
+bool(false)
+File permission : 411
+bool(true)
+bool(true)
+bool(false)
+File permission : 412
+bool(true)
+bool(true)
+bool(false)
+File permission : 413
+bool(true)
+bool(true)
+bool(false)
+File permission : 414
+bool(true)
+bool(true)
+bool(false)
+File permission : 415
+bool(true)
+bool(true)
+bool(false)
+File permission : 416
+bool(true)
+bool(true)
+bool(false)
+File permission : 417
+bool(true)
+bool(true)
+bool(false)
+File permission : 418
+bool(true)
+bool(true)
+bool(false)
+File permission : 419
+bool(true)
+bool(true)
+bool(false)
+File permission : 420
+bool(true)
+bool(true)
+bool(false)
+File permission : 421
+bool(true)
+bool(true)
+bool(false)
+File permission : 422
+bool(true)
+bool(true)
+bool(false)
+File permission : 423
+bool(true)
+bool(true)
+bool(false)
+File permission : 424
+bool(true)
+bool(true)
+bool(false)
+File permission : 425
+bool(true)
+bool(true)
+bool(false)
+File permission : 426
+bool(true)
+bool(true)
+bool(false)
+File permission : 427
+bool(true)
+bool(true)
+bool(false)
+File permission : 428
+bool(true)
+bool(true)
+bool(false)
+File permission : 429
+bool(true)
+bool(true)
+bool(false)
+File permission : 430
+bool(true)
+bool(true)
+bool(false)
+File permission : 431
+bool(true)
+bool(true)
+bool(false)
+File permission : 432
+bool(true)
+bool(true)
+bool(false)
+File permission : 433
+bool(true)
+bool(true)
+bool(false)
+File permission : 434
+bool(true)
+bool(true)
+bool(false)
+File permission : 435
+bool(true)
+bool(true)
+bool(false)
+File permission : 436
+bool(true)
+bool(true)
+bool(false)
+File permission : 437
+bool(true)
+bool(true)
+bool(false)
+File permission : 438
+bool(true)
+bool(true)
+bool(false)
+File permission : 439
+bool(true)
+bool(true)
+bool(false)
+File permission : 440
+bool(true)
+bool(true)
+bool(false)
+File permission : 441
+bool(true)
+bool(true)
+bool(false)
+File permission : 442
+bool(true)
+bool(true)
+bool(false)
+File permission : 443
+bool(true)
+bool(true)
+bool(false)
+File permission : 444
+bool(true)
+bool(true)
+bool(false)
+File permission : 445
+bool(true)
+bool(true)
+bool(false)
+File permission : 446
+bool(true)
+bool(true)
+bool(false)
+File permission : 447
+bool(true)
+bool(true)
+bool(false)
+File permission : 448
+bool(true)
+bool(true)
+bool(false)
+File permission : 449
+bool(true)
+bool(true)
+bool(false)
+File permission : 450
+bool(true)
+bool(true)
+bool(false)
+File permission : 451
+bool(true)
+bool(true)
+bool(false)
+File permission : 452
+bool(true)
+bool(true)
+bool(false)
+File permission : 453
+bool(true)
+bool(true)
+bool(false)
+File permission : 454
+bool(true)
+bool(true)
+bool(false)
+File permission : 455
+bool(true)
+bool(true)
+bool(false)
+File permission : 456
+bool(true)
+bool(true)
+bool(false)
+File permission : 457
+bool(true)
+bool(true)
+bool(false)
+File permission : 458
+bool(true)
+bool(true)
+bool(false)
+File permission : 459
+bool(true)
+bool(true)
+bool(false)
+File permission : 460
+bool(true)
+bool(true)
+bool(false)
+File permission : 461
+bool(true)
+bool(true)
+bool(false)
+File permission : 462
+bool(true)
+bool(true)
+bool(false)
+File permission : 463
+bool(true)
+bool(true)
+bool(false)
+File permission : 464
+bool(true)
+bool(true)
+bool(false)
+File permission : 465
+bool(true)
+bool(true)
+bool(false)
+File permission : 466
+bool(true)
+bool(true)
+bool(false)
+File permission : 467
+bool(true)
+bool(true)
+bool(false)
+File permission : 468
+bool(true)
+bool(true)
+bool(false)
+File permission : 469
+bool(true)
+bool(true)
+bool(false)
+File permission : 470
+bool(true)
+bool(true)
+bool(false)
+File permission : 471
+bool(true)
+bool(true)
+bool(false)
+File permission : 472
+bool(true)
+bool(true)
+bool(false)
+File permission : 473
+bool(true)
+bool(true)
+bool(false)
+File permission : 474
+bool(true)
+bool(true)
+bool(false)
+File permission : 475
+bool(true)
+bool(true)
+bool(false)
+File permission : 476
+bool(true)
+bool(true)
+bool(false)
+File permission : 477
+bool(true)
+bool(true)
+bool(false)
+File permission : 478
+bool(true)
+bool(true)
+bool(false)
+File permission : 479
+bool(true)
+bool(true)
+bool(false)
+File permission : 480
+bool(true)
+bool(true)
+bool(false)
+File permission : 481
+bool(true)
+bool(true)
+bool(false)
+File permission : 482
+bool(true)
+bool(true)
+bool(false)
+File permission : 483
+bool(true)
+bool(true)
+bool(false)
+File permission : 484
+bool(true)
+bool(true)
+bool(false)
+File permission : 485
+bool(true)
+bool(true)
+bool(false)
+File permission : 486
+bool(true)
+bool(true)
+bool(false)
+File permission : 487
+bool(true)
+bool(true)
+bool(false)
+File permission : 488
+bool(true)
+bool(true)
+bool(false)
+File permission : 489
+bool(true)
+bool(true)
+bool(false)
+File permission : 490
+bool(true)
+bool(true)
+bool(false)
+File permission : 491
+bool(true)
+bool(true)
+bool(false)
+File permission : 492
+bool(true)
+bool(true)
+bool(false)
+File permission : 493
+bool(true)
+bool(true)
+bool(false)
+File permission : 494
+bool(true)
+bool(true)
+bool(false)
+File permission : 495
+bool(true)
+bool(true)
+bool(false)
+File permission : 496
+bool(true)
+bool(true)
+bool(false)
+File permission : 497
+bool(true)
+bool(true)
+bool(false)
+File permission : 498
+bool(true)
+bool(true)
+bool(false)
+File permission : 499
+bool(true)
+bool(true)
+bool(false)
+File permission : 500
+bool(true)
+bool(true)
+bool(false)
+File permission : 501
+bool(true)
+bool(true)
+bool(false)
+File permission : 502
+bool(true)
+bool(true)
+bool(false)
+File permission : 503
+bool(true)
+bool(true)
+bool(false)
+File permission : 504
+bool(true)
+bool(true)
+bool(false)
+File permission : 505
+bool(true)
+bool(true)
+bool(false)
+File permission : 506
+bool(true)
+bool(true)
+bool(false)
+File permission : 507
+bool(true)
+bool(true)
+bool(false)
+File permission : 508
+bool(true)
+bool(true)
+bool(false)
+File permission : 509
+bool(true)
+bool(true)
+bool(false)
+File permission : 510
+bool(true)
+bool(true)
+bool(false)
+File permission : 511
+bool(true)
+bool(true)
+bool(false)
+Done
diff --git a/ext/standard/tests/file/unlink_variation6.phpt b/ext/standard/tests/file/unlink_variation6.phpt
new file mode 100644
index 0000000..ede9ada
--- /dev/null
+++ b/ext/standard/tests/file/unlink_variation6.phpt
@@ -0,0 +1,41 @@
+--TEST--
+Test unlink() function : variation
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : bool unlink(string filename[, context context])
+ * Description: Delete a file
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing unlink() : variation: contexts and relative files ***\n";
+
+// test relative directories and stream contexts.
+$subdir = 'subdir';
+$testfile = $subdir.'/testfile.txt';
+mkdir($subdir);
+touch($testfile);
+f_exists($testfile);
+$context = stream_context_create();
+var_dump(unlink($testfile, $context));
+f_exists($testfile);
+rmdir($subdir);
+
+function f_exists($file) {
+ if (file_exists($file) == true) {
+ echo "$file exists\n";
+ }
+ else {
+ echo "$file doesn't exist\n";
+ }
+}
+?>
+===DONE===
+--EXPECTF--
+*** Testing unlink() : variation: contexts and relative files ***
+subdir/testfile.txt exists
+bool(true)
+subdir/testfile.txt doesn't exist
+===DONE===
diff --git a/ext/standard/tests/file/unlink_variation7.phpt b/ext/standard/tests/file/unlink_variation7.phpt
new file mode 100644
index 0000000..4c63e11
--- /dev/null
+++ b/ext/standard/tests/file/unlink_variation7.phpt
@@ -0,0 +1,246 @@
+--TEST--
+Test unlink() function : usage variation different types for context
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--FILE--
+<?php
+/* Prototype : bool unlink(string filename[, context context])
+ * Description: Delete a file
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing unlink() : usage variation different types for context ***\n";
+
+// Define error handler
+function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
+ if (error_reporting() != 0) {
+ // report non-silenced errors
+ echo "Error: $err_no - $err_msg, $filename($linenum)\n";
+ }
+}
+set_error_handler('test_error_handler');
+
+// Initialise function arguments not being substituted (if any)
+$filename = __FILE__.'tmp';
+$fileRes = fopen(__FILE__, 'r');
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+// define some classes
+class classWithToString
+{
+ public function __toString() {
+ return "Class A object";
+ }
+}
+
+class classWithoutToString
+{
+}
+
+// heredoc string
+$heredoc = <<<EOT
+hello world
+EOT;
+
+// add arrays
+$index_array = array (1, 2, 3);
+$assoc_array = array ('one' => 1, 'two' => 2);
+
+//array of values to iterate over
+$inputs = array(
+
+ // int data
+ 'int 0' => 0,
+ 'int 1' => 1,
+ 'int 12345' => 12345,
+ 'int -12345' => -2345,
+
+ // float data
+ 'float 10.5' => 10.5,
+ 'float -10.5' => -10.5,
+ 'float 12.3456789000e10' => 12.3456789000e10,
+ 'float -12.3456789000e10' => -12.3456789000e10,
+ 'float .5' => .5,
+
+ // array data
+ 'empty array' => array(),
+ 'int indexed array' => $index_array,
+ 'associative array' => $assoc_array,
+ 'nested arrays' => array('foo', $index_array, $assoc_array),
+
+ // null data
+ 'uppercase NULL' => NULL,
+ 'lowercase null' => null,
+
+ // boolean data
+ 'lowercase true' => true,
+ 'lowercase false' =>false,
+ 'uppercase TRUE' =>TRUE,
+ 'uppercase FALSE' =>FALSE,
+
+ // empty data
+ 'empty string DQ' => "",
+ 'empty string SQ' => '',
+
+ // string data
+ 'string DQ' => "string",
+ 'string SQ' => 'string',
+ 'mixed case string' => "sTrInG",
+ 'heredoc' => $heredoc,
+
+ // object data
+ 'instance of classWithToString' => new classWithToString(),
+ 'instance of classWithoutToString' => new classWithoutToString(),
+
+ // undefined data
+ 'undefined var' => @$undefined_var,
+
+ // unset data
+ 'unset var' => @$unset_var,
+
+ // file resource
+ 'file resource' => $fileRes
+);
+
+// loop through each element of the array for context
+
+foreach($inputs as $key =>$value) {
+ echo "\n--$key--\n";
+ touch($filename); // create if it doesn't exist
+ var_dump( unlink($filename, $value) );
+};
+
+if (file_exists($filename)) {
+ unlink($filename);
+}
+fclose($fileRes);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing unlink() : usage variation different types for context ***
+
+--int 0--
+Error: 2 - unlink() expects parameter 2 to be resource, integer given, %s(%d)
+bool(false)
+
+--int 1--
+Error: 2 - unlink() expects parameter 2 to be resource, integer given, %s(%d)
+bool(false)
+
+--int 12345--
+Error: 2 - unlink() expects parameter 2 to be resource, integer given, %s(%d)
+bool(false)
+
+--int -12345--
+Error: 2 - unlink() expects parameter 2 to be resource, integer given, %s(%d)
+bool(false)
+
+--float 10.5--
+Error: 2 - unlink() expects parameter 2 to be resource, double given, %s(%d)
+bool(false)
+
+--float -10.5--
+Error: 2 - unlink() expects parameter 2 to be resource, double given, %s(%d)
+bool(false)
+
+--float 12.3456789000e10--
+Error: 2 - unlink() expects parameter 2 to be resource, double given, %s(%d)
+bool(false)
+
+--float -12.3456789000e10--
+Error: 2 - unlink() expects parameter 2 to be resource, double given, %s(%d)
+bool(false)
+
+--float .5--
+Error: 2 - unlink() expects parameter 2 to be resource, double given, %s(%d)
+bool(false)
+
+--empty array--
+Error: 2 - unlink() expects parameter 2 to be resource, array given, %s(%d)
+bool(false)
+
+--int indexed array--
+Error: 2 - unlink() expects parameter 2 to be resource, array given, %s(%d)
+bool(false)
+
+--associative array--
+Error: 2 - unlink() expects parameter 2 to be resource, array given, %s(%d)
+bool(false)
+
+--nested arrays--
+Error: 2 - unlink() expects parameter 2 to be resource, array given, %s(%d)
+bool(false)
+
+--uppercase NULL--
+Error: 2 - unlink() expects parameter 2 to be resource, null given, %s(%d)
+bool(false)
+
+--lowercase null--
+Error: 2 - unlink() expects parameter 2 to be resource, null given, %s(%d)
+bool(false)
+
+--lowercase true--
+Error: 2 - unlink() expects parameter 2 to be resource, boolean given, %s(%d)
+bool(false)
+
+--lowercase false--
+Error: 2 - unlink() expects parameter 2 to be resource, boolean given, %s(%d)
+bool(false)
+
+--uppercase TRUE--
+Error: 2 - unlink() expects parameter 2 to be resource, boolean given, %s(%d)
+bool(false)
+
+--uppercase FALSE--
+Error: 2 - unlink() expects parameter 2 to be resource, boolean given, %s(%d)
+bool(false)
+
+--empty string DQ--
+Error: 2 - unlink() expects parameter 2 to be resource, string given, %s(%d)
+bool(false)
+
+--empty string SQ--
+Error: 2 - unlink() expects parameter 2 to be resource, string given, %s(%d)
+bool(false)
+
+--string DQ--
+Error: 2 - unlink() expects parameter 2 to be resource, string given, %s(%d)
+bool(false)
+
+--string SQ--
+Error: 2 - unlink() expects parameter 2 to be resource, string given, %s(%d)
+bool(false)
+
+--mixed case string--
+Error: 2 - unlink() expects parameter 2 to be resource, string given, %s(%d)
+bool(false)
+
+--heredoc--
+Error: 2 - unlink() expects parameter 2 to be resource, string given, %s(%d)
+bool(false)
+
+--instance of classWithToString--
+Error: 2 - unlink() expects parameter 2 to be resource, object given, %s(%d)
+bool(false)
+
+--instance of classWithoutToString--
+Error: 2 - unlink() expects parameter 2 to be resource, object given, %s(%d)
+bool(false)
+
+--undefined var--
+Error: 2 - unlink() expects parameter 2 to be resource, null given, %s(%d)
+bool(false)
+
+--unset var--
+Error: 2 - unlink() expects parameter 2 to be resource, null given, %s(%d)
+bool(false)
+
+--file resource--
+Error: 2 - unlink(): supplied resource is not a valid Stream-Context resource, %s(%d)
+bool(true)
+===DONE===
diff --git a/ext/standard/tests/file/unlink_variation8-win32.phpt b/ext/standard/tests/file/unlink_variation8-win32.phpt
new file mode 100644
index 0000000..3ad7ff2
--- /dev/null
+++ b/ext/standard/tests/file/unlink_variation8-win32.phpt
@@ -0,0 +1,113 @@
+--TEST--
+Test unlink() function : variation: various valid and invalid paths
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip.. only for Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype : bool unlink(string filename[, context context])
+ * Description: Delete a file
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing unlink() : variation ***\n";
+
+$workDir = "unlinkVar8.tmp";
+$tmpFile = "file.tmp";
+chdir(__DIR__);
+mkdir($workDir);
+$cwd = __DIR__;
+
+$files = array(
+ // relative
+ $workDir.'/'.$tmpFile,
+ './'.$workDir.'/'.$tmpFile,
+ $workDir.'/../'.$workDir.'/'.$tmpFile,
+
+ // relative bad path
+ $workDir.'/../BADDIR/'.$tmpFile,
+ 'BADDIR/'.$tmpFile,
+
+ //absolute
+ $cwd.'/'.$workDir.'/'.$tmpFile,
+ $cwd.'/./'.$workDir.'/'.$tmpFile,
+ $cwd.'/'.$workDir.'/../'.$workDir.'/'.$tmpFile,
+
+ //absolute bad path
+ $cwd.'/BADDIR/'.$tmpFile,
+
+ //trailing separators
+ $workDir.'/'.$tmpFile.'/',
+ $cwd.'/'.$workDir.'/'.$tmpFile.'/',
+
+ // multiple separators
+ $workDir.'//'.$tmpFile,
+ $cwd.'//'.$workDir.'//'.$tmpFile,
+
+ );
+
+
+foreach($files as $fileToUnlink) {
+ test_realfile($workDir.'/'.$tmpFile, $fileToUnlink);
+}
+
+rmdir($workDir);
+
+function test_realfile($file, $tounlink) {
+ touch($file);
+ echo "-- removing $tounlink --\n";
+ $res = unlink($tounlink);
+ if ($res === true) {
+ if (file_exists($tounlink) === false) {
+ echo "file removed\n";
+ }
+ else {
+ echo "FAILED: file not removed\n";
+ }
+ }
+ else {
+ unlink($file);
+ }
+}
+?>
+===DONE===
+--EXPECTF--
+*** Testing unlink() : variation ***
+-- removing unlinkVar8.tmp/file.tmp --
+file removed
+-- removing ./unlinkVar8.tmp/file.tmp --
+file removed
+-- removing unlinkVar8.tmp/../unlinkVar8.tmp/file.tmp --
+file removed
+-- removing unlinkVar8.tmp/../BADDIR/file.tmp --
+
+Warning: unlink(unlinkVar8.tmp/../BADDIR/file.tmp): No such file or directory in %s on line %d
+-- removing BADDIR/file.tmp --
+
+Warning: unlink(BADDIR/file.tmp): No such file or directory in %s on line %d
+-- removing %s/unlinkVar8.tmp/file.tmp --
+file removed
+-- removing %s/./unlinkVar8.tmp/file.tmp --
+file removed
+-- removing %s/unlinkVar8.tmp/../unlinkVar8.tmp/file.tmp --
+file removed
+-- removing %s/BADDIR/file.tmp --
+
+Warning: unlink(%s/BADDIR/file.tmp): No such file or directory in %s on line %d
+-- removing unlinkVar8.tmp/file.tmp/ --
+
+Warning: unlink(unlinkVar8.tmp/file.tmp/): Invalid argument in %s on line %d
+-- removing %s/unlinkVar8.tmp/file.tmp/ --
+
+Warning: unlink(%s/unlinkVar8.tmp/file.tmp/): Invalid argument in %s on line %d
+-- removing unlinkVar8.tmp//file.tmp --
+file removed
+-- removing %s//unlinkVar8.tmp//file.tmp --
+file removed
+===DONE===
diff --git a/ext/standard/tests/file/unlink_variation8.phpt b/ext/standard/tests/file/unlink_variation8.phpt
new file mode 100644
index 0000000..e142763
--- /dev/null
+++ b/ext/standard/tests/file/unlink_variation8.phpt
@@ -0,0 +1,206 @@
+--TEST--
+Test unlink() function : variation: various valid and invalid paths
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip.. Not for Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype : bool unlink(string filename[, context context])
+ * Description: Delete a file
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing unlink() : variation ***\n";
+
+$workDir = "unlinkVar8.tmp";
+$tmpFile = "file.tmp";
+$fileToLinkTo = $workDir.'/'."linkme.tmp";
+
+mkdir($workDir);
+$cwd = getcwd();
+touch($fileToLinkTo);
+
+$files = array(
+ // relative
+ $workDir.'/'.$tmpFile,
+ './'.$workDir.'/'.$tmpFile,
+ $workDir.'/../'.$workDir.'/'.$tmpFile,
+
+ // relative bad path
+ $workDir.'/../BADDIR/'.$tmpFile,
+ 'BADDIR/'.$tmpFile,
+
+ //absolute
+ $cwd.'/'.$workDir.'/'.$tmpFile,
+ $cwd.'/./'.$workDir.'/'.$tmpFile,
+ $cwd.'/'.$workDir.'/../'.$workDir.'/'.$tmpFile,
+
+ //absolute bad path
+ $cwd.'/BADDIR/'.$tmpFile,
+
+ //trailing separators
+ $workDir.'/'.$tmpFile.'/',
+ $cwd.'/'.$workDir.'/'.$tmpFile.'/',
+
+ // multiple separators
+ $workDir.'//'.$tmpFile,
+ $cwd.'//'.$workDir.'//'.$tmpFile,
+
+ );
+
+
+foreach($files as $fileToUnlink) {
+ test_realfile($workDir.'/'.$tmpFile, $fileToUnlink);
+ test_link($workDir.'/'.$tmpFile, $fileToLinkTo, $fileToUnlink, true); //soft link
+ test_link($workDir.'/'.$tmpFile, $fileToLinkTo, $fileToUnlink, false); //hard link
+}
+
+unlink($fileToLinkTo);
+rmdir($workDir);
+
+function test_realfile($file, $tounlink) {
+ touch($file);
+ echo "-- removing $tounlink --\n";
+ $res = unlink($tounlink);
+ if ($res === true) {
+ if (file_exists($tounlink) === false) {
+ echo "file removed\n";
+ }
+ else {
+ echo "FAILED: file not removed\n";
+ }
+ }
+ else {
+ unlink($file);
+ }
+}
+
+function test_link($linkedfile, $toLinkTo, $tounlink, $softlink) {
+ if ($softlink == true) {
+ symlink($toLinkTo, $linkedfile);
+ $msg = "soft link";
+ }
+ else {
+ link($toLinkTo, $linkedfile);
+ $msg = "hard link";
+ }
+ echo "-- unlinking $msg $tounlink --\n";
+ $res = unlink($tounlink);
+ if ($res === true) {
+ if (file_exists($tounlink) === false) {
+ echo "file unlinked\n";
+ }
+ else {
+ echo "FAILED: file not unlinked\n";
+ }
+ }
+ else {
+ unlink($linkedfile);
+ }
+}
+
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing unlink() : variation ***
+-- removing unlinkVar8.tmp/file.tmp --
+file removed
+-- unlinking soft link unlinkVar8.tmp/file.tmp --
+file unlinked
+-- unlinking hard link unlinkVar8.tmp/file.tmp --
+file unlinked
+-- removing ./unlinkVar8.tmp/file.tmp --
+file removed
+-- unlinking soft link ./unlinkVar8.tmp/file.tmp --
+file unlinked
+-- unlinking hard link ./unlinkVar8.tmp/file.tmp --
+file unlinked
+-- removing unlinkVar8.tmp/../unlinkVar8.tmp/file.tmp --
+file removed
+-- unlinking soft link unlinkVar8.tmp/../unlinkVar8.tmp/file.tmp --
+file unlinked
+-- unlinking hard link unlinkVar8.tmp/../unlinkVar8.tmp/file.tmp --
+file unlinked
+-- removing unlinkVar8.tmp/../BADDIR/file.tmp --
+
+Warning: unlink(unlinkVar8.tmp/../BADDIR/file.tmp): No such file or directory in %s on line %d
+-- unlinking soft link unlinkVar8.tmp/../BADDIR/file.tmp --
+
+Warning: unlink(unlinkVar8.tmp/../BADDIR/file.tmp): No such file or directory in %s on line %d
+-- unlinking hard link unlinkVar8.tmp/../BADDIR/file.tmp --
+
+Warning: unlink(unlinkVar8.tmp/../BADDIR/file.tmp): No such file or directory in %s on line %d
+-- removing BADDIR/file.tmp --
+
+Warning: unlink(BADDIR/file.tmp): No such file or directory in %s on line %d
+-- unlinking soft link BADDIR/file.tmp --
+
+Warning: unlink(BADDIR/file.tmp): No such file or directory in %s on line %d
+-- unlinking hard link BADDIR/file.tmp --
+
+Warning: unlink(BADDIR/file.tmp): No such file or directory in %s on line %d
+-- removing /%s/unlinkVar8.tmp/file.tmp --
+file removed
+-- unlinking soft link /%s/unlinkVar8.tmp/file.tmp --
+file unlinked
+-- unlinking hard link /%s/unlinkVar8.tmp/file.tmp --
+file unlinked
+-- removing /%s/./unlinkVar8.tmp/file.tmp --
+file removed
+-- unlinking soft link /%s/./unlinkVar8.tmp/file.tmp --
+file unlinked
+-- unlinking hard link /%s/./unlinkVar8.tmp/file.tmp --
+file unlinked
+-- removing /%s/unlinkVar8.tmp/../unlinkVar8.tmp/file.tmp --
+file removed
+-- unlinking soft link /%s/unlinkVar8.tmp/../unlinkVar8.tmp/file.tmp --
+file unlinked
+-- unlinking hard link /%s/unlinkVar8.tmp/../unlinkVar8.tmp/file.tmp --
+file unlinked
+-- removing /%s/BADDIR/file.tmp --
+
+Warning: unlink(/%s/BADDIR/file.tmp): No such file or directory in %s on line %d
+-- unlinking soft link /%s/BADDIR/file.tmp --
+
+Warning: unlink(/%s/BADDIR/file.tmp): No such file or directory in %s on line %d
+-- unlinking hard link /%s/BADDIR/file.tmp --
+
+Warning: unlink(/%s/BADDIR/file.tmp): No such file or directory in %s on line %d
+-- removing unlinkVar8.tmp/file.tmp/ --
+
+Warning: unlink(unlinkVar8.tmp/file.tmp/): Not a directory in %s on line %d
+-- unlinking soft link unlinkVar8.tmp/file.tmp/ --
+
+Warning: unlink(unlinkVar8.tmp/file.tmp/): %s directory in %s on line %d
+-- unlinking hard link unlinkVar8.tmp/file.tmp/ --
+
+Warning: unlink(unlinkVar8.tmp/file.tmp/): Not a directory in %s on line %d
+-- removing /%s/unlinkVar8.tmp/file.tmp/ --
+
+Warning: unlink(/%s/unlinkVar8.tmp/file.tmp/): Not a directory in %s on line %d
+-- unlinking soft link /%s/unlinkVar8.tmp/file.tmp/ --
+
+Warning: unlink(/%s/unlinkVar8.tmp/file.tmp/): %s directory in %s on line %d
+-- unlinking hard link /%s/unlinkVar8.tmp/file.tmp/ --
+
+Warning: unlink(/%s/unlinkVar8.tmp/file.tmp/): Not a directory in %s on line %d
+-- removing unlinkVar8.tmp//file.tmp --
+file removed
+-- unlinking soft link unlinkVar8.tmp//file.tmp --
+file unlinked
+-- unlinking hard link unlinkVar8.tmp//file.tmp --
+file unlinked
+-- removing /%s//unlinkVar8.tmp//file.tmp --
+file removed
+-- unlinking soft link /%s//unlinkVar8.tmp//file.tmp --
+file unlinked
+-- unlinking hard link /%s//unlinkVar8.tmp//file.tmp --
+file unlinked
+===DONE===
diff --git a/ext/standard/tests/file/unlink_variation9-win32.phpt b/ext/standard/tests/file/unlink_variation9-win32.phpt
new file mode 100644
index 0000000..acc2ce6
--- /dev/null
+++ b/ext/standard/tests/file/unlink_variation9-win32.phpt
@@ -0,0 +1,117 @@
+--TEST--
+Test unlink() function : variation: various valid and invalid paths
+--CREDITS--
+Dave Kelsey <d_kelsey@uk.ibm.com>
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip.. only for Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype : bool unlink(string filename[, context context])
+ * Description: Delete a file
+ * Source code: ext/standard/file.c
+ * Alias to functions:
+ */
+
+echo "*** Testing unlink() : variation ***\n";
+
+$workDir = "unlinkVar9.tmp";
+$tmpFile = "file.tmp";
+chdir(__DIR__);
+mkdir($workDir);
+$cwd = __DIR__;
+$unixifiedFile = '/'.substr(str_replace('\\','/',$cwd).'/'.$workDir.'/'.$tmpFile, 3);
+
+$files = array(
+ // relative
+ $workDir.'\\'.$tmpFile,
+ '.\\'.$workDir.'\\'.$tmpFile,
+ $workDir.'\\..\\'.$workDir.'\\'.$tmpFile,
+
+ // relative bad path
+ $workDir.'\\..\\BADDIR\\'.$tmpFile,
+ 'BADDIR\\'.$tmpFile,
+
+ //absolute
+ $cwd.'\\'.$workDir.'\\'.$tmpFile,
+ $cwd.'\\.\\'.$workDir.'\\'.$tmpFile,
+ $cwd.'\\'.$workDir.'\\..\\'.$workDir.'\\'.$tmpFile,
+
+ //absolute bad path
+ $cwd.'\\BADDIR\\'.$tmpFile,
+
+ //trailing separators
+ $workDir.'\\'.$tmpFile.'\\',
+ $cwd.'\\'.$workDir.'\\'.$tmpFile.'\\',
+
+ // multiple separators
+ $workDir.'\\\\'.$tmpFile,
+ $cwd.'\\\\'.$workDir.'\\\\'.$tmpFile,
+
+ // Unixified File
+ $unixifiedFile,
+
+ );
+
+
+foreach($files as $fileToUnlink) {
+ $file = $workDir.'/'.$tmpFile;
+ $tounlink = $fileToUnlink;
+ touch($file);
+ echo "-- removing $tounlink --\n";
+ $res = unlink($tounlink);
+ if ($res === true) {
+ if (file_exists($tounlink) === false) {
+ echo "file removed\n";
+ }
+ else {
+ echo "FAILED: file not removed\n";
+ }
+ }
+ else {
+ unlink($file);
+ }
+}
+
+rmdir($workDir);
+?>
+===DONE===
+--EXPECTF--
+*** Testing unlink() : variation ***
+-- removing unlinkVar9.tmp\file.tmp --
+file removed
+-- removing .\unlinkVar9.tmp\file.tmp --
+file removed
+-- removing unlinkVar9.tmp\..\unlinkVar9.tmp\file.tmp --
+file removed
+-- removing unlinkVar9.tmp\..\BADDIR\file.tmp --
+
+Warning: unlink(unlinkVar9.tmp\..\BADDIR\file.tmp): No such file or directory in %s on line %d
+-- removing BADDIR\file.tmp --
+
+Warning: unlink(BADDIR\file.tmp): No such file or directory in %s on line %d
+-- removing %s\unlinkVar9.tmp\file.tmp --
+file removed
+-- removing %s\.\unlinkVar9.tmp\file.tmp --
+file removed
+-- removing %s\unlinkVar9.tmp\..\unlinkVar9.tmp\file.tmp --
+file removed
+-- removing %s\BADDIR\file.tmp --
+
+Warning: unlink(%s\BADDIR\file.tmp): No such file or directory in %s on line %d
+-- removing unlinkVar9.tmp\file.tmp\ --
+
+Warning: unlink(unlinkVar9.tmp\file.tmp\): Invalid argument in %s on line %d
+-- removing %s\unlinkVar9.tmp\file.tmp\ --
+
+Warning: unlink(%s\unlinkVar9.tmp\file.tmp\): Invalid argument in %s on line %d
+-- removing unlinkVar9.tmp\\file.tmp --
+file removed
+-- removing %s\\unlinkVar9.tmp\\file.tmp --
+file removed
+-- removing /%s/unlinkVar9.tmp/file.tmp --
+file removed
+===DONE===
diff --git a/ext/standard/tests/file/userdirstream.phpt b/ext/standard/tests/file/userdirstream.phpt
new file mode 100644
index 0000000..a83e899
--- /dev/null
+++ b/ext/standard/tests/file/userdirstream.phpt
@@ -0,0 +1,51 @@
+--TEST--
+Directory Streams
+--FILE--
+<?php
+class test {
+ public $idx = 0;
+
+ function dir_opendir($path, $options) {
+ print "Opening\n";
+ $this->idx = 0;
+
+ return true;
+ }
+
+ function dir_readdir() {
+ $sample = array('first','second','third','fourth');
+
+ if ($this->idx >= count($sample)) return false;
+ else return $sample[$this->idx++];
+ }
+
+ function dir_rewinddir() {
+ $this->idx = 0;
+
+ return true;
+ }
+
+ function dir_closedir() {
+ print "Closing up!\n";
+
+ return true;
+ }
+}
+
+stream_wrapper_register('test', 'test');
+
+var_dump(scandir('test://example.com/path/to/test'));
+?>
+--EXPECT--
+Opening
+Closing up!
+array(4) {
+ [0]=>
+ string(5) "first"
+ [1]=>
+ string(6) "fourth"
+ [2]=>
+ string(6) "second"
+ [3]=>
+ string(5) "third"
+}
diff --git a/ext/standard/tests/file/userfilters.phpt b/ext/standard/tests/file/userfilters.phpt
new file mode 100644
index 0000000..2246b5d
--- /dev/null
+++ b/ext/standard/tests/file/userfilters.phpt
@@ -0,0 +1,37 @@
+--TEST--
+stream userfilter test
+--FILE--
+<?php
+# vim600:syn=php:
+class testfilter extends php_user_filter {
+ function filter($in, $out, &$consumed, $closing) {
+ while ($bucket = stream_bucket_make_writeable($in)) {
+ $bucket->data = strtoupper($bucket->data);
+ $consumed += strlen($bucket->data);
+ stream_bucket_append($out, $bucket);
+ }
+ return PSFS_PASS_ON;
+ }
+
+ function oncreate() {
+ echo "params: {$this->params}\n";
+ }
+}
+
+stream_filter_register('testfilter','testfilter');
+
+$text = b"Hello There!";
+
+$fp = tmpfile();
+fwrite($fp, $text);
+
+rewind($fp);
+stream_filter_append($fp, 'testfilter', STREAM_FILTER_READ, 'testuserfilter');
+
+var_dump(fgets($fp));
+fclose($fp);
+
+?>
+--EXPECT--
+params: testuserfilter
+string(12) "HELLO THERE!"
diff --git a/ext/standard/tests/file/userstreams.phpt b/ext/standard/tests/file/userstreams.phpt
new file mode 100644
index 0000000..b5a9707
--- /dev/null
+++ b/ext/standard/tests/file/userstreams.phpt
@@ -0,0 +1,325 @@
+--TEST--
+User-space streams
+--FILE--
+<?php
+# vim600:syn=php:
+
+/* This is a fairly aggressive test that looks at
+ * user streams and also gives the seek/gets/buffer
+ * layer of streams a thorough testing */
+
+$lyrics = <<<EOD
+...and the road becomes my bride
+I have stripped of all but pride
+so in her I do confide
+and she keeps me satisfied
+gives me all I need
+...and with dust in throat I crave
+to the game you stay a slave
+rover wanderer
+nomad vagabond
+call me what you will
+ But Ill take my time anywhere
+ Free to speak my mind anywhere
+ and Ill redefine anywhere
+ Anywhere I roam
+ Where I lay my head is home
+...and the earth becomes my throne
+I adapt to the unknown
+under wandering stars Ive grown
+by myself but not alone
+I ask no one
+...and my ties are severed clean
+the less I have the more I gain
+off the beaten path I reign
+rover wanderer
+nomad vagabond
+call me what you will
+ But Ill take my time anywhere
+ Free to speak my mind anywhere
+ and Ill never mind anywhere
+ Anywhere I roam
+ Where I lay my head is home
+ But Ill take my time anywhere
+ Free to speak my mind anywhere
+ and Ill take my find anywhere
+ Anywhere I roam
+ Where I lay my head is home
+ carved upon my stone
+ my body lie but still I roam
+ Wherever I may roam.
+
+Wherever I May Roam
+
+EOD;
+
+/* repeat the data a few times so that it grows larger than
+ * the default cache chunk size and that we have something
+ * to seek around... */
+$DATA = "";
+for ($i = 0; $i < 30; $i++) {
+ if ($i % 2 == 0)
+ $DATA .= str_rot13($lyrics);
+ else
+ $DATA .= $lyrics;
+}
+
+/* store the data in a regular file so that we can compare
+ * the results */
+$tf = tmpfile();
+fwrite($tf, (binary)$DATA);
+$n = ftell($tf);
+rewind($tf) or die("failed to rewind tmp file!");
+if (ftell($tf) != 0)
+ die("tmpfile is not at start!");
+$DATALEN = strlen($DATA);
+if ($n != $DATALEN)
+ die("tmpfile stored $n bytes; should be $DATALEN!");
+
+class uselessstream
+{
+}
+
+class mystream
+{
+ public $path;
+ public $mode;
+ public $options;
+
+ public $position;
+ public $varname;
+
+ function stream_open($path, $mode, $options, &$opened_path)
+ {
+ $this->path = $path;
+ $this->mode = $mode;
+ $this->options = $options;
+
+ $split = parse_url($path);
+ $this->varname = $split["host"];
+
+ if (strchr($mode, 'a'))
+ $this->position = strlen($GLOBALS[$this->varname]);
+ else
+ $this->position = 0;
+
+ return true;
+ }
+
+ function stream_read($count)
+ {
+ $ret = substr($GLOBALS[$this->varname], $this->position, $count);
+ $this->position += strlen($ret);
+ return $ret;
+ }
+
+ function stream_tell()
+ {
+ return $this->position;
+ }
+
+ function stream_eof()
+ {
+ return $this->position >= strlen($GLOBALS[$this->varname]);
+ }
+
+ function stream_seek($offset, $whence)
+ {
+ switch($whence) {
+ case SEEK_SET:
+ if ($offset < strlen($GLOBALS[$this->varname]) && $offset >= 0) {
+ $this->position = $offset;
+ return true;
+ } else {
+ return false;
+ }
+ break;
+ case SEEK_CUR:
+ if ($offset >= 0) {
+ $this->position += $offset;
+ return true;
+ } else {
+ return false;
+ }
+ break;
+ case SEEK_END:
+ if (strlen($GLOBALS[$this->varname]) + $offset >= 0) {
+ $this->position = strlen($GLOBALS[$this->varname]) + $offset;
+ return true;
+ } else {
+ return false;
+ }
+ break;
+ default:
+ return false;
+ }
+ }
+
+}
+
+if (@stream_wrapper_register("bogus", "class_not_exist")) {
+ die("Registered a non-existant class!!!???");
+}
+echo "Not Registered\n";
+
+if (!stream_wrapper_register("test", "mystream")) {
+ die("test wrapper registration failed");
+}
+echo "Registered\n";
+
+if (!stream_wrapper_register("bogon", "uselessstream")) {
+ die("bogon wrapper registration failed");
+}
+echo "Registered\n";
+
+$b = @fopen("bogon://url", "rb");
+if (is_resource($b)) {
+ die("Opened a bogon??");
+}
+
+$fp = fopen("test://DATA", "rb");
+if (!$fp || !is_resource($fp)) {
+ die("Failed to open resource");
+}
+
+/* some default seeks that will cause buffer/cache misses */
+$seeks = array(
+ array(SEEK_SET, 0, 0),
+ array(SEEK_CUR, 8450, 8450),
+ array(SEEK_CUR, -7904, 546),
+ array(SEEK_CUR, 12456, 13002),
+
+ /* end up at BOF so that randomly generated seek offsets
+ * below will know where they are supposed to be */
+ array(SEEK_SET, 0, 0)
+);
+
+$whence_map = array(
+ SEEK_CUR,
+ SEEK_SET,
+ SEEK_END
+);
+$whence_names = array(
+ SEEK_CUR => "SEEK_CUR",
+ SEEK_SET => "SEEK_SET",
+ SEEK_END => "SEEK_END"
+ );
+
+/* generate some random seek offsets */
+$position = 0;
+for ($i = 0; $i < 256; $i++) {
+ $whence = $whence_map[array_rand($whence_map, 1)];
+ switch($whence) {
+ case SEEK_SET:
+ $offset = rand(0, $DATALEN - 1);
+ $position = $offset;
+ break;
+ case SEEK_END:
+ $offset = -rand(0, $DATALEN - 1);
+ $position = $DATALEN + $offset;
+ break;
+ case SEEK_CUR:
+ $offset = rand(0, $DATALEN - 1);
+ $offset -= $position;
+ $position += $offset;
+ break;
+ }
+
+ $seeks[] = array($whence, $offset, $position);
+}
+
+/* we compare the results of fgets using differing line lengths to
+ * test the fgets layer also */
+$line_lengths = array(1024, 256, 64, 16);
+$fail_count = 0;
+
+ob_start();
+foreach($line_lengths as $line_length) {
+ /* now compare the real stream with the user stream */
+ $j = 0;
+ rewind($tf);
+ rewind($fp);
+ foreach($seeks as $seekdata) {
+ list($whence, $offset, $position) = $seekdata;
+
+ $rpb = ftell($tf);
+ $rr = (int)fseek($tf, $offset, $whence);
+ $rpa = ftell($tf);
+ $rline = fgets($tf, $line_length);
+ (int)fseek($tf, - strlen($rline), SEEK_CUR);
+
+ $upb = ftell($fp);
+ $ur = (int)fseek($fp, $offset, $whence);
+ $upa = ftell($fp);
+ $uline = fgets($fp, $line_length);
+ (int)fseek($fp, - strlen($uline), SEEK_CUR);
+
+ printf("\n--[%d] whence=%s offset=%d line_length=%d position_should_be=%d --\n",
+ $j, $whence_names[$whence], $offset, $line_length, $position);
+ printf("REAL: pos=(%d,%d,%d) ret=%d line[%d]=`%s'\n", $rpb, $rpa, ftell($tf), $rr, strlen($rline), $rline);
+ printf("USER: pos=(%d,%d,%d) ret=%d line[%d]=`%s'\n", $upb, $upa, ftell($fp), $ur, strlen($uline), $uline);
+
+ if ($rr != $ur || $rline != $uline || $rpa != $position || $upa != $position) {
+ $fail_count++;
+ echo "###################################### FAIL!\n";
+ $dat = stream_get_meta_data($fp);
+ var_dump($dat);
+ break;
+ }
+
+ $j++;
+ }
+ if ($fail_count)
+ break;
+}
+
+if ($fail_count == 0) {
+ ob_end_clean();
+ echo "SEEK: OK\n";
+} else {
+ echo "SEEK: FAIL\n";
+ ob_end_flush();
+}
+
+$fail_count = 0;
+
+fseek($fp, $DATALEN / 2, SEEK_SET);
+fseek($tf, $DATALEN / 2, SEEK_SET);
+
+if (ftell($fp) != ftell($tf)) {
+ echo "SEEK: positions do not match!\n";
+}
+
+$n = 0;
+while(!feof($fp)) {
+ $uline = fgets($fp, 1024);
+ $rline = fgets($tf, 1024);
+
+ if ($uline != $rline) {
+ echo "FGETS: FAIL\niter=$n user=$uline [pos=" . ftell($fp) . "]\nreal=$rline [pos=" . ftell($tf) . "]\n";
+ $fail_count++;
+ break;
+ }
+}
+
+if ($fail_count == 0) {
+ echo "FGETS: OK\n";
+}
+
+/* One final test to see if the position is respected when opened for append */
+$fp = fopen("test://lyrics", "a+");
+rewind($fp);
+var_dump(ftell($fp));
+$data = fgets($fp);
+fclose($fp);
+echo $data . "\n";
+
+?>
+--EXPECT--
+Not Registered
+Registered
+Registered
+SEEK: OK
+FGETS: OK
+int(0)
+...and the road becomes my bride
diff --git a/ext/standard/tests/file/userstreams_002.phpt b/ext/standard/tests/file/userstreams_002.phpt
new file mode 100644
index 0000000..81f463d
--- /dev/null
+++ b/ext/standard/tests/file/userstreams_002.phpt
@@ -0,0 +1,94 @@
+--TEST--
+User-space streams: stream_cast()
+--FILE--
+<?php
+class test_wrapper_base {
+ public $return_value;
+ function stream_open($path, $mode, $openedpath) {
+ return true;
+ }
+ function stream_eof() {
+ return false;
+ }
+}
+class test_wrapper extends test_wrapper_base {
+ function stream_cast($castas) {
+ return $this->return_value;
+ }
+}
+function test($name, $fd, $return_value) {
+ echo "\n------ $name: -------\n";
+ $data = stream_get_meta_data($fd);
+ $data['wrapper_data']->return_value = $return_value;
+ $r = array($fd);
+ $w = $e = null;
+ var_dump(stream_select($r, $w, $e, 0) !== false);
+}
+
+var_dump(stream_wrapper_register('test', 'test_wrapper'));
+var_dump(stream_wrapper_register('test2', 'test_wrapper_base'));
+
+$fd = fopen("test://foo","r");
+$fd2 = fopen("test2://foo","r");
+
+test("valid stream", $fd, STDIN);
+test("stream_cast not implemented", $fd2, null);
+test("return value is false", $fd, false);
+test("return value not a stream resource", $fd, "foo");
+test("return value is stream itself", $fd, $fd);
+test("return value cannot be casted", $fd, $fd2);
+
+?>
+--EXPECTF--
+bool(true)
+bool(true)
+
+------ valid stream: -------
+bool(true)
+
+------ stream_cast not implemented: -------
+
+Warning: stream_select(): test_wrapper_base::stream_cast is not implemented! in %s
+
+Warning: stream_select(): cannot represent a stream of type user-space as a select()able descriptor in %s
+
+Warning: stream_select(): No stream arrays were passed in %s
+bool(false)
+
+------ return value is false: -------
+
+Warning: stream_select(): cannot represent a stream of type user-space as a select()able descriptor in %s
+
+Warning: stream_select(): No stream arrays were passed in %s
+bool(false)
+
+------ return value not a stream resource: -------
+
+Warning: stream_select(): supplied argument is not a valid stream resource in %s
+
+Warning: stream_select(): test_wrapper::stream_cast must return a stream resource in %s
+
+Warning: stream_select(): cannot represent a stream of type user-space as a select()able descriptor in %s
+
+Warning: stream_select(): No stream arrays were passed in %s
+bool(false)
+
+------ return value is stream itself: -------
+
+Warning: stream_select(): test_wrapper::stream_cast must not return itself in %s
+
+Warning: stream_select(): cannot represent a stream of type user-space as a select()able descriptor in %s
+
+Warning: stream_select(): No stream arrays were passed in %s
+bool(false)
+
+------ return value cannot be casted: -------
+
+Warning: stream_select(): test_wrapper_base::stream_cast is not implemented! in %s
+
+Warning: stream_select(): cannot represent a stream of type user-space as a select()able descriptor in %s
+
+Warning: stream_select(): cannot represent a stream of type user-space as a select()able descriptor in %s
+
+Warning: stream_select(): No stream arrays were passed in %s
+bool(false)
diff --git a/ext/standard/tests/file/userstreams_003.phpt b/ext/standard/tests/file/userstreams_003.phpt
new file mode 100644
index 0000000..01a8efb
--- /dev/null
+++ b/ext/standard/tests/file/userstreams_003.phpt
@@ -0,0 +1,153 @@
+--TEST--
+User-space streams: stream_set_option()
+--FILE--
+<?php
+class test_wrapper_base {
+ public $return_value;
+ public $expected_option;
+ public $expected_value;
+ function stream_open($path, $mode, $openedpath) {
+ return true;
+ }
+ function stream_eof() {
+ return false;
+ }
+}
+class test_wrapper extends test_wrapper_base {
+ function stream_set_option($option, $value, $ptrparam) {
+ echo "value:\n";
+ var_dump($value);
+ echo "ptrparam:\n";
+ var_dump($ptrparam);
+ echo "\$option === $option === " . $this->expected_option . ":\n";;
+ var_dump($option === $this->expected_option);
+ echo "\$value === $value === " . $this->expected_value. ":\n";;
+ var_dump($value === $this->expected_value);
+ return $this->return_value;
+ }
+}
+
+function test($name, $fd, $return_value, $func, $args, $expected_option, $expected_value) {
+ echo "\n------ $name: -------\n";
+ $data = stream_get_meta_data($fd);
+ $data['wrapper_data']->return_value = $return_value;
+ $data['wrapper_data']->expected_option = $expected_option;
+ $data['wrapper_data']->expected_value = $expected_value;
+ var_dump(call_user_func_array($func, $args));
+}
+
+var_dump(stream_wrapper_register('test', 'test_wrapper'));
+var_dump(stream_wrapper_register('test2', 'test_wrapper_base'));
+
+$fd = fopen("test://foo","r");
+$fd2 = fopen("test2://foo","r");
+
+test("stream_set_blocking - 1", $fd, true, "stream_set_blocking", array($fd,0), STREAM_OPTION_BLOCKING, 0);
+test("stream_set_blocking - 2", $fd, false, "stream_set_blocking", array($fd,1), STREAM_OPTION_BLOCKING, 1);
+test("stream_set_blocking - 3", $fd, "foo", "stream_set_blocking", array($fd,0), STREAM_OPTION_BLOCKING, 0);
+test("stream_set_blocking - 4", $fd2, true, "stream_set_blocking", array($fd2,1), STREAM_OPTION_BLOCKING, 1);
+
+test("stream_set_write_buffer - 1", $fd, true, "stream_set_write_buffer", array($fd,0), STREAM_OPTION_WRITE_BUFFER, STREAM_BUFFER_NONE);
+test("stream_set_write_buffer - 2", $fd, true, "stream_set_write_buffer", array($fd,4096), STREAM_OPTION_WRITE_BUFFER, STREAM_BUFFER_FULL);
+test("stream_set_write_buffer - 3", $fd, false, "stream_set_write_buffer", array($fd,8192), STREAM_OPTION_WRITE_BUFFER, STREAM_BUFFER_FULL);
+
+test("stream_set_timeout - 1", $fd, true, "stream_set_timeout", array($fd,10,11), STREAM_OPTION_READ_TIMEOUT, 10);
+test("stream_set_timeout - 2", $fd, false, "stream_set_timeout", array($fd,11,12), STREAM_OPTION_READ_TIMEOUT, 11);
+
+?>
+--EXPECTF--
+bool(true)
+bool(true)
+
+------ stream_set_blocking - 1: -------
+value:
+int(0)
+ptrparam:
+NULL
+$option === 1 === 1:
+bool(true)
+$value === 0 === 0:
+bool(true)
+bool(true)
+
+------ stream_set_blocking - 2: -------
+value:
+int(1)
+ptrparam:
+NULL
+$option === 1 === 1:
+bool(true)
+$value === 1 === 1:
+bool(true)
+bool(false)
+
+------ stream_set_blocking - 3: -------
+value:
+int(0)
+ptrparam:
+NULL
+$option === 1 === 1:
+bool(true)
+$value === 0 === 0:
+bool(true)
+bool(true)
+
+------ stream_set_blocking - 4: -------
+
+Warning: stream_set_blocking(): test_wrapper_base::stream_set_option is not implemented! in %s
+bool(false)
+
+------ stream_set_write_buffer - 1: -------
+value:
+int(0)
+ptrparam:
+int(%d)
+$option === 3 === 3:
+bool(true)
+$value === 0 === 0:
+bool(true)
+int(0)
+
+------ stream_set_write_buffer - 2: -------
+value:
+int(2)
+ptrparam:
+int(4096)
+$option === 3 === 3:
+bool(true)
+$value === 2 === 2:
+bool(true)
+int(0)
+
+------ stream_set_write_buffer - 3: -------
+value:
+int(2)
+ptrparam:
+int(8192)
+$option === 3 === 3:
+bool(true)
+$value === 2 === 2:
+bool(true)
+int(-1)
+
+------ stream_set_timeout - 1: -------
+value:
+int(10)
+ptrparam:
+int(11)
+$option === 4 === 4:
+bool(true)
+$value === 10 === 10:
+bool(true)
+bool(true)
+
+------ stream_set_timeout - 2: -------
+value:
+int(11)
+ptrparam:
+int(12)
+$option === 4 === 4:
+bool(true)
+$value === 11 === 11:
+bool(true)
+bool(false)
diff --git a/ext/standard/tests/file/userstreams_004.phpt b/ext/standard/tests/file/userstreams_004.phpt
new file mode 100644
index 0000000..da9f148
--- /dev/null
+++ b/ext/standard/tests/file/userstreams_004.phpt
@@ -0,0 +1,58 @@
+--TEST--
+User-space streams: stream_lock()
+--FILE--
+<?php
+class test_wrapper_base {
+ public $mode;
+ function stream_open($path, $mode, $openedpath) {
+ return true;
+ }
+ function stream_eof() {
+ return false;
+ }
+}
+class test_wrapper extends test_wrapper_base {
+ function stream_lock($mode) {
+ $this->mode = $mode;
+ }
+}
+function test($name, $fd, $mode) {
+ echo "------ $name: -------\n";
+ flock($fd, $mode);
+ $data = stream_get_meta_data($fd);
+ var_dump($data['wrapper_data']->mode === $mode);
+}
+
+var_dump(stream_wrapper_register('test', 'test_wrapper'));
+var_dump(stream_wrapper_register('test2', 'test_wrapper_base'));
+
+$fd = fopen("test://foo","r");
+$fd2 = fopen("test2://foo","r");
+
+test("stream_lock not implemented", $fd2, LOCK_EX);
+
+foreach(array("LOCK_SH","LOCK_EX","LOCK_UN") as $mode) {
+ test("fclock($mode)", $fd, constant($mode));
+ test("fclock($mode|LOCK_NB)", $fd, constant($mode)|LOCK_NB);
+}
+
+?>
+--EXPECTF--
+bool(true)
+bool(true)
+------ stream_lock not implemented: -------
+
+Warning: flock(): test_wrapper_base::stream_lock is not implemented! in %s
+bool(false)
+------ fclock(LOCK_SH): -------
+bool(true)
+------ fclock(LOCK_SH|LOCK_NB): -------
+bool(true)
+------ fclock(LOCK_EX): -------
+bool(true)
+------ fclock(LOCK_EX|LOCK_NB): -------
+bool(true)
+------ fclock(LOCK_UN): -------
+bool(true)
+------ fclock(LOCK_UN|LOCK_NB): -------
+bool(true)
diff --git a/ext/standard/tests/file/userstreams_005.phpt b/ext/standard/tests/file/userstreams_005.phpt
new file mode 100644
index 0000000..2d39be2
--- /dev/null
+++ b/ext/standard/tests/file/userstreams_005.phpt
@@ -0,0 +1,63 @@
+--TEST--
+User-space streams: stream_truncate()
+--FILE--
+<?php
+class test_wrapper_base {
+ public $mode;
+ function stream_open($path, $mode, $openedpath) {
+ return true;
+ }
+ function stream_eof() {
+ return false;
+ }
+}
+class test_wrapper extends test_wrapper_base {
+ function stream_truncate($new_size) {
+ echo "truncation with new_size=$new_size\n";
+ return true;
+ }
+}
+class test_wrapper_bad extends test_wrapper_base {
+ function stream_truncate($new_size) {
+ echo "truncation with new_size=$new_size\n";
+ return "kkk";
+ }
+}
+function test($name, $fd, $dest_size) {
+ echo "------ $name: -------\n";
+ var_dump(ftruncate($fd, $dest_size));
+}
+var_dump(stream_wrapper_register('test', 'test_wrapper'));
+var_dump(stream_wrapper_register('test2', 'test_wrapper_base'));
+var_dump(stream_wrapper_register('test3', 'test_wrapper_bad'));
+
+$fd = fopen("test://foo","r");
+$fd2 = fopen("test2://foo","r");
+$fd3 = fopen("test3://foo","r");
+
+test("stream_truncate not implemented", $fd2, 0);
+test("stream_truncate size 0", $fd, 0);
+test("stream_truncate size 10", $fd, 10);
+test("stream_truncate negative size", $fd, -1);
+test("stream_truncate bad return", $fd3, 0);
+--EXPECTF--
+bool(true)
+bool(true)
+bool(true)
+------ stream_truncate not implemented: -------
+
+Warning: ftruncate(): Can't truncate this stream! in %s on line %d
+bool(false)
+------ stream_truncate size 0: -------
+truncation with new_size=0
+bool(true)
+------ stream_truncate size 10: -------
+truncation with new_size=10
+bool(true)
+------ stream_truncate negative size: -------
+bool(false)
+------ stream_truncate bad return: -------
+truncation with new_size=0
+
+Warning: ftruncate(): test_wrapper_bad::stream_truncate did not return a boolean! in %s on line %d
+bool(false)
diff --git a/ext/standard/tests/file/userstreams_006.phpt b/ext/standard/tests/file/userstreams_006.phpt
new file mode 100644
index 0000000..69ebd8d
--- /dev/null
+++ b/ext/standard/tests/file/userstreams_006.phpt
@@ -0,0 +1,38 @@
+--TEST--
+User-space streams: set_options returns "not implemented" for unhandled option types
+--FILE--
+<?php
+class test_wrapper {
+ function stream_open($path, $mode, $openedpath) {
+ return true;
+ }
+ function stream_eof() {
+ return false;
+ }
+ function stream_write($data) {
+ echo "size: ", strlen($data), "\n";
+ return strlen($data);
+ }
+ function stream_set_option($option, $arg1, $arg2) {
+ echo "option: ", $option, ", ", $arg1, ", ", $arg2, "\n";
+ return false;
+ }
+}
+
+var_dump(stream_wrapper_register('test', 'test_wrapper'));
+
+$fd = fopen("test://foo","r");
+
+var_dump(stream_set_write_buffer($fd, 50));
+var_dump(stream_set_chunk_size($fd, 42));
+
+var_dump(fwrite($fd, str_repeat('0', 70)));
+
+--EXPECT--
+bool(true)
+option: 3, 2, 50
+int(-1)
+int(8192)
+size: 42
+size: 28
+int(70)
diff --git a/ext/standard/tests/file/userstreams_007.phpt b/ext/standard/tests/file/userstreams_007.phpt
new file mode 100644
index 0000000..3f66f18
--- /dev/null
+++ b/ext/standard/tests/file/userstreams_007.phpt
@@ -0,0 +1,49 @@
+--TEST--
+User-space streams: test metadata option
+--FILE--
+<?php
+class test_wrapper {
+ function stream_open($path, $mode, $openedpath) {
+ return true;
+ }
+ public function stream_metadata($path, $option, $var) {
+ echo "metadata: $path, $option\n";
+ if(is_array($var)) {
+ echo join(",", $var);
+ } else {
+ echo $var;
+ }
+ echo "\n";
+ return false;
+ }
+}
+
+var_dump(stream_wrapper_register('test', 'test_wrapper'));
+
+$fd = fopen("test://foo","r");
+touch("test://testdir/touch");
+touch("test://testdir/touch", 1);
+touch("test://testdir/touch", 1, 2);
+chown("test://testdir/chown", "test");
+chown("test://testdir/chown", 42);
+chgrp("test://testdir/chgrp", "test");
+chgrp("test://testdir/chgrp", 42);
+chmod("test://testdir/chmod", 0755);
+--EXPECT--
+bool(true)
+metadata: test://testdir/touch, 1
+
+metadata: test://testdir/touch, 1
+1,1
+metadata: test://testdir/touch, 1
+1,2
+metadata: test://testdir/chown, 2
+test
+metadata: test://testdir/chown, 3
+42
+metadata: test://testdir/chgrp, 4
+test
+metadata: test://testdir/chgrp, 5
+42
+metadata: test://testdir/chmod, 6
+493 \ No newline at end of file
diff --git a/ext/standard/tests/file/userwrapper.phpt b/ext/standard/tests/file/userwrapper.phpt
new file mode 100644
index 0000000..717e73c
--- /dev/null
+++ b/ext/standard/tests/file/userwrapper.phpt
@@ -0,0 +1,83 @@
+--TEST--
+Userstream unlink, rename, mkdir, rmdir, and url_stat.
+--FILE--
+<?php # vim:ft=php:
+class test {
+ function unlink($file) {
+ print "Unlinking file: $file\n";
+ }
+
+ function rename($from, $to) {
+ print "Renaming $from to $to\n";
+ }
+
+ function mkdir($directory, $mode, $options) {
+ printf("Making directory: %s as %o%s\n", $directory, $mode, $options & STREAM_MKDIR_RECURSIVE ? " recursively" : "");
+ }
+
+ function rmdir($directory, $options) {
+ print "Removing directory: $directory\n";
+ }
+
+ function url_stat($path, $options) {
+ /* By printing out a notice that we are actively stating the file
+ then subsequently performing multiple stat operations on it
+ we effectively test the stat cache mechanism */
+ print "Stating file: $path\n";
+ return array('dev'=>1, 'ino'=>2, 'mode'=>0644, 'nlink'=>3,
+ 'uid'=>100, 'gid'=>1000, 'rdev'=>-1, 'size'=>31337,
+ 'atime'=>1234567890, 'mtime'=>1231231231, 'ctime'=>1234564564,
+ 'blksize'=>-1, 'blocks'=>-1);
+ }
+}
+
+stream_wrapper_register('test', 'test');
+
+unlink('test://example.com/path/to/file');
+rename('test://example.com/path/to/from', 'test://example.com/path/to/to');
+/* We *want* this to fail and thus not output the watch statement */
+@rename('test://example.com/path/to/from', 'http://example.com/path/to/to');
+mkdir('test://example.com/path/to/directory', 0755);
+rmdir('test://example.com/path/to/directory');
+print_r(stat('test://example.com/path/to/file'));
+echo "Filesize = " . filesize('test://example.com/path/to/file') . "\n";
+echo "filemtime = " . filemtime('test://example.com/path/to/file') . "\n";
+?>
+--EXPECT--
+Unlinking file: test://example.com/path/to/file
+Renaming test://example.com/path/to/from to test://example.com/path/to/to
+Making directory: test://example.com/path/to/directory as 755
+Removing directory: test://example.com/path/to/directory
+Stating file: test://example.com/path/to/file
+Array
+(
+ [0] => 1
+ [1] => 2
+ [2] => 420
+ [3] => 3
+ [4] => 100
+ [5] => 1000
+ [6] => -1
+ [7] => 31337
+ [8] => 1234567890
+ [9] => 1231231231
+ [10] => 1234564564
+ [11] => -1
+ [12] => -1
+ [dev] => 1
+ [ino] => 2
+ [mode] => 420
+ [nlink] => 3
+ [uid] => 100
+ [gid] => 1000
+ [rdev] => -1
+ [size] => 31337
+ [atime] => 1234567890
+ [mtime] => 1231231231
+ [ctime] => 1234564564
+ [blksize] => -1
+ [blocks] => -1
+)
+Filesize = 31337
+filemtime = 1231231231
+
diff --git a/ext/standard/tests/file/windows_acls/bug44859.phpt b/ext/standard/tests/file/windows_acls/bug44859.phpt
new file mode 100644
index 0000000..952b6eb
--- /dev/null
+++ b/ext/standard/tests/file/windows_acls/bug44859.phpt
@@ -0,0 +1,63 @@
+--TEST--
+bug #44859 (incorrect result with NTFS ACL permissions, is_writable)
+--SKIPIF--
+<?php
+include_once __DIR__ . '/common.inc';
+skipif();
+?>
+--FILE--
+<?php
+include_once __DIR__ . '/common.inc';
+fix_acls();
+
+$iteration = array(
+ PHPT_ACL_READ => false,
+ PHPT_ACL_NONE => false,
+ PHPT_ACL_WRITE => true,
+ PHPT_ACL_WRITE|PHPT_ACL_READ => true,
+);
+
+echo "Testing file:\n";
+$i = 1;
+$path = __DIR__ . '/a.txt';
+foreach ($iteration as $perms => $exp) {
+ create_file($path, $perms);
+ clearstatcache(true, $path);
+ echo 'Iteration #' . $i++ . ': ';
+ if (is_writable($path) == $exp) {
+ echo "passed.\n";
+ } else {
+ var_dump(is_writable($path), $exp);
+ echo "failed.\n";
+ }
+ delete_file($path);
+}
+
+echo "Testing directory:\n";
+$path = __DIR__ . '/adir';
+$i = 1;
+foreach ($iteration as $perms => $exp) {
+ create_file($path, $perms);
+ clearstatcache(true, $path);
+ echo 'Iteration #' . $i++ . ': ';
+ if (is_writable($path) == $exp) {
+ echo "passed.\n";
+ } else {
+ var_dump(is_writable($path), $exp);
+ echo "failed.\n";
+ }
+ delete_file($path);
+}
+
+?>
+--EXPECT--
+Testing file:
+Iteration #1: passed.
+Iteration #2: passed.
+Iteration #3: passed.
+Iteration #4: passed.
+Testing directory:
+Iteration #1: passed.
+Iteration #2: passed.
+Iteration #3: passed.
+Iteration #4: passed.
diff --git a/ext/standard/tests/file/windows_acls/bug44859_2.phpt b/ext/standard/tests/file/windows_acls/bug44859_2.phpt
new file mode 100644
index 0000000..d741156
--- /dev/null
+++ b/ext/standard/tests/file/windows_acls/bug44859_2.phpt
@@ -0,0 +1,63 @@
+--TEST--
+bug #44859 (incorrect result with NTFS ACL permissions, is_readable)
+--SKIPIF--
+<?php
+include_once __DIR__ . '/common.inc';
+skipif();
+?>
+--FILE--
+<?php
+include_once __DIR__ . '/common.inc';
+fix_acls();
+
+$iteration = array(
+ PHPT_ACL_READ => true,
+ PHPT_ACL_NONE => false,
+ PHPT_ACL_WRITE => false,
+ PHPT_ACL_WRITE|PHPT_ACL_READ => true,
+);
+
+echo "Testing file:\n";
+$i = 1;
+$path = __DIR__ . '/a.txt';
+foreach ($iteration as $perms => $exp) {
+ create_file($path, $perms);
+ clearstatcache(true, $path);
+ echo 'Iteration #' . $i++ . ': ';
+ if (is_readable($path) == $exp) {
+ echo "passed.\n";
+ } else {
+ var_dump(is_readable($path), $exp);
+ echo "failed.\n";
+ }
+ delete_file($path);
+}
+
+echo "Testing directory:\n";
+$path = __DIR__ . '/adir';
+$i = 1;
+foreach ($iteration as $perms => $exp) {
+ create_file($path, $perms);
+ clearstatcache(true, $path);
+ echo 'Iteration #' . $i++ . ': ';
+ if (is_readable($path) == $exp) {
+ echo "passed.\n";
+ } else {
+ var_dump(is_readable($path), $exp);
+ echo "failed.\n";
+ }
+ delete_file($path);
+}
+
+?>
+--EXPECT--
+Testing file:
+Iteration #1: passed.
+Iteration #2: passed.
+Iteration #3: passed.
+Iteration #4: passed.
+Testing directory:
+Iteration #1: passed.
+Iteration #2: passed.
+Iteration #3: passed.
+Iteration #4: passed.
diff --git a/ext/standard/tests/file/windows_acls/bug44859_3.phpt b/ext/standard/tests/file/windows_acls/bug44859_3.phpt
new file mode 100644
index 0000000..ed57abb
--- /dev/null
+++ b/ext/standard/tests/file/windows_acls/bug44859_3.phpt
@@ -0,0 +1,37 @@
+--TEST--
+bug #44859 (incorrect result with NTFS ACL permissions, is_executable)
+--SKIPIF--
+<?php
+include_once __DIR__ . '/common.inc';
+skipif();
+?>
+--FILE--
+<?php
+include_once __DIR__ . '/common.inc';
+fix_acls();
+
+$iteration = array(
+ 'tiny.exe' => true,
+ //'tiny.bat' => true, To be fixed in _access
+ __FILE__ => false
+);
+
+$i = 1;
+$path = __DIR__;
+
+foreach ($iteration as $file => $exp) {
+ $path = __DIR__ . '/' . $file;
+ echo 'Iteration #' . $i++ . ': ';
+ if (is_executable($path) == $exp) {
+ echo "passed.\n";
+ } else {
+ var_dump(is_executable($path), $exp);
+ echo "failed.\n";
+ }
+}
+
+
+?>
+--EXPECT--
+Iteration #1: passed.
+Iteration #2: passed.
diff --git a/ext/standard/tests/file/windows_acls/bug44859_4.phpt b/ext/standard/tests/file/windows_acls/bug44859_4.phpt
new file mode 100644
index 0000000..954c100
--- /dev/null
+++ b/ext/standard/tests/file/windows_acls/bug44859_4.phpt
@@ -0,0 +1,65 @@
+--TEST--
+bug #44859 (incorrect result with NTFS ACL permissions, is_readable)
+--CREDITS--
+Venkat Raman Don
+--SKIPIF--
+<?php
+include_once __DIR__ . '/common.inc';
+skipif();
+?>
+--FILE--
+<?php
+include_once __DIR__ . '/common.inc';
+fix_acls();
+
+$iteration = array(
+ PHPT_ACL_READ => true,
+ PHPT_ACL_NONE => false,
+ PHPT_ACL_WRITE => false,
+ PHPT_ACL_WRITE|PHPT_ACL_READ => true,
+);
+
+echo "Testing file with relative path:\n";
+$i = 1;
+$path = './a.txt';
+foreach ($iteration as $perms => $exp) {
+ create_file($path, $perms);
+ clearstatcache(true, $path);
+ echo 'Iteration #' . $i++ . ': ';
+ if (is_readable($path) == $exp) {
+ echo "passed.\n";
+ } else {
+ var_dump(is_readable($path), $exp);
+ echo "failed.\n";
+ }
+ delete_file($path);
+}
+
+echo "Testing directory with relative path:\n";
+$path = 'adir';
+$i = 1;
+foreach ($iteration as $perms => $exp) {
+ create_file($path, $perms);
+ clearstatcache(true, $path);
+ echo 'Iteration #' . $i++ . ': ';
+ if (is_readable($path) == $exp) {
+ echo "passed.\n";
+ } else {
+ var_dump(is_readable($path), $exp);
+ echo "failed.\n";
+ }
+ delete_file($path);
+}
+
+?>
+--EXPECT--
+Testing file with relative path:
+Iteration #1: passed.
+Iteration #2: passed.
+Iteration #3: passed.
+Iteration #4: passed.
+Testing directory with relative path:
+Iteration #1: passed.
+Iteration #2: passed.
+Iteration #3: passed.
+Iteration #4: passed.
diff --git a/ext/standard/tests/file/windows_acls/common.inc b/ext/standard/tests/file/windows_acls/common.inc
new file mode 100644
index 0000000..26fadf3
--- /dev/null
+++ b/ext/standard/tests/file/windows_acls/common.inc
@@ -0,0 +1,199 @@
+<?php
+error_reporting(E_ALL);
+define('PHPT_ACL_READ', 1 << 1);
+define('PHPT_ACL_WRITE', 1 << 2);
+define('PHPT_ACL_EXEC', 1 << 3);
+define('PHPT_ACL_NONE', 1 << 4);
+define('PHPT_ACL_FULL', 1 << 5);
+
+define('PHPT_ACL_GRANT', 1);
+define('PHPT_ACL_DENY', 2);
+
+function skipif() {
+ if(substr(PHP_OS, 0, 3) != 'WIN' ) {
+ die('skip windows only test');
+ }
+ if(stripos(php_uname(), 'XP') !== FALSE) {
+ die('skip windows 2003 or newer only test');
+ }
+}
+
+function get_username(){
+ $user = getenv('USERNAME');
+
+ if (!$user) {
+ $user = get_current_user();
+ }
+
+ if (!$user) {
+ $user = exec('echo %USERNAME%');
+ }
+
+ return $user;
+}
+
+function get_domainname()
+{
+ $domain = getenv('USERDOMAIN');
+
+ return $domain;
+}
+
+function get_icacls()
+{
+ $sysroot = exec('echo %SYSTEMROOT%');
+
+ return "$sysroot\\System32\\icacls.exe";
+}
+
+function fix_acls() {
+ $user = get_username();
+ /* Current user needs to be owner of the test files. As well
+ all the other users having acls on the files must loose them.
+ The following fixes this just partially, as dynamically reading
+ all the users having acls on a file could be sophisticated. */
+ exec(get_icacls() . ' . /setowner $user /T /L /Q 2> nul');
+ exec(get_icacls() . ' . /remove:g Administrators /T /L /Q 2> nul');
+}
+
+function icacls_set($path, $mode, $perm) {
+ $icacls = get_icacls();
+ $user = get_username();
+ $path_escaped = '"' . $path . '"';
+ $perm_entry = array();
+
+ if ($perm & PHPT_ACL_READ) $perm_entry[] = 'R';
+ if ($perm & PHPT_ACL_WRITE) $perm_entry[] = 'W';
+ if ($perm & PHPT_ACL_EXEC) $perm_entry[] = 'RX';
+ if ($perm & PHPT_ACL_FULL) $perm_entry[] = 'F';
+
+ // Deny all
+ $cmd = $icacls . ' ' . $path_escaped . ' /inheritance:r /deny ' . $user . ':(F,M,R,RX,W)';
+ exec($cmd);
+
+ if ($perm & PHPT_ACL_NONE) {
+ /*
+ This is required to remove all the previously denied
+ permission for the USER. Just granting permission doesn't
+ remove the previously denied permission.
+ */
+ $cmd = $icacls . ' ' . $path_escaped . ' /remove:d ' . $user;
+ exec($cmd);
+ $cmd = $icacls . ' ' . $path_escaped . ' /remove:g ' . $user;
+ exec($cmd);
+ return;
+ }
+
+ if ($mode == PHPT_ACL_GRANT) {
+ $mode = 'grant';
+ } else {
+ $mode = 'deny';
+ }
+
+
+ // Deny all
+ $cmd = $icacls . ' ' . $path_escaped . ' /deny ' . $user . ':(F,M,R,RX,W)';
+ exec($cmd);
+
+ /*
+ This is required to remove all the previously denied
+ permission for the USER. Just granting permission doesn't
+ remove the previously denied permission.
+ */
+ $cmd = $icacls . ' ' . $path_escaped . ' /remove:d ' . $user;
+ exec($cmd);
+ $cmd = $icacls . ' ' . $path_escaped . ' /remove:g ' . $user;
+ exec($cmd);
+
+
+ /*
+ Required to set no permission and check that is_readable()
+ returns false. If the $perm_entry contains 'N' skip this step.
+ This will make the file/dir with NO aceess.
+ */
+ if (!in_array('N', $perm_entry)) {
+ /*
+ This is required to remove all the previously denied
+ permission for the USER. Just granting permission doesn't
+ remove the previously denied permission.
+ */
+ $cmd = $icacls . ' ' . $path_escaped . ' /remove:d ' . $user;
+ exec($cmd);
+ $cmd = $icacls . ' ' . $path_escaped . ' /remove:g ' . $user;
+ exec($cmd);
+
+ $cmd = $icacls . ' ' . $path_escaped . ' /' . $mode . ' ' . $user;
+ $cmd .= ':' . '(' . implode($perm_entry, ',') . ')';
+ exec($cmd);
+ }
+}
+
+function create_dir($name, $perms) {
+ if (empty($name)) {
+ echo "create_dir: Empty name is not allowed\n";
+ return;
+ }
+
+ mkdir($name);
+ $dst = realpath($name);
+ icacls_set($name, PHPT_ACL_GRANT, $perms);
+}
+
+function create_file($name, $perms) {
+ if (empty($name)) {
+ echo "create_file: Empty name is not allowed\n";
+ return;
+ }
+
+ touch($name);
+ icacls_set($name, PHPT_ACL_GRANT, $perms);
+}
+
+function delete_file($path) {
+ icacls_set($path, PHPT_ACL_GRANT, PHPT_ACL_FULL);
+ if (is_file($path)) {
+ unlink($path);
+ } else {
+ echo "delete_file: '$path' is not a file\n";
+ return;
+ }
+}
+
+function delete_dir($path) {
+ if (is_dir($path)) {
+ icacls_set($path, PHPT_ACL_GRANT, PHPT_ACL_FULL);
+ rmdir($path);
+ } else {
+ echo "delete_dir: '$path' is not a directory\n";
+ return;
+ }
+}
+if (0) {
+$path = __DIR__ . '/a.txt';
+create_file($path, PHPT_ACL_NONE);
+if (!is_writable($path)) {
+ echo "PHPT_ACL_NONE success!!\n";
+} else {
+ echo "PHPT_ACL_NONE failed!!\n";
+}
+delete_file($path);
+
+$path = __DIR__ . '/a.txt';
+create_file($path, PHPT_ACL_READ);
+if (!is_writable($path)) {
+ echo "PHPT_ACL_READ success!!\n";
+} else {
+ echo "PHPT_ACL_READ failed!!\n";
+}
+delete_file($path);
+
+$path = __DIR__ . '/adir';
+create_dir($path, PHPT_ACL_READ);
+if (!is_writable($path)) {
+ echo "PHPT_ACL_READ dir success!!\n";
+} else {
+ echo "PHPT_ACL_READ dir failed!!\n";
+}
+delete_dir($path);
+
+}
diff --git a/ext/standard/tests/file/windows_acls/tiny.bat b/ext/standard/tests/file/windows_acls/tiny.bat
new file mode 100644
index 0000000..c5464d3
--- /dev/null
+++ b/ext/standard/tests/file/windows_acls/tiny.bat
@@ -0,0 +1 @@
+echo FOO
diff --git a/ext/standard/tests/file/windows_acls/tiny.exe b/ext/standard/tests/file/windows_acls/tiny.exe
new file mode 100644
index 0000000..a27e3e6
--- /dev/null
+++ b/ext/standard/tests/file/windows_acls/tiny.exe
Binary files differ
diff --git a/ext/standard/tests/file/windows_links/bug48746.phpt b/ext/standard/tests/file/windows_links/bug48746.phpt
new file mode 100644
index 0000000..5978e7f
--- /dev/null
+++ b/ext/standard/tests/file/windows_links/bug48746.phpt
@@ -0,0 +1,58 @@
+--TEST--
+Bug#48746 - Junction not working properly
+
+--CREDITS--
+Venkat Raman Don (don.raman@microsoft.com)
+
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != 'WIN' ) {
+ die('skip windows only test');
+}
+include_once __DIR__ . '/common.inc';
+$cmd = "mklink /?";
+$ret = @exec($cmd, $output, $return_val);
+if (count($output) == 0) {
+ die("mklink.exe not found in PATH");
+}
+?>
+--FILE--
+<?php
+include_once __DIR__ . '/common.inc';
+$mountvol = get_mountvol();
+$old_dir = __DIR__;
+$dirname = __DIR__ . "\\mnt\\test\\directory";
+mkdir($dirname, 0700, true);
+chdir(__DIR__ . "\\mnt\\test");
+$drive = substr(__DIR__, 0, 2);
+$pathwithoutdrive = substr(__DIR__, 2);
+$ret = exec($mountvol . " " . $drive . " /L", $output, $ret_val);
+exec("mklink /j mounted_volume " . $ret, $output, $ret_val);
+$fullpath = "mounted_volume" . $pathwithoutdrive;
+exec("mklink /j mklink_junction directory", $output, $ret_val);
+var_dump(file_exists("directory"));
+var_dump(file_exists("mklink_junction"));
+var_dump(file_exists("mounted_volume"));
+var_dump(file_exists("$fullpath"));
+var_dump(is_dir("mklink_junction"));
+var_dump(is_dir("$fullpath"));
+var_dump(is_readable("mklink_junction"));
+var_dump(is_writeable("$fullpath"));
+chdir($old_dir);
+
+rmdir(__DIR__ . "\\mnt\\test\\directory");
+rmdir(__DIR__ . "\\mnt\\test\\mklink_junction");
+rmdir(__DIR__ . "\\mnt\\test\\mounted_volume");
+rmdir(__DIR__ . "\\mnt\\test");
+rmdir(__DIR__ . "\\mnt");
+
+?>
+--EXPECT--
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
diff --git a/ext/standard/tests/file/windows_links/bug48746_1.phpt b/ext/standard/tests/file/windows_links/bug48746_1.phpt
new file mode 100644
index 0000000..a4277a4
--- /dev/null
+++ b/ext/standard/tests/file/windows_links/bug48746_1.phpt
@@ -0,0 +1,59 @@
+--TEST--
+Bug#48746 - Junction not working properly
+
+--CREDITS--
+Venkat Raman Don (don.raman@microsoft.com)
+
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != 'WIN' ) {
+ die('skip windows only test');
+}
+include_once __DIR__ . '/common.inc';
+$cmd = "mklink /?";
+$ret = @exec($cmd, $output, $return_val);
+if (count($output) == 0) {
+ die("mklink.exe not found in PATH");
+}
+?>
+--FILE--
+<?php
+include_once __DIR__ . '/common.inc';
+$mountvol = get_mountvol();
+$old_dir = __DIR__;
+$dirname = __DIR__ . "\\mnt\\test\\directory";
+exec("mkdir " . $dirname, $output, $ret_val);
+chdir(__DIR__ . "\\mnt\\test");
+$drive = substr(__DIR__, 0, 2);
+$pathwithoutdrive = substr(__DIR__, 2);
+$ret = exec($mountvol . " " . $drive . " /L", $output, $ret_val);
+exec("mklink /j mounted_volume " . $ret, $output, $ret_val);
+$fullpath = "mounted_volume" . $pathwithoutdrive;
+exec("mklink /j mklink_junction directory", $output, $ret_val);
+file_put_contents("mklink_junction\\a.php", "<?php echo \"I am included.\n\" ?>");
+include_once "mklink_junction\\a.php";
+file_put_contents("$fullpath\\mnt\\test\\directory\\b.php", "<?php echo \"I am included.\n\" ?>");
+require "$fullpath\\mnt\\test\\directory\\b.php";
+file_put_contents("$fullpath\\mnt\\test\\mklink_junction\\c.php", "<?php echo \"I am included.\n\" ?>");
+require_once "$fullpath\\mnt\\test\\mklink_junction\\c.php";
+var_dump(is_file("mklink_junction\\a.php"));
+var_dump(is_file("$fullpath\\mnt\\test\\directory\\b.php"));
+var_dump(is_file("$fullpath\\mnt\\test\\mklink_junction\\c.php"));
+unlink("$fullpath\\mnt\\test\\directory\\b.php");
+unlink("$fullpath\\mnt\\test\\mklink_junction\\c.php");
+unlink("mklink_junction\\a.php");
+chdir($old_dir);
+rmdir(__DIR__ . "\\mnt\\test\\directory");
+rmdir(__DIR__ . "\\mnt\\test\\mklink_junction");
+rmdir(__DIR__ . "\\mnt\\test\\mounted_volume");
+rmdir(__DIR__ . "\\mnt\\test");
+rmdir(__DIR__ . "\\mnt");
+
+?>
+--EXPECT--
+I am included.
+I am included.
+I am included.
+bool(true)
+bool(true)
+bool(true)
diff --git a/ext/standard/tests/file/windows_links/bug48746_2.phpt b/ext/standard/tests/file/windows_links/bug48746_2.phpt
new file mode 100644
index 0000000..509610f
--- /dev/null
+++ b/ext/standard/tests/file/windows_links/bug48746_2.phpt
@@ -0,0 +1,69 @@
+--TEST--
+Bug#48746 - Junction not working properly
+
+--CREDITS--
+Venkat Raman Don (don.raman@microsoft.com)
+
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != 'WIN' ) {
+ die('skip windows only test');
+}
+include_once __DIR__ . '/common.inc';
+$ret = exec('mklink bug48746_tmp.lnk ' . __FILE__ .' 2>&1', $out);
+if (strpos($ret, 'privilege')) {
+ die('skip. SeCreateSymbolicLinkPrivilege not enable for this user.');
+}
+unlink('bug48746_tmp.lnk');
+?>
+--FILE--
+<?php
+include_once __DIR__ . '/common.inc';
+$mountvol = get_mountvol();
+$old_dir = __DIR__;
+$dirname = __DIR__ . "\\mnt\\test\\directory";
+exec("mkdir " . $dirname, $output, $ret_val);
+chdir(__DIR__ . "\\mnt\\test");
+$drive = substr(__DIR__, 0, 2);
+$pathwithoutdrive = substr(__DIR__, 2);
+$ret = exec($mountvol . " " . $drive . " /L", $output, $ret_val);
+exec("mklink /j mounted_volume " . $ret, $output, $ret_val);
+$fullpath = "mounted_volume" . $pathwithoutdrive;
+exec("mklink /j mklink_junction directory", $output, $ret_val);
+file_put_contents("mklink_junction\\a.php", "<?php echo \"I am included.\n\" ?>");
+file_put_contents("$fullpath\\mnt\\test\\directory\\b.php", "<?php echo \"I am included.\n\" ?>");
+print_r(scandir("mklink_junction"));
+print_r(scandir("$fullpath\\mnt\\test\\directory"));
+print_r(scandir("$fullpath\\mnt\\test\\mklink_junction"));
+unlink("$fullpath\\mnt\\test\\directory\\b.php");
+unlink("mklink_junction\\a.php");
+chdir($old_dir);
+rmdir(__DIR__ . "\\mnt\\test\\directory");
+rmdir(__DIR__ . "\\mnt\\test\\mklink_junction");
+rmdir(__DIR__ . "\\mnt\\test\\mounted_volume");
+rmdir(__DIR__ . "\\mnt\\test");
+rmdir(__DIR__ . "\\mnt");
+
+?>
+--EXPECT--
+Array
+(
+ [0] => .
+ [1] => ..
+ [2] => a.php
+ [3] => b.php
+)
+Array
+(
+ [0] => .
+ [1] => ..
+ [2] => a.php
+ [3] => b.php
+)
+Array
+(
+ [0] => .
+ [1] => ..
+ [2] => a.php
+ [3] => b.php
+)
diff --git a/ext/standard/tests/file/windows_links/bug48746_3.phpt b/ext/standard/tests/file/windows_links/bug48746_3.phpt
new file mode 100644
index 0000000..98e8178
--- /dev/null
+++ b/ext/standard/tests/file/windows_links/bug48746_3.phpt
@@ -0,0 +1,50 @@
+--TEST--
+Bug#48746 - Junction not working properly
+
+--CREDITS--
+Venkat Raman Don (don.raman@microsoft.com)
+
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != 'WIN' ) {
+ die('skip windows only test');
+}
+include_once __DIR__ . '/common.inc';
+$ret = exec(get_junction().' /? 2>&1', $out);
+if (strpos($out[0], 'recognized')) {
+ die('skip. junction.exe not found in PATH.');
+}
+
+?>
+--FILE--
+<?php
+include_once __DIR__ . '/common.inc';
+$old_dir = __DIR__;
+$dirname = __DIR__ . "\\mnt\\test\\directory";
+exec("mkdir " . $dirname, $output, $ret_val);
+chdir(__DIR__ . "\\mnt\\test");
+exec(get_junction()." junction directory", $output, $ret_val);
+file_put_contents("junction\\a.php", "<?php echo \"I am included.\n\" ?>");
+file_put_contents("junction\\b.php", "<?php echo \"I am included.\n\" ?>");
+include "junction/a.php";
+require_once "junction\\b.php";
+print_r(scandir("junction"));
+unlink("junction\\a.php");
+unlink("junction\\b.php");
+chdir($old_dir);
+rmdir(__DIR__ . "\\mnt\\test\\directory");
+rmdir(__DIR__ . "\\mnt\\test\\junction");
+rmdir(__DIR__ . "\\mnt\\test");
+rmdir(__DIR__ . "\\mnt");
+
+?>
+--EXPECT--
+I am included.
+I am included.
+Array
+(
+ [0] => .
+ [1] => ..
+ [2] => a.php
+ [3] => b.php
+)
diff --git a/ext/standard/tests/file/windows_links/common.inc b/ext/standard/tests/file/windows_links/common.inc
new file mode 100644
index 0000000..2d4b47c
--- /dev/null
+++ b/ext/standard/tests/file/windows_links/common.inc
@@ -0,0 +1,23 @@
+<?php
+
+function get_sysroot() {
+ // usually c:\\windows, but not always
+ return exec('echo %SYSTEMROOT%');
+}
+
+function get_junction(){
+ // junction.exe isn't included with Windows
+ // its a sysinternals tool for working with filesystem links
+ // see: http://technet.microsoft.com/en-us/sysinternals/bb896768
+
+ // install somewhere that is on %path% or added to %path%
+ return "junction.exe";
+}
+
+function get_mountvol() {
+ $sysroot = get_sysroot();
+
+ return "$sysroot\\System32\\mountvol.exe";
+}
+
+?>