php-src / Zend / tests / isset_str_offset.phpt

--TEST--
Testing isset with string offsets
--FILE--
<?php

print "- isset ---\n";

$str = "test0123";

var_dump(isset($str[-1]));
var_dump(isset($str[0]));
var_dump(isset($str[1]));
var_dump(isset($str[4])); // 0
var_dump(isset($str[5])); // 1
var_dump(isset($str[8]));
var_dump(isset($str[10000]));
// non-numeric offsets
print "- string ---\n";
var_dump(isset($str['-1']));
var_dump(isset($str['0']));
var_dump(isset($str['1']));
var_dump(isset($str['4'])); // 0
var_dump(isset($str['1.5']));
var_dump(isset($str['good']));
var_dump(isset($str['3 and a half']));
print "- bool ---\n";
var_dump(isset($str[true]));
var_dump(isset($str[false]));
var_dump(isset($str[false][true]));
print "- null ---\n";
var_dump(isset($str[null]));
print "- double ---\n";
var_dump(isset($str[-1.1]));
var_dump(isset($str[-0.8]));
var_dump(isset($str[-0.1]));
var_dump(isset($str[0.2]));
var_dump(isset($str[0.9]));
var_dump(isset($str[M_PI]));
var_dump(isset($str[100.5001]));
print "- array ---\n";
var_dump(isset($str[array()]));
var_dump(isset($str[array(1,2,3)]));
print "- object ---\n";
var_dump(isset($str[new stdClass()]));
print "- resource ---\n";
$f = fopen(__FILE__, 'r');
var_dump(isset($str[$f]));
print "done\n";

?>
--EXPECTF--
- isset ---
bool(false)
bool(true)
bool(true)
bool(true)
bool(true)
bool(false)
bool(false)
- string ---
bool(false)
bool(true)
bool(true)
bool(true)
bool(false)
bool(false)

Notice: A non well formed numeric value encountered in %s line %d
bool(true)
- bool ---
bool(true)
bool(true)
bool(false)
- null ---
bool(true)
- double ---
bool(false)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(false)
- array ---
bool(false)
bool(false)
- object ---
bool(false)
- resource ---
bool(false)
done
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.