Quote:
Changed silent conversion of array to string to produce a notice.
|
Finally!
Printing "Array" is not useful at all and is *never* what you want. Instead, do what every other programming language does: Just print contents (i.e. what
print_r() does), so we're not quite there yet. In any case, a warning is a lot better.
We also *finally* get the "short" array syntax, which is also what pretty much every other language does. This feature only took about 4 years to implement in PHP (literally, this has been in the works for ages).
You can now use:
$arr = ['key' => 'value'];
instead of:
$arr = array('key' => 'value');
Both "indexed arrays" and "associative arrays" use the same syntax, which is a bit of a shame IMHO. They're really separate data structures with different properties, at least, they are in most languages, maybe there is no difference in PHP's implementation (I would not be surprised...)?
Ofcourse, you still have to use
array_*() function which makes the saving minimal, not only are they pretty long to type, they're not always easy to work with since you never know which order the specify the arguments. For example, it's
array_map($callback, $array) and
array_walk_recursive ($array, $callback) just to name one example. It's just really really silly.
One more piece of good(-ish) news is that you can now use:
$var = fun()['2'];
This is probably something of a quick syntax hack, and certainly not the same "everything's an object" model Python or Ruby sport, but it saves a line of typing.
I wonder if it allows:
$vars = fun()['2']['4'];
or
$vars = fun2(fun()['2'])['3'];
One new feature that's also interesting is proper upload tracking through sessions, you can access
$_SESSION['upload_progress'] and get the upload start time, file size, filename, etc. Very useful for creating progress bars and the like: Something that was previously semi-impossible, all the existing "solutions" only worked with Apache/mod_php and/or were not reliable in large numbers.