SlideShare a Scribd company logo
AnnouncementsPHP 5.2.10 is available (June 18 release)CodeWorks 2009 Announced – Washington, D.C.Tutorial Day: October 2Main Conference: October 3Two day conference for PHP developersEach event is limited to 300 attendeeshttp://cw.mtacon.com/signup/index to RegisterDiscount prices until July 152009 DC PHP Conference & ExpoSeptember 16 & 17Discount prices until August 15No sessions available yet1
PHP 5.3July 2009 Baltimore/Washington PHP MeetupChris Stonechris@emoxie.comFollow me @cmstone
Release InformationExisting code should still workThere are only a few incompatibilities and new features that should be consideredMajor improvement of the 5.x seriesOver 140 bug fixesComprehensive migration information from PHP 5.2.x to 5.3.x at: http://us.php.net/migration533
Key FeaturesNamespace supportLate static bindingLambda functions/closures (anonymous)Syntax additions (NOWDOC, ?:, goto…)Performance improvementsGarbage collection for cyclic referencesmysqlnd PHP native replacement for libmysqlDeprecation notices are handled E_DEPRECATED instead of E_STRICT4
Improved PerformanceImproved runtime speedImproved memory usageSmaller binary sizeFaster startup speed with GCC4md5() is faster (10-15%)require_once() and include_once() uses only 1  fopen(3) callImproved exception handlingOverall performance improvement of 5-15%5
Namespaces
NamespacesSingle largest addition in 5.3Feature completeSimplifies naming conventionsIf you developed larger projects, you would probably have used long class namesi.e. Zend class names can be HUGEZend_Search_Lucene_Document_HtmlDifferent namespaces can contain classes, functions, and constants with the same name.Defined using the namespace keyword7
Sub Namespaces<?phpnamespace Project1\Sub\Level;const CONNECT_OK = 1;class Connection { /* ... */ }function connect() { /* ... */  }?> 8
Multiple Namespaces Per File<?phpnamespace Project 1;const CONNECT_OK = 1;class Connection { /* ... */ }function connect() { /* ... */  }namespace Project2;const CONNECT_OK = 1;class Connection { /* ... */ }function connect() { /* ... */  }?> 9
Namespaces Aliasing/ImportingPHP namespaces support two kinds of aliasing or importing: aliasing a class name, and aliasing a namespace name.<?phpnamespace foo;use My\Full\Classname as Another;// this is the same as use My\Full\NSname as NSnameuse My\Full\NSname;// importing a global classuse \ArrayObject;$obj = new namespace\Another;// instantiates object of class foo\Another$obj = new Another;// instantiates object of class My\Full\ClassnameNSname\subns\func(); // calls function My\Full\NSname\subns\func$a = new ArrayObject(array(1));// instantiates object of class ArrayObject// without the "use \ArrayObject" we would instantiate an object of classfoo\ArrayObject?> 10
Namespaces Aliasing/ImportingPHP additionally supports a convenience shortcut to place multiple use statements on the same line <?phpuse My\Full\Classname as Another, My\Full\NSname;$obj = new Another;// instantiates object of class My\Full\ClassnameNSname\subns\func(); // calls function My\Full\NSname\subns\func?> 11
Namespaces Aliasing/ImportingPHP additionally supports a convenience shortcut to place multiple use statements on the same line <?phpuse My\Full\Classname as Another, My\Full\NSname;$obj = new Another;// instantiates object of class My\Full\ClassnameNSname\subns\func(); // calls function My\Full\NSname\subns\func?> 12
Common Namespace QuestionsQ:	If I don't use namespaces, should I care 	about any of this?A:	No. Namespaces do not affect any existing 	code in any way, or any as-yet-to-be-	written code that does not contain 	namespaces.Q:	How does a name like \my\name or \name 	resolve? A:		Names that begin with a \ always resolve to 	what they look like, so \my\name is in fact 	my\name, and \Exception is Exception.13
MySQLnd – MySQL Native DriverReplacement for the MySQL Client LibraryDoes NOT provide a new API to the programmerHigh speed library to interface with MySQL designed for PHPBuilt in driverNo external dependenciesImproved persistent connectionsThe special function mysqli_fetch_all()Return all rows as an array with one functionCan fetch performance statisticsmysqli_get_cache_stats()mysqli_get_client_stats()mysqli_get_connection_stats()14
New Language Features
__DIR____DIR__ is a magic constant that indicates where the current script is located.The below produce the same thing:<?php/* PHP < 5.3 */	echo dirname(__FILE__);/* PHP >= 5.3 */echo __DIR__;?>16
?: Ternary OperatorIt’s now possible to leave out the middle part of the ternary operator.  This allows fast retrieval of a non-empty value from 2 values and/or expressions.Expression expr1 ?: expr3 returns expr1 if expr1 evaluates to TRUE, and expr3 otherwise. <?php$test = true ?: false; // Returns true$test = false ?: true; // Returns true$test = 0 ?: 2; // Returns 2$test = “” ?: 1; // Returns 1?>17
__callStaticSame as __call, except for static methodsExample<?phpclass tester {	static function __callStatic($name, $args) {		echo $name . ‘ (‘ . implode(‘,’, $args) . ‘)’;	}}tester::testFunction(“test1”, “test2”);?>OutputstestFunction(test1,test2);Note:  Dynamic function calls (static/standard) are slow18
Dynamic Static CallsPHP 5.3 introduced the ability to call static method dynamically<?phpclass tester {	static functionfoobar() {		echo “Dynamic Static Call”;	}}$variable1 = “tester”;$variable2 = “foobar”;$variable1::$variable2();   // Calls tester:foobar();?>OutputsDynamic Static CallNote:  Dynamic function calls (static/standard) are slow19
Late Static BindingLimitations of self::<?phpclass A {    public static function who() {        echo __CLASS__;    }    public static function test() {        self::who();    }}class B extends A {    public static function who() {         echo __CLASS__;    }}B::test();?>OutputA20Late static binding is used to reference the called class in a context of static inheritance.  Processing of static events has been moved from compile time, to execution time.static:: simple usage<?phpclass A {    public static function who() {        echo __CLASS__;    }    public static function test() {        static::who();    }}class B extends A {    public static function who() {         echo __CLASS__;    }}B::test();?>OutputB
Anonymous FunctionsAlso known as closures, allow the creation of functions which have no specified name.  They are most useful as the value of a callback parameter.Example #1 - Anonymous function example<?phpecho preg_replace_callback('~-([a-z])~', function ($match) {    return strtoupper($match[1]);}, 'hello-world');?> OutputshelloWorldExample #2 - Anonymous function variable assignment example<?php$greet = function($name) {    printf("Hello %s\r\n", $name);};$greet('World');$greet('PHP');?> OutputsHello WorldHello PHP21
gotoThe goto operator can be used to jump to another section in the program. The target point is specified by a label followed by a colon, and the instruction is given as goto followed by the desired target label. This is not a full unrestricted goto. The target label must be within the same file and context, meaning that you cannot jump out of a function or method, nor can you jump into one. You also cannot jump into any sort of loop or switch structure. You may jump out of these, and a common use is to use a goto in place of a multi-level break. Example #1 – goto Example<?phpgoto a;echo 'Foo'; a:echo 'Bar';?> OutputsBar22
goto Continued…Example #2 - Anonymous function variable assignment example<?phpfor ($i=0,$j=50; $i<100; $i++) {  while ($j--) {    if ($j==17) goto end;   }}echo "i = $i";end:echo 'j hit 17';?> Outputsj hit 1723
DeprecationNew error modes E_USER_DEPRECATEDE_DEPRECATEDUsed to inform about deprecated functionality that is scheduled for removal in future version of PHP.Used to throw E_STRICT24
INI File Handling
INI Changes OverviewSupport for .htaccess style INI controlsPer directory/host INI settings that can not be overridden by the user[PATH=/var/www/www.phpmeetup.com/][HOST=www.meetup.com]Only supported by CGI/FastCGI, not for PHP-CLI, or as an Apache moduleImproved error handling"ini-variables" can now be used almost anywhere in a php.ini file.26
INI Changes ExampleName for user-defined php.ini (.htaccess) files. Default is ".user.ini“user_ini.filename= ".user.ini"To disable this feature set this option to empty valueuser_ini.filename=TTL for user-defined php.ini files (time-to-live) in seconds.Default is 300 seconds (5 minutes)user_ini.cache_ttl= 300[PATH=/var/www/phpmeetup.com]error_reporting= E_ALL & ~E_DEPRECATEDhtml_errors = off27
Other ImprovementsImproved streamsImproved DNS APIImproved hash extensionImproved IMAP supportImproved mbstring extensionImproved OCI8 extensionImproved OpenSSL (OpenID in mind, simplify implementation)Improved crypt() functionMany, many more!28
The EndSlides will be posted on MeetUp and http://www.e-moxie.comI can also e-mail them to you if you would like, just make sure I have your e-mail address.Next TopicProject & Code Management using Trac w/ 	Subversion IntegrationPresented by Steve CrumpAugust 12, 2009 @ 6:30 p.m.29

More Related Content

What's hot (20)

ODP
The promise of asynchronous PHP
Wim Godden
 
PDF
PHP7 is coming
julien pauli
 
PDF
PHP Basic and Fundamental Questions and Answers with Detail Explanation
Abdul Rahman Sherzad
 
PPT
Perl Tidy Perl Critic
olegmmiller
 
PDF
2021.laravelconf.tw.slides2
LiviaLiaoFontech
 
DOC
Php tutorial
S Bharadwaj
 
PDF
What is the Joomla Framework and why do we need it?
Rouven Weßling
 
PDF
CLI, the other SAPI
Combell NV
 
PPTX
PHP 7 Crash Course - php[world] 2015
Colin O'Dell
 
PDF
Php tutorial
Niit
 
PPT
Introduction to PHP
Kengatharaiyer Sarveswaran
 
PDF
Insecure coding in C (and C++)
Olve Maudal
 
PPTX
PHP 7
Joshua Copeland
 
PDF
Winter%200405%20-%20Beginning%20PHP
tutorialsruby
 
PDF
Static Analysis of PHP Code – IPC Berlin 2016
Rouven Weßling
 
PDF
Yapc::NA::2009 - Command Line Perl
Bruce Gray
 
PPTX
Yeahhhh the final requirement!!!
olracoatalub
 
PDF
2 debugging-c
Subhashis Pradhan
 
PDF
Deep C
Olve Maudal
 
PDF
Boo Manifesto
hu hans
 
The promise of asynchronous PHP
Wim Godden
 
PHP7 is coming
julien pauli
 
PHP Basic and Fundamental Questions and Answers with Detail Explanation
Abdul Rahman Sherzad
 
Perl Tidy Perl Critic
olegmmiller
 
2021.laravelconf.tw.slides2
LiviaLiaoFontech
 
Php tutorial
S Bharadwaj
 
What is the Joomla Framework and why do we need it?
Rouven Weßling
 
CLI, the other SAPI
Combell NV
 
PHP 7 Crash Course - php[world] 2015
Colin O'Dell
 
Php tutorial
Niit
 
Introduction to PHP
Kengatharaiyer Sarveswaran
 
Insecure coding in C (and C++)
Olve Maudal
 
Winter%200405%20-%20Beginning%20PHP
tutorialsruby
 
Static Analysis of PHP Code – IPC Berlin 2016
Rouven Weßling
 
Yapc::NA::2009 - Command Line Perl
Bruce Gray
 
Yeahhhh the final requirement!!!
olracoatalub
 
2 debugging-c
Subhashis Pradhan
 
Deep C
Olve Maudal
 
Boo Manifesto
hu hans
 

Viewers also liked (6)

PPT
Brudnick Net Ppt Portfolio
brudnick1212
 
PDF
Shell Revolution
Chris Stone
 
PDF
Charm City Linux - Jan 2014 - Web Dev Made Easy - Shell Revolution
Chris Stone
 
PPT
Lai
laila arceo
 
PDF
Cutting Edge Proposal
Jason Novinger
 
PDF
On Air
Jason Novinger
 
Brudnick Net Ppt Portfolio
brudnick1212
 
Shell Revolution
Chris Stone
 
Charm City Linux - Jan 2014 - Web Dev Made Easy - Shell Revolution
Chris Stone
 
Cutting Edge Proposal
Jason Novinger
 
Ad

Similar to PHP 5.3 (20)

ODP
What's new, what's hot in PHP 5.3
Jeremy Coates
 
ODP
New Stuff In Php 5.3
Chris Chubb
 
PPTX
Introducing PHP Latest Updates
Iftekhar Eather
 
PDF
Introduction to PHP 5.3
guestcc91d4
 
KEY
Can't Miss Features of PHP 5.3 and 5.4
Jeff Carouth
 
PDF
PHP 5.3 Overview
jsmith92
 
PDF
Php Development With Eclipde PDT
Bastian Feder
 
PPT
PHP 5.3 Part 1 - Introduction to PHP 5.3
melechi
 
PPTX
FFW Gabrovo PMG - PHP OOP Part 3
Toni Kolev
 
PPT
Phpwebdevelping
mohamed ashraf
 
PPT
ZendCon 08 php 5.3
webhostingguy
 
PDF
08 Advanced PHP #burningkeyboards
Denis Ristic
 
PDF
PHP 5
Rafael Corral
 
PPT
Phpwebdev
Luv'k Verma
 
PPT
PHP
webhostingguy
 
ODP
PHP: The Beginning and the Zend
doublecompile
 
PPTX
Unit 4-6 sem 7 Web Technologies.pptx
prathameshp9922
 
PDF
Preparing for the next PHP version (5.6)
Damien Seguy
 
ODP
The why and how of moving to php 5.4
Wim Godden
 
PPT
UNIT-IV WT web technology for 1st year cs
javed75
 
What's new, what's hot in PHP 5.3
Jeremy Coates
 
New Stuff In Php 5.3
Chris Chubb
 
Introducing PHP Latest Updates
Iftekhar Eather
 
Introduction to PHP 5.3
guestcc91d4
 
Can't Miss Features of PHP 5.3 and 5.4
Jeff Carouth
 
PHP 5.3 Overview
jsmith92
 
Php Development With Eclipde PDT
Bastian Feder
 
PHP 5.3 Part 1 - Introduction to PHP 5.3
melechi
 
FFW Gabrovo PMG - PHP OOP Part 3
Toni Kolev
 
Phpwebdevelping
mohamed ashraf
 
ZendCon 08 php 5.3
webhostingguy
 
08 Advanced PHP #burningkeyboards
Denis Ristic
 
Phpwebdev
Luv'k Verma
 
PHP: The Beginning and the Zend
doublecompile
 
Unit 4-6 sem 7 Web Technologies.pptx
prathameshp9922
 
Preparing for the next PHP version (5.6)
Damien Seguy
 
The why and how of moving to php 5.4
Wim Godden
 
UNIT-IV WT web technology for 1st year cs
javed75
 
Ad

Recently uploaded (20)

PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 

PHP 5.3

  • 1. AnnouncementsPHP 5.2.10 is available (June 18 release)CodeWorks 2009 Announced – Washington, D.C.Tutorial Day: October 2Main Conference: October 3Two day conference for PHP developersEach event is limited to 300 attendeeshttp://cw.mtacon.com/signup/index to RegisterDiscount prices until July 152009 DC PHP Conference & ExpoSeptember 16 & 17Discount prices until August 15No sessions available yet1
  • 2. PHP 5.3July 2009 Baltimore/Washington PHP MeetupChris [email protected] me @cmstone
  • 3. Release InformationExisting code should still workThere are only a few incompatibilities and new features that should be consideredMajor improvement of the 5.x seriesOver 140 bug fixesComprehensive migration information from PHP 5.2.x to 5.3.x at: http://us.php.net/migration533
  • 4. Key FeaturesNamespace supportLate static bindingLambda functions/closures (anonymous)Syntax additions (NOWDOC, ?:, goto…)Performance improvementsGarbage collection for cyclic referencesmysqlnd PHP native replacement for libmysqlDeprecation notices are handled E_DEPRECATED instead of E_STRICT4
  • 5. Improved PerformanceImproved runtime speedImproved memory usageSmaller binary sizeFaster startup speed with GCC4md5() is faster (10-15%)require_once() and include_once() uses only 1 fopen(3) callImproved exception handlingOverall performance improvement of 5-15%5
  • 7. NamespacesSingle largest addition in 5.3Feature completeSimplifies naming conventionsIf you developed larger projects, you would probably have used long class namesi.e. Zend class names can be HUGEZend_Search_Lucene_Document_HtmlDifferent namespaces can contain classes, functions, and constants with the same name.Defined using the namespace keyword7
  • 9. Multiple Namespaces Per File<?phpnamespace Project 1;const CONNECT_OK = 1;class Connection { /* ... */ }function connect() { /* ... */  }namespace Project2;const CONNECT_OK = 1;class Connection { /* ... */ }function connect() { /* ... */  }?> 9
  • 10. Namespaces Aliasing/ImportingPHP namespaces support two kinds of aliasing or importing: aliasing a class name, and aliasing a namespace name.<?phpnamespace foo;use My\Full\Classname as Another;// this is the same as use My\Full\NSname as NSnameuse My\Full\NSname;// importing a global classuse \ArrayObject;$obj = new namespace\Another;// instantiates object of class foo\Another$obj = new Another;// instantiates object of class My\Full\ClassnameNSname\subns\func(); // calls function My\Full\NSname\subns\func$a = new ArrayObject(array(1));// instantiates object of class ArrayObject// without the "use \ArrayObject" we would instantiate an object of classfoo\ArrayObject?> 10
  • 11. Namespaces Aliasing/ImportingPHP additionally supports a convenience shortcut to place multiple use statements on the same line <?phpuse My\Full\Classname as Another, My\Full\NSname;$obj = new Another;// instantiates object of class My\Full\ClassnameNSname\subns\func(); // calls function My\Full\NSname\subns\func?> 11
  • 12. Namespaces Aliasing/ImportingPHP additionally supports a convenience shortcut to place multiple use statements on the same line <?phpuse My\Full\Classname as Another, My\Full\NSname;$obj = new Another;// instantiates object of class My\Full\ClassnameNSname\subns\func(); // calls function My\Full\NSname\subns\func?> 12
  • 13. Common Namespace QuestionsQ: If I don't use namespaces, should I care about any of this?A: No. Namespaces do not affect any existing code in any way, or any as-yet-to-be- written code that does not contain namespaces.Q: How does a name like \my\name or \name resolve? A: Names that begin with a \ always resolve to what they look like, so \my\name is in fact my\name, and \Exception is Exception.13
  • 14. MySQLnd – MySQL Native DriverReplacement for the MySQL Client LibraryDoes NOT provide a new API to the programmerHigh speed library to interface with MySQL designed for PHPBuilt in driverNo external dependenciesImproved persistent connectionsThe special function mysqli_fetch_all()Return all rows as an array with one functionCan fetch performance statisticsmysqli_get_cache_stats()mysqli_get_client_stats()mysqli_get_connection_stats()14
  • 16. __DIR____DIR__ is a magic constant that indicates where the current script is located.The below produce the same thing:<?php/* PHP < 5.3 */ echo dirname(__FILE__);/* PHP >= 5.3 */echo __DIR__;?>16
  • 17. ?: Ternary OperatorIt’s now possible to leave out the middle part of the ternary operator. This allows fast retrieval of a non-empty value from 2 values and/or expressions.Expression expr1 ?: expr3 returns expr1 if expr1 evaluates to TRUE, and expr3 otherwise. <?php$test = true ?: false; // Returns true$test = false ?: true; // Returns true$test = 0 ?: 2; // Returns 2$test = “” ?: 1; // Returns 1?>17
  • 18. __callStaticSame as __call, except for static methodsExample<?phpclass tester { static function __callStatic($name, $args) { echo $name . ‘ (‘ . implode(‘,’, $args) . ‘)’; }}tester::testFunction(“test1”, “test2”);?>OutputstestFunction(test1,test2);Note: Dynamic function calls (static/standard) are slow18
  • 19. Dynamic Static CallsPHP 5.3 introduced the ability to call static method dynamically<?phpclass tester { static functionfoobar() { echo “Dynamic Static Call”; }}$variable1 = “tester”;$variable2 = “foobar”;$variable1::$variable2(); // Calls tester:foobar();?>OutputsDynamic Static CallNote: Dynamic function calls (static/standard) are slow19
  • 20. Late Static BindingLimitations of self::<?phpclass A {    public static function who() {        echo __CLASS__;    }    public static function test() {        self::who();    }}class B extends A {    public static function who() {         echo __CLASS__;    }}B::test();?>OutputA20Late static binding is used to reference the called class in a context of static inheritance. Processing of static events has been moved from compile time, to execution time.static:: simple usage<?phpclass A {    public static function who() {        echo __CLASS__;    }    public static function test() {        static::who();    }}class B extends A {    public static function who() {         echo __CLASS__;    }}B::test();?>OutputB
  • 21. Anonymous FunctionsAlso known as closures, allow the creation of functions which have no specified name. They are most useful as the value of a callback parameter.Example #1 - Anonymous function example<?phpecho preg_replace_callback('~-([a-z])~', function ($match) {    return strtoupper($match[1]);}, 'hello-world');?> OutputshelloWorldExample #2 - Anonymous function variable assignment example<?php$greet = function($name) {    printf("Hello %s\r\n", $name);};$greet('World');$greet('PHP');?> OutputsHello WorldHello PHP21
  • 22. gotoThe goto operator can be used to jump to another section in the program. The target point is specified by a label followed by a colon, and the instruction is given as goto followed by the desired target label. This is not a full unrestricted goto. The target label must be within the same file and context, meaning that you cannot jump out of a function or method, nor can you jump into one. You also cannot jump into any sort of loop or switch structure. You may jump out of these, and a common use is to use a goto in place of a multi-level break. Example #1 – goto Example<?phpgoto a;echo 'Foo'; a:echo 'Bar';?> OutputsBar22
  • 23. goto Continued…Example #2 - Anonymous function variable assignment example<?phpfor ($i=0,$j=50; $i<100; $i++) {  while ($j--) {    if ($j==17) goto end;   }}echo "i = $i";end:echo 'j hit 17';?> Outputsj hit 1723
  • 24. DeprecationNew error modes E_USER_DEPRECATEDE_DEPRECATEDUsed to inform about deprecated functionality that is scheduled for removal in future version of PHP.Used to throw E_STRICT24
  • 26. INI Changes OverviewSupport for .htaccess style INI controlsPer directory/host INI settings that can not be overridden by the user[PATH=/var/www/www.phpmeetup.com/][HOST=www.meetup.com]Only supported by CGI/FastCGI, not for PHP-CLI, or as an Apache moduleImproved error handling"ini-variables" can now be used almost anywhere in a php.ini file.26
  • 27. INI Changes ExampleName for user-defined php.ini (.htaccess) files. Default is ".user.ini“user_ini.filename= ".user.ini"To disable this feature set this option to empty valueuser_ini.filename=TTL for user-defined php.ini files (time-to-live) in seconds.Default is 300 seconds (5 minutes)user_ini.cache_ttl= 300[PATH=/var/www/phpmeetup.com]error_reporting= E_ALL & ~E_DEPRECATEDhtml_errors = off27
  • 28. Other ImprovementsImproved streamsImproved DNS APIImproved hash extensionImproved IMAP supportImproved mbstring extensionImproved OCI8 extensionImproved OpenSSL (OpenID in mind, simplify implementation)Improved crypt() functionMany, many more!28
  • 29. The EndSlides will be posted on MeetUp and http://www.e-moxie.comI can also e-mail them to you if you would like, just make sure I have your e-mail address.Next TopicProject & Code Management using Trac w/ Subversion IntegrationPresented by Steve CrumpAugust 12, 2009 @ 6:30 p.m.29