3 ms·
php > $x = array("a" => 1, "b" => 2); php > echo $x["a"] . "\n"; 1 php > echo array("a" => 1, "b" => 2)["a"] . "\n"; PHP Parse error: syntax er
by adambard 13y ago
php > $x = array("a" => 1, "b" => 2);
php > echo $x["a"] . "\n";
1
php > echo array("a" => 1, "b" => 2)["a"] . "\n";
PHP Parse error: syntax error, unexpected '[', expecting ',' or ';' in php shell code on line 1
I don't mean to denigrate everyone who uses PHP. But there's a whole world of great languages out there, and the vast majority of them act in more consistent (not to mention pleasant) ways than PHP.
When I got into web dev I spent 2 years developing in PHP before moving on. My programs worked fine, eventually, and some were even well-written. I'm sure yours are too. That doesn't make PHP any less of a mess. But I never understood until I moved on to Ruby and Python and beyond just what a mess it was.