SlideShare a Scribd company logo
What’s coming in PHP 5.3
By Stas Malyshev




                           Copyright © 2007, Zend Technologies Inc.
5.2 vs 5.3 vs 6


  • 5.3 is a major version, should be 5½.0

  • 6 taking long time, features drift back

  • No sudden moves in 5.x




                                              What's new in PHP 5.3 | 2-Apr-10 | 2
Syntax


  • Namespaces!
  •   Late static binding (static::foo vs self::foo)
  •   $classname::method()
  •   __callstatic()
  •   Goto
  •   ?:
  •   $NOWDOC = <<„END‟
  •   __DIR__



                                              What's new in PHP 5.3 | 2-Apr-10 | 3
Functions


  •   Phar – PHP Archive
  •   Pect/intl – ICU support
  •   MySQLnd
  •   INI magic – per dir, per user, .htaccess-style
  •   OpenSSL for OpenID
  •   SPL class library
  •   Date/time improvements
  •   Getopt() support
  •   E_DEPRECATED


                                             What's new in PHP 5.3 | 2-Apr-10 | 4
Engine


  • Garbage collection!
  • Stack usage improvements
  • Opcode optimizations
  • System call reduction




                               What's new in PHP 5.3 | 2-Apr-10 | 5
Namespaces

 define(“MY_HTTP_GET”, 1);        namespace My::Http;
 define(“MY_HTTP_POST”, 2);
                                  const GET = 1;
                                  const PUT = 2;
 class My_Http_Request {
    function __construct(         class Request {
         $method =                    function __construct(
    ZEND_HTTP_GET)                          $method = GET)
                                      {
    {                                 }
    }                             }
 }
                                  function send_request(
                                     Request $request) {
 function my_http_send_request(   }
    My_Http_Request $request) {
 }




                                                    What's new in PHP 5.3 | 2-Apr-10 | 6
Namespaces

 • Organize OO code into self-contained units
 • Reduce conflicts
 • Shorten names
      class
       Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum_CaseInsensiti
       ve extends Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum

 •   Compile-time definition
 •   Mostly compile-time resolution
 •   Many NS per file, many files per NS
 •   Real names have ::


                                                      What's new in PHP 5.3 | 2-Apr-10 | 7
Namespaces – new syntax


  • namespace foo::bar;
  • use foo::bar as baz, boo::hoo::foo;

  • __NAMESPACE__
  • namespace::foo
  • ::foo() - means global one




                                          What's new in PHP 5.3 | 2-Apr-10 | 8
Late Static Binding

Gateway to ActiveRecord
class Singleton {
   const ID = 0;
   static $instance = array();
   static function getInstance() {
                   $id = static::ID;
                   if (empty(self::$instance[$id])) {
                             self::$instance[$id] = new static;
                   }
                   return self::$instance[$id];
   }
}
class Foo extends Singleton {
   const ID = 1;
}
$x = Foo::getInstance();

                                                                  What's new in PHP 5.3 | 2-Apr-10 | 9
Dynamic class name

 Everything can be variable, class name too
 class DbDriver {
    const NAME = “MySQLDriver”;
    static function execute($sql) {
    }
 }

 $db = “DbDriver”;
 echo $db::NAME;
 $db::execute(“SELCT * FROM foo;”);


                                         What's new in PHP 5.3 | 2-Apr-10 | 10
__callStatic

 __call‟s static cousin
 class DummyDriver {
    const NAME = „Dummy‟;
    static function __callstatic($name, $args) {
                 echo static::NAME.“::$name is not implemented”;
    }
 }
 class MySqlDriver extends DummyDriver {
    const NAME = „MySQL‟;
 }
 $db = „MySqlDriver‟;
 $db::execute(„SELCT * FROM foo;‟);



                                                What's new in PHP 5.3 | 2-Apr-10 | 11
?:

 Shortcut for $a?$a:$b
 $name = $_GET[„name‟] ?: „anonymous‟;




                                         What's new in PHP 5.3 | 2-Apr-10 | 12
goto

 Guess what it does ;)
 RETRY:
 try {
    …
 } catch (Exception $e) {
    recovery($e);
    goto RETRY;
 }

 • Don‟t try it at home – unless you know what you do
 • Can‟t jump into blocks



                                         What's new in PHP 5.3 | 2-Apr-10 | 13
NOWDOC

Repeat after me, exactly as I say it:
 $a = 3; $b = 5;
 echo <<<EOF
 $a+$b
 EOF;     // prints 3+5
 echo <<<„EOF‟
 $a+$b
 EOF;     // prints $a+$b
 echo <<<“EOF”
 $a+$b
 EOF;     // printd 3+5


Note HEREDOC has two syntaxes now



                                        What's new in PHP 5.3 | 2-Apr-10 | 14
__DIR__

__FILE__‟s brother – constant dirname(__FILE__)

 class Foo {
    const BAR = dirname(__FILE__); // can‟t!
    const BAR = __DIR__;
    public $bar = dirname(__FILE__); // can‟t!
    public $bar = __DIR__;
 }




                                           What's new in PHP 5.3 | 2-Apr-10 | 15
Phar


  • Packs multiple PHP files into one .phar
  • Supports streams & includes into phar
  • Supports running CLI and Web apps from phar

 include „phar://mylib.phar/My/Http.php‟;
 $img = „phar://mylib.phar/My/img/logo.jpg‟;
 header(„Content-type: image/jpeg‟);
 echo file_get_contents($img);




                                               What's new in PHP 5.3 | 2-Apr-10 | 16
ICU extension


  • Supports internationalization functions from IBM
      ICU
  •   Collation (plain English: sorting)
  •   Number/Date/Message formatting
  •   Locale representation
  •   Normalization
  •   Graphemes




                                           What's new in PHP 5.3 | 2-Apr-10 | 17
INI improvements


  • Localized sections:
      [PATH=/var/www/html/mysite]
      [HOST=www.myblog.com]
  • .htaccess-style user files
      user_ini.filename = “.user.ini”
      user_ini.cache_ttl = 300




                                         What's new in PHP 5.3 | 2-Apr-10 | 18
MySQLnd


 •   PHP-specific MySQL client library
 •   Uses Zend MM
 •   Reduces copying of data
 •   Uses PHP streams
 •   --with-mysql=mysqlnd




                                         What's new in PHP 5.3 | 2-Apr-10 | 19
E_DEPRECATED


 • Functionality that will be removed in next versions




                                         What's new in PHP 5.3 | 2-Apr-10 | 20
Other function improvements

• OpenSSL support for OpenID
     openssl_digest(), openssl_encrypt(), openssl_decrypt(), DH key
      exchange
•   Getopt() on all OSes with –support-long-options
•   Faster md5()
•   OCI8 connection pooling
•   SPL class library additions:
     DoublyLinkedList, Stack, Queue, PriorityQueue, Heap
     FilesystemIterator, GlobIterator
• Date/time improvements
     date_create_from_format(), date_get_last_errors()


                                                    What's new in PHP 5.3 | 2-Apr-10 | 21
Garbage collector


  • Collects memory lost in loops
  • Invisible to the untrained eye
  • gc_collect_lops, gc_enable, gc_disable

 $a = array();
 $a[0] =& $a;




                                        What's new in PHP 5.3 | 2-Apr-10 | 22
Performance


  • Bench.php



                              4.075
                                                                                 php 5.3
    PHP version




                                      5.577
                                                                                 php 5.2
                                      5.38                                       php 5.1
                                                              13.415             php 5.0
                                                                                 php 4.4
                                                                   14.443


                  0   2   4            6      8     10   12   14         16
                                              sec




                                                                What's new in PHP 5.3 | 2-Apr-10 | 23
Thank you!


  • Questions?




                 What's new in PHP 5.3 | 2-Apr-10 | 24

More Related Content

What's hot

PHP FUNCTIONS
PHP FUNCTIONSPHP FUNCTIONS
PHP FUNCTIONS
Zeeshan Ahmed
 
How PHP works
How PHP works How PHP works
Psr 7 symfony-day
Psr 7 symfony-dayPsr 7 symfony-day
Psr 7 symfony-day
Marco Perone
 
PHP 5.6 New and Deprecated Features
PHP 5.6  New and Deprecated FeaturesPHP 5.6  New and Deprecated Features
PHP 5.6 New and Deprecated Features
Mark Niebergall
 
Develop webservice in PHP
Develop webservice in PHPDevelop webservice in PHP
Develop webservice in PHP
Sanil Subhash Chandra Bose
 
PECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life betterPECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life better
ZendCon
 
PHP 良好實踐 (Best Practice)
PHP 良好實踐 (Best Practice)PHP 良好實踐 (Best Practice)
PHP 良好實踐 (Best Practice)
Win Yu
 
Php.ppt
Php.pptPhp.ppt
Php.ppt
Nidhi mishra
 
Lean Php Presentation
Lean Php PresentationLean Php Presentation
Lean Php Presentation
Alan Pinstein
 
Php 7 hhvm and co
Php 7 hhvm and coPhp 7 hhvm and co
Php 7 hhvm and co
Pierre Joye
 
PHP - History, Introduction, Summary, Extensions and Frameworks
PHP - History, Introduction, Summary, Extensions and FrameworksPHP - History, Introduction, Summary, Extensions and Frameworks
PHP - History, Introduction, Summary, Extensions and Frameworks
Royston Olivera
 
PHP in one presentation
PHP in one presentationPHP in one presentation
PHP in one presentation
Milad Rahimi
 
How PHP Works ?
How PHP Works ?How PHP Works ?
How PHP Works ?
Ravi Raj
 
Psr-7
Psr-7Psr-7
When e-commerce meets Symfony
When e-commerce meets SymfonyWhen e-commerce meets Symfony
When e-commerce meets Symfony
Marc Morera
 
Fluentd meetup dive into fluent plugin (outdated)
Fluentd meetup dive into fluent plugin (outdated)Fluentd meetup dive into fluent plugin (outdated)
Fluentd meetup dive into fluent plugin (outdated)
N Masahiro
 
PHP - Introduction to PHP Date and Time Functions
PHP -  Introduction to  PHP Date and Time FunctionsPHP -  Introduction to  PHP Date and Time Functions
PHP - Introduction to PHP Date and Time Functions
Vibrant Technologies & Computers
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
Bradley Holt
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
Taha Malampatti
 
Rails vs Web2py
Rails vs Web2pyRails vs Web2py
Rails vs Web2py
jonromero
 

What's hot (20)

PHP FUNCTIONS
PHP FUNCTIONSPHP FUNCTIONS
PHP FUNCTIONS
 
How PHP works
How PHP works How PHP works
How PHP works
 
Psr 7 symfony-day
Psr 7 symfony-dayPsr 7 symfony-day
Psr 7 symfony-day
 
PHP 5.6 New and Deprecated Features
PHP 5.6  New and Deprecated FeaturesPHP 5.6  New and Deprecated Features
PHP 5.6 New and Deprecated Features
 
Develop webservice in PHP
Develop webservice in PHPDevelop webservice in PHP
Develop webservice in PHP
 
PECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life betterPECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life better
 
PHP 良好實踐 (Best Practice)
PHP 良好實踐 (Best Practice)PHP 良好實踐 (Best Practice)
PHP 良好實踐 (Best Practice)
 
Php.ppt
Php.pptPhp.ppt
Php.ppt
 
Lean Php Presentation
Lean Php PresentationLean Php Presentation
Lean Php Presentation
 
Php 7 hhvm and co
Php 7 hhvm and coPhp 7 hhvm and co
Php 7 hhvm and co
 
PHP - History, Introduction, Summary, Extensions and Frameworks
PHP - History, Introduction, Summary, Extensions and FrameworksPHP - History, Introduction, Summary, Extensions and Frameworks
PHP - History, Introduction, Summary, Extensions and Frameworks
 
PHP in one presentation
PHP in one presentationPHP in one presentation
PHP in one presentation
 
How PHP Works ?
How PHP Works ?How PHP Works ?
How PHP Works ?
 
Psr-7
Psr-7Psr-7
Psr-7
 
When e-commerce meets Symfony
When e-commerce meets SymfonyWhen e-commerce meets Symfony
When e-commerce meets Symfony
 
Fluentd meetup dive into fluent plugin (outdated)
Fluentd meetup dive into fluent plugin (outdated)Fluentd meetup dive into fluent plugin (outdated)
Fluentd meetup dive into fluent plugin (outdated)
 
PHP - Introduction to PHP Date and Time Functions
PHP -  Introduction to  PHP Date and Time FunctionsPHP -  Introduction to  PHP Date and Time Functions
PHP - Introduction to PHP Date and Time Functions
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
Rails vs Web2py
Rails vs Web2pyRails vs Web2py
Rails vs Web2py
 

Viewers also liked

Tier 1 - Mac Virtual Machines and Virtual PC. Automation and ...
Tier 1 - Mac Virtual Machines and Virtual PC. Automation and ...Tier 1 - Mac Virtual Machines and Virtual PC. Automation and ...
Tier 1 - Mac Virtual Machines and Virtual PC. Automation and ...
webhostingguy
 
download presentation
download presentationdownload presentation
download presentation
webhostingguy
 
Security.ppt
Security.pptSecurity.ppt
Security.ppt
webhostingguy
 
Seasons
SeasonsSeasons
Seasons
webhostingguy
 
Space Review.ppt
Space Review.pptSpace Review.ppt
Space Review.ppt
webhostingguy
 
Presentation
PresentationPresentation
Presentation
webhostingguy
 
Managing Clients' Mission Critical Applications
Managing Clients' Mission Critical ApplicationsManaging Clients' Mission Critical Applications
Managing Clients' Mission Critical Applications
webhostingguy
 

Viewers also liked (7)

Tier 1 - Mac Virtual Machines and Virtual PC. Automation and ...
Tier 1 - Mac Virtual Machines and Virtual PC. Automation and ...Tier 1 - Mac Virtual Machines and Virtual PC. Automation and ...
Tier 1 - Mac Virtual Machines and Virtual PC. Automation and ...
 
download presentation
download presentationdownload presentation
download presentation
 
Security.ppt
Security.pptSecurity.ppt
Security.ppt
 
Seasons
SeasonsSeasons
Seasons
 
Space Review.ppt
Space Review.pptSpace Review.ppt
Space Review.ppt
 
Presentation
PresentationPresentation
Presentation
 
Managing Clients' Mission Critical Applications
Managing Clients' Mission Critical ApplicationsManaging Clients' Mission Critical Applications
Managing Clients' Mission Critical Applications
 

Similar to ZendCon 08 php 5.3

Preparing code for Php 7 workshop
Preparing code for Php 7 workshopPreparing code for Php 7 workshop
Preparing code for Php 7 workshop
Damien Seguy
 
Key features PHP 5.3 - 5.6
Key features PHP 5.3 - 5.6Key features PHP 5.3 - 5.6
Key features PHP 5.3 - 5.6
Federico Damián Lozada Mosto
 
Php 7 compliance workshop singapore
Php 7 compliance workshop singaporePhp 7 compliance workshop singapore
Php 7 compliance workshop singapore
Damien Seguy
 
The why and how of moving to php 5.4
The why and how of moving to php 5.4The why and how of moving to php 5.4
The why and how of moving to php 5.4
Wim Godden
 
What's new with PHP7
What's new with PHP7What's new with PHP7
What's new with PHP7
SWIFTotter Solutions
 
The why and how of moving to PHP 5.4/5.5
The why and how of moving to PHP 5.4/5.5The why and how of moving to PHP 5.4/5.5
The why and how of moving to PHP 5.4/5.5
Wim Godden
 
What To Expect From PHP7
What To Expect From PHP7What To Expect From PHP7
What To Expect From PHP7
Codemotion
 
Last train to php 7
Last train to php 7Last train to php 7
Last train to php 7
Damien Seguy
 
PHP 5.3 in practice
PHP 5.3 in practicePHP 5.3 in practice
PHP 5.3 in practice
Fabien Potencier
 
The why and how of moving to php 5.4/5.5
The why and how of moving to php 5.4/5.5The why and how of moving to php 5.4/5.5
The why and how of moving to php 5.4/5.5
Wim Godden
 
Php7 HHVM and co
Php7 HHVM and coPhp7 HHVM and co
Php7 HHVM and co
weltling
 
PHP5.5 is Here
PHP5.5 is HerePHP5.5 is Here
PHP5.5 is Here
julien pauli
 
Simplify your professional web development with symfony
Simplify your professional web development with symfonySimplify your professional web development with symfony
Simplify your professional web development with symfony
Francois Zaninotto
 
Damien seguy php 5.6
Damien seguy php 5.6Damien seguy php 5.6
Damien seguy php 5.6
Damien Seguy
 
PHP 5.3
PHP 5.3PHP 5.3
PHP 5.3
Idaf_1er
 
Migrating to PHP 7
Migrating to PHP 7Migrating to PHP 7
Migrating to PHP 7
John Coggeshall
 
What's new in Rails 4
What's new in Rails 4What's new in Rails 4
What's new in Rails 4
Lucas Caton
 
Php7 hhvm and co
Php7 hhvm and coPhp7 hhvm and co
Php7 hhvm and co
Pierre Joye
 
Php 7.2 compliance workshop php benelux
Php 7.2 compliance workshop php beneluxPhp 7.2 compliance workshop php benelux
Php 7.2 compliance workshop php benelux
Damien Seguy
 
[4developers2016] PHP 7 (Michał Pipa)
[4developers2016] PHP 7 (Michał Pipa)[4developers2016] PHP 7 (Michał Pipa)
[4developers2016] PHP 7 (Michał Pipa)
PROIDEA
 

Similar to ZendCon 08 php 5.3 (20)

Preparing code for Php 7 workshop
Preparing code for Php 7 workshopPreparing code for Php 7 workshop
Preparing code for Php 7 workshop
 
Key features PHP 5.3 - 5.6
Key features PHP 5.3 - 5.6Key features PHP 5.3 - 5.6
Key features PHP 5.3 - 5.6
 
Php 7 compliance workshop singapore
Php 7 compliance workshop singaporePhp 7 compliance workshop singapore
Php 7 compliance workshop singapore
 
The why and how of moving to php 5.4
The why and how of moving to php 5.4The why and how of moving to php 5.4
The why and how of moving to php 5.4
 
What's new with PHP7
What's new with PHP7What's new with PHP7
What's new with PHP7
 
The why and how of moving to PHP 5.4/5.5
The why and how of moving to PHP 5.4/5.5The why and how of moving to PHP 5.4/5.5
The why and how of moving to PHP 5.4/5.5
 
What To Expect From PHP7
What To Expect From PHP7What To Expect From PHP7
What To Expect From PHP7
 
Last train to php 7
Last train to php 7Last train to php 7
Last train to php 7
 
PHP 5.3 in practice
PHP 5.3 in practicePHP 5.3 in practice
PHP 5.3 in practice
 
The why and how of moving to php 5.4/5.5
The why and how of moving to php 5.4/5.5The why and how of moving to php 5.4/5.5
The why and how of moving to php 5.4/5.5
 
Php7 HHVM and co
Php7 HHVM and coPhp7 HHVM and co
Php7 HHVM and co
 
PHP5.5 is Here
PHP5.5 is HerePHP5.5 is Here
PHP5.5 is Here
 
Simplify your professional web development with symfony
Simplify your professional web development with symfonySimplify your professional web development with symfony
Simplify your professional web development with symfony
 
Damien seguy php 5.6
Damien seguy php 5.6Damien seguy php 5.6
Damien seguy php 5.6
 
PHP 5.3
PHP 5.3PHP 5.3
PHP 5.3
 
Migrating to PHP 7
Migrating to PHP 7Migrating to PHP 7
Migrating to PHP 7
 
What's new in Rails 4
What's new in Rails 4What's new in Rails 4
What's new in Rails 4
 
Php7 hhvm and co
Php7 hhvm and coPhp7 hhvm and co
Php7 hhvm and co
 
Php 7.2 compliance workshop php benelux
Php 7.2 compliance workshop php beneluxPhp 7.2 compliance workshop php benelux
Php 7.2 compliance workshop php benelux
 
[4developers2016] PHP 7 (Michał Pipa)
[4developers2016] PHP 7 (Michał Pipa)[4developers2016] PHP 7 (Michał Pipa)
[4developers2016] PHP 7 (Michał Pipa)
 

More from webhostingguy

File Upload
File UploadFile Upload
File Upload
webhostingguy
 
Running and Developing Tests with the Apache::Test Framework
Running and Developing Tests with the Apache::Test FrameworkRunning and Developing Tests with the Apache::Test Framework
Running and Developing Tests with the Apache::Test Framework
webhostingguy
 
MySQL and memcached Guide
MySQL and memcached GuideMySQL and memcached Guide
MySQL and memcached Guide
webhostingguy
 
Novell® iChain® 2.3
Novell® iChain® 2.3Novell® iChain® 2.3
Novell® iChain® 2.3
webhostingguy
 
Load-balancing web servers Load-balancing web servers
Load-balancing web servers Load-balancing web serversLoad-balancing web servers Load-balancing web servers
Load-balancing web servers Load-balancing web servers
webhostingguy
 
SQL Server 2008 Consolidation
SQL Server 2008 ConsolidationSQL Server 2008 Consolidation
SQL Server 2008 Consolidation
webhostingguy
 
What is mod_perl?
What is mod_perl?What is mod_perl?
What is mod_perl?
webhostingguy
 
What is mod_perl?
What is mod_perl?What is mod_perl?
What is mod_perl?
webhostingguy
 
Master Service Agreement
Master Service AgreementMaster Service Agreement
Master Service Agreementwebhostingguy
 
Notes8
Notes8Notes8
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...webhostingguy
 
Dell Reference Architecture Guide Deploying Microsoft® SQL ...
Dell Reference Architecture Guide Deploying Microsoft® SQL ...Dell Reference Architecture Guide Deploying Microsoft® SQL ...
Dell Reference Architecture Guide Deploying Microsoft® SQL ...
webhostingguy
 
Managing Diverse IT Infrastructure
Managing Diverse IT InfrastructureManaging Diverse IT Infrastructure
Managing Diverse IT Infrastructure
webhostingguy
 
Web design for business.ppt
Web design for business.pptWeb design for business.ppt
Web design for business.ppt
webhostingguy
 
IT Power Management Strategy
IT Power Management Strategy IT Power Management Strategy
IT Power Management Strategy
webhostingguy
 
Excel and SQL Quick Tricks for Merchandisers
Excel and SQL Quick Tricks for MerchandisersExcel and SQL Quick Tricks for Merchandisers
Excel and SQL Quick Tricks for Merchandisers
webhostingguy
 
OLUG_xen.ppt
OLUG_xen.pptOLUG_xen.ppt
OLUG_xen.ppt
webhostingguy
 
Parallels Hosting Products
Parallels Hosting ProductsParallels Hosting Products
Parallels Hosting Products
webhostingguy
 
Microsoft PowerPoint presentation 2.175 Mb
Microsoft PowerPoint presentation 2.175 MbMicrosoft PowerPoint presentation 2.175 Mb
Microsoft PowerPoint presentation 2.175 Mb
webhostingguy
 
Reseller's Guide
Reseller's GuideReseller's Guide
Reseller's Guide
webhostingguy
 

More from webhostingguy (20)

File Upload
File UploadFile Upload
File Upload
 
Running and Developing Tests with the Apache::Test Framework
Running and Developing Tests with the Apache::Test FrameworkRunning and Developing Tests with the Apache::Test Framework
Running and Developing Tests with the Apache::Test Framework
 
MySQL and memcached Guide
MySQL and memcached GuideMySQL and memcached Guide
MySQL and memcached Guide
 
Novell® iChain® 2.3
Novell® iChain® 2.3Novell® iChain® 2.3
Novell® iChain® 2.3
 
Load-balancing web servers Load-balancing web servers
Load-balancing web servers Load-balancing web serversLoad-balancing web servers Load-balancing web servers
Load-balancing web servers Load-balancing web servers
 
SQL Server 2008 Consolidation
SQL Server 2008 ConsolidationSQL Server 2008 Consolidation
SQL Server 2008 Consolidation
 
What is mod_perl?
What is mod_perl?What is mod_perl?
What is mod_perl?
 
What is mod_perl?
What is mod_perl?What is mod_perl?
What is mod_perl?
 
Master Service Agreement
Master Service AgreementMaster Service Agreement
Master Service Agreement
 
Notes8
Notes8Notes8
Notes8
 
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
 
Dell Reference Architecture Guide Deploying Microsoft® SQL ...
Dell Reference Architecture Guide Deploying Microsoft® SQL ...Dell Reference Architecture Guide Deploying Microsoft® SQL ...
Dell Reference Architecture Guide Deploying Microsoft® SQL ...
 
Managing Diverse IT Infrastructure
Managing Diverse IT InfrastructureManaging Diverse IT Infrastructure
Managing Diverse IT Infrastructure
 
Web design for business.ppt
Web design for business.pptWeb design for business.ppt
Web design for business.ppt
 
IT Power Management Strategy
IT Power Management Strategy IT Power Management Strategy
IT Power Management Strategy
 
Excel and SQL Quick Tricks for Merchandisers
Excel and SQL Quick Tricks for MerchandisersExcel and SQL Quick Tricks for Merchandisers
Excel and SQL Quick Tricks for Merchandisers
 
OLUG_xen.ppt
OLUG_xen.pptOLUG_xen.ppt
OLUG_xen.ppt
 
Parallels Hosting Products
Parallels Hosting ProductsParallels Hosting Products
Parallels Hosting Products
 
Microsoft PowerPoint presentation 2.175 Mb
Microsoft PowerPoint presentation 2.175 MbMicrosoft PowerPoint presentation 2.175 Mb
Microsoft PowerPoint presentation 2.175 Mb
 
Reseller's Guide
Reseller's GuideReseller's Guide
Reseller's Guide
 

ZendCon 08 php 5.3

  • 1. What’s coming in PHP 5.3 By Stas Malyshev Copyright © 2007, Zend Technologies Inc.
  • 2. 5.2 vs 5.3 vs 6 • 5.3 is a major version, should be 5½.0 • 6 taking long time, features drift back • No sudden moves in 5.x What's new in PHP 5.3 | 2-Apr-10 | 2
  • 3. Syntax • Namespaces! • Late static binding (static::foo vs self::foo) • $classname::method() • __callstatic() • Goto • ?: • $NOWDOC = <<„END‟ • __DIR__ What's new in PHP 5.3 | 2-Apr-10 | 3
  • 4. Functions • Phar – PHP Archive • Pect/intl – ICU support • MySQLnd • INI magic – per dir, per user, .htaccess-style • OpenSSL for OpenID • SPL class library • Date/time improvements • Getopt() support • E_DEPRECATED What's new in PHP 5.3 | 2-Apr-10 | 4
  • 5. Engine • Garbage collection! • Stack usage improvements • Opcode optimizations • System call reduction What's new in PHP 5.3 | 2-Apr-10 | 5
  • 6. Namespaces define(“MY_HTTP_GET”, 1); namespace My::Http; define(“MY_HTTP_POST”, 2); const GET = 1; const PUT = 2; class My_Http_Request { function __construct( class Request { $method = function __construct( ZEND_HTTP_GET) $method = GET) { { } } } } function send_request( Request $request) { function my_http_send_request( } My_Http_Request $request) { } What's new in PHP 5.3 | 2-Apr-10 | 6
  • 7. Namespaces • Organize OO code into self-contained units • Reduce conflicts • Shorten names  class Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum_CaseInsensiti ve extends Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum • Compile-time definition • Mostly compile-time resolution • Many NS per file, many files per NS • Real names have :: What's new in PHP 5.3 | 2-Apr-10 | 7
  • 8. Namespaces – new syntax • namespace foo::bar; • use foo::bar as baz, boo::hoo::foo; • __NAMESPACE__ • namespace::foo • ::foo() - means global one What's new in PHP 5.3 | 2-Apr-10 | 8
  • 9. Late Static Binding Gateway to ActiveRecord class Singleton { const ID = 0; static $instance = array(); static function getInstance() { $id = static::ID; if (empty(self::$instance[$id])) { self::$instance[$id] = new static; } return self::$instance[$id]; } } class Foo extends Singleton { const ID = 1; } $x = Foo::getInstance(); What's new in PHP 5.3 | 2-Apr-10 | 9
  • 10. Dynamic class name Everything can be variable, class name too class DbDriver { const NAME = “MySQLDriver”; static function execute($sql) { } } $db = “DbDriver”; echo $db::NAME; $db::execute(“SELCT * FROM foo;”); What's new in PHP 5.3 | 2-Apr-10 | 10
  • 11. __callStatic __call‟s static cousin class DummyDriver { const NAME = „Dummy‟; static function __callstatic($name, $args) { echo static::NAME.“::$name is not implemented”; } } class MySqlDriver extends DummyDriver { const NAME = „MySQL‟; } $db = „MySqlDriver‟; $db::execute(„SELCT * FROM foo;‟); What's new in PHP 5.3 | 2-Apr-10 | 11
  • 12. ?: Shortcut for $a?$a:$b $name = $_GET[„name‟] ?: „anonymous‟; What's new in PHP 5.3 | 2-Apr-10 | 12
  • 13. goto Guess what it does ;) RETRY: try { … } catch (Exception $e) { recovery($e); goto RETRY; } • Don‟t try it at home – unless you know what you do • Can‟t jump into blocks What's new in PHP 5.3 | 2-Apr-10 | 13
  • 14. NOWDOC Repeat after me, exactly as I say it: $a = 3; $b = 5; echo <<<EOF $a+$b EOF; // prints 3+5 echo <<<„EOF‟ $a+$b EOF; // prints $a+$b echo <<<“EOF” $a+$b EOF; // printd 3+5 Note HEREDOC has two syntaxes now What's new in PHP 5.3 | 2-Apr-10 | 14
  • 15. __DIR__ __FILE__‟s brother – constant dirname(__FILE__) class Foo { const BAR = dirname(__FILE__); // can‟t! const BAR = __DIR__; public $bar = dirname(__FILE__); // can‟t! public $bar = __DIR__; } What's new in PHP 5.3 | 2-Apr-10 | 15
  • 16. Phar • Packs multiple PHP files into one .phar • Supports streams & includes into phar • Supports running CLI and Web apps from phar include „phar://mylib.phar/My/Http.php‟; $img = „phar://mylib.phar/My/img/logo.jpg‟; header(„Content-type: image/jpeg‟); echo file_get_contents($img); What's new in PHP 5.3 | 2-Apr-10 | 16
  • 17. ICU extension • Supports internationalization functions from IBM ICU • Collation (plain English: sorting) • Number/Date/Message formatting • Locale representation • Normalization • Graphemes What's new in PHP 5.3 | 2-Apr-10 | 17
  • 18. INI improvements • Localized sections:  [PATH=/var/www/html/mysite]  [HOST=www.myblog.com] • .htaccess-style user files  user_ini.filename = “.user.ini”  user_ini.cache_ttl = 300 What's new in PHP 5.3 | 2-Apr-10 | 18
  • 19. MySQLnd • PHP-specific MySQL client library • Uses Zend MM • Reduces copying of data • Uses PHP streams • --with-mysql=mysqlnd What's new in PHP 5.3 | 2-Apr-10 | 19
  • 20. E_DEPRECATED • Functionality that will be removed in next versions What's new in PHP 5.3 | 2-Apr-10 | 20
  • 21. Other function improvements • OpenSSL support for OpenID  openssl_digest(), openssl_encrypt(), openssl_decrypt(), DH key exchange • Getopt() on all OSes with –support-long-options • Faster md5() • OCI8 connection pooling • SPL class library additions:  DoublyLinkedList, Stack, Queue, PriorityQueue, Heap  FilesystemIterator, GlobIterator • Date/time improvements  date_create_from_format(), date_get_last_errors() What's new in PHP 5.3 | 2-Apr-10 | 21
  • 22. Garbage collector • Collects memory lost in loops • Invisible to the untrained eye • gc_collect_lops, gc_enable, gc_disable $a = array(); $a[0] =& $a; What's new in PHP 5.3 | 2-Apr-10 | 22
  • 23. Performance • Bench.php 4.075 php 5.3 PHP version 5.577 php 5.2 5.38 php 5.1 13.415 php 5.0 php 4.4 14.443 0 2 4 6 8 10 12 14 16 sec What's new in PHP 5.3 | 2-Apr-10 | 23
  • 24. Thank you! • Questions? What's new in PHP 5.3 | 2-Apr-10 | 24