[ create a new paste ] login | about

Link: http://codepad.org/qLk9bQqp    [ raw code | output | fork ]

PHP, pasted on Apr 22:
1
2
3
4
5
6
7
8
9
10
11
12
13
<?php
$x = new stdclass;
$x->{42} = "foo";
$x->{"42"} = 1337;
var_dump($x);
$y = (array)$x;
var_dump($y);
$y["42"] = "wat";
var_dump($y);
$z = (object)$y;
var_dump($z);
var_dump($z->{42})
?>


Output:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
object(stdClass)#1 (1) {
  ["42"]=>
  int(1337)
}
array(1) {
  ["42"]=>
  int(1337)
}
array(2) {
  ["42"]=>
  int(1337)
  [42]=>
  string(3) "wat"
}
object(stdClass)#2 (2) {
  ["42"]=>
  int(1337)
  [42]=>
  string(3) "wat"
}
int(1337)


Create a new paste based on this one


Comments: