Your SlideShare is downloading. ×
  • Like
What's New In PHP 5.3: Volume One
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

What's New In PHP 5.3: Volume One

  • 3,946 views
Published

Part one of the joint presentation with Johannes Schlüter on PHP 5.3, given on May 27, 2009 at International PHP Conference Spring Edition in Berlin, Germany

Part one of the joint presentation with Johannes Schlüter on PHP 5.3, given on May 27, 2009 at International PHP Conference Spring Edition in Berlin, Germany

Published in Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
  • thank you for this good doc bout php 5.3 news
    Are you sure you want to
    Your message goes here
No Downloads

Views

Total Views
3,946
On SlideShare
0
From Embeds
0
Number of Embeds
2

Actions

Shares
Downloads
168
Comments
1
Likes
16

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. What’s New in PHP 5.3
  • 2. Johannes Schlüter
  • 3. David Zülke
  • 4. PHP Awesomeness History Woot Level 100.000.000.000 100.000.000.000 75.000.000.000 75.000.000.000 50.000.000.000 25.000.000.000 1 10.000 100.000 1.000.000 1.500.000 2.000.000 0 PHP/FI PHP 3 PHP 4 PHP 5 PHP 5.1 PHP 5.2 PHP 5.3 PHP 6
  • 5. PHP Awesomeness History, on a logarithmic scale Woot Level 100.000.000.000 75.000.000.000 100.000.000.000 177.827.941 1.000.000 1.500.000 2.000.000 316.228 100.000 10.000 562 1 1 PHP/FI PHP 3 PHP 4 PHP 5 PHP 5.1 PHP 5.2 PHP 5.3 PHP 6
  • 6. Volume One Volume Two Namespaces PHAR Closures, Part One Closures, Part Two SPL Late Static Binding Stream Changes Operators, Syntax, Magic Date and Time Handling Methods & Constants ext/mysqlnd New & Removed ext/intl Extensions, BC getopt, OpenSSL, php.ini Windows Support Performance/Internals/GC
  • 7. What’s New in PHP 5.3 Volume One
  • 8. NameSpaces Because Underscores Are Not Enough
  • 9. Namespaceable Elements namespace Foo; const ANSWER = 42; echo FooANSWER; class C { /* ... */ } new FooC(); function f() { } Foof();
  • 10. Multiple Namespaces namespace Foo {     class C { /* ... */ } } namespace Bar {     class C { /* ... */ } }
  • 11. Namespaces Example #1 MyFramework/someModule/Foo.class.php: <?php namespace MyFrameworksomeModule; class Foo { /* ... */  } ?> app/Bar.class.php: <?php class Bar extends MyFrameworksomeModuleFoo { /* ... */  } ?>
  • 12. Namespaces Example #2 MyFramework/someModule/Foo.class.php: <?php namespace MyFrameworksomeModule; class Foo { /* ... */  } ?> MyFramework/someModule/Bar.class.php: <?php namespace MyFrameworksomeModule; class Bar extends Foo { /* ... */  } ?>
  • 13. Namespaces: call_user_func // it's a string, so we need to use a FQN call_user_func_array(   array(     __NAMESPACE__.'some_class',     'method'   ),   $params );
  • 14. Class Resolution namespace MyFrameworksomeModule; class PdoException { } new PdoException(); // MyFrameworkmyModule new PdoException(); // ext/pdo new DateTime(); // class not found! new DateTime(); // works
  • 15. Function Resolution namespace MyFrameworksomeModule; function strlen($param) {     return 0; } echo strlen(quot;hello worldquot;); // 0 echo strlen(quot;hello worldquot;); // 11 echo someotherspacestrlen(quot;hello worldquot;);
  • 16. Using Namespaces foo/bar.php: <?php namespace foobar; class class1 {} // foobarclass1 ?> some/code.php: <?php use foobar; new barclass1(); ?>
  • 17. Aliasing foo/bar.php: <?php namespace foobar; class class1 {} // foobarclass1 ?> some/code.php: <?php use foobar as baz; use foobarclass1 as zomg; new bazclass2(); new zomg(); ?>
  • 18. Closures Chapter One: The Basics
  • 19. Closures: Very Basic $array = array(3, 9, 2); array_filter(   $array,   function($element) {     return $element > 5;    } );
  • 20. Late Static Binding ohai, I’m in ur base, calling teh selfz
  • 21. The ActiveRecord example $user = User::findByID(23); echo quot;Hello quot; . $user‐>getName() . quot;!nquot;; $user‐>setPassword(quot;verysecretquot;); $user‐>save();
  • 22. Implementation (w/ Injection) abstract class ActiveRecord {   static function findById($id) {     $table= get_called_class();     $query = quot;SELECT * FROM quot; . $table . quot; WHERE id=quot; . $id;     /* .... */   } } class User extends ActiveRecord {} class Entry extends ActiveRecord {} $a = User::findById(2); $b = Entry::findById(4);
  • 23. self vs static with LSB class Base {   public static function m()   {     self::printName();     static::printName();   } Base   static function printName() Base   {     echo __CLASS__;   } } Base::m();
  • 24. self vs static with LSB class Extended extends Base {   static function printName()   { Base     echo __CLASS__; Extended   } }
  • 25. Operators, Syntax, Magic Methods & Constants And Exceptions That Eat Each Other
  • 26. __callStatic() class Foo {     public static function __callStatic($name, $args) {         echo $name;     } } Foo::boats(); boats
  • 27. Static Calls w/ $classname $cls = 'DateTime'; $cls::getLastErrors();
  • 28. Constants in Global Scope const EGG = 'bacon';
  • 29. NOWDOC echo <<<'BAI' Price: $US 375 BAI; Price: $US 375
  • 30. HEREDOC echo <<<quot;BAIquot; Price: $US 375 BAI; Notice: Undefined  variable: US...
  • 31. __DIR__ // old: function call, conditional include include(dirname(__FILE__) . '/brother.php'); // new: magic constant, no conditional include include(__DIR__ . '/brother.php');
  • 32. Exception Linking try {     $pdoStatement‐>execute(); } catch(PDOException $e) {     $up = new RuntimeException('PDO fell over', 0, $e);     throw $up; // lame joke, ain't it? }
  • 33. Ifsetor $id = $_GET[quot;idquot;] ?: 0;
  • 34. Notice: Undefined index: id
  • 35. goto label: durr; $i++; if($i < 100) {   goto durr; }
  • 36. New/Removed Extensions And Backwards Compatibility Changes
  • 37. New Extensions intl sqlite3 mysqlnd phar fileinfo enchant
  • 38. Removed Extensions msql dbase fbsql fdf Deprecated: ereg ncurses ming sybase (-> sybase_ct)
  • 39. Potential BC breaks New Keywords: Parameter parsing: objects not interpreted as arrays namespace anymore by these funcs: goto current, next, key, each, New global identifiers: reset, end New extensions natsort, natcasesort, usort, uasort, uksort New Closure class array_flip, array_unique zend.ze1_comptibility_mode
  • 40. call_user_func_array w/ refs function foo(&$param) {} // breaks call_user_func_array(quot;fooquot;, array(23)); // breaks call_user_func_array(quot;fooquot;, array($var)); // works call_user_func_array(quot;fooquot;, array(&$var));
  • 41. E_DEPRECATED New error level to indicated deprecated stuff scheduled for removal in later releases Part of E_ALL which is good :) E_USER_DEPRECATED for userland errors Should be used for deprecated stuff, so E_STRICT can be used for the intended “bad practice” purpose
  • 42. Windows Much improved
  • 43. Bugfixes Some of which are really, really important
  • 44. - Fixed bug #47757 (rename JPG to JPEG in phpinfo). (Pierre)
  • 45. Thank You And Goodbye! Johannes Schlüter (johannes@php.net) http://twitter.com/phperror David Zülke (david.zuelke@bitextender.com) http://twitter.com/dzuelke