SlideShare a Scribd company logo
1 of 49
Download to read offline
Ilia Alshanetsky | Centah Inc.


Hidden Features of PHP
Hidden Features
                              of PHP
                           International PHP Conference 2011
                                     Ilia Alshanetsky
                                           @iliaa




Wednesday, June 1, 2011                                        1
root@foo $: whois ilia
           PHP: Core Developer Since 2001
                Release Manager of 4.3, 5.1 and 5.2 branches
                Author of a “few” extensions
           Work: CIO at Centah Inc.
           Hobbies: Photography, Biking
           Dev. Interests: Performance & Security



Wednesday, June 1, 2011                                        2
__DIR__ Magic
         The __DIR__ constant is a simple and fast
         solution to the “where am i?” question for PHP
         scripts.
                           ilia@s3 /tmp $ php a.php


                             <?php echo __DIR__;


                                    /tmp



Wednesday, June 1, 2011                                   3
We               Perl
        Allows quick retrieval of a non-empty value from
        2 values and/or expressions
            $a = true ?: false; // true
            $a = false ?: true; // true
            $a = "" ?: 1; // 1
            $a = 0 ?: 2; // 2
            $a = array() ?: array(1); // array(1)
            $a = strlen("") ?: strlen("a"); // 1
                          ** The variable or array key must exist


Wednesday, June 1, 2011                                             4
GOTO ...
  restart:
  if (error_condition1) {
      goto error;
  }
  if (error_condition2) {
      goto restart;
  }

  error:
      report_error();
      exit;
                              My favourite 5.3 feature ;-)

Wednesday, June 1, 2011                                      5
Encryption Functions
$pwd = 'very secret';
$data = 'test 123';
// over 50 supported algorithms
foreach (openssl_get_cipher_methods() as $v) {
    // really bad iv generation
    $iv = substr(md5(time()), 0, openssl_cipher_iv_length($v));

    // encrypt
    $enc = openssl_encrypt($data, $v, $pwd, false, $iv);

    // decrypt
    $dec = openssl_decrypt($enc, $v, $pwd, false, $iv);
}




Wednesday, June 1, 2011                                           6
Double Encoding
   Prevent double encoding of html-entities via 4th
   argument to htmlspecialchars() and htmlentities()

    $foo = "bar > foo &amp; that&quot;s all";

   htmlspecialchars($foo, ENT_COMPAT, 'UTF-8');
   htmlentities($foo, ENT_COMPAT, 'UTF-8');

                          bar &gt; foo &amp;amp; that&amp;quot;s all




Wednesday, June 1, 2011                                                7
Double Encoding
   Prevent double encoding of html-entities via 4th
   argument to htmlspecialchars() and htmlentities()

    $foo = "bar > foo &amp; that&quot;s all";

   htmlspecialchars($foo, ENT_COMPAT, 'UTF-8');
   htmlentities($foo, ENT_COMPAT, 'UTF-8');

                           bar &gt; foo &amp;amp; that&amp;quot;s all
    htmlspecialchars($foo, ENT_COMPAT, 'UTF-8', false);
    htmlentities($foo, ENT_COMPAT, 'UTF-8', false);

                          bar &gt; foo &amp; that&quot;s all



Wednesday, June 1, 2011                                                 7
Date Parsing
                           October 5, 2012


      05-10-12              May 10, 2012


                           December 10, 2005




Wednesday, June 1, 2011                        8
Date Parsing
                           October 5, 2012


      05-10-12              May 10, 2012


                           December 10, 2005




Wednesday, June 1, 2011                        8
Date Parsing
                             October 5, 2012


      05-10-12                May 10, 2012


                             December 10, 2005

$date = 
date_create_from_format('y-m-d', '05-10-12');

var_dump(date_format($date, 'F d, Y'));

                          string(16) "October 12, 2005"


Wednesday, June 1, 2011                                   8
Dude, where is my code?
              PHP does a lot of magic to resolve partial file
              paths for include/require. Now you can too.


  stream_resolve_include_path("PEAR.php");




                          /usr/share/php/PEAR.php



Wednesday, June 1, 2011                                        9
session ini magic

           • Improve randomness of session id via the use of /
                  dev/urandom
                      session.entropy_file = /dev/urandom
                      session.entropy_length = 32

           • Secure your session cookies from JavaScript
                      session.use_only_cookies = 1
                      session.cookie_httponly = 1



Wednesday, June 1, 2011                                          10
mail logging
     Want to know what scripts are sending out e-mail?
     Well, now you can!

      ;; This will log every mail() call
      mail.log = /path/to/file
      mail() on [/tmp/script.php:2]: To: ilia@ilia.ws -- Headers:


       ;; Adds X-PHP-Originating-Script header
       ;; Contains UID & filename of the script
       mail.add_x_header = On
       X-PHP-Originating-Script: 1000:script.php



Wednesday, June 1, 2011                                             11
Better Hashing
            A built-in PHP mechanism for generating HMAC
            (Hash-based Message Authentication Code)
            secured hashes for many algorithms

   // 8b266369505f0c90bf193c856aa8f49dc87a759088fd31f28217e4db42a5ac4c
   echo hash_hmac('sha256', 'l337PwD', 'secretkey') , "n";

   // d82bba393cb2f5e38a4021efc30d43883b1e0a40e30d8ed1c89e7ec263023ec0
   echo hash_hmac_file('sha256', __FILE__, 'secretkey') , "n";




Wednesday, June 1, 2011                                                  12
SPL FS Tricks
                          Simple recursive directory traversal

      foreach (
        new RecursiveIteratorIterator(
          new RecursiveDirectoryIterator('.')
        ) as $file)
      {
          echo $file , "n";
      }




Wednesday, June 1, 2011                                          13
SPL FS Tricks
 Recursive directory traversal with pattern matching

        $it = new RecursiveIteratorIterator(
            new RecursiveDirectoryIterator('.')
        );
        $regx = new RegexIterator(
            $it,
            '/^.*.php$/i', // returns only matching text
            RecursiveRegexIterator::GET_MATCH
        );

        foreach ($regx as $file) {
            echo $file[0] , "n";
        }



Wednesday, June 1, 2011                                     14
igbinary
           • The awesome PHP Serializer you should use!
            • Faster
            • More Compact
                          ;; Load igbinary extension
                          extension=igbinary.so

                          ;; Use igbinary as session serializer
                          session.serialize_handler=igbinary


                                 http://github.com/igbinary


Wednesday, June 1, 2011                                           15
igbinary
      Provides functions you can use for non-session data.


     ini_set("igbinary.compact_strings", 0);
     igbinary_serialize($_SERVER);

     ini_set("igbinary.compact_strings", 1);
     igbinary_serialize($_SERVER);

     // Un-serialize
     igbinary_unserialize($x);




Wednesday, June 1, 2011                                      16
Igbinary speed test
                           Serialized Size      Speed - Serialize   Speed - Unserialize
               3100                                                                       15

               2975                                                                  11.25

               2850                                                                       7.5

               2725                                                                   3.75

               2600                                                                        0
                              Serialize      Igbinary w/Compact     Igbinary




Wednesday, June 1, 2011                                                                         17
FileInfo

                   • A reliable mechanism for identifying files
                          ‣   Not dependant on file extension
                          ‣   Can provide mime types
                          ‣   Identifies hundreds of file types




Wednesday, June 1, 2011                                          18
FileInfo How-To
 $finfo = finfo_open();
 $file = __FILE__;

 // mime description -- PHP script text
 finfo_file($finfo, $file);

 // mime type -- text/x-php
 finfo_file($finfo, $file, FILEINFO_MIME_TYPE);
  
 // mime -- text/x-php; charset=us-ascii
 finfo_file($finfo, $file, FILEINFO_MIME); 

 // mime encoding -- us-ascii
 finfo_file($finfo, $file, FILEINFO_MIME_ENCODING);




Wednesday, June 1, 2011                               19
StatGrab
                   • An system informatics extension that
                          provides information on:

              Memory               Running Processed           System Load

              CPU                  Swap Utilization            System Info

              Network              User Statistics             etc...

                                http://pecl.php.net/statgrab


Wednesday, June 1, 2011                                                      20
StatGrab
  sg_cpu_percent_usage()                 sg_cpu_totals()      (in ticks)
  Array                                  Array
  (                                      (
      [user] => 6.543484210968               [user] => 255652817
      [kernel] => 3.2332751750946            [kernel] => 126323501
      [idle] => 90.219924926758              [idle] => 3524877111
      [iowait] => 0                          [iowait] => 0
      [swap] => 0                            [swap] => 0
      [nice] => 0.0033116859849542           [nice] => 129387
      [previous_run] => 1306895319           [total] => 3906982816
  )                                          [previous_run] => 1306895319
                                         )

         sg_cpu_diff()     (in ticks)
         Array
         (
             [user] => 0 [kernel] => 1 [idle] => 1 [iowait] => 0
             [swap] => 0 [nice] => 0 [total] => 2 [previous_run] => 0
         )



Wednesday, June 1, 2011                                                     21
StatGrab
                          sg_diskio_stats()
                          Array (
                              [sda] => Array (
                                      [read] => 447667436032
                                      [written] => 1098788713472
                                      [time_frame] => 1306895319
                                  )
                          )

                          sg_diskio_stats_diff()
                          Array (
                              [sda] => Array (
                                      [read] => 0
                                      [written] => 0
                                      [time_frame] => 0
                                  )
                          )




Wednesday, June 1, 2011                                            22
StatGrab
                          sg_fs_stats()
                          Array (
                               [0] => Array (
                                       [device_name] => /dev/sda2
                                       [fs_type] => ext3
                                       [mnt_point] => /
                                       [size] => 152892084224
                                       [used] => 126607642624
                                       [avail] => 18392698880
                                       [total_inodes] => 38535168
                                       [used_inodes] => 2324584
                                       [free_inodes] => 36210584
                                       [avail_inodes] => 36210584
                                       [io_size] => 4096
                                       [block_size] => 4096
                                       [total_blocks] => 37327169
                                       [free_blocks] => 6417100
                                       [used_blocks] => 30910069
                                       [avail_blocks] => 4490405
                             )
                          )




Wednesday, June 1, 2011                                             23
StatGrab

                 sg_general_stats()
                 Array
                 (
                     [os_name] => Linux
                     [os_release] => 2.6.34-gentoo-r1
                     [os_version] => #1 SMP Tue Aug 3 13:42:41 EDT 2010
                     [platform] => x86_64
                     [hostname] => dev.linux
                     [uptime] => 9856588
                 )




Wednesday, June 1, 2011                                                   24
StatGrab
                                  sg_swap_stats()
      sg_load_stats()             Array
      Array
                                  (
      (
                                      [total] => 2097438720
          [min1] => 0.48
                                      [free] => 556400640
          [min5] => 0.46
                                      [used] => 1541038080
          [min15] => 0.45
                                  )
      )

                                  sg_process_count()
      sg_memory_stats()           Array
      Array
                                  (
      (
                                      [total] => 324
          [total] => 5272272896
                                      [running] => 1
          [free] => 978161664
                                      [sleeping] => 322
          [used] => 4294111232
                                      [stopped] => 0
          [cache] => 2546839552
                                      [zombie] => 1
      )
                                  )




Wednesday, June 1, 2011                                       25
StatGrab
                          sg_network_stats()
                          Array
                          (
                              [eth1] => Array
                                  (
                                      [sent] => 512193380346
                                      [received] => 88677061172
                                      [packets_received] => 481445357
                                      [packets_transmitted] => 527259007
                                      [receive_errors] => 0
                                      [transmit_errors] => 0
                                      [collisions] => 0
                                      [time_frame] => 1306895319
                                  )
                          )




Wednesday, June 1, 2011                                                    26
StatGrab
                          sg_network_stats_diff()
                          Array
                          (
                                  [eth1] => Array
                                    (
                                        [sent] => 211456
                                        [received] => 33257
                                        [packets_received] => 228
                                        [packets_transmitted] => 231
                                        [receive_errors] => 0
                                        [transmit_errors] => 0
                                        [collisions] => 0
                                        [time_frame] => 5
                                    )
                          )




Wednesday, June 1, 2011                                                27
StatGrab
         sg_process_stats()
         Array
         (
             [87] => Array
                 (
                     [process_name] => postgres
                     [proc_title] => postgres: autovacuum launcher process
                     [pid] => 3650
                     [parent_pid] => 3643
                     [leader_pid] => 3650
                     [uid] => 70
                     [gid] => 70
                     [euid] => 70
                     [egid] => 70
                     [size] => 65830912
                     [size_in_mem] => 823296
                     [time_spent] => 119
                     [cpu_percent] => 0.0012106672247309
                     [nice] => 0
                     [state] => 1
                 )
         )




Wednesday, June 1, 2011                                                      28
MailParse

                   • A very good mechanism for parsing
                          complex e-mails
                   • Does a lot of the legwork for you
                   • Stable & Fast
                               http://pecl.php.net/mailparse



Wednesday, June 1, 2011                                        29
MailParse
   $msg = file_get_contents("php://stdin");

   $mime = mailparse_msg_create();
   if (!mailparse_msg_parse($mime, $msg)) {
     exit("could not parse email!n");
   }

   if (!($msg_info = mailparse_msg_get_part_data($mime))) {
     exit("could not get message info!n");
   } // $msg_info['headers'] is the headers associated array

   $structure = mailparse_msg_get_structure($mime);




Wednesday, June 1, 2011                                        30
$msg_info[‘headers’]
    Array
    (
       [return-path] => <apache@sender.com>
       [envelope-to] => ilia@ilia.ws
       [delivery-date] => Mon, 20 Jul 2009 13:15:32 -0400
       [received] => Array
         (
            [0] => from attendant.sender.net ([208.68.18.236] helo=hydrogen.sender.net) by ilia.ws with
    esmtp (Exim 4.69) (envelope-from <apache@sender.com>) id 1MSwSa-0006lY-4O for ilia@ilia.ws; Mon,
    20 Jul 2009 13:15:32 -0400
            [1] => from hydrogen.sender.net (hydrogen.sender.net [127.0.0.1]) by hydrogen.sender.net
    (8.13.8/8.13.8) with ESMTP id n6KHFQ1g022841 for <ilia@ilia.ws>; Mon, 20 Jul 2009 11:15:26 -0600
            [2] => (from apache@localhost) by hydrogen.sender.net (8.13.8/8.13.8/Submit) id
    n6KHFQR4022840; Mon, 20 Jul 2009 11:15:26 -0600
         )

        [date] => Mon, 20 Jul 2009 11:15:26 -0600
        [message-id] => <200907201715.n6KHFQR4022840@hydrogen.sender.net>
        [to] => ilia@ilia.ws
        [subject] => 2027197
        [from] => from@sender.com
        [mime-version] => 1.0
        [content-type] => multipart/mixed; boundary="______b7bfcc06f00337de46276f92b6833d5c++++++"
    )




Wednesday, June 1, 2011                                                                                   31
MailParse
   // go through components of the e-mail
   $body = ''; $atms = array();
   foreach ($structure as $element) {
     $part_mime = mailparse_msg_get_part($mime, $element);
     $part = mailparse_msg_get_part_data($part_mime);

     if (!$part) continue;

     $part_content = substr($msg,
                     $part['starting-pos-body'],
                     $part['ending-pos-body'] - 
                        $part['starting-pos-body']);




Wednesday, June 1, 2011                                      32
MailParse

if ($part['transfer-encoding'] == 'base64') {
  $part_content = base64_decode($part_content);
} else if ($part['transfer-encoding'] 
                       == 'quoted-printable') {
  $part_content = quoted_printable_decode($part_content);
}




Wednesday, June 1, 2011                                 33
MailParse

 if ($part['content-type'] == 'text/plain') {
   $body .= $part_content;
 } elseif ($part['content-type'] == 'text/html') {
   $body .= strip_tags($part_content);
 } elseif (!empty($part_info['content-disposition'])
     && $part['content-disposition'] == 'attachment'
 ) {
   $atms[] = array('headers' => $part, 'content' => $part_content);
 } else { //inline attachments
   $atms[] = array('headers' => $part, 'content' => $part_content);
 }




Wednesday, June 1, 2011                                               34
MailParse
                          $to = '"Ilia A." <ilia@ilia.ws>, 
                          Test <test@test.com>, 
                          foo@bar.com';

                          print_r(
                           mailparse_rfc822_parse_addresses($to)
                          );

      Array
      (
        [0] => Array                     [1] => Array                      [2] => Array
          (                                (                                 (
             [display] => Ilia A.             [display] => Test                 [display] => foo@bar.com
             [address] => ilia@ilia.ws        [address] => test@test.com        [address] => foo@bar.com
             [is_group] =>                    [is_group] =>                     [is_group] =>
          )                                )                                 )
      )




Wednesday, June 1, 2011                                                                                    35
PHP-Excel

                • An interface to LibXL library
                 • Allows generation of Excel Biff8 & XML
                          documents
                      • Can parse Excel Biff (5-8) and XML
                          documents
                      • Wickedly FAST! 200k rows in < 1 second
                           https://github.com/iliaal/php_excel


Wednesday, June 1, 2011                                          36
Creating Excel Docs
  $x = new ExcelBook();
      
  $s = $x->addSheet("Sheet 1");
  $s->write(1, 1, 'Test');
  $s->write(2, 2, 123);

  $x->save("file.xls");




Wednesday, June 1, 2011                    37
Reading Excel Docs
    $x = new ExcelBook();

    $x->loadFile("file.xls");

    $s = $x->getSheet();

    for ($i = 0, $e = $s->lastRow(); $i < $e; $i++) {
        print_r(array_filter($s->readRow($i)));
    }

                              Array ( [1] => Test)

                              Array ( [2] => 123 )



Wednesday, June 1, 2011                                 38
xhprof
           • Light weight PHP profiler designed for in
                  production use.
                 • Aggregate run data
                 • Web interface
                 • In-Production “sampling” mode
                           http://pecl.php.net/package/xhprof
                          http://github.com/preinheimer/xhprof


Wednesday, June 1, 2011                                          39
Profiling
   ;; Pre-pended to every PHP script (init)
   auto_prepend_file = /xhprof/external/header.php

        include_once __DIR__ . '/xhprof_lib/config.php');
        include_once __DIR__ . '/xhprof_lib/utils/xhprof_lib.php';
        include_once __DIR__ . '/xhprof_lib/utils/xhprof_runs.php';
        xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);


   ;; Appended to every PHP script (store)
   auto_append_file = /xhprof/external/footer.php

     $xhprof_data = xhprof_disable();
     $xhprof_runs = new XHProfRuns_Default();
     $xhprof_runs->save_run($xhprof_data, 'AppName', null, $_xhprof);




Wednesday, June 1, 2011                                                 40
Profile Output




Wednesday, June 1, 2011                   41
Profile Output




Wednesday, June 1, 2011                   42
Profile Output




Wednesday, June 1, 2011                   43
Profile Output




Wednesday, June 1, 2011                   44
Slides will be available
                              at http://ilia.ws

                          Please give me your feedback
                            http://joind.in/3512


                              Ilia Alshanetsky
                                    @iliaa




Wednesday, June 1, 2011                                  45

More Related Content

What's hot

The state of Symfony2 - SymfonyDay 2010
The state of Symfony2 - SymfonyDay 2010The state of Symfony2 - SymfonyDay 2010
The state of Symfony2 - SymfonyDay 2010Fabien Potencier
 
Php on the desktop and php gtk2
Php on the desktop and php gtk2Php on the desktop and php gtk2
Php on the desktop and php gtk2Elizabeth Smith
 
New Symfony Tips & Tricks (SymfonyCon Paris 2015)
New Symfony Tips & Tricks (SymfonyCon Paris 2015)New Symfony Tips & Tricks (SymfonyCon Paris 2015)
New Symfony Tips & Tricks (SymfonyCon Paris 2015)Javier Eguiluz
 
Writing and using php streams and sockets tek11
Writing and using php streams and sockets   tek11Writing and using php streams and sockets   tek11
Writing and using php streams and sockets tek11Elizabeth Smith
 
Looping the Loop with SPL Iterators
Looping the Loop with SPL IteratorsLooping the Loop with SPL Iterators
Looping the Loop with SPL IteratorsMark Baker
 
November Camp - Spec BDD with PHPSpec 2
November Camp - Spec BDD with PHPSpec 2November Camp - Spec BDD with PHPSpec 2
November Camp - Spec BDD with PHPSpec 2Kacper Gunia
 
Php on the Web and Desktop
Php on the Web and DesktopPhp on the Web and Desktop
Php on the Web and DesktopElizabeth Smith
 
Typed Properties and more: What's coming in PHP 7.4?
Typed Properties and more: What's coming in PHP 7.4?Typed Properties and more: What's coming in PHP 7.4?
Typed Properties and more: What's coming in PHP 7.4?Nikita Popov
 
Functional Structures in PHP
Functional Structures in PHPFunctional Structures in PHP
Functional Structures in PHPMarcello Duarte
 
Your code sucks, let's fix it
Your code sucks, let's fix itYour code sucks, let's fix it
Your code sucks, let's fix itRafael Dohms
 
SADI in Perl - Protege Plugin Tutorial (fixed Aug 24, 2011)
SADI in Perl - Protege Plugin Tutorial (fixed Aug 24, 2011)SADI in Perl - Protege Plugin Tutorial (fixed Aug 24, 2011)
SADI in Perl - Protege Plugin Tutorial (fixed Aug 24, 2011)Mark Wilkinson
 
Speed up your developments with Symfony2
Speed up your developments with Symfony2Speed up your developments with Symfony2
Speed up your developments with Symfony2Hugo Hamon
 
News of the Symfony2 World
News of the Symfony2 WorldNews of the Symfony2 World
News of the Symfony2 WorldFabien Potencier
 
PHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with thisPHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with thisIan Macali
 

What's hot (20)

The state of Symfony2 - SymfonyDay 2010
The state of Symfony2 - SymfonyDay 2010The state of Symfony2 - SymfonyDay 2010
The state of Symfony2 - SymfonyDay 2010
 
Spl in the wild
Spl in the wildSpl in the wild
Spl in the wild
 
Php on the desktop and php gtk2
Php on the desktop and php gtk2Php on the desktop and php gtk2
Php on the desktop and php gtk2
 
Zero to SOLID
Zero to SOLIDZero to SOLID
Zero to SOLID
 
New in php 7
New in php 7New in php 7
New in php 7
 
Twig tips and tricks
Twig tips and tricksTwig tips and tricks
Twig tips and tricks
 
Symfony2 - WebExpo 2010
Symfony2 - WebExpo 2010Symfony2 - WebExpo 2010
Symfony2 - WebExpo 2010
 
New Symfony Tips & Tricks (SymfonyCon Paris 2015)
New Symfony Tips & Tricks (SymfonyCon Paris 2015)New Symfony Tips & Tricks (SymfonyCon Paris 2015)
New Symfony Tips & Tricks (SymfonyCon Paris 2015)
 
Writing and using php streams and sockets tek11
Writing and using php streams and sockets   tek11Writing and using php streams and sockets   tek11
Writing and using php streams and sockets tek11
 
Looping the Loop with SPL Iterators
Looping the Loop with SPL IteratorsLooping the Loop with SPL Iterators
Looping the Loop with SPL Iterators
 
Lithium Best
Lithium Best Lithium Best
Lithium Best
 
November Camp - Spec BDD with PHPSpec 2
November Camp - Spec BDD with PHPSpec 2November Camp - Spec BDD with PHPSpec 2
November Camp - Spec BDD with PHPSpec 2
 
Php on the Web and Desktop
Php on the Web and DesktopPhp on the Web and Desktop
Php on the Web and Desktop
 
Typed Properties and more: What's coming in PHP 7.4?
Typed Properties and more: What's coming in PHP 7.4?Typed Properties and more: What's coming in PHP 7.4?
Typed Properties and more: What's coming in PHP 7.4?
 
Functional Structures in PHP
Functional Structures in PHPFunctional Structures in PHP
Functional Structures in PHP
 
Your code sucks, let's fix it
Your code sucks, let's fix itYour code sucks, let's fix it
Your code sucks, let's fix it
 
SADI in Perl - Protege Plugin Tutorial (fixed Aug 24, 2011)
SADI in Perl - Protege Plugin Tutorial (fixed Aug 24, 2011)SADI in Perl - Protege Plugin Tutorial (fixed Aug 24, 2011)
SADI in Perl - Protege Plugin Tutorial (fixed Aug 24, 2011)
 
Speed up your developments with Symfony2
Speed up your developments with Symfony2Speed up your developments with Symfony2
Speed up your developments with Symfony2
 
News of the Symfony2 World
News of the Symfony2 WorldNews of the Symfony2 World
News of the Symfony2 World
 
PHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with thisPHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with this
 

Viewers also liked

international PHP2011_Kore Nordmann_Designing multilingual applications
international PHP2011_Kore Nordmann_Designing multilingual applications international PHP2011_Kore Nordmann_Designing multilingual applications
international PHP2011_Kore Nordmann_Designing multilingual applications smueller_sandsmedia
 
international PHP2011_Jordi Boggiano_PHP Reset
international PHP2011_Jordi Boggiano_PHP Resetinternational PHP2011_Jordi Boggiano_PHP Reset
international PHP2011_Jordi Boggiano_PHP Resetsmueller_sandsmedia
 
webinale2011_Dirk Jesse:Responsive Web Design oder "Unwissenheit ist ein Segen"
webinale2011_Dirk Jesse:Responsive Web Design oder "Unwissenheit ist ein Segen"webinale2011_Dirk Jesse:Responsive Web Design oder "Unwissenheit ist ein Segen"
webinale2011_Dirk Jesse:Responsive Web Design oder "Unwissenheit ist ein Segen"smueller_sandsmedia
 
international PHP2011_Bastian Hofmann_Mashing up java script
international PHP2011_Bastian Hofmann_Mashing up java scriptinternational PHP2011_Bastian Hofmann_Mashing up java script
international PHP2011_Bastian Hofmann_Mashing up java scriptsmueller_sandsmedia
 
international PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secretsinternational PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secretssmueller_sandsmedia
 
international PHP2011_Bastian Feder_The most unknown Parts of PHPUnit
international PHP2011_Bastian Feder_The most unknown Parts of PHPUnitinternational PHP2011_Bastian Feder_The most unknown Parts of PHPUnit
international PHP2011_Bastian Feder_The most unknown Parts of PHPUnitsmueller_sandsmedia
 
webinale2011_Kai Radusch_Landingpage-Optimierung für Adwords-Kampagnen
webinale2011_Kai Radusch_Landingpage-Optimierung für Adwords-Kampagnenwebinale2011_Kai Radusch_Landingpage-Optimierung für Adwords-Kampagnen
webinale2011_Kai Radusch_Landingpage-Optimierung für Adwords-Kampagnensmueller_sandsmedia
 

Viewers also liked (8)

international PHP2011_Kore Nordmann_Designing multilingual applications
international PHP2011_Kore Nordmann_Designing multilingual applications international PHP2011_Kore Nordmann_Designing multilingual applications
international PHP2011_Kore Nordmann_Designing multilingual applications
 
international PHP2011_Jordi Boggiano_PHP Reset
international PHP2011_Jordi Boggiano_PHP Resetinternational PHP2011_Jordi Boggiano_PHP Reset
international PHP2011_Jordi Boggiano_PHP Reset
 
webinale2011_Dirk Jesse:Responsive Web Design oder "Unwissenheit ist ein Segen"
webinale2011_Dirk Jesse:Responsive Web Design oder "Unwissenheit ist ein Segen"webinale2011_Dirk Jesse:Responsive Web Design oder "Unwissenheit ist ein Segen"
webinale2011_Dirk Jesse:Responsive Web Design oder "Unwissenheit ist ein Segen"
 
Golf
GolfGolf
Golf
 
international PHP2011_Bastian Hofmann_Mashing up java script
international PHP2011_Bastian Hofmann_Mashing up java scriptinternational PHP2011_Bastian Hofmann_Mashing up java script
international PHP2011_Bastian Hofmann_Mashing up java script
 
international PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secretsinternational PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secrets
 
international PHP2011_Bastian Feder_The most unknown Parts of PHPUnit
international PHP2011_Bastian Feder_The most unknown Parts of PHPUnitinternational PHP2011_Bastian Feder_The most unknown Parts of PHPUnit
international PHP2011_Bastian Feder_The most unknown Parts of PHPUnit
 
webinale2011_Kai Radusch_Landingpage-Optimierung für Adwords-Kampagnen
webinale2011_Kai Radusch_Landingpage-Optimierung für Adwords-Kampagnenwebinale2011_Kai Radusch_Landingpage-Optimierung für Adwords-Kampagnen
webinale2011_Kai Radusch_Landingpage-Optimierung für Adwords-Kampagnen
 

Similar to international PHP2011_ilia alshanetsky_Hidden Features of PHP

Conquistando el Servidor con Node.JS
Conquistando el Servidor con Node.JSConquistando el Servidor con Node.JS
Conquistando el Servidor con Node.JSCaridy Patino
 
The Solar Framework for PHP
The Solar Framework for PHPThe Solar Framework for PHP
The Solar Framework for PHPConFoo
 
node.js for front-end developers
node.js for front-end developersnode.js for front-end developers
node.js for front-end developersGarann Means
 
Javascript - How to avoid the bad parts
Javascript - How to avoid the bad partsJavascript - How to avoid the bad parts
Javascript - How to avoid the bad partsMikko Ohtamaa
 
The Fast, The Slow and the Lazy
The Fast, The Slow and the LazyThe Fast, The Slow and the Lazy
The Fast, The Slow and the LazyMaurício Linhares
 
Barcelona 2010 hidden_features
Barcelona 2010 hidden_featuresBarcelona 2010 hidden_features
Barcelona 2010 hidden_featuresAnis Berejeb
 
The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016
The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016
The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016Codemotion
 
Unit Testing in SilverStripe
Unit Testing in SilverStripeUnit Testing in SilverStripe
Unit Testing in SilverStripeIngo Schommer
 
Deploying on the cutting edge
Deploying on the cutting edgeDeploying on the cutting edge
Deploying on the cutting edgeericholscher
 
Mike hostetler - jQuery knowledge append to you
Mike hostetler - jQuery knowledge append to youMike hostetler - jQuery knowledge append to you
Mike hostetler - jQuery knowledge append to youStarTech Conference
 
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.4Wim Godden
 
Shell Scripts for Oracle Database and E-Business Suite.pdf
Shell Scripts for Oracle Database and E-Business Suite.pdfShell Scripts for Oracle Database and E-Business Suite.pdf
Shell Scripts for Oracle Database and E-Business Suite.pdfAkhashRamnath
 
What To Expect From PHP7
What To Expect From PHP7What To Expect From PHP7
What To Expect From PHP7Codemotion
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHPBradley Holt
 

Similar to international PHP2011_ilia alshanetsky_Hidden Features of PHP (20)

Caridy patino - node-js
Caridy patino - node-jsCaridy patino - node-js
Caridy patino - node-js
 
Conquistando el Servidor con Node.JS
Conquistando el Servidor con Node.JSConquistando el Servidor con Node.JS
Conquistando el Servidor con Node.JS
 
The Solar Framework for PHP
The Solar Framework for PHPThe Solar Framework for PHP
The Solar Framework for PHP
 
node.js for front-end developers
node.js for front-end developersnode.js for front-end developers
node.js for front-end developers
 
Javascript - How to avoid the bad parts
Javascript - How to avoid the bad partsJavascript - How to avoid the bad parts
Javascript - How to avoid the bad parts
 
The Fast, The Slow and the Lazy
The Fast, The Slow and the LazyThe Fast, The Slow and the Lazy
The Fast, The Slow and the Lazy
 
55j7
55j755j7
55j7
 
Barcelona 2010 hidden_features
Barcelona 2010 hidden_featuresBarcelona 2010 hidden_features
Barcelona 2010 hidden_features
 
The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016
The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016
The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016
 
The new features of PHP 7
The new features of PHP 7The new features of PHP 7
The new features of PHP 7
 
Unit Testing in SilverStripe
Unit Testing in SilverStripeUnit Testing in SilverStripe
Unit Testing in SilverStripe
 
Deploying on the cutting edge
Deploying on the cutting edgeDeploying on the cutting edge
Deploying on the cutting edge
 
Apc Memcached Confoo 2011
Apc Memcached Confoo 2011Apc Memcached Confoo 2011
Apc Memcached Confoo 2011
 
PHP for hacks
PHP for hacksPHP for hacks
PHP for hacks
 
Mike hostetler - jQuery knowledge append to you
Mike hostetler - jQuery knowledge append to youMike hostetler - jQuery knowledge append to you
Mike hostetler - jQuery knowledge append to you
 
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
 
Shell Scripts for Oracle Database and E-Business Suite.pdf
Shell Scripts for Oracle Database and E-Business Suite.pdfShell Scripts for Oracle Database and E-Business Suite.pdf
Shell Scripts for Oracle Database and E-Business Suite.pdf
 
What To Expect From PHP7
What To Expect From PHP7What To Expect From PHP7
What To Expect From PHP7
 
Php hacku
Php hackuPhp hacku
Php hacku
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 

More from smueller_sandsmedia

webinale 2011_Gabriel Yoran_Der Schlüssel zum erfolg: Besser aussehen, als ma...
webinale 2011_Gabriel Yoran_Der Schlüssel zum erfolg: Besser aussehen, als ma...webinale 2011_Gabriel Yoran_Der Schlüssel zum erfolg: Besser aussehen, als ma...
webinale 2011_Gabriel Yoran_Der Schlüssel zum erfolg: Besser aussehen, als ma...smueller_sandsmedia
 
international PHP2011_Henning Wolf_ Mit Retrospektivenzu erfolgreichen Projekten
international PHP2011_Henning Wolf_ Mit Retrospektivenzu erfolgreichen Projekteninternational PHP2011_Henning Wolf_ Mit Retrospektivenzu erfolgreichen Projekten
international PHP2011_Henning Wolf_ Mit Retrospektivenzu erfolgreichen Projektensmueller_sandsmedia
 
international PHP2011_Kore Nordmann_Tobias Schlitt_Modular Application Archit...
international PHP2011_Kore Nordmann_Tobias Schlitt_Modular Application Archit...international PHP2011_Kore Nordmann_Tobias Schlitt_Modular Application Archit...
international PHP2011_Kore Nordmann_Tobias Schlitt_Modular Application Archit...smueller_sandsmedia
 
webinale2011_Chris Mills_Brave new world of HTML5Html5
webinale2011_Chris Mills_Brave new world of HTML5Html5webinale2011_Chris Mills_Brave new world of HTML5Html5
webinale2011_Chris Mills_Brave new world of HTML5Html5smueller_sandsmedia
 
international PHP2011_J.Hartmann_DevOps für PHP
international PHP2011_J.Hartmann_DevOps für PHPinternational PHP2011_J.Hartmann_DevOps für PHP
international PHP2011_J.Hartmann_DevOps für PHPsmueller_sandsmedia
 
webinale2011_Daniel Höpfner_Förderprogramme für dummies
webinale2011_Daniel Höpfner_Förderprogramme für dummieswebinale2011_Daniel Höpfner_Förderprogramme für dummies
webinale2011_Daniel Höpfner_Förderprogramme für dummiessmueller_sandsmedia
 

More from smueller_sandsmedia (6)

webinale 2011_Gabriel Yoran_Der Schlüssel zum erfolg: Besser aussehen, als ma...
webinale 2011_Gabriel Yoran_Der Schlüssel zum erfolg: Besser aussehen, als ma...webinale 2011_Gabriel Yoran_Der Schlüssel zum erfolg: Besser aussehen, als ma...
webinale 2011_Gabriel Yoran_Der Schlüssel zum erfolg: Besser aussehen, als ma...
 
international PHP2011_Henning Wolf_ Mit Retrospektivenzu erfolgreichen Projekten
international PHP2011_Henning Wolf_ Mit Retrospektivenzu erfolgreichen Projekteninternational PHP2011_Henning Wolf_ Mit Retrospektivenzu erfolgreichen Projekten
international PHP2011_Henning Wolf_ Mit Retrospektivenzu erfolgreichen Projekten
 
international PHP2011_Kore Nordmann_Tobias Schlitt_Modular Application Archit...
international PHP2011_Kore Nordmann_Tobias Schlitt_Modular Application Archit...international PHP2011_Kore Nordmann_Tobias Schlitt_Modular Application Archit...
international PHP2011_Kore Nordmann_Tobias Schlitt_Modular Application Archit...
 
webinale2011_Chris Mills_Brave new world of HTML5Html5
webinale2011_Chris Mills_Brave new world of HTML5Html5webinale2011_Chris Mills_Brave new world of HTML5Html5
webinale2011_Chris Mills_Brave new world of HTML5Html5
 
international PHP2011_J.Hartmann_DevOps für PHP
international PHP2011_J.Hartmann_DevOps für PHPinternational PHP2011_J.Hartmann_DevOps für PHP
international PHP2011_J.Hartmann_DevOps für PHP
 
webinale2011_Daniel Höpfner_Förderprogramme für dummies
webinale2011_Daniel Höpfner_Förderprogramme für dummieswebinale2011_Daniel Höpfner_Förderprogramme für dummies
webinale2011_Daniel Höpfner_Förderprogramme für dummies
 

Recently uploaded

What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 

Recently uploaded (20)

What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 

international PHP2011_ilia alshanetsky_Hidden Features of PHP

  • 1. Ilia Alshanetsky | Centah Inc. Hidden Features of PHP
  • 2. Hidden Features of PHP International PHP Conference 2011 Ilia Alshanetsky @iliaa Wednesday, June 1, 2011 1
  • 3. root@foo $: whois ilia PHP: Core Developer Since 2001 Release Manager of 4.3, 5.1 and 5.2 branches Author of a “few” extensions Work: CIO at Centah Inc. Hobbies: Photography, Biking Dev. Interests: Performance & Security Wednesday, June 1, 2011 2
  • 4. __DIR__ Magic The __DIR__ constant is a simple and fast solution to the “where am i?” question for PHP scripts. ilia@s3 /tmp $ php a.php <?php echo __DIR__; /tmp Wednesday, June 1, 2011 3
  • 5. We Perl Allows quick retrieval of a non-empty value from 2 values and/or expressions $a = true ?: false; // true $a = false ?: true; // true $a = "" ?: 1; // 1 $a = 0 ?: 2; // 2 $a = array() ?: array(1); // array(1) $a = strlen("") ?: strlen("a"); // 1 ** The variable or array key must exist Wednesday, June 1, 2011 4
  • 6. GOTO ... restart: if (error_condition1) {     goto error; } if (error_condition2) {     goto restart; } error:     report_error();     exit; My favourite 5.3 feature ;-) Wednesday, June 1, 2011 5
  • 8. Double Encoding Prevent double encoding of html-entities via 4th argument to htmlspecialchars() and htmlentities() $foo = "bar > foo &amp; that&quot;s all"; htmlspecialchars($foo, ENT_COMPAT, 'UTF-8'); htmlentities($foo, ENT_COMPAT, 'UTF-8'); bar &gt; foo &amp;amp; that&amp;quot;s all Wednesday, June 1, 2011 7
  • 9. Double Encoding Prevent double encoding of html-entities via 4th argument to htmlspecialchars() and htmlentities() $foo = "bar > foo &amp; that&quot;s all"; htmlspecialchars($foo, ENT_COMPAT, 'UTF-8'); htmlentities($foo, ENT_COMPAT, 'UTF-8'); bar &gt; foo &amp;amp; that&amp;quot;s all htmlspecialchars($foo, ENT_COMPAT, 'UTF-8', false); htmlentities($foo, ENT_COMPAT, 'UTF-8', false); bar &gt; foo &amp; that&quot;s all Wednesday, June 1, 2011 7
  • 10. Date Parsing October 5, 2012 05-10-12 May 10, 2012 December 10, 2005 Wednesday, June 1, 2011 8
  • 11. Date Parsing October 5, 2012 05-10-12 May 10, 2012 December 10, 2005 Wednesday, June 1, 2011 8
  • 12. Date Parsing October 5, 2012 05-10-12 May 10, 2012 December 10, 2005 $date =  date_create_from_format('y-m-d', '05-10-12'); var_dump(date_format($date, 'F d, Y')); string(16) "October 12, 2005" Wednesday, June 1, 2011 8
  • 13. Dude, where is my code? PHP does a lot of magic to resolve partial file paths for include/require. Now you can too. stream_resolve_include_path("PEAR.php"); /usr/share/php/PEAR.php Wednesday, June 1, 2011 9
  • 14. session ini magic • Improve randomness of session id via the use of / dev/urandom session.entropy_file = /dev/urandom session.entropy_length = 32 • Secure your session cookies from JavaScript session.use_only_cookies = 1 session.cookie_httponly = 1 Wednesday, June 1, 2011 10
  • 15. mail logging Want to know what scripts are sending out e-mail? Well, now you can! ;; This will log every mail() call mail.log = /path/to/file mail() on [/tmp/script.php:2]: To: ilia@ilia.ws -- Headers: ;; Adds X-PHP-Originating-Script header ;; Contains UID & filename of the script mail.add_x_header = On X-PHP-Originating-Script: 1000:script.php Wednesday, June 1, 2011 11
  • 16. Better Hashing A built-in PHP mechanism for generating HMAC (Hash-based Message Authentication Code) secured hashes for many algorithms // 8b266369505f0c90bf193c856aa8f49dc87a759088fd31f28217e4db42a5ac4c echo hash_hmac('sha256', 'l337PwD', 'secretkey') , "n"; // d82bba393cb2f5e38a4021efc30d43883b1e0a40e30d8ed1c89e7ec263023ec0 echo hash_hmac_file('sha256', __FILE__, 'secretkey') , "n"; Wednesday, June 1, 2011 12
  • 17. SPL FS Tricks Simple recursive directory traversal foreach ( new RecursiveIteratorIterator( new RecursiveDirectoryIterator('.') ) as $file) {     echo $file , "n"; } Wednesday, June 1, 2011 13
  • 18. SPL FS Tricks Recursive directory traversal with pattern matching $it = new RecursiveIteratorIterator(     new RecursiveDirectoryIterator('.') ); $regx = new RegexIterator( $it, '/^.*.php$/i', // returns only matching text RecursiveRegexIterator::GET_MATCH ); foreach ($regx as $file) {     echo $file[0] , "n"; } Wednesday, June 1, 2011 14
  • 19. igbinary • The awesome PHP Serializer you should use! • Faster • More Compact ;; Load igbinary extension extension=igbinary.so ;; Use igbinary as session serializer session.serialize_handler=igbinary http://github.com/igbinary Wednesday, June 1, 2011 15
  • 20. igbinary Provides functions you can use for non-session data. ini_set("igbinary.compact_strings", 0); igbinary_serialize($_SERVER); ini_set("igbinary.compact_strings", 1); igbinary_serialize($_SERVER); // Un-serialize igbinary_unserialize($x); Wednesday, June 1, 2011 16
  • 21. Igbinary speed test Serialized Size Speed - Serialize Speed - Unserialize 3100 15 2975 11.25 2850 7.5 2725 3.75 2600 0 Serialize Igbinary w/Compact Igbinary Wednesday, June 1, 2011 17
  • 22. FileInfo • A reliable mechanism for identifying files ‣ Not dependant on file extension ‣ Can provide mime types ‣ Identifies hundreds of file types Wednesday, June 1, 2011 18
  • 23. FileInfo How-To $finfo = finfo_open(); $file = __FILE__; // mime description -- PHP script text finfo_file($finfo, $file); // mime type -- text/x-php finfo_file($finfo, $file, FILEINFO_MIME_TYPE);   // mime -- text/x-php; charset=us-ascii finfo_file($finfo, $file, FILEINFO_MIME);  // mime encoding -- us-ascii finfo_file($finfo, $file, FILEINFO_MIME_ENCODING); Wednesday, June 1, 2011 19
  • 24. StatGrab • An system informatics extension that provides information on: Memory Running Processed System Load CPU Swap Utilization System Info Network User Statistics etc... http://pecl.php.net/statgrab Wednesday, June 1, 2011 20
  • 25. StatGrab sg_cpu_percent_usage() sg_cpu_totals() (in ticks) Array Array ( ( [user] => 6.543484210968 [user] => 255652817 [kernel] => 3.2332751750946 [kernel] => 126323501 [idle] => 90.219924926758 [idle] => 3524877111 [iowait] => 0 [iowait] => 0 [swap] => 0 [swap] => 0 [nice] => 0.0033116859849542 [nice] => 129387 [previous_run] => 1306895319 [total] => 3906982816 ) [previous_run] => 1306895319 ) sg_cpu_diff() (in ticks) Array ( [user] => 0 [kernel] => 1 [idle] => 1 [iowait] => 0 [swap] => 0 [nice] => 0 [total] => 2 [previous_run] => 0 ) Wednesday, June 1, 2011 21
  • 26. StatGrab sg_diskio_stats() Array ( [sda] => Array ( [read] => 447667436032 [written] => 1098788713472 [time_frame] => 1306895319 ) ) sg_diskio_stats_diff() Array ( [sda] => Array ( [read] => 0 [written] => 0 [time_frame] => 0 ) ) Wednesday, June 1, 2011 22
  • 27. StatGrab sg_fs_stats() Array ( [0] => Array ( [device_name] => /dev/sda2 [fs_type] => ext3 [mnt_point] => / [size] => 152892084224 [used] => 126607642624 [avail] => 18392698880 [total_inodes] => 38535168 [used_inodes] => 2324584 [free_inodes] => 36210584 [avail_inodes] => 36210584 [io_size] => 4096 [block_size] => 4096 [total_blocks] => 37327169 [free_blocks] => 6417100 [used_blocks] => 30910069 [avail_blocks] => 4490405 ) ) Wednesday, June 1, 2011 23
  • 28. StatGrab sg_general_stats() Array ( [os_name] => Linux [os_release] => 2.6.34-gentoo-r1 [os_version] => #1 SMP Tue Aug 3 13:42:41 EDT 2010 [platform] => x86_64 [hostname] => dev.linux [uptime] => 9856588 ) Wednesday, June 1, 2011 24
  • 29. StatGrab sg_swap_stats() sg_load_stats() Array Array ( ( [total] => 2097438720 [min1] => 0.48 [free] => 556400640 [min5] => 0.46 [used] => 1541038080 [min15] => 0.45 ) ) sg_process_count() sg_memory_stats() Array Array ( ( [total] => 324 [total] => 5272272896 [running] => 1 [free] => 978161664 [sleeping] => 322 [used] => 4294111232 [stopped] => 0 [cache] => 2546839552 [zombie] => 1 ) ) Wednesday, June 1, 2011 25
  • 30. StatGrab sg_network_stats() Array ( [eth1] => Array ( [sent] => 512193380346 [received] => 88677061172 [packets_received] => 481445357 [packets_transmitted] => 527259007 [receive_errors] => 0 [transmit_errors] => 0 [collisions] => 0 [time_frame] => 1306895319 ) ) Wednesday, June 1, 2011 26
  • 31. StatGrab sg_network_stats_diff() Array ( [eth1] => Array ( [sent] => 211456 [received] => 33257 [packets_received] => 228 [packets_transmitted] => 231 [receive_errors] => 0 [transmit_errors] => 0 [collisions] => 0 [time_frame] => 5 ) ) Wednesday, June 1, 2011 27
  • 32. StatGrab sg_process_stats() Array ( [87] => Array ( [process_name] => postgres [proc_title] => postgres: autovacuum launcher process [pid] => 3650 [parent_pid] => 3643 [leader_pid] => 3650 [uid] => 70 [gid] => 70 [euid] => 70 [egid] => 70 [size] => 65830912 [size_in_mem] => 823296 [time_spent] => 119 [cpu_percent] => 0.0012106672247309 [nice] => 0 [state] => 1 ) ) Wednesday, June 1, 2011 28
  • 33. MailParse • A very good mechanism for parsing complex e-mails • Does a lot of the legwork for you • Stable & Fast http://pecl.php.net/mailparse Wednesday, June 1, 2011 29
  • 34. MailParse $msg = file_get_contents("php://stdin"); $mime = mailparse_msg_create(); if (!mailparse_msg_parse($mime, $msg)) {   exit("could not parse email!n"); } if (!($msg_info = mailparse_msg_get_part_data($mime))) {   exit("could not get message info!n"); } // $msg_info['headers'] is the headers associated array $structure = mailparse_msg_get_structure($mime); Wednesday, June 1, 2011 30
  • 35. $msg_info[‘headers’] Array ( [return-path] => <apache@sender.com> [envelope-to] => ilia@ilia.ws [delivery-date] => Mon, 20 Jul 2009 13:15:32 -0400 [received] => Array ( [0] => from attendant.sender.net ([208.68.18.236] helo=hydrogen.sender.net) by ilia.ws with esmtp (Exim 4.69) (envelope-from <apache@sender.com>) id 1MSwSa-0006lY-4O for ilia@ilia.ws; Mon, 20 Jul 2009 13:15:32 -0400 [1] => from hydrogen.sender.net (hydrogen.sender.net [127.0.0.1]) by hydrogen.sender.net (8.13.8/8.13.8) with ESMTP id n6KHFQ1g022841 for <ilia@ilia.ws>; Mon, 20 Jul 2009 11:15:26 -0600 [2] => (from apache@localhost) by hydrogen.sender.net (8.13.8/8.13.8/Submit) id n6KHFQR4022840; Mon, 20 Jul 2009 11:15:26 -0600 ) [date] => Mon, 20 Jul 2009 11:15:26 -0600 [message-id] => <200907201715.n6KHFQR4022840@hydrogen.sender.net> [to] => ilia@ilia.ws [subject] => 2027197 [from] => from@sender.com [mime-version] => 1.0 [content-type] => multipart/mixed; boundary="______b7bfcc06f00337de46276f92b6833d5c++++++" ) Wednesday, June 1, 2011 31
  • 36. MailParse // go through components of the e-mail $body = ''; $atms = array(); foreach ($structure as $element) {   $part_mime = mailparse_msg_get_part($mime, $element);   $part = mailparse_msg_get_part_data($part_mime);   if (!$part) continue;   $part_content = substr($msg,                   $part['starting-pos-body'],                   $part['ending-pos-body'] -  $part['starting-pos-body']); Wednesday, June 1, 2011 32
  • 37. MailParse if ($part['transfer-encoding'] == 'base64') { $part_content = base64_decode($part_content); } else if ($part['transfer-encoding']  == 'quoted-printable') { $part_content = quoted_printable_decode($part_content); } Wednesday, June 1, 2011 33
  • 38. MailParse if ($part['content-type'] == 'text/plain') { $body .= $part_content; } elseif ($part['content-type'] == 'text/html') { $body .= strip_tags($part_content); } elseif (!empty($part_info['content-disposition']) && $part['content-disposition'] == 'attachment' ) { $atms[] = array('headers' => $part, 'content' => $part_content); } else { //inline attachments $atms[] = array('headers' => $part, 'content' => $part_content); } Wednesday, June 1, 2011 34
  • 39. MailParse $to = '"Ilia A." <ilia@ilia.ws>,  Test <test@test.com>,  foo@bar.com'; print_r( mailparse_rfc822_parse_addresses($to) ); Array ( [0] => Array [1] => Array [2] => Array ( ( ( [display] => Ilia A. [display] => Test [display] => foo@bar.com [address] => ilia@ilia.ws [address] => test@test.com [address] => foo@bar.com [is_group] => [is_group] => [is_group] => ) ) ) ) Wednesday, June 1, 2011 35
  • 40. PHP-Excel • An interface to LibXL library • Allows generation of Excel Biff8 & XML documents • Can parse Excel Biff (5-8) and XML documents • Wickedly FAST! 200k rows in < 1 second https://github.com/iliaal/php_excel Wednesday, June 1, 2011 36
  • 41. Creating Excel Docs $x = new ExcelBook();      $s = $x->addSheet("Sheet 1"); $s->write(1, 1, 'Test'); $s->write(2, 2, 123); $x->save("file.xls"); Wednesday, June 1, 2011 37
  • 42. Reading Excel Docs $x = new ExcelBook(); $x->loadFile("file.xls"); $s = $x->getSheet(); for ($i = 0, $e = $s->lastRow(); $i < $e; $i++) {     print_r(array_filter($s->readRow($i))); } Array ( [1] => Test) Array ( [2] => 123 ) Wednesday, June 1, 2011 38
  • 43. xhprof • Light weight PHP profiler designed for in production use. • Aggregate run data • Web interface • In-Production “sampling” mode http://pecl.php.net/package/xhprof http://github.com/preinheimer/xhprof Wednesday, June 1, 2011 39
  • 44. Profiling ;; Pre-pended to every PHP script (init) auto_prepend_file = /xhprof/external/header.php include_once __DIR__ . '/xhprof_lib/config.php'); include_once __DIR__ . '/xhprof_lib/utils/xhprof_lib.php'; include_once __DIR__ . '/xhprof_lib/utils/xhprof_runs.php'; xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY); ;; Appended to every PHP script (store) auto_append_file = /xhprof/external/footer.php $xhprof_data = xhprof_disable(); $xhprof_runs = new XHProfRuns_Default(); $xhprof_runs->save_run($xhprof_data, 'AppName', null, $_xhprof); Wednesday, June 1, 2011 40
  • 49. Slides will be available at http://ilia.ws Please give me your feedback http://joind.in/3512 Ilia Alshanetsky @iliaa Wednesday, June 1, 2011 45