1--TEST-- 2Testing isset with string offsets 3--FILE-- 4<?php 5 6print "- isset ---\n"; 7 8$str = "test0123"; 9 10var_dump(isset($str[-1])); 11var_dump(isset($str[-10])); 12var_dump(isset($str[0])); 13var_dump(isset($str[1])); 14var_dump(isset($str[4])); // 0 15var_dump(isset($str[5])); // 1 16var_dump(isset($str[8])); 17var_dump(isset($str[10000])); 18// non-numeric offsets 19print "- string literal ---\n"; 20var_dump(isset($str['-1'])); // 3 21var_dump(isset($str['-10'])); 22var_dump(isset($str['0'])); 23var_dump(isset($str['1'])); 24var_dump(isset($str['4'])); // 0 25var_dump(isset($str['1.5'])); 26var_dump(isset($str['good'])); 27var_dump(isset($str['3 and a half'])); 28print "- string variable ---\n"; 29var_dump(isset($str[$key = '-1'])); // 3 30var_dump(isset($str[$key = '-10'])); 31var_dump(isset($str[$key = '0'])); 32var_dump(isset($str[$key = '1'])); 33var_dump(isset($str[$key = '4'])); // 0 34var_dump(isset($str[$key = '1.5'])); 35var_dump(isset($str[$key = 'good'])); 36var_dump(isset($str[$key = '3 and a half'])); 37print "- bool ---\n"; 38var_dump(isset($str[true])); 39var_dump(isset($str[false])); 40var_dump(isset($str[false][true])); 41print "- null ---\n"; 42var_dump(isset($str[null])); 43print "- double ---\n"; 44var_dump(isset($str[-1.1])); 45var_dump(isset($str[-10.5])); 46var_dump(isset($str[-0.8])); 47var_dump(isset($str[-0.1])); 48var_dump(isset($str[0.2])); 49var_dump(isset($str[0.9])); 50var_dump(isset($str[M_PI])); 51var_dump(isset($str[100.5001])); 52print "- array ---\n"; 53var_dump(isset($str[array()])); 54var_dump(isset($str[array(1,2,3)])); 55print "- object ---\n"; 56var_dump(isset($str[new stdClass()])); 57print "- resource ---\n"; 58$f = fopen(__FILE__, 'r'); 59var_dump(isset($str[$f])); 60print "done\n"; 61 62?> 63--EXPECT-- 64- isset --- 65bool(true) 66bool(false) 67bool(true) 68bool(true) 69bool(true) 70bool(true) 71bool(false) 72bool(false) 73- string literal --- 74bool(true) 75bool(false) 76bool(true) 77bool(true) 78bool(true) 79bool(false) 80bool(false) 81bool(false) 82- string variable --- 83bool(true) 84bool(false) 85bool(true) 86bool(true) 87bool(true) 88bool(false) 89bool(false) 90bool(false) 91- bool --- 92bool(true) 93bool(true) 94bool(false) 95- null --- 96bool(true) 97- double --- 98bool(true) 99bool(false) 100bool(true) 101bool(true) 102bool(true) 103bool(true) 104bool(true) 105bool(false) 106- array --- 107bool(false) 108bool(false) 109- object --- 110bool(false) 111- resource --- 112bool(false) 113done 114