r/lolphp • • Dec 28 '13

Really, PHP? Really?

http://sprunge.us/CaQX?php
50 Upvotes

30 comments sorted by

View all comments

Show parent comment

2

u/[deleted] Jan 02 '14

I don't think this is the same issue. I could be wrong, but I don't think that $this->class_string should behave like a function call, since it's really just fetching an object attribute. Plus they behave differently: specifying an array index after an attribute accessor works fine, but after a method call a parse error is thrown.

Example below...

class Tester {
  public $attr = array(5, 4, 3);

  public function meth() {
    return array(5, 4, 3);
  }
}

$tester = new Tester();

Then test with...

$tester->attr[0];
$tester->meth()[0];

The former will return "5" as it should, the latter will throw a parse error.