123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- --TEST--
- Unset on non-array
- --FILE--
- <?php
- unset($x[0]);
- $x = null;
- unset($x[0]);
- $x = false;
- unset($x[0]);
- $x = true;
- try {
- unset($x[0]);
- } catch (Error $e) {
- echo $e->getMessage(), "\n";
- }
- $x = 1;
- try {
- unset($x[0]);
- } catch (Error $e) {
- echo $e->getMessage(), "\n";
- }
- $x = 3.14;
- try {
- unset($x[0]);
- } catch (Error $e) {
- echo $e->getMessage(), "\n";
- }
- $x = "str";
- try {
- unset($x[0]);
- } catch (Error $e) {
- echo $e->getMessage(), "\n";
- }
- $x = new stdClass;
- try {
- unset($x[0]);
- } catch (Error $e) {
- echo $e->getMessage(), "\n";
- }
- // And now repeat the same with a nested offset.
- unset($x);
- unset($x[0][0]);
- $x = null;
- unset($x[0][0]);
- $x = false;
- unset($x[0][0]);
- $x = true;
- try {
- unset($x[0][0]);
- } catch (Error $e) {
- echo $e->getMessage(), "\n";
- }
- $x = 1;
- try {
- unset($x[0][0]);
- } catch (Error $e) {
- echo $e->getMessage(), "\n";
- }
- $x = 3.14;
- try {
- unset($x[0][0]);
- } catch (Error $e) {
- echo $e->getMessage(), "\n";
- }
- $x = "str";
- try {
- unset($x[0][0]);
- } catch (Error $e) {
- echo $e->getMessage(), "\n";
- }
- $x = new stdClass;
- try {
- unset($x[0][0]);
- } catch (Error $e) {
- echo $e->getMessage(), "\n";
- }
- ?>
- --EXPECTF--
- Warning: Undefined variable $x in %s on line %d
- Deprecated: Automatic conversion of false to array is deprecated in %s
- Cannot unset offset in a non-array variable
- Cannot unset offset in a non-array variable
- Cannot unset offset in a non-array variable
- Cannot unset string offsets
- Cannot use object of type stdClass as array
- Warning: Undefined variable $x in %s on line %d
- Deprecated: Automatic conversion of false to array is deprecated in %s
- Cannot unset offset in a non-array variable
- Cannot unset offset in a non-array variable
- Cannot unset offset in a non-array variable
- Cannot unset string offsets
- Cannot use object of type stdClass as array
|