Djkanna Posted March 6, 2012 Share Posted March 6, 2012 (edited) Whilst not many will be using it straight away (for obvious reasons), PHP 5.4 has been released. To be honest, there is a fair few things, I am liking about this release (besides performance enhancements) 'Traits' being one of them. Thoughts? (Summary Link: (at) Net.Tuts+) (PS: I know I am a little late, but no one else had posted it, so I did. & Apache 2.4 was also released a while ago) Edited March 6, 2012 by Djkanna Added PS Quote Link to comment Share on other sites More sharing options...
a_bertrand Posted March 6, 2012 Share Posted March 6, 2012 trait... I never needed something like that myself. So I can't say I will ever use it... and for the remaining... honestly they are cool... but not all that killer yet, of course make your script in-compatible with previous versions so personally I would not rely on them for quiet some time. Quote Link to comment Share on other sites More sharing options...
Danny696 Posted March 6, 2012 Share Posted March 6, 2012 Ech, I actually quite like the traits, not too sure if I would actually use it, but it is very handy if I did ever need to use it. I also like the new syntax bit, where, in the link you posted, they do echo (new Facebook_API)->get('500058753')->name; // Facebook_API being a class (Just for people who didnt actually read it.) Also, the 2 new array systems (syntax and dereferencing) are very handy, very, erm.... Javascripty Use of binary, not that useful, even though I do know binary now. $_SERVER['REQUEST_TIME_FLOAT'] Could be handy, I suppose its quicker than what I used in my engine ;) Quote Link to comment Share on other sites More sharing options...
bluegman991 Posted March 6, 2012 Share Posted March 6, 2012 I'm happy they added dereferencing. No more wasting time/memory storing it in a variable first. Traits will be great for developing scripts that have have consistent methods. Allowing for an easily remembered api. Binary is a nice addition. Can make low level code management and/or certain tasks a bit more understandable (for some people). The shortened literal array syntax is nice but could be shorter. If you don't know the shortened syntax is: $blah=['a' => 'value a','b' => 'value b']; This only made making an array 5 less characters to type. I wish they had went with this shortened syntax instead: $blah=['a':'value a','b':'value b']; Upload progress for files. Yayy. No more need for flash to have a good looking upload system. Quote Link to comment Share on other sites More sharing options...
Spudinski Posted March 6, 2012 Share Posted March 6, 2012 Traits, as everyone seems to ignore, could have been much more developed upon. For some of you who like to give forth they know what traits actually are, here's a brief description: Traits are a shortened method for copying functions into classes multiple times. When you are calling a trait into a class, you are calling a member function of that specific class, as the trait is copied into the class at runtime. There is a lot of room for improvement here, they could have improved traits by making them an entity within memory that exists only once, and is called by each class and also having the trait follow the class' scope. Even though, that's not a functional solution. In short, PHP 5.4 has given us a bit more to the inheritance model, by giving us multiple inheritance. Now, there are also quite a few things that changed, which of course, Nettuts+ didn't cover. They are, in order of importance: complete removal of register_globals, safe_mode and magic_quotes. On the OOP side, they removed call_time_pass_reference, even though this has been deprecated for some time. Again, for those of you that don't know what it is: $my_function_data = myFunction(&$var); And also some useful GLOBALS, see: http://docs.php.net/manual/en/migration54.global-constants.php On the upside, things that actually are of greater importance: PHP default character set is now UTF-8. Removal of old, deprecated, functions. Session upload progress, even though I've already had my debates on this, let's just say it's "there". CLI SAPI includes a web server, this is incredibly useful for debugging, even though many of us have already made a hack like this ourselves(sockets). @bluegman991: Shorthand arrays, PHP is not JSON. If you want syntax like that use json_encode, but for PHP this syntax makes perfect sense. The only thing about shorthand arrays is that it's used for shorthand. If you are going with larger than 2D arrays, use proper formatting to enhance readability. Quote Link to comment Share on other sites More sharing options...
Djkanna Posted March 6, 2012 Author Share Posted March 6, 2012 (edited) [...] Now, there are also quite a few things that changed, which of course, Nettuts+ didn't cover. They are, in order of importance: complete removal of register_globals, safe_mode and magic_quotes. [...] It mentioned those... As for the JSON style syntax (Blue) for arrays. $array = [ 'key' => 'val', 'key' => 'val' ]; Makes more sense to do it this way really. Edit: Though I do prefer the norm of; $array = array ( ... ); Edited March 6, 2012 by Djkanna Quote Link to comment Share on other sites More sharing options...
Spudinski Posted March 6, 2012 Share Posted March 6, 2012 It mentioned those... Did not see that, thanks for correcting me. Quote Link to comment Share on other sites More sharing options...
bluegman991 Posted March 6, 2012 Share Posted March 6, 2012 (edited) @bluegman991: Shorthand arrays, PHP is not JSON. If you want syntax like that use json_encode, but for PHP this syntax makes perfect sense. Didn't say I wanted json. Yea it definitely makes more sense the way they did it. But i'm basically saying I wanted something that would require less typing. It could have been $blah=['a'='value a', 'b'='value b']; or $blah=['a'>'value a', 'b'>'value b']; for all I care. As long as it was shorter. Edited March 6, 2012 by bluegman991 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.