Php v5.3+ features
Click here to load reader
-
Upload
michael-bui -
Category
Software
-
view
174 -
download
0
Transcript of Php v5.3+ features
PHP v5.3+ FEATURESMichael Bui
(FB & TW: MichaelBui2812)
PHP v5.3
● “ereg” deprecated● SPL always enabled● Reflection always enabled● Magic methods
○ __invoke()○ __callStatic()
● Performance improved
PHP v5.3
● Namespace○ PSR-0○ Composer○ For classes, functions and constants
● Import classes○ “use” keyword○ relative & absolute namespaces
● Closures
PHP v5.4
● PHP_BINARY constant● Array to string conversions will trigger
a notice● Array callbacks:
○ [$obj, ‘method’]○ [‘ClassName’, ‘method’]
● Memory & performance improved
PHP v5.4
● Traits○ “compiler level” copy-n-paste (literally)○ “insteadof” & “as” to solve collisions
● Closures○ Support “$this”○ Re-bind “$this”
● Short echo tags “<?=...?>” always work● Binary numbers (0b...)
PHP v5.4 (Cont.)
● Short array syntax: ○ [‘a’=>1,’b’=>2] === array(‘a’=>1,’b’=>2)○ Array dereferencing: getArray()[0];
● Initiation time access○ (new Classname())->method()
● Dynamic method calls:○ ClassName::{$var}()○ (new ClassName())->{$var}()
PHP v5.5
● RegExp /e modifier deprecated● Mysql extension officially deprecated● boolval()● empty() support any expression● OPCache built-in
PHP v5.5
● “finally” supported● Fully qualified classname constant
○ ClassName::CLASS
● Literal Dereferencing○ [‘a’,’b’,’c’][1] will return ‘b’
● “foreach” support “list()”○ foreach ($records as list($name, $email)) {}
● Generators & Co-routines
PHP v5.6
● Import functions & constants○ use function Name\Spaced\method;○ use const Name\Spaced\CONSTANT;
● Scalar expressions supported in○ Constants: const FOO = self::BAR . “!”;○ Class properties: public $a = 1 + 1;○ Function arguments: function f($a = 1 + 1) {}○ …
● __debugInfo()
PHP v5.6 (cont.)
● Variadic functions○ Referencing○ Type hinting
● Argument unpacking● Exponent operator (**)● Upload more than 2GB
ONE MORE THING...
THANK YOU!Michael Bui
(FB & TW: MichaelBui2812)