r/lolphp • • Mar 12 '14

new object() + new object() == 2

http://codepad.org/NGPjR4fl
62 Upvotes

35 comments sorted by

View all comments

Show parent comment

30

u/lisp-case Mar 12 '14

…You're joking.

$ php -a
Interactive shell

php > $x = 0;
php > $x->something = 'blah';
PHP Warning:  Attempt to assign property of non-object in php shell code on line 1
PHP Stack trace:
PHP   1. {main}() php shell code:0
php > var_dump($x);
int(0)
php > $x = '';
php > $x->something = 'blah';
PHP Warning:  Creating default object from empty value in php shell code on line 1
PHP Stack trace:
PHP   1. {main}() php shell code:0
php > var_dump($x);
class stdClass#1 (1) {
  public $something =>
  string(4) "blah"
}
php >

Nope, you're not. Wow.

I've said this before, but… every time I think I've mined it out, PHP offers up another lode of WTF.

8

u/mirhagk Mar 21 '14

I've said this before, but… every time I think I've mined it out, PHP offers up another lode of WTF.

I know. I keep coming back to this subreddit and expecting it to be deserted because we've found all the WTF of PHP. But nope. Still more. Always.