php 5.3 and php 6; a look ahead - stefan priebsch

53
What is new in PHP 5.3? What is new in PHP 5.3? Stefan Priebsch, e-novative GmbH Stefan Priebsch, e-novative GmbH

Upload: dpc

Post on 24-Apr-2015

1.975 views

Category:

Technology


3 download

DESCRIPTION

 

TRANSCRIPT

Page 1: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

What is new in PHP 5.3?What is new in PHP 5.3?

Stefan Priebsch, e-novative GmbHStefan Priebsch, e-novative GmbH

Page 2: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

DisclaimerDisclaimer

Page 3: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

First Plans for PHP 6First Plans for PHP 6● Paris Developer MeetingParis Developer Meeting● Derick's Meeting MinutesDerick's Meeting Minutes

● www.php.net/~derick/meeting-notes.htmlwww.php.net/~derick/meeting-notes.html● First Release Candidate late 2006First Release Candidate late 2006

Page 4: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

First Plans for PHP 6First Plans for PHP 6● Paris Developer MeetingParis Developer Meeting● Derick's Meeting MinutesDerick's Meeting Minutes

● www.php.net/~derick/meeting-notes.htmlwww.php.net/~derick/meeting-notes.html● First Release Candidate late 2007First Release Candidate late 2007

Page 5: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

First Plans for PHP 6First Plans for PHP 6● Paris Developer MeetingParis Developer Meeting● Derick's Meeting MinutesDerick's Meeting Minutes

● www.php.net/~derick/meeting-notes.htmlwww.php.net/~derick/meeting-notes.html● First Release Candidate ... some dayFirst Release Candidate ... some day

Page 6: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

And PHP 6 ...And PHP 6 ...

Page 7: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

... became PHP 5.3 ...... became PHP 5.3 ...

Page 8: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

... almost... almost

Page 9: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

UnicodeUnicode

Page 10: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

UnicodeUnicode● One Standard to rule them all● PHP 6's killer feature● One character != one byte

Page 11: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

Garbage CollectionGarbage Collection

Page 12: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

Garbage CollectionGarbage Collection● Free memory while script is running● gc_enable();● gc_disable();

Page 13: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

SPL ImprovementsSPL Improvements

Page 14: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

SPL ImprovementsSPL Improvements● SplDoublyLinkedList ● SPLStack● SPLQueue● SplPriorityQueue

Page 15: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

SPL StackSPL Stack$stack = new SplStack();

$stack->push('a');$stack->push('b');$stack->push('c');

echo $stack->pop();echo $stack->pop();echo $stack->pop();

Page 16: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

SPL StackSPL Stack$stack = new SplStack();

$stack->push('a');$stack->push('b');$stack->push('c');

echo $stack->pop();echo $stack->pop();echo $stack->pop();

-> cba

Page 17: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

Magic Static CallsMagic Static Calls

Page 18: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

Magic CallsMagic Callsclass Foo{ public function __call($aName, $aParameters) { var_dump($aName); var_dump($aParameters); }}

$foo = new Foo();$foo->test('something');

Page 19: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

Magic CallsMagic Callsclass Foo{ public function __call($aName, $aParameters) { var_dump($aName); var_dump($aParameters); }}

$foo = new Foo();$foo->test('something');

->

string(4) "test"array(1) { [0]=> string(9) "something"}

Page 20: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

Magic CallsMagic Calls

Strict standards: Non-static method Foo::test() should not be called statically

Page 21: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

Magic Static CallsMagic Static Callsclass Foo{ public static function __callStatic($aName, $aParameters) { ... }}

Foo::doSomething(...);

Page 22: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

Late Static BindingLate Static Binding

Page 23: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

Late Static BindingLate Static Bindingclass Foo{ protected static $foo = 'Test';

public static function getFoo() { return self::$foo; }}

var_dump(Foo::getFoo());

Page 24: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

Late Static BindingLate Static Bindingclass Foo{ protected static $foo = 'Test';

public static function getFoo() { return self::$foo; }}

var_dump(Foo::getFoo());

-> Test

Page 25: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

Late Static BindingLate Static Bindingclass Foo{ protected static $foo = 'Test';

public static function getFoo() { return self::$foo; }}

class MyFoo extends Foo{ protected static $foo = 'MyTest';}

var_dump(Foo::getFoo());var_dump(MyFoo::getFoo());

Page 26: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

Late Static BindingLate Static Bindingclass Foo{ protected static $foo = 'Test';

public static function getFoo() { return self::$foo; }}

class MyFoo extends Foo{ protected static $foo = 'MyTest';}

var_dump(Foo::getFoo());var_dump(MyFoo::getFoo());

-> string(4) "Test" string(4) "Test"

Page 27: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

Late Static BindingLate Static Bindingclass Foo{ protected static $foo = 'Test';

public static function getFoo() { return static::$foo; }}

class MyFoo extends Foo{ protected static $foo = 'MyTest';}

var_dump(Foo::getFoo());var_dump(MyFoo::getFoo());

Page 28: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

Late Static BindingLate Static Bindingclass Foo{ protected static $foo = 'Test';

public static function getFoo() { return static::$foo; }}

class MyFoo extends Foo{ protected static $foo = 'MyTest';}

var_dump(Foo::getFoo());var_dump(MyFoo::getFoo());

-> string(4) "Test" string(6) "MyTest"

Page 29: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

NamespacesNamespaces

Page 30: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

class File{ ...}

NamespacesNamespaces

Page 31: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

class File{ ...}

// somewhere else

class File{ ...}

NamespacesNamespaces

Page 32: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

class my_Web_Framework_Foo_Bar_Baz{ ...}

NamespacesNamespaces

Page 33: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

namespace my::Web::Framework::Foo::Bar;

class Baz{ ...}

NamespacesNamespaces

Page 34: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

namespace my::Web::Framework::Foo::Bar;

class Baz { ... }

// somewhere else:

$baz = new my::Web::Framework::Foo::Bar::Baz();

NamespacesNamespaces

Page 35: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

use my::Web::Framework::Foo::Bar::Baz as MyBaz;

$baz = new myBaz();

NamespacesNamespaces

Page 36: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

namespace crypt;

function gnupg_decrypt($aText, $aKeyFile){ return 'some plaintext';}

NamespacesNamespaces

Page 37: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

namespace crypt;

function gnupg_decrypt($aText, $aKeyFile){ return 'some plaintext';}

var_dump(gnupg_decrypt('sa45hzq734hrq243rwaefsd80', 'my.key'));

NamespacesNamespaces

Page 38: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

namespace foo;

class bar{ static public function baz() { return 'baz method'; }}

var_dump(foo::bar::baz());

NamespacesNamespaces

Page 39: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

namespace foo;

class bar{ static public function baz() { return 'baz method'; }}

var_dump(foo::bar::baz());

-> string(10) "baz method"

NamespacesNamespaces

Page 40: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

namespace foo::bar;

function baz(){ return 'baz function';}

namespace foo;

class bar{ static public function baz() { return 'baz method'; }}

var_dump(foo::bar::baz());

NamespacesNamespaces

Page 41: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

NamespacesNamespaces● Access built-in functions/classes by

prefixing ::● some_fn(...) vs. ::some_fn(...)

● __NAMESPACE__ constant● Multiple namespaces per file

Page 42: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

More New FeaturesMore New Features● ifsetor● OpenID support● SQLite3● getopt() works on Windows● __DIR__ = dirname(__FILE__)

Page 43: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

Error HandlingError Handling

Page 44: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

Error HandlingError Handling● New error class E_DEPRECATED● E_ALL includes E_STRICT

Page 45: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

Future-ProofingFuture-Proofing

Page 46: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

Regular ExpressionsRegular Expressions● ereg will move to PECL

● replace ereg_* by preg_*● by the way, ereg is not binary safe

Page 47: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

Deprecated php.ini SettingsDeprecated php.ini Settings● short open tags● magic quotes● register_globals● register_long_arrays● ze1.compatibility_mode● allow_call_time_pass_reference● safe_mode

Page 48: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

Blatant AdvertisementBlatant Advertisement

Page 49: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch
Page 50: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch
Page 51: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

Thank you.Thank you.

Page 52: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch

http://www.priebsch.de (de)http://www.priebsch.de (de)http://inside.e-novative.de (en)http://inside.e-novative.de (en)

[email protected]@e-novative.de

Page 53: PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch