1--TEST-- 2casting different variables to resource using settype() 3--FILE-- 4<?php 5 6$r = fopen(__FILE__, "r"); 7 8class test { 9 function __toString() { 10 return "10"; 11 } 12} 13 14$o = new test; 15 16$vars = array( 17 "string", 18 "8754456", 19 "", 20 "\0", 21 9876545, 22 0.10, 23 array(), 24 array(1,2,3), 25 false, 26 true, 27 NULL, 28 $r, 29 $o 30); 31 32foreach ($vars as $var) { 33 settype($var, "resource"); 34 var_dump($var); 35} 36 37echo "Done\n"; 38?> 39--EXPECTF-- 40Warning: settype(): Cannot convert to resource type in %s on line %d 41string(6) "string" 42 43Warning: settype(): Cannot convert to resource type in %s on line %d 44string(7) "8754456" 45 46Warning: settype(): Cannot convert to resource type in %s on line %d 47string(0) "" 48 49Warning: settype(): Cannot convert to resource type in %s on line %d 50string(1) "" 51 52Warning: settype(): Cannot convert to resource type in %s on line %d 53int(9876545) 54 55Warning: settype(): Cannot convert to resource type in %s on line %d 56float(0.1) 57 58Warning: settype(): Cannot convert to resource type in %s on line %d 59array(0) { 60} 61 62Warning: settype(): Cannot convert to resource type in %s on line %d 63array(3) { 64 [0]=> 65 int(1) 66 [1]=> 67 int(2) 68 [2]=> 69 int(3) 70} 71 72Warning: settype(): Cannot convert to resource type in %s on line %d 73bool(false) 74 75Warning: settype(): Cannot convert to resource type in %s on line %d 76bool(true) 77 78Warning: settype(): Cannot convert to resource type in %s on line %d 79NULL 80 81Warning: settype(): Cannot convert to resource type in %s on line %d 82resource(%d) of type (stream) 83 84Warning: settype(): Cannot convert to resource type in %s on line %d 85object(test)#%d (0) { 86} 87Done 88