May 16, 20179 yr So out of curiosity what are your thoughts on PHP 7? Personally i find it a big upgrade from previous versions some of the newer features i like is... Short hand version for writing arrays(PHP 5.4) Well this is not to much shorter but it does look neater instead of writing arrays like this... $colors = array("color1","color2","color3"); you can write arrays like this... $colors = ["color1","color2","color3"]; As noted below shorthand arrays actually came out in PHP 5.4 . My Mistake Type Hints You can now apply data type hints to parameters of functions/class methods function hello(string $msg){ return $msg; } echo hello("Hello World"); you can also turn on strict type mode in order to hold you accountable by displaying a fatal error if you pass a data type other then the type specified. declare(strict_types=1); that line must be the first line on the page. And it has to go on each page. There is no way to make it global The ?? Operator Normally you would do this ... $action = (isset($_GET['action')) ? $_GET['action'] : "no_action_set"; Now you can do a short hand version using ?? $action = $_GET['action'] ?? "no_action_set"; Constant Arrays You can now define array constants using define instead of just const define("COLORS", ["red","blue","orange"] ); SPEED PHP 7 is said to be about 3x faster than PHP 5.6 Edited May 16, 20179 yr by webdesigner93
May 16, 20179 yr Great outline, thanks! I have to say I've really noticed the speed differences. Makes life a lot easier.
May 16, 20179 yr I don't think the array shorthand is PHP7, I've definitely used it on older versions. I like the strict typing stuff they've added though.
May 16, 20179 yr I haven't gotten the chance to check out many of the new features, but I find anonymous classes to be a cool new feature. I'm not entirely sure why it hasn't been added yet, though.
May 16, 20179 yr Author PHP 5.4 http://php.net/releases/5_4_0.php Mmm wonder why some people have listed that as a new feature of PHP 7 personally i've never used it before so figure it was. Thanks Jack and Nock for the correction. Edited May 16, 20179 yr by webdesigner93
May 16, 20179 yr Author I haven't gotten the chance to check out many of the new features, but I find anonymous classes to be a cool new feature. I'm not entirely sure why it hasn't been added yet, though. Anonymous classes are already added haven't fooled around with them yet tho
May 16, 20179 yr Anonymous classes are already added haven't fooled around with them yet tho Yeah, I didn't phrase my sentence properly. I meant to say: I wonder why it hasn't been added until now.
Create an account or sign in to comment