4 ms·
I don't see how this will ever be useful. The state "echo boo()[1];" assumes you're only ever going to need that one value from the array. The rest of the array
by paradox95 15y ago
I don't see how this will ever be useful. The state "echo boo()[1];" assumes you're only ever going to need that one value from the array. The rest of the array is lost. What if the next line in the code needs index 3 from the array? Now you have to run the function again.
I also don't agree that PHP needs constructors to return $this for the same reason. You need to assign the object to a variable so you can reuse it.
$a = new Foo()->bar();
In this case if I later want to call another method on the Foo instance I have recreate it.
- etherealG 15y agoyou're assuming that cases don't exist where you won't reuse something. this is a false assumption, e.g. if all I wanted was the creation date of a file: stat("filepath")[7] is a reasonable way to do this in php, but you can't currently.