Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

PHP 5.3 And PHP 6 A Look Ahead

8,849 views

Published on

Published in: Technology
  • Be the first to comment

PHP 5.3 And PHP 6 A Look Ahead

  1. 1. What is new in PHP 5.3? <ul><li>Stefan Priebsch, e-novative GmbH </li></ul>
  2. 2. Disclaimer
  3. 3. First Plans for PHP 6 <ul><li>Paris Developer Meeting </li></ul><ul><li>Derick's Meeting Minutes </li></ul><ul><ul><li>www.php.net/~derick/meeting-notes.html </li></ul></ul><ul><li>First Release Candidate late 2006 </li></ul>
  4. 4. First Plans for PHP 6 <ul><li>Paris Developer Meeting </li></ul><ul><li>Derick's Meeting Minutes </li></ul><ul><ul><li>www.php.net/~derick/meeting-notes.html </li></ul></ul><ul><li>First Release Candidate late 2007 </li></ul>
  5. 5. First Plans for PHP 6 <ul><li>Paris Developer Meeting </li></ul><ul><li>Derick's Meeting Minutes </li></ul><ul><ul><li>www.php.net/~derick/meeting-notes.html </li></ul></ul><ul><li>First Release Candidate ... some day </li></ul>
  6. 6. And PHP 6 ...
  7. 7. ... became PHP 5.3 ...
  8. 8. ... almost
  9. 9. Unicode
  10. 10. Unicode <ul><li>One Standard to rule them all </li></ul><ul><li>PHP 6's killer feature </li></ul><ul><li>One character != one byte </li></ul>
  11. 11. Garbage Collection
  12. 12. Garbage Collection <ul><li>Free memory while script is running </li></ul><ul><li>gc_enable(); </li></ul><ul><li>gc_disable(); </li></ul>
  13. 13. SPL Improvements
  14. 14. SPL Improvements <ul><li>SplDoublyLinkedList </li></ul><ul><li>SPLStack </li></ul><ul><li>SPLQueue </li></ul><ul><li>SplPriorityQueue </li></ul>
  15. 15. SPL Stack <ul><li>$stack = new SplStack(); $stack->push('a'); $stack->push('b'); $stack->push('c'); echo $stack->pop(); echo $stack->pop(); echo $stack->pop(); </li></ul>
  16. 16. SPL Stack <ul><li>$stack = new SplStack(); $stack->push('a'); $stack->push('b'); $stack->push('c'); echo $stack->pop(); echo $stack->pop(); echo $stack->pop(); -> cba </li></ul>
  17. 17. Magic Static Calls
  18. 18. Magic Calls <ul><li>class Foo { public function __call($aName, $aParameters) { var_dump($aName); var_dump($aParameters); } } $foo = new Foo(); $foo->test('something'); </li></ul>
  19. 19. Magic Calls <ul><li>class Foo { public function __call($aName, $aParameters) { var_dump($aName); var_dump($aParameters); } } $foo = new Foo(); $foo->test('something'); -> string(4) &quot;test&quot; array(1) { [0]=> string(9) &quot;something&quot; } </li></ul>
  20. 20. Magic Calls <ul><li>Strict standards: Non-static method Foo::test() should not be called statically </li></ul>
  21. 21. Magic Static Calls <ul><li>class Foo { public static function __callStatic($aName, $aParameters) { ... } } Foo::doSomething(...); </li></ul>
  22. 22. Late Static Binding
  23. 23. Late Static Binding <ul><li>class Foo { protected static $foo = 'Test'; public static function getFoo() { return self::$foo; } } var_dump(Foo::getFoo()); </li></ul>
  24. 24. Late Static Binding <ul><li>class Foo { protected static $foo = 'Test'; public static function getFoo() { return self::$foo; } } var_dump(Foo::getFoo()); -> Test </li></ul>
  25. 25. Late Static Binding <ul><li>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()); </li></ul>
  26. 26. Late Static Binding <ul><li>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) &quot;Test&quot; string(4) &quot;Test&quot; </li></ul>
  27. 27. Late Static Binding <ul><li>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()); </li></ul>
  28. 28. Late Static Binding <ul><li>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) &quot;Test&quot; string(6) &quot;MyTest&quot; </li></ul>
  29. 29. Namespaces
  30. 30. <ul><li>class File { ... } </li></ul>Namespaces
  31. 31. <ul><li>class File { ... } // somewhere else class File { ... } </li></ul>Namespaces
  32. 32. <ul><li>class my_Web_Framework_Foo_Bar_Baz { ... } </li></ul>Namespaces
  33. 33. <ul><li>namespace my::Web::Framework::Foo::Bar; class Baz { ... } </li></ul>Namespaces
  34. 34. <ul><li> namespace my::Web::Framework::Foo::Bar; class Baz { ... } </li></ul><ul><li> // somewhere else: $baz = new my::Web::Framework::Foo::Bar::Baz(); </li></ul>Namespaces
  35. 35. <ul><li>use my::Web::Framework::Foo::Bar::Baz as MyBaz; $baz = new myBaz(); </li></ul>Namespaces
  36. 36. <ul><li>namespace crypt; function gnupg_decrypt($aText, $aKeyFile) { return 'some plaintext'; } </li></ul>Namespaces
  37. 37. <ul><li>namespace crypt; function gnupg_decrypt($aText, $aKeyFile) { return 'some plaintext'; } var_dump(gnupg_decrypt('sa45hzq734hrq243rwaefsd80', 'my.key')); </li></ul>Namespaces
  38. 38. <ul><li>namespace foo; class bar { static public function baz() { return 'baz method'; } } var_dump(foo::bar::baz()); </li></ul>Namespaces
  39. 39. <ul><li>namespace foo; class bar { static public function baz() { return 'baz method'; } } var_dump(foo::bar::baz()); -> string(10) &quot;baz method&quot; </li></ul>Namespaces
  40. 40. <ul><li>namespace foo::bar; function baz() { return 'baz function'; } namespace foo; class bar { static public function baz() { return 'baz method'; } } var_dump(foo::bar::baz()); </li></ul>Namespaces
  41. 41. Namespaces <ul><li>Access built-in functions/classes by prefixing :: </li></ul><ul><ul><li>some_fn(...) vs. ::some_fn(...) </li></ul></ul><ul><li>__NAMESPACE__ constant </li></ul><ul><li>Multiple namespaces per file </li></ul>
  42. 42. More New Features <ul><li>ifsetor </li></ul><ul><li>OpenID support </li></ul><ul><li>SQLite3 </li></ul><ul><li>getopt() works on Windows </li></ul><ul><li>__DIR__ = dirname(__FILE__) </li></ul>
  43. 43. Error Handling
  44. 44. Error Handling <ul><li>New error class E_DEPRECATED </li></ul><ul><li>E_ALL includes E_STRICT </li></ul>
  45. 45. Future-Proofing
  46. 46. Regular Expressions <ul><li>ereg will move to PECL </li></ul><ul><ul><li>replace ereg_* by preg_* </li></ul></ul><ul><li>by the way, ereg is not binary safe </li></ul>
  47. 47. Deprecated php.ini Settings <ul><li>short open tags </li></ul><ul><li>magic quotes </li></ul><ul><li>register_globals </li></ul><ul><li>register_long_arrays </li></ul><ul><li>ze1.compatibility_mode </li></ul><ul><li>allow_call_time_pass_reference </li></ul><ul><li>safe_mode </li></ul>
  48. 48. Blatant Advertisement
  49. 51. Thank you.
  50. 52. http://www.priebsch.de (de) http://inside.e-novative.de (en) [email_address]

×