1--TEST-- 2Test > operator : different types 3--FILE-- 4<?php 5$valid_true = array(1, "1", "true", 1.0, array(1)); 6$valid_false = array(0, "", 0.0, array(), NULL); 7 8$int1 = 679; 9$int2 = -67835; 10$valid_int1 = array("678", "678abc", " 678", "678 ", 678.0, 6.789E2, "+678", +678); 11$valid_int2 = array("-67836", "-67836abc", " -67836", "-67836 ", -67835.0001, -6.78351E4); 12$invalid_int1 = array(679, "679"); 13$invalid_int2 = array(-67835, "-67835"); 14 15$float1 = 57385.45835; 16$float2 = -67345.76567; 17$valid_float1 = array("57385.45834", "57385.45834aaa", " 57385.45834", 5.738545834e4); 18$valid_float2 = array("-67345.76568", "-67345.76568aaa", " -67345.76568", -6.734576568E4); 19$invalid_float1 = array(57385.45835, 5.738545835e4); 20$invalid_float2 = array(-67345.76567, -6.734576567E4); 21 22 23$toCompare = array( 24// boolean test will result in both sides being converted to boolean so !0 = true and true is not > true for example 25// also note that a string of "0" is converted to false but a string of "0.0" is converted to true 26// false cannot be tested as 0 can never be > 0 or 1 27 true, $valid_false, $valid_true, 28 $int1, $valid_int1, $invalid_int1, 29 $int2, $valid_int2, $invalid_int2, 30 $float1, $valid_float1, $invalid_float1, 31 $float2, $valid_float2, $invalid_float2 32); 33 34$failed = false; 35for ($i = 0; $i < count($toCompare); $i +=3) { 36 $typeToTest = $toCompare[$i]; 37 $valid_compares = $toCompare[$i + 1]; 38 $invalid_compares = $toCompare[$i + 2]; 39 40 foreach($valid_compares as $compareVal) { 41 if ($typeToTest > $compareVal) { 42 // do nothing 43 } 44 else { 45 echo "FAILED: '$typeToTest' <= '$compareVal'\n"; 46 $failed = true; 47 } 48 } 49 50 foreach($invalid_compares as $compareVal) { 51 if ($typeToTest > $compareVal) { 52 echo "FAILED: '$typeToTest' > '$compareVal'\n"; 53 $failed = true; 54 } 55 } 56 57} 58if ($failed == false) { 59 echo "Test Passed\n"; 60} 61?> 62===DONE=== 63--EXPECT-- 64Test Passed 65===DONE=== 66