SlideShare une entreprise Scribd logo
1  sur  38
Télécharger pour lire hors ligne
PHP 5.3/6
Standortbestimmung
About me
   Application Developer
     ▹   PHP
     ▹   XSLT/XPath
     ▹   (some) Javascript

    papaya CMS
     ▹   PHP based Content Management System
     ▹   uses XSLT for Templates


Thomas Weinert, papaya Software GmbH           2
PHP 5.3




                          „PHP 5.3 is still young“




Thomas Weinert, papaya Software GmbH                 3
PHP 5.3




Thomas Weinert, papaya Software GmbH             4
PHP 6




               „PHP 6 is already in development“




Thomas Weinert, papaya Software GmbH               5
PHP 6




                             … for some years ...




Thomas Weinert, papaya Software GmbH                6
PHP 5.3




                                What do we get?




Thomas Weinert, papaya Software GmbH              7
Bugfixes


All              Closed          Open        Critical   Verified   Analyzed


13085            4007(199)       919 (50)    2          11         2

 Assigned         Suspended       Feedback   No         Wont fix   Bogus
                                             Feedback


 261              26              45         1651       350        5806




Thomas Weinert, papaya Software GmbH                                          8
Performance




                                       Performance

                         about 5 – 15% or more?




Thomas Weinert, papaya Software GmbH                   9
Garbage Collection
   gc_enable()
     ▹   Activates the circular reference collector

    gc_collect_cycles()
     ▹   Forces collection of any existing garbage cycles.
   gc_disable()

    gc_enabled()



Thomas Weinert, papaya Software GmbH                         10
PHP.INI
   per directory (like .htaccess)
     ▹   Cached

    [PATH=/opt/httpd/www.example.com/]

    [HOST=www.example.com]




    Ini „variables“

    absolute paths for extensions

Thomas Weinert, papaya Software GmbH             11
Extensions Changed
   PCRE, Reflection, SPL
     ▹   can not be disabled any more

    MySQL(i)
     ▹   mysqlnd
   SQLite
     ▹   SQLite 3 Support

    GD
     ▹   removed GD1 and Freetype1 support
Thomas Weinert, papaya Software GmbH                 12
Extensions Moved
   Moved to PECL
     ▹   fdf
     ▹   ncurses
     ▹   sybase
     ▹   ming
     ▹   dbase
     ▹   fbsql
     ▹   mime_magic

Thomas Weinert, papaya Software GmbH                  13
Extensions Added
   fileinfo
   intl

    phar




Thomas Weinert, papaya Software GmbH                  14
Fileinfo
   File mimetype
     ▹   from magic bytes
     ▹   not bullet proof


   BC to ext/mime_magic
     ▹   mime_content_type()




Thomas Weinert, papaya Software GmbH              15
Fileinfo Sample
<?php

$finfo = finfo_open(FILEINFO_MIME);

foreach (glob(quot;*quot;) as $filename) {
  echo finfo_file($finfo, $filename) . quot;nquot;;
}

finfo_close($finfo);
?>




Thomas Weinert, papaya Software GmbH                     16
INTL
   ICU
     ▹   International Components for Unicode

    Internationalization
     ▹   String functions
     ▹   Collator
     ▹   Number Formatter
     ▹   Message Formatter
     ▹   Normalizer
     ▹   Locale
Thomas Weinert, papaya Software GmbH            17
PHAR
   PHP applications in one package
   easy distribution and installation

    verify archive integrity

    PHP stream wrapper

    tar and zip

    Phar format with stub
<?php
  include
     'phar:///path/to/myphar.phar/file.php';
?> Weinert, papaya Software GmbH
Thomas                                         18
PHAR
   Using a stub
   Makes a PHAR file a PHP script

<?php
Phar::webPhar();
__HALT_COMPILER();



    http://www.domain.tld/app.phar/page.php


Thomas Weinert, papaya Software GmbH          19
SPL
   Now always enabled


    many iterators and recursive iterators

    SPLFixedArray

    http://www.php.net/spl




Thomas Weinert, papaya Software GmbH         20
Error Reporting
   E_DEPRECATED splitted from E_STRICT
   E_DEPRECATED included in E_ALL


    is_a() is not in E_DEPRECATED any more
     ▹   but documentation still says it is




Thomas Weinert, papaya Software GmbH                     21
Syntax Sugar
   __DIR__ replaces dirname(__FILE__)
   ?:
     ▹   $foo = $bar ?: 'default'

    Nowdoc
     ▹   $foo = <<<'HTML' // no variables parsed

    Heredoc
     ▹   double quotes
     ▹   static $foo = <<<HTML // no variables allowed
Thomas Weinert, papaya Software GmbH                     22
Static
   Late Static Binding
   __callStatic

    static::foo




Thomas Weinert, papaya Software GmbH            23
LSB - Why
<?php
class bar {
   public function show() {
     var_dump(new self);
   }
}
class foo extends bar {
   public function test() {
     parent::show();
   }
}
$foo = new foo;
$foo->test();
?>                                           object(bar)#2 (0) { }
Thomas Weinert, papaya Software GmbH                             24
LSB - Why
<?php
class bar {
   public function show() {
     var_dump(new static);
   }
}
class foo extends bar {
   public function test() {
     parent::show();
   }
}
$foo = new foo;
$foo->test();
?>                                           object(foo)#2 (0) { }
Thomas Weinert, papaya Software GmbH                             25
Dynamic Static Calls
<?php
class foo {
  function bar() {
    var_dump('Hello World');
  }
}
foo::bar();

$o = new foo();
$o::bar();

$s = 'foo';
$s::bar();
?>
Thomas Weinert, papaya Software GmbH                  26
Lambda Functions
<?php
header('Content-type: text/plain');
$text = '<b>Hello <i>World</i></b>';
$ptn = '(<(/?)(w+)([^>]*)>)';

$cb = function($m) {
   if (strtolower($m[2]) == 'b') {
     return '<'.$m[1].'strong'.$m[3].'>';
   }
   return '';
};
echo preg_replace_callback($ptn, $cb, $text);
?>
Thomas Weinert, papaya Software GmbH                 27
Closures
...
$repl = array(
   'b' => 'strong',
   'i' => 'em'
);
$cb = function ($m) use ($repl) {
   $tag = strtolower($m[2]);
   if (!empty($replace[$tag])) {
     return '<'.$m[1].$repl[$tag].$m[3].'>';
   }
   return '';
};
echo preg_replace_callback($ptn, $cb, $t);
?>
Thomas Weinert, papaya Software GmbH              28
Currying
function curry($callback) {
  $args = func_get_args();
  array_shift($args);
  return function() use ($callback, $args) {
     $args = array_merge(
        func_get_args(),
        $args
     );
     return call_user_func_array(
        $callback,
        $args
     );
  };
}
Thomas Weinert, papaya Software GmbH              29
Currying
$cb = curry(array('replace', 'tags'), $replace);
echo preg_replace_callback(
   $pattern, $cb, $text
);

class replace {
  function tags($m, $repl) {
    $tag = strtolower($m[2]);
    if (!empty($repl[$tag])) {
      return '<'.$m[1].$repl[$tag].$m[3].'>';
    }
    return '';
  }
}
Thomas Weinert, papaya Software GmbH              30
Namespaces
   Encapsulation
     ▹   Classes
     ▹   Functions
     ▹   Constants

    __NAMESPACE__

    Overload classes



Thomas Weinert, papaya Software GmbH                31
Namespace Separator
   Old                                   Current
     ▹   Double Colon                      ▹   Backslash?
     ▹   Paamayim                          ▹   Discussion started
         Nekudotayim




                  ::                                
Thomas Weinert, papaya Software GmbH                                32
Namespaces: Classes
<?php
namespace carica::core::strings;

const CHARSET = 'utf-8';

class escape {
   public static function forXML($content) {
     return htmlspecialchars(
        $content, ENT_QUOTES, CHARSET
     );
   }
}
?>
Thomas Weinert, papaya Software GmbH                33
Use Namespaces
...
namespace carica::frontend;
use carica::core::strings as strings;
...
  public function execute() {
    echo strings::escape::forXML(
       'Hello World'
    );
  }
...




Thomas Weinert, papaya Software GmbH                    34
Namespaces: Constants
   PHP-Wiki:
     ▹   constants are case-sensitive, but namespaces are
         case-insensitive.
     ▹   defined() is not aware of namespace aliases.
     ▹   the namespace part of constants defined with
         const are lowercased.




Thomas Weinert, papaya Software GmbH                        35
GOTO
<?php
  goto a;
  print 'Foo';

   a:
   print 'Bar';
?>




Thomas Weinert, papaya Software GmbH          36
PHP 6
   „Backports“ to PHP 5.3


    Upload progress in session

    Unicode
     ▹   PHP Source
     ▹   Functions
     ▹   Resources


Thomas Weinert, papaya Software GmbH           37
Links
   Slides
     ▹   http://www.abasketfulofpapayas.de

    PHP 5.3 upgrading notes
     ▹   http://wiki.php.net/doc/scratchpad/upgrade/53
   PHP 5.3 ToDo
     ▹   http://wiki.php.net/todo/php53

    PHP 6 ToDo
     ▹   http://wiki.php.net/todo/php60
Thomas Weinert, papaya Software GmbH                     38

Contenu connexe

Tendances

Introducing PHP Latest Updates
Introducing PHP Latest UpdatesIntroducing PHP Latest Updates
Introducing PHP Latest Updates
Iftekhar Eather
 
PHP traits, treat or threat?
PHP traits, treat or threat?PHP traits, treat or threat?
PHP traits, treat or threat?
Nick Belhomme
 
Anatomy of a PHP Request ( UTOSC 2010 )
Anatomy of a PHP Request ( UTOSC 2010 )Anatomy of a PHP Request ( UTOSC 2010 )
Anatomy of a PHP Request ( UTOSC 2010 )
Joseph Scott
 
What's new in PHP 5.5
What's new in PHP 5.5What's new in PHP 5.5
What's new in PHP 5.5
Tom Corrigan
 
Perl 101 - The Basics of Perl Programming
Perl  101 - The Basics of Perl ProgrammingPerl  101 - The Basics of Perl Programming
Perl 101 - The Basics of Perl Programming
Utkarsh Sengar
 
Beginning PHPUnit
Beginning PHPUnitBeginning PHPUnit
Beginning PHPUnit
Jace Ju
 

Tendances (19)

The why and how of moving to PHP 5.5/5.6
The why and how of moving to PHP 5.5/5.6The why and how of moving to PHP 5.5/5.6
The why and how of moving to PHP 5.5/5.6
 
Flask RESTful Flask HTTPAuth
Flask RESTful Flask HTTPAuthFlask RESTful Flask HTTPAuth
Flask RESTful Flask HTTPAuth
 
Hello Go
Hello GoHello Go
Hello Go
 
Puppetcamp module design talk
Puppetcamp module design talkPuppetcamp module design talk
Puppetcamp module design talk
 
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
 
PHP7 - Scalar Type Hints & Return Types
PHP7 - Scalar Type Hints & Return TypesPHP7 - Scalar Type Hints & Return Types
PHP7 - Scalar Type Hints & Return Types
 
Introducing PHP Latest Updates
Introducing PHP Latest UpdatesIntroducing PHP Latest Updates
Introducing PHP Latest Updates
 
Test your code like a pro - PHPUnit in practice
Test your code like a pro - PHPUnit in practiceTest your code like a pro - PHPUnit in practice
Test your code like a pro - PHPUnit in practice
 
PHP traits, treat or threat?
PHP traits, treat or threat?PHP traits, treat or threat?
PHP traits, treat or threat?
 
Unlock The Mystery Of PHPUnit (Wave PHP 2018)
Unlock The Mystery Of PHPUnit (Wave PHP 2018)Unlock The Mystery Of PHPUnit (Wave PHP 2018)
Unlock The Mystery Of PHPUnit (Wave PHP 2018)
 
Anatomy of a PHP Request ( UTOSC 2010 )
Anatomy of a PHP Request ( UTOSC 2010 )Anatomy of a PHP Request ( UTOSC 2010 )
Anatomy of a PHP Request ( UTOSC 2010 )
 
Yapc::NA::2009 - Command Line Perl
Yapc::NA::2009 - Command Line PerlYapc::NA::2009 - Command Line Perl
Yapc::NA::2009 - Command Line Perl
 
Cli the other sapi pbc11
Cli the other sapi pbc11Cli the other sapi pbc11
Cli the other sapi pbc11
 
What's new in PHP 5.5
What's new in PHP 5.5What's new in PHP 5.5
What's new in PHP 5.5
 
Unit 1-introduction to perl
Unit 1-introduction to perlUnit 1-introduction to perl
Unit 1-introduction to perl
 
Perl 101 - The Basics of Perl Programming
Perl  101 - The Basics of Perl ProgrammingPerl  101 - The Basics of Perl Programming
Perl 101 - The Basics of Perl Programming
 
PHP 7 performances from PHP 5
PHP 7 performances from PHP 5PHP 7 performances from PHP 5
PHP 7 performances from PHP 5
 
Cli the other SAPI confoo11
Cli the other SAPI confoo11Cli the other SAPI confoo11
Cli the other SAPI confoo11
 
Beginning PHPUnit
Beginning PHPUnitBeginning PHPUnit
Beginning PHPUnit
 

En vedette

Documentos primaria-sesiones-comunicacion-quinto grado-orientaciones-para_la_...
Documentos primaria-sesiones-comunicacion-quinto grado-orientaciones-para_la_...Documentos primaria-sesiones-comunicacion-quinto grado-orientaciones-para_la_...
Documentos primaria-sesiones-comunicacion-quinto grado-orientaciones-para_la_...
Sulio Chacón Yauris
 
5 to primaria
5 to primaria5 to primaria
5 to primaria
CEDAM9C
 
Taller olimpicos
Taller olimpicosTaller olimpicos
Taller olimpicos
mariadulbi
 
Documentos primaria-sesiones-comunicacion-quinto grado-orientaciones-para_la_...
Documentos primaria-sesiones-comunicacion-quinto grado-orientaciones-para_la_...Documentos primaria-sesiones-comunicacion-quinto grado-orientaciones-para_la_...
Documentos primaria-sesiones-comunicacion-quinto grado-orientaciones-para_la_...
Marilu Alarcon
 
Ud 5 La Nutricion En Los Seres Vivos
 Ud 5 La Nutricion En Los Seres Vivos Ud 5 La Nutricion En Los Seres Vivos
Ud 5 La Nutricion En Los Seres Vivos
mdrmor
 
6 to primaria
6 to primaria6 to primaria
6 to primaria
CEDAM9C
 
Exámenes de 1° a 6°
Exámenes de 1° a 6°Exámenes de 1° a 6°
Exámenes de 1° a 6°
Kz Zgv
 
La organización del espacio y tiempo en el aula de educación primaria tema 5
La organización del espacio y tiempo en el aula de educación primaria tema 5La organización del espacio y tiempo en el aula de educación primaria tema 5
La organización del espacio y tiempo en el aula de educación primaria tema 5
Pepe García Hernández
 

En vedette (20)

Documentos primaria-sesiones-comunicacion-quinto grado-orientaciones-para_la_...
Documentos primaria-sesiones-comunicacion-quinto grado-orientaciones-para_la_...Documentos primaria-sesiones-comunicacion-quinto grado-orientaciones-para_la_...
Documentos primaria-sesiones-comunicacion-quinto grado-orientaciones-para_la_...
 
El Cole Encantado
El Cole EncantadoEl Cole Encantado
El Cole Encantado
 
Multicubos
MulticubosMulticubos
Multicubos
 
5 to primaria
5 to primaria5 to primaria
5 to primaria
 
Taller olimpicos
Taller olimpicosTaller olimpicos
Taller olimpicos
 
Planeación didáctica primaria 5 2015
Planeación didáctica primaria 5 2015Planeación didáctica primaria 5 2015
Planeación didáctica primaria 5 2015
 
Avance programatico 5
Avance programatico 5Avance programatico 5
Avance programatico 5
 
Documentos primaria-sesiones-comunicacion-quinto grado-orientaciones-para_la_...
Documentos primaria-sesiones-comunicacion-quinto grado-orientaciones-para_la_...Documentos primaria-sesiones-comunicacion-quinto grado-orientaciones-para_la_...
Documentos primaria-sesiones-comunicacion-quinto grado-orientaciones-para_la_...
 
juegos matematicos
juegos matematicosjuegos matematicos
juegos matematicos
 
Solucionario desafíos matemáticos 5
Solucionario desafíos matemáticos 5Solucionario desafíos matemáticos 5
Solucionario desafíos matemáticos 5
 
Juegos matemáticos grado 5° primaria power point 2014 ideas
Juegos matemáticos grado 5° primaria power point 2014 ideasJuegos matemáticos grado 5° primaria power point 2014 ideas
Juegos matemáticos grado 5° primaria power point 2014 ideas
 
Ud 5 La Nutricion En Los Seres Vivos
 Ud 5 La Nutricion En Los Seres Vivos Ud 5 La Nutricion En Los Seres Vivos
Ud 5 La Nutricion En Los Seres Vivos
 
6 to primaria
6 to primaria6 to primaria
6 to primaria
 
Ficha técnica-Prevengo el sobrepeso y la obesidad.
Ficha técnica-Prevengo el sobrepeso y la obesidad.Ficha técnica-Prevengo el sobrepeso y la obesidad.
Ficha técnica-Prevengo el sobrepeso y la obesidad.
 
Exámenes de 1° a 6°
Exámenes de 1° a 6°Exámenes de 1° a 6°
Exámenes de 1° a 6°
 
Ejercicios 5 primaria
Ejercicios 5 primariaEjercicios 5 primaria
Ejercicios 5 primaria
 
Numeros romanos
Numeros romanosNumeros romanos
Numeros romanos
 
La organización del espacio y tiempo en el aula de educación primaria tema 5
La organización del espacio y tiempo en el aula de educación primaria tema 5La organización del espacio y tiempo en el aula de educación primaria tema 5
La organización del espacio y tiempo en el aula de educación primaria tema 5
 
Solucionario 5º
Solucionario 5º Solucionario 5º
Solucionario 5º
 
Solucionario 6° 2015 2016
Solucionario 6° 2015 2016Solucionario 6° 2015 2016
Solucionario 6° 2015 2016
 

Similaire à PHP 5.3/6

Deliver Files With PHP
Deliver Files With PHPDeliver Files With PHP
Deliver Files With PHP
Thomas Weinert
 
Optimizing Your Frontend Performance
Optimizing Your Frontend PerformanceOptimizing Your Frontend Performance
Optimizing Your Frontend Performance
Thomas Weinert
 

Similaire à PHP 5.3/6 (20)

Deliver Files With PHP
Deliver Files With PHPDeliver Files With PHP
Deliver Files With PHP
 
PHP 5.3
PHP 5.3PHP 5.3
PHP 5.3
 
第1回PHP拡張勉強会
第1回PHP拡張勉強会第1回PHP拡張勉強会
第1回PHP拡張勉強会
 
Bubbles & Trees with jQuery
Bubbles & Trees with jQueryBubbles & Trees with jQuery
Bubbles & Trees with jQuery
 
Php
PhpPhp
Php
 
Gore: Go REPL
Gore: Go REPLGore: Go REPL
Gore: Go REPL
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy Code
 
Prepare for PHP Test Fest 2009
Prepare for PHP Test Fest 2009Prepare for PHP Test Fest 2009
Prepare for PHP Test Fest 2009
 
Php mysql ppt
Php mysql pptPhp mysql ppt
Php mysql ppt
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
Optimizing Your Frontend Performance
Optimizing Your Frontend PerformanceOptimizing Your Frontend Performance
Optimizing Your Frontend Performance
 
Api Design
Api DesignApi Design
Api Design
 
Introduction to PowerShell
Introduction to PowerShellIntroduction to PowerShell
Introduction to PowerShell
 
Adventures in infrastructure as code
Adventures in infrastructure as codeAdventures in infrastructure as code
Adventures in infrastructure as code
 
Os Treat
Os TreatOs Treat
Os Treat
 
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
 
PHP: The easiest language to learn.
PHP: The easiest language to learn.PHP: The easiest language to learn.
PHP: The easiest language to learn.
 
Apache and PHP: Why httpd.conf is your new BFF!
Apache and PHP: Why httpd.conf is your new BFF!Apache and PHP: Why httpd.conf is your new BFF!
Apache and PHP: Why httpd.conf is your new BFF!
 
Incredible Machine with Pipelines and Generators
Incredible Machine with Pipelines and GeneratorsIncredible Machine with Pipelines and Generators
Incredible Machine with Pipelines and Generators
 
The Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/PressThe Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/Press
 

Plus de Thomas Weinert (12)

PHPUG CGN: Controlling Arduino With PHP
PHPUG CGN: Controlling Arduino With PHPPHPUG CGN: Controlling Arduino With PHP
PHPUG CGN: Controlling Arduino With PHP
 
Controlling Arduino With PHP
Controlling Arduino With PHPControlling Arduino With PHP
Controlling Arduino With PHP
 
Decoupling Objects With Standard Interfaces
Decoupling Objects With Standard InterfacesDecoupling Objects With Standard Interfaces
Decoupling Objects With Standard Interfaces
 
Asynchronous I/O in PHP
Asynchronous I/O in PHPAsynchronous I/O in PHP
Asynchronous I/O in PHP
 
Lumberjack XPath 101
Lumberjack XPath 101Lumberjack XPath 101
Lumberjack XPath 101
 
FluentDom
FluentDomFluentDom
FluentDom
 
Optimizing Your Frontend Performance
Optimizing Your Frontend PerformanceOptimizing Your Frontend Performance
Optimizing Your Frontend Performance
 
Experiences With Pre Commit Hooks
Experiences With Pre Commit HooksExperiences With Pre Commit Hooks
Experiences With Pre Commit Hooks
 
The Lumber Mill - XSLT For Your Templates
The Lumber Mill  - XSLT For Your TemplatesThe Lumber Mill  - XSLT For Your Templates
The Lumber Mill - XSLT For Your Templates
 
The Lumber Mill Xslt For Your Templates
The Lumber Mill   Xslt For Your TemplatesThe Lumber Mill   Xslt For Your Templates
The Lumber Mill Xslt For Your Templates
 
SVN Hook
SVN HookSVN Hook
SVN Hook
 
Optimizing Your Frontend Performance
Optimizing Your Frontend PerformanceOptimizing Your Frontend Performance
Optimizing Your Frontend Performance
 

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Dernier (20)

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 

PHP 5.3/6

  • 2. About me  Application Developer ▹ PHP ▹ XSLT/XPath ▹ (some) Javascript  papaya CMS ▹ PHP based Content Management System ▹ uses XSLT for Templates Thomas Weinert, papaya Software GmbH 2
  • 3. PHP 5.3 „PHP 5.3 is still young“ Thomas Weinert, papaya Software GmbH 3
  • 4. PHP 5.3 Thomas Weinert, papaya Software GmbH 4
  • 5. PHP 6 „PHP 6 is already in development“ Thomas Weinert, papaya Software GmbH 5
  • 6. PHP 6 … for some years ... Thomas Weinert, papaya Software GmbH 6
  • 7. PHP 5.3 What do we get? Thomas Weinert, papaya Software GmbH 7
  • 8. Bugfixes All Closed Open Critical Verified Analyzed 13085 4007(199) 919 (50) 2 11 2 Assigned Suspended Feedback No Wont fix Bogus Feedback 261 26 45 1651 350 5806 Thomas Weinert, papaya Software GmbH 8
  • 9. Performance Performance about 5 – 15% or more? Thomas Weinert, papaya Software GmbH 9
  • 10. Garbage Collection  gc_enable() ▹ Activates the circular reference collector  gc_collect_cycles() ▹ Forces collection of any existing garbage cycles.  gc_disable()  gc_enabled() Thomas Weinert, papaya Software GmbH 10
  • 11. PHP.INI  per directory (like .htaccess) ▹ Cached  [PATH=/opt/httpd/www.example.com/]  [HOST=www.example.com]   Ini „variables“  absolute paths for extensions Thomas Weinert, papaya Software GmbH 11
  • 12. Extensions Changed  PCRE, Reflection, SPL ▹ can not be disabled any more  MySQL(i) ▹ mysqlnd  SQLite ▹ SQLite 3 Support  GD ▹ removed GD1 and Freetype1 support Thomas Weinert, papaya Software GmbH 12
  • 13. Extensions Moved  Moved to PECL ▹ fdf ▹ ncurses ▹ sybase ▹ ming ▹ dbase ▹ fbsql ▹ mime_magic Thomas Weinert, papaya Software GmbH 13
  • 14. Extensions Added  fileinfo  intl  phar Thomas Weinert, papaya Software GmbH 14
  • 15. Fileinfo  File mimetype ▹ from magic bytes ▹ not bullet proof  BC to ext/mime_magic ▹ mime_content_type() Thomas Weinert, papaya Software GmbH 15
  • 16. Fileinfo Sample <?php $finfo = finfo_open(FILEINFO_MIME); foreach (glob(quot;*quot;) as $filename) { echo finfo_file($finfo, $filename) . quot;nquot;; } finfo_close($finfo); ?> Thomas Weinert, papaya Software GmbH 16
  • 17. INTL  ICU ▹ International Components for Unicode  Internationalization ▹ String functions ▹ Collator ▹ Number Formatter ▹ Message Formatter ▹ Normalizer ▹ Locale Thomas Weinert, papaya Software GmbH 17
  • 18. PHAR  PHP applications in one package  easy distribution and installation  verify archive integrity  PHP stream wrapper  tar and zip  Phar format with stub <?php include 'phar:///path/to/myphar.phar/file.php'; ?> Weinert, papaya Software GmbH Thomas 18
  • 19. PHAR  Using a stub  Makes a PHAR file a PHP script <?php Phar::webPhar(); __HALT_COMPILER();  http://www.domain.tld/app.phar/page.php Thomas Weinert, papaya Software GmbH 19
  • 20. SPL  Now always enabled  many iterators and recursive iterators  SPLFixedArray  http://www.php.net/spl Thomas Weinert, papaya Software GmbH 20
  • 21. Error Reporting  E_DEPRECATED splitted from E_STRICT  E_DEPRECATED included in E_ALL  is_a() is not in E_DEPRECATED any more ▹ but documentation still says it is Thomas Weinert, papaya Software GmbH 21
  • 22. Syntax Sugar  __DIR__ replaces dirname(__FILE__)  ?: ▹ $foo = $bar ?: 'default'  Nowdoc ▹ $foo = <<<'HTML' // no variables parsed  Heredoc ▹ double quotes ▹ static $foo = <<<HTML // no variables allowed Thomas Weinert, papaya Software GmbH 22
  • 23. Static  Late Static Binding  __callStatic  static::foo Thomas Weinert, papaya Software GmbH 23
  • 24. LSB - Why <?php class bar { public function show() { var_dump(new self); } } class foo extends bar { public function test() { parent::show(); } } $foo = new foo; $foo->test(); ?> object(bar)#2 (0) { } Thomas Weinert, papaya Software GmbH 24
  • 25. LSB - Why <?php class bar { public function show() { var_dump(new static); } } class foo extends bar { public function test() { parent::show(); } } $foo = new foo; $foo->test(); ?> object(foo)#2 (0) { } Thomas Weinert, papaya Software GmbH 25
  • 26. Dynamic Static Calls <?php class foo { function bar() { var_dump('Hello World'); } } foo::bar(); $o = new foo(); $o::bar(); $s = 'foo'; $s::bar(); ?> Thomas Weinert, papaya Software GmbH 26
  • 27. Lambda Functions <?php header('Content-type: text/plain'); $text = '<b>Hello <i>World</i></b>'; $ptn = '(<(/?)(w+)([^>]*)>)'; $cb = function($m) { if (strtolower($m[2]) == 'b') { return '<'.$m[1].'strong'.$m[3].'>'; } return ''; }; echo preg_replace_callback($ptn, $cb, $text); ?> Thomas Weinert, papaya Software GmbH 27
  • 28. Closures ... $repl = array( 'b' => 'strong', 'i' => 'em' ); $cb = function ($m) use ($repl) { $tag = strtolower($m[2]); if (!empty($replace[$tag])) { return '<'.$m[1].$repl[$tag].$m[3].'>'; } return ''; }; echo preg_replace_callback($ptn, $cb, $t); ?> Thomas Weinert, papaya Software GmbH 28
  • 29. Currying function curry($callback) { $args = func_get_args(); array_shift($args); return function() use ($callback, $args) { $args = array_merge( func_get_args(), $args ); return call_user_func_array( $callback, $args ); }; } Thomas Weinert, papaya Software GmbH 29
  • 30. Currying $cb = curry(array('replace', 'tags'), $replace); echo preg_replace_callback( $pattern, $cb, $text ); class replace { function tags($m, $repl) { $tag = strtolower($m[2]); if (!empty($repl[$tag])) { return '<'.$m[1].$repl[$tag].$m[3].'>'; } return ''; } } Thomas Weinert, papaya Software GmbH 30
  • 31. Namespaces  Encapsulation ▹ Classes ▹ Functions ▹ Constants  __NAMESPACE__  Overload classes Thomas Weinert, papaya Software GmbH 31
  • 32. Namespace Separator  Old  Current ▹ Double Colon ▹ Backslash? ▹ Paamayim ▹ Discussion started Nekudotayim :: Thomas Weinert, papaya Software GmbH 32
  • 33. Namespaces: Classes <?php namespace carica::core::strings; const CHARSET = 'utf-8'; class escape { public static function forXML($content) { return htmlspecialchars( $content, ENT_QUOTES, CHARSET ); } } ?> Thomas Weinert, papaya Software GmbH 33
  • 34. Use Namespaces ... namespace carica::frontend; use carica::core::strings as strings; ... public function execute() { echo strings::escape::forXML( 'Hello World' ); } ... Thomas Weinert, papaya Software GmbH 34
  • 35. Namespaces: Constants  PHP-Wiki: ▹ constants are case-sensitive, but namespaces are case-insensitive. ▹ defined() is not aware of namespace aliases. ▹ the namespace part of constants defined with const are lowercased. Thomas Weinert, papaya Software GmbH 35
  • 36. GOTO <?php goto a; print 'Foo'; a: print 'Bar'; ?> Thomas Weinert, papaya Software GmbH 36
  • 37. PHP 6  „Backports“ to PHP 5.3  Upload progress in session  Unicode ▹ PHP Source ▹ Functions ▹ Resources Thomas Weinert, papaya Software GmbH 37
  • 38. Links  Slides ▹ http://www.abasketfulofpapayas.de  PHP 5.3 upgrading notes ▹ http://wiki.php.net/doc/scratchpad/upgrade/53  PHP 5.3 ToDo ▹ http://wiki.php.net/todo/php53  PHP 6 ToDo ▹ http://wiki.php.net/todo/php60 Thomas Weinert, papaya Software GmbH 38