Php 5.3: New Language Features

  • May 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Php 5.3: New Language Features as PDF for free.

More details

  • Words: 1,041
  • Pages: 32
PHP 5.3: New Language Features Sebastian Bergmann July 14th  2009

Who I am 







Sebastian Bergmann Involved in the PHP project since 2000 Creator of PHPUnit Co-Founder and Principal Consultant with thePHP.cc

PHP 5.3 New Language Features 

Lambda Functions



Closures



Functors



Late Static Binding

\

Namespaces



goto

PHP 5.3 Other Improvements 

New extensions 

phar, intl, fileinfo



Garbage Collector



MySQL Native Driver



Improved Windows support

PHP 5.3 Performance Improvements

30

20

10

0

PHP 5.0.5

PHP 5.1.6

PHP 5.2.10 PHP 5.3.0

Lambda Functions In a nutshell

Anonymous functions that 

are declared on-the-fly,



can be assigned to a variable,



and passed to other functions

Lambda Functions Usage

Lambda Functions Usage Hello World!

Lambda Functions Usage Hello World!

Lambda Functions Usage Hello World!

Lambda Functions Usage Scenarios Array ( [0] [1] [2] [3] )

=> => => =>

4 19 22 78

Lambda Functions Usage Scenarios Array ( [0] [1] [2] [3] [4] )

=> => => => =>

1 8 27 64 125

Lambda Functions Prior to PHP 5.3 Hello World!

Lambda Functions Prior to PHP 5.3 Hello World!

Lambda Functions Prior to PHP 5.3 Hello World!

Closures In a nutshell

Anonymous functions that 

are declared on-the-fly,



can be assigned to a variable,



passed to other functions,



and remember what happens around them

Closures Lexical Variables Hello World!

Closures Lexical Variables Array ( [0] => 101 [1] => 102 [2] => 103 )

Closures Y-Combinator
}

return $func( function ($f) use($F) { return $F( function ($x) use($f) { $ff = $f($f); return $ff($x); } ); } );

http://en.wikipedia.org/wiki/Fixed_point_combinator

Closures Lexical Variables with references 1 1 1 2

Closures Reflection API Closure [ <user> function {closure} ] { @@ /home/sb/closure_reflection.php 2 - 2 - Parameters [2] { Parameter #0 [ <required> $a ] Parameter #1 [ <required> $b ] } }

Functors In a nutshell 





Allow an object to be invoked or called as if it were an ordinary function Can be used to implement stateful callbacks Also called function objects, functionals or functionoids

Functors Usage Example::__invoke

Static Binding Early Static Binding Base::a Base::b

Static Binding Late Static Binding Base::a Child::b

Namespaces Declaration a.php

Namespaces Fully qualified names a.php b.php

Namespaces Import from namespace into local scope a.php c.php

Namespaces Import from namespace into local scope (conflict) a.php c.php Fatal error: Cannot use project\SomeClass as SomeClass because the name is already in use in /tmp/c.php on line 6

Namespaces Import from namespace into local scope with alias a.php d.php

The End Thank you for your interest! These slides will be posted on http://slideshare.net/sebastian_bergmann

License  





This presentation material is published under the Attribution-Share Alike 3.0 Unported license. You are free: ✔

to Share – to copy, distribute and transmit the work.



to Remix – to adapt the work.

Under the following conditions: ●









Attribution. You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work). Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under the same, similar or a compatible license.

For any reuse or distribution, you must make clear to others the license terms of this work. Any of the above conditions can be waived if you get permission from the copyright holder. Nothing in this license impairs or restricts the author's moral rights.

Related Documents

New Language Features
May 2020 12
New Features
November 2019 39
New Features
November 2019 54
Php Language Detection
October 2019 9
R12 - New Features
May 2020 21