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 MinutesDeri...
First Plans for PHP 6First Plans for PHP 6
●
Paris Developer MeetingParis Developer Meeting
●
Derick's Meeting MinutesDeri...
First Plans for PHP 6First Plans for PHP 6
●
Paris Developer MeetingParis Developer Meeting
●
Derick's Meeting MinutesDeri...
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();
e...
SPL StackSPL Stack
$stack = new SplStack();
$stack->push('a');
$stack->push('b');
$stack->push('c');
echo $stack->pop();
e...
Magic Static CallsMagic Static Calls
Magic CallsMagic Calls
class Foo
{
public function __call($aName, $aParameters)
{
var_dump($aName);
var_dump($aParameters)...
Magic CallsMagic Calls
class Foo
{
public function __call($aName, $aParameters)
{
var_dump($aName);
var_dump($aParameters)...
Magic CallsMagic Calls
Strict standards: Non-static method Foo::test() should not be called statically
Magic Static CallsMagic Static Calls
class Foo
{
public static function __callStatic($aName, $aParameters)
{
...
}
}
Foo::...
Late Static BindingLate Static Binding
Late Static BindingLate Static Binding
class Foo
{
protected static $foo = 'Test';
public static function getFoo()
{
retur...
Late Static BindingLate Static Binding
class Foo
{
protected static $foo = 'Test';
public static function getFoo()
{
retur...
Late Static BindingLate Static Binding
class Foo
{
protected static $foo = 'Test';
public static function getFoo()
{
retur...
Late Static BindingLate Static Binding
class Foo
{
protected static $foo = 'Test';
public static function getFoo()
{
retur...
Late Static BindingLate Static Binding
class Foo
{
protected static $foo = 'Test';
public static function getFoo()
{
retur...
Late Static BindingLate Static Binding
class Foo
{
protected static $foo = 'Test';
public static function getFoo()
{
retur...
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(...
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('sa45hzq734...
namespace foo;
class bar
{
static public function baz()
{
return 'baz method';
}
}
var_dump(foo::bar::baz());
NamespacesNa...
namespace foo;
class bar
{
static public function baz()
{
return 'baz method';
}
}
var_dump(foo::bar::baz());
-> string(10...
namespace foo::bar;
function baz()
{
return 'baz function';
}
namespace foo;
class bar
{
static public function baz()
{
re...
NamespacesNamespaces
● Access built-in functions/classes by
prefixing ::
● some_fn(...) vs. ::some_fn(...)
● __NAMESPACE__...
More New FeaturesMore New Features
● ifsetor
● OpenID support
● SQLite3
● getopt() works on Windows
● __DIR__ = dirname(__...
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 binar...
Deprecated php.ini SettingsDeprecated php.ini Settings
● short open tags
● magic quotes
● register_globals
● register_long...
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)
st...
PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch
PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch
PHP 5.3 and PHP 6; a look ahead - Stefan Priebsch
Upcoming SlideShare
Loading in …5
×

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

1,414 views

Published on

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,414
On SlideShare
0
From Embeds
0
Number of Embeds
29
Actions
Shares
0
Downloads
32
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

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

  1. 1. What is new in PHP 5.3?What is new in PHP 5.3? Stefan Priebsch, e-novative GmbHStefan Priebsch, e-novative GmbH
  2. 2. DisclaimerDisclaimer
  3. 3. 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
  4. 4. 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
  5. 5. 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
  6. 6. And PHP 6 ...And PHP 6 ...
  7. 7. ... became PHP 5.3 ...... became PHP 5.3 ...
  8. 8. ... almost... almost
  9. 9. UnicodeUnicode
  10. 10. UnicodeUnicode ● One Standard to rule them all ● PHP 6's killer feature ● One character != one byte
  11. 11. Garbage CollectionGarbage Collection
  12. 12. Garbage CollectionGarbage Collection ● Free memory while script is running ● gc_enable(); ● gc_disable();
  13. 13. SPL ImprovementsSPL Improvements
  14. 14. SPL ImprovementsSPL Improvements ● SplDoublyLinkedList ● SPLStack ● SPLQueue ● SplPriorityQueue
  15. 15. SPL StackSPL Stack $stack = new SplStack(); $stack->push('a'); $stack->push('b'); $stack->push('c'); echo $stack->pop(); echo $stack->pop(); echo $stack->pop();
  16. 16. 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
  17. 17. Magic Static CallsMagic Static Calls
  18. 18. Magic CallsMagic Calls class Foo { public function __call($aName, $aParameters) { var_dump($aName); var_dump($aParameters); } } $foo = new Foo(); $foo->test('something');
  19. 19. Magic CallsMagic Calls class 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" }
  20. 20. Magic CallsMagic Calls Strict standards: Non-static method Foo::test() should not be called statically
  21. 21. Magic Static CallsMagic Static Calls class Foo { public static function __callStatic($aName, $aParameters) { ... } } Foo::doSomething(...);
  22. 22. Late Static BindingLate Static Binding
  23. 23. Late Static BindingLate Static Binding class Foo { protected static $foo = 'Test'; public static function getFoo() { return self::$foo; } } var_dump(Foo::getFoo());
  24. 24. Late Static BindingLate Static Binding class Foo { protected static $foo = 'Test'; public static function getFoo() { return self::$foo; } } var_dump(Foo::getFoo()); -> Test
  25. 25. Late Static BindingLate Static Binding class 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());
  26. 26. Late Static BindingLate Static Binding class 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"
  27. 27. Late Static BindingLate Static Binding class 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());
  28. 28. Late Static BindingLate Static Binding class 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"
  29. 29. NamespacesNamespaces
  30. 30. class File { ... } NamespacesNamespaces
  31. 31. class File { ... } // somewhere else class File { ... } NamespacesNamespaces
  32. 32. class my_Web_Framework_Foo_Bar_Baz { ... } NamespacesNamespaces
  33. 33. namespace my::Web::Framework::Foo::Bar; class Baz { ... } NamespacesNamespaces
  34. 34. namespace my::Web::Framework::Foo::Bar; class Baz { ... } // somewhere else: $baz = new my::Web::Framework::Foo::Bar::Baz(); NamespacesNamespaces
  35. 35. use my::Web::Framework::Foo::Bar::Baz as MyBaz; $baz = new myBaz(); NamespacesNamespaces
  36. 36. namespace crypt; function gnupg_decrypt($aText, $aKeyFile) { return 'some plaintext'; } NamespacesNamespaces
  37. 37. namespace crypt; function gnupg_decrypt($aText, $aKeyFile) { return 'some plaintext'; } var_dump(gnupg_decrypt('sa45hzq734hrq243rwaefsd80', 'my.key')); NamespacesNamespaces
  38. 38. namespace foo; class bar { static public function baz() { return 'baz method'; } } var_dump(foo::bar::baz()); NamespacesNamespaces
  39. 39. namespace foo; class bar { static public function baz() { return 'baz method'; } } var_dump(foo::bar::baz()); -> string(10) "baz method" NamespacesNamespaces
  40. 40. 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
  41. 41. NamespacesNamespaces ● Access built-in functions/classes by prefixing :: ● some_fn(...) vs. ::some_fn(...) ● __NAMESPACE__ constant ● Multiple namespaces per file
  42. 42. More New FeaturesMore New Features ● ifsetor ● OpenID support ● SQLite3 ● getopt() works on Windows ● __DIR__ = dirname(__FILE__)
  43. 43. Error HandlingError Handling
  44. 44. Error HandlingError Handling ● New error class E_DEPRECATED ● E_ALL includes E_STRICT
  45. 45. Future-ProofingFuture-Proofing
  46. 46. Regular ExpressionsRegular Expressions ● ereg will move to PECL ● replace ereg_* by preg_* ● by the way, ereg is not binary safe
  47. 47. 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
  48. 48. Blatant AdvertisementBlatant Advertisement
  49. 49. Thank you.Thank you.
  50. 50. 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

×