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