1--TEST-- 2Test image_type_to_mime_type() function : usage variations - Pass different data types as imagetype 3--SKIPIF-- 4<?php if (PHP_INT_SIZE != 8) die("skip this test is for 64-bit only"); 5--FILE-- 6<?php 7/* Prototype : string image_type_to_mime_type(int imagetype) 8 * Description: Get Mime-Type for image-type returned by getimagesize, exif_read_data, exif_thumbnail, exif_imagetype 9 * Source code: ext/standard/image.c 10 */ 11 12echo "*** Testing image_type_to_mime_type() : usage variations ***\n"; 13 14error_reporting(E_ALL ^ E_NOTICE); 15 16//get an unset variable 17$unset_var = 10; 18unset ($unset_var); 19 20class MyClass 21{ 22 function __toString() { 23 return "MyClass"; 24 } 25} 26 27//array of values to iterate over 28$values = array( 29 30 // float data 31 100.5, 32 -100.5, 33 100.1234567e10, 34 100.7654321E-10, 35 .5, 36 37 // array data 38 array(), 39 array('color' => 'red', 'item' => 'pen'), 40 41 // null data 42 NULL, 43 null, 44 45 // boolean data 46 true, 47 false, 48 TRUE, 49 FALSE, 50 51 // empty data 52 "", 53 '', 54 55 // string data 56 "string", 57 'string', 58 59 // object data 60 new MyClass(), 61 62 // undefined data 63 @$undefined_var, 64 65 // unset data 66 @$unset_var, 67); 68 69// loop through each element of the array for imagetype 70$iterator = 1; 71foreach($values as $value) { 72 echo "\n-- Iteration $iterator --\n"; 73 var_dump( image_type_to_mime_type($value) ); 74 $iterator++; 75}; 76?> 77===DONE=== 78--EXPECTF-- 79*** Testing image_type_to_mime_type() : usage variations *** 80 81-- Iteration 1 -- 82string(24) "application/octet-stream" 83 84-- Iteration 2 -- 85string(24) "application/octet-stream" 86 87-- Iteration 3 -- 88string(24) "application/octet-stream" 89 90-- Iteration 4 -- 91string(24) "application/octet-stream" 92 93-- Iteration 5 -- 94string(24) "application/octet-stream" 95 96-- Iteration 6 -- 97 98Warning: image_type_to_mime_type() expects parameter 1 to be integer, array given in %s on line %d 99NULL 100 101-- Iteration 7 -- 102 103Warning: image_type_to_mime_type() expects parameter 1 to be integer, array given in %s on line %d 104NULL 105 106-- Iteration 8 -- 107string(24) "application/octet-stream" 108 109-- Iteration 9 -- 110string(24) "application/octet-stream" 111 112-- Iteration 10 -- 113string(9) "image/gif" 114 115-- Iteration 11 -- 116string(24) "application/octet-stream" 117 118-- Iteration 12 -- 119string(9) "image/gif" 120 121-- Iteration 13 -- 122string(24) "application/octet-stream" 123 124-- Iteration 14 -- 125 126Warning: image_type_to_mime_type() expects parameter 1 to be integer, string given in %s on line %d 127NULL 128 129-- Iteration 15 -- 130 131Warning: image_type_to_mime_type() expects parameter 1 to be integer, string given in %s on line %d 132NULL 133 134-- Iteration 16 -- 135 136Warning: image_type_to_mime_type() expects parameter 1 to be integer, string given in %s on line %d 137NULL 138 139-- Iteration 17 -- 140 141Warning: image_type_to_mime_type() expects parameter 1 to be integer, string given in %s on line %d 142NULL 143 144-- Iteration 18 -- 145 146Warning: image_type_to_mime_type() expects parameter 1 to be integer, object given in %s on line %d 147NULL 148 149-- Iteration 19 -- 150string(24) "application/octet-stream" 151 152-- Iteration 20 -- 153string(24) "application/octet-stream" 154===DONE=== 155