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

Post on 24-Apr-2015

1.975 Views

Category:

Technology

3 Downloads

Preview:

Click to see full reader

DESCRIPTION

 

TRANSCRIPT

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

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

DisclaimerDisclaimer

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

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

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

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

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

... almost... almost

UnicodeUnicode

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

Garbage CollectionGarbage Collection

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

SPL ImprovementsSPL Improvements

SPL ImprovementsSPL Improvements● SplDoublyLinkedList ● SPLStack● SPLQueue● SplPriorityQueue

SPL StackSPL Stack$stack = new SplStack();

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

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

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

Magic Static CallsMagic Static Calls

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

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

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"}

Magic CallsMagic Calls

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

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

Foo::doSomething(...);

Late Static BindingLate Static Binding

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

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

var_dump(Foo::getFoo());

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

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

var_dump(Foo::getFoo());

-> Test

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());

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"

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());

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"

NamespacesNamespaces

class File{ ...}

NamespacesNamespaces

class File{ ...}

// somewhere else

class File{ ...}

NamespacesNamespaces

class my_Web_Framework_Foo_Bar_Baz{ ...}

NamespacesNamespaces

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

class Baz{ ...}

NamespacesNamespaces

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

class Baz { ... }

// somewhere else:

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

NamespacesNamespaces

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

$baz = new myBaz();

NamespacesNamespaces

namespace crypt;

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

NamespacesNamespaces

namespace crypt;

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

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

NamespacesNamespaces

namespace foo;

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

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

NamespacesNamespaces

namespace foo;

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

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

-> string(10) "baz method"

NamespacesNamespaces

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

NamespacesNamespaces● Access built-in functions/classes by

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

● __NAMESPACE__ constant● Multiple namespaces per file

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

Error HandlingError Handling

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

Future-ProofingFuture-Proofing

Regular ExpressionsRegular Expressions● ereg will move to PECL

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

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

Blatant AdvertisementBlatant Advertisement

Thank you.Thank you.

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

stefan.priebsch@e-novative.destefan.priebsch@e-novative.de

top related