SlideShare una empresa de Scribd logo
1 de 28
Descargar para leer sin conexión
HidDen Features
of PHP
Barcelona 2010
Ilia Alshanetsky
1Friday, October 29, 2010
__DIR__ Magic
The __DIR__ constant is a simple and fast
solution to the “where am i?” question for
php scripts.
<?php echo!__DIR__;
ilia@s3 /tmp $ php a.php
/tmp
2Friday, October 29, 2010
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
3Friday, October 29, 2010
GOTO ...
My favourite 5.3 feature ;-)
restart:
if!(error_condition1)!{
!!!!goto!error;
}
if!(error_condition2)!{
!!!!goto!restart;
}
error:
!!!!report_error();
!!!!exit;
4Friday, October 29, 2010
Digest Functions
OpenSSL Digest Functions
//!md5,!sha1,!sha512,!etc...!>20!algorithms
foreach!(openssl_get_md_methods()!as!$d)!{!
!!!!echo!openssl_digest("foo",!$d)!.!"n";
//!hex!value
}
5Friday, October 29, 2010
Encryption Functions
OpenSSL Two-Way 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);
!!!!//!descrypt
!!!!$dec!=!openssl_decrypt($enc,!$v,!$pwd,!false,!$iv);
}
6Friday, October 29, 2010
Double Encoding
Prevent double encoding of html-entities
via 4th argument to htmlspecialchars() and
htmlentities()
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);
$foo!=!"bar!>!foo!&amp;!that&quot;s!all";
bar!&gt;!foo!&amp;!that&quot;s!all
7Friday, October 29, 2010
Date Parsing
05-10-12
October 5, 2012
December 10, 2005
May 10, 2012
string(16) "October 12, 2005"
$date!=!
date_create_from_format('y-m-d',!'05-10-12');
var_dump(date_format($date,!'F!d,!Y'));
8Friday, October 29, 2010
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
9Friday, October 29, 2010
session ini magic
Improve randomness of session id via the
use of /dev/urandom
Secure your session cookies from
JavaScript
session.entropy_file = /dev/urandom
session.entropy_length = 32
session.use_only_cookies = 1
session.cookie_httponly = 1
10Friday, October 29, 2010
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
;; Adds X-PHP-Originating-Script header
;; Contains UID & filename of the script
mail.add_x_header = On
mail() on [/tmp/script.php:2]: To: ilia@ilia.ws -- Headers:
X-PHP-Originating-Script: 1000:script.php
11Friday, October 29, 2010
SPL FS Tricks
Simple recursive directory traversal
foreach!(
new!RecursiveIteratorIterator(
new!RecursiveDirectoryIterator('.')
)!as!$file)!{
!!!!echo!$file!,!"n";
}
12Friday, October 29, 2010
SPL FS Tricks
recursive directory traversal w/Matching
$it!=!new!RecursiveIteratorIterator(
!!!!new!RecursiveDirectoryIterator('.')
);
$regx!=!new!RegexIterator(
$it,
'/^.*.php$/i', !//!only match will be returned
RecursiveRegexIterator::GET_MATCH
);
foreach!($regx!as!$file)!{
!!!!echo!$file[0]!,!"n";
}
13Friday, October 29, 2010
igbinary
The awesome PHP Serializer you should use!
Faster
More Compact
http://github.com/phadej/igbinary
;; Load igbinary extension
extension=igbinary.so
;; Use igbinary as session serializer
session.serialize_handler=igbinary
14Friday, October 29, 2010
igbinary
Provides functions you can use for non-
session data.
serialize($_SERVER);
ini_set("igbinary.compact_strings",!0);
igbinary_serialize($_SERVER);
ini_set("igbinary.compact_strings",!1);
igbinary_serialize($_SERVER);
//!Un-serialize
igbinary_unserialize($x);
15Friday, October 29, 2010
Igbinary speed test
2600
2725
2850
2975
3100
Serialize Igbinary w/Compact Igbinary
0
3.75
7.5
11.25
15
Serialized Size Speed - Serialize Speed - Unserialize
Optimal
16Friday, October 29, 2010
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
17Friday, October 29, 2010
Profiling
;; Pre-pended to every PHP script (init)
auto_prepend_file = /xhprof/external/header.php
;; Appended to every PHP script (store)
auto_append_file = /xhprof/external/footer.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
);
$xhprof_data!=!xhprof_disable();
$xhprof_runs!=!new!XHProfRuns_Default();
$xhprof_runs->save_run($xhprof_data,
'AppName',!null,!$_xhprof);
18Friday, October 29, 2010
Profile Output
19Friday, October 29, 2010
Profile Output
20Friday, October 29, 2010
Profile Output
21Friday, October 29, 2010
Profile Output
22Friday, October 29, 2010
fileinfo
A reliable mechanism for identifying files
Not dependant on file extension
Can provide mime types
Identifies hundreds of file types
23Friday, October 29, 2010
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);
24Friday, October 29, 2010
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
25Friday, October 29, 2010
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");
26Friday, October 29, 2010
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 )
27Friday, October 29, 2010
Thank You For
Listening
Slides will be available
at http://ilia.ws
28Friday, October 29, 2010

Más contenido relacionado

La actualidad más candente

Python for Linux System Administration
Python for Linux System AdministrationPython for Linux System Administration
Python for Linux System Administrationvceder
 
Unix shell scripting basics
Unix shell scripting basicsUnix shell scripting basics
Unix shell scripting basicsAbhay Sapru
 
Best training-in-mumbai-shell scripting
Best training-in-mumbai-shell scriptingBest training-in-mumbai-shell scripting
Best training-in-mumbai-shell scriptingvibrantuser
 
Talk Unix Shell Script
Talk Unix Shell ScriptTalk Unix Shell Script
Talk Unix Shell ScriptDr.Ravi
 
Augeas
AugeasAugeas
Augeaslutter
 
Maybe you do not know that ...
Maybe you do not know that ...Maybe you do not know that ...
Maybe you do not know that ...Viktor Turskyi
 
Beautiful PHP CLI Scripts
Beautiful PHP CLI ScriptsBeautiful PHP CLI Scripts
Beautiful PHP CLI ScriptsJesse Donat
 
Unix And C
Unix And CUnix And C
Unix And CDr.Ravi
 
Python utan-stodhjul-motorsag
Python utan-stodhjul-motorsagPython utan-stodhjul-motorsag
Python utan-stodhjul-motorsagniklal
 
Scripting 101
Scripting 101Scripting 101
Scripting 101ohardebol
 
2-introduction_to_shell_scripting
2-introduction_to_shell_scripting2-introduction_to_shell_scripting
2-introduction_to_shell_scriptingerbipulkumar
 
Programming Under Linux In Python
Programming Under Linux In PythonProgramming Under Linux In Python
Programming Under Linux In PythonMarwan Osman
 
Python Programming in Entertainment Industry: Coding Style
Python Programming in Entertainment Industry: Coding StylePython Programming in Entertainment Industry: Coding Style
Python Programming in Entertainment Industry: Coding StyleShuen-Huei Guan
 
Hubot: a look inside our robot friend
Hubot: a look inside our robot friendHubot: a look inside our robot friend
Hubot: a look inside our robot friendajacksified
 
Shell实现的windows回收站功能的脚本
Shell实现的windows回收站功能的脚本Shell实现的windows回收站功能的脚本
Shell实现的windows回收站功能的脚本Lingfei Kong
 
Whatsnew in-perl
Whatsnew in-perlWhatsnew in-perl
Whatsnew in-perldaoswald
 
Talk Unix Shell Script 1
Talk Unix Shell Script 1Talk Unix Shell Script 1
Talk Unix Shell Script 1Dr.Ravi
 

La actualidad más candente (20)

Stackful
StackfulStackful
Stackful
 
Python for Linux System Administration
Python for Linux System AdministrationPython for Linux System Administration
Python for Linux System Administration
 
Unix shell scripting basics
Unix shell scripting basicsUnix shell scripting basics
Unix shell scripting basics
 
Best training-in-mumbai-shell scripting
Best training-in-mumbai-shell scriptingBest training-in-mumbai-shell scripting
Best training-in-mumbai-shell scripting
 
Talk Unix Shell Script
Talk Unix Shell ScriptTalk Unix Shell Script
Talk Unix Shell Script
 
Augeas
AugeasAugeas
Augeas
 
Maybe you do not know that ...
Maybe you do not know that ...Maybe you do not know that ...
Maybe you do not know that ...
 
Beautiful PHP CLI Scripts
Beautiful PHP CLI ScriptsBeautiful PHP CLI Scripts
Beautiful PHP CLI Scripts
 
Unix And C
Unix And CUnix And C
Unix And C
 
Python utan-stodhjul-motorsag
Python utan-stodhjul-motorsagPython utan-stodhjul-motorsag
Python utan-stodhjul-motorsag
 
Scripting 101
Scripting 101Scripting 101
Scripting 101
 
2-introduction_to_shell_scripting
2-introduction_to_shell_scripting2-introduction_to_shell_scripting
2-introduction_to_shell_scripting
 
Perl Moderno
Perl ModernoPerl Moderno
Perl Moderno
 
Having Fun Programming!
Having Fun Programming!Having Fun Programming!
Having Fun Programming!
 
Programming Under Linux In Python
Programming Under Linux In PythonProgramming Under Linux In Python
Programming Under Linux In Python
 
Python Programming in Entertainment Industry: Coding Style
Python Programming in Entertainment Industry: Coding StylePython Programming in Entertainment Industry: Coding Style
Python Programming in Entertainment Industry: Coding Style
 
Hubot: a look inside our robot friend
Hubot: a look inside our robot friendHubot: a look inside our robot friend
Hubot: a look inside our robot friend
 
Shell实现的windows回收站功能的脚本
Shell实现的windows回收站功能的脚本Shell实现的windows回收站功能的脚本
Shell实现的windows回收站功能的脚本
 
Whatsnew in-perl
Whatsnew in-perlWhatsnew in-perl
Whatsnew in-perl
 
Talk Unix Shell Script 1
Talk Unix Shell Script 1Talk Unix Shell Script 1
Talk Unix Shell Script 1
 

Similar a Barcelona 2010 hidden_features

international PHP2011_ilia alshanetsky_Hidden Features of PHP
international PHP2011_ilia alshanetsky_Hidden Features of PHPinternational PHP2011_ilia alshanetsky_Hidden Features of PHP
international PHP2011_ilia alshanetsky_Hidden Features of PHPsmueller_sandsmedia
 
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
 
Javascript fundamentals for php developers
Javascript fundamentals for php developersJavascript fundamentals for php developers
Javascript fundamentals for php developersChris Ramakers
 
WordPress Plugin Localization
WordPress Plugin LocalizationWordPress Plugin Localization
WordPress Plugin LocalizationRonald Huereca
 
PHP Basics and Demo HackU
PHP Basics and Demo HackUPHP Basics and Demo HackU
PHP Basics and Demo HackUAnshu Prateek
 
잘 알려지지 않은 Php 코드 활용하기
잘 알려지지 않은 Php 코드 활용하기잘 알려지지 않은 Php 코드 활용하기
잘 알려지지 않은 Php 코드 활용하기형우 안
 
IPC2010SE Doctrine2 Enterprise Persistence Layer for PHP
IPC2010SE Doctrine2 Enterprise Persistence Layer for PHPIPC2010SE Doctrine2 Enterprise Persistence Layer for PHP
IPC2010SE Doctrine2 Enterprise Persistence Layer for PHPGuilherme Blanco
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHPBradley Holt
 
[PL] Jak nie zostać "programistą" PHP?
[PL] Jak nie zostać "programistą" PHP?[PL] Jak nie zostać "programistą" PHP?
[PL] Jak nie zostać "programistą" PHP?Radek Benkel
 
PHP in 2018 - Q4 - AFUP Limoges
PHP in 2018 - Q4 - AFUP LimogesPHP in 2018 - Q4 - AFUP Limoges
PHP in 2018 - Q4 - AFUP Limoges✅ William Pinaud
 

Similar a Barcelona 2010 hidden_features (20)

Php 7 evolution
Php 7 evolutionPhp 7 evolution
Php 7 evolution
 
international PHP2011_ilia alshanetsky_Hidden Features of PHP
international PHP2011_ilia alshanetsky_Hidden Features of PHPinternational PHP2011_ilia alshanetsky_Hidden Features of PHP
international PHP2011_ilia alshanetsky_Hidden Features of PHP
 
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
 
Sf2 wtf
Sf2 wtfSf2 wtf
Sf2 wtf
 
Javascript fundamentals for php developers
Javascript fundamentals for php developersJavascript fundamentals for php developers
Javascript fundamentals for php developers
 
WordPress Plugin Localization
WordPress Plugin LocalizationWordPress Plugin Localization
WordPress Plugin Localization
 
PHP Basics and Demo HackU
PHP Basics and Demo HackUPHP Basics and Demo HackU
PHP Basics and Demo HackU
 
잘 알려지지 않은 Php 코드 활용하기
잘 알려지지 않은 Php 코드 활용하기잘 알려지지 않은 Php 코드 활용하기
잘 알려지지 않은 Php 코드 활용하기
 
My cool new Slideshow!
My cool new Slideshow!My cool new Slideshow!
My cool new Slideshow!
 
slidesharenew1
slidesharenew1slidesharenew1
slidesharenew1
 
Es.next
Es.nextEs.next
Es.next
 
Php mysql
Php mysqlPhp mysql
Php mysql
 
IPC2010SE Doctrine2 Enterprise Persistence Layer for PHP
IPC2010SE Doctrine2 Enterprise Persistence Layer for PHPIPC2010SE Doctrine2 Enterprise Persistence Layer for PHP
IPC2010SE Doctrine2 Enterprise Persistence Layer for PHP
 
Php1
Php1Php1
Php1
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
[PL] Jak nie zostać "programistą" PHP?
[PL] Jak nie zostać "programistą" PHP?[PL] Jak nie zostać "programistą" PHP?
[PL] Jak nie zostać "programistą" PHP?
 
PHP7: Hello World!
PHP7: Hello World!PHP7: Hello World!
PHP7: Hello World!
 
PHP in 2018 - Q4 - AFUP Limoges
PHP in 2018 - Q4 - AFUP LimogesPHP in 2018 - Q4 - AFUP Limoges
PHP in 2018 - Q4 - AFUP Limoges
 
Php introduction
Php introductionPhp introduction
Php introduction
 

Más de Anis Berejeb

Advanced Date/Time Handling with PHP
Advanced Date/Time Handling with PHPAdvanced Date/Time Handling with PHP
Advanced Date/Time Handling with PHPAnis Berejeb
 
APC & Memcache the High Performance Duo
APC & Memcache the High Performance DuoAPC & Memcache the High Performance Duo
APC & Memcache the High Performance DuoAnis Berejeb
 
Mysqlnd Query Cache
Mysqlnd Query CacheMysqlnd Query Cache
Mysqlnd Query CacheAnis Berejeb
 
Barcelona mysqlnd qc
Barcelona mysqlnd qcBarcelona mysqlnd qc
Barcelona mysqlnd qcAnis Berejeb
 

Más de Anis Berejeb (9)

Perf tuning2
Perf tuning2Perf tuning2
Perf tuning2
 
Explain2
Explain2Explain2
Explain2
 
Advanced Date/Time Handling with PHP
Advanced Date/Time Handling with PHPAdvanced Date/Time Handling with PHP
Advanced Date/Time Handling with PHP
 
APC & Memcache the High Performance Duo
APC & Memcache the High Performance DuoAPC & Memcache the High Performance Duo
APC & Memcache the High Performance Duo
 
Mysqlnd Query Cache
Mysqlnd Query CacheMysqlnd Query Cache
Mysqlnd Query Cache
 
Barcelona mysqlnd qc
Barcelona mysqlnd qcBarcelona mysqlnd qc
Barcelona mysqlnd qc
 
Mysql tracing
Mysql tracingMysql tracing
Mysql tracing
 
Mysql tracing
Mysql tracingMysql tracing
Mysql tracing
 
Ipc mysql php
Ipc mysql php Ipc mysql php
Ipc mysql php
 

Barcelona 2010 hidden_features

  • 1. HidDen Features of PHP Barcelona 2010 Ilia Alshanetsky 1Friday, October 29, 2010
  • 2. __DIR__ Magic The __DIR__ constant is a simple and fast solution to the “where am i?” question for php scripts. <?php echo!__DIR__; ilia@s3 /tmp $ php a.php /tmp 2Friday, October 29, 2010
  • 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 3Friday, October 29, 2010
  • 4. GOTO ... My favourite 5.3 feature ;-) restart: if!(error_condition1)!{ !!!!goto!error; } if!(error_condition2)!{ !!!!goto!restart; } error: !!!!report_error(); !!!!exit; 4Friday, October 29, 2010
  • 5. Digest Functions OpenSSL Digest Functions //!md5,!sha1,!sha512,!etc...!>20!algorithms foreach!(openssl_get_md_methods()!as!$d)!{! !!!!echo!openssl_digest("foo",!$d)!.!"n"; //!hex!value } 5Friday, October 29, 2010
  • 6. Encryption Functions OpenSSL Two-Way 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); !!!!//!descrypt !!!!$dec!=!openssl_decrypt($enc,!$v,!$pwd,!false,!$iv); } 6Friday, October 29, 2010
  • 7. Double Encoding Prevent double encoding of html-entities via 4th argument to htmlspecialchars() and htmlentities() 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); $foo!=!"bar!>!foo!&amp;!that&quot;s!all"; bar!&gt;!foo!&amp;!that&quot;s!all 7Friday, October 29, 2010
  • 8. Date Parsing 05-10-12 October 5, 2012 December 10, 2005 May 10, 2012 string(16) "October 12, 2005" $date!=! date_create_from_format('y-m-d',!'05-10-12'); var_dump(date_format($date,!'F!d,!Y')); 8Friday, October 29, 2010
  • 9. 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 9Friday, October 29, 2010
  • 10. session ini magic Improve randomness of session id via the use of /dev/urandom Secure your session cookies from JavaScript session.entropy_file = /dev/urandom session.entropy_length = 32 session.use_only_cookies = 1 session.cookie_httponly = 1 10Friday, October 29, 2010
  • 11. 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 ;; Adds X-PHP-Originating-Script header ;; Contains UID & filename of the script mail.add_x_header = On mail() on [/tmp/script.php:2]: To: ilia@ilia.ws -- Headers: X-PHP-Originating-Script: 1000:script.php 11Friday, October 29, 2010
  • 12. SPL FS Tricks Simple recursive directory traversal foreach!( new!RecursiveIteratorIterator( new!RecursiveDirectoryIterator('.') )!as!$file)!{ !!!!echo!$file!,!"n"; } 12Friday, October 29, 2010
  • 13. SPL FS Tricks recursive directory traversal w/Matching $it!=!new!RecursiveIteratorIterator( !!!!new!RecursiveDirectoryIterator('.') ); $regx!=!new!RegexIterator( $it, '/^.*.php$/i', !//!only match will be returned RecursiveRegexIterator::GET_MATCH ); foreach!($regx!as!$file)!{ !!!!echo!$file[0]!,!"n"; } 13Friday, October 29, 2010
  • 14. igbinary The awesome PHP Serializer you should use! Faster More Compact http://github.com/phadej/igbinary ;; Load igbinary extension extension=igbinary.so ;; Use igbinary as session serializer session.serialize_handler=igbinary 14Friday, October 29, 2010
  • 15. igbinary Provides functions you can use for non- session data. serialize($_SERVER); ini_set("igbinary.compact_strings",!0); igbinary_serialize($_SERVER); ini_set("igbinary.compact_strings",!1); igbinary_serialize($_SERVER); //!Un-serialize igbinary_unserialize($x); 15Friday, October 29, 2010
  • 16. Igbinary speed test 2600 2725 2850 2975 3100 Serialize Igbinary w/Compact Igbinary 0 3.75 7.5 11.25 15 Serialized Size Speed - Serialize Speed - Unserialize Optimal 16Friday, October 29, 2010
  • 17. 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 17Friday, October 29, 2010
  • 18. Profiling ;; Pre-pended to every PHP script (init) auto_prepend_file = /xhprof/external/header.php ;; Appended to every PHP script (store) auto_append_file = /xhprof/external/footer.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 ); $xhprof_data!=!xhprof_disable(); $xhprof_runs!=!new!XHProfRuns_Default(); $xhprof_runs->save_run($xhprof_data, 'AppName',!null,!$_xhprof); 18Friday, October 29, 2010
  • 23. fileinfo A reliable mechanism for identifying files Not dependant on file extension Can provide mime types Identifies hundreds of file types 23Friday, October 29, 2010
  • 24. 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); 24Friday, October 29, 2010
  • 25. 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 25Friday, October 29, 2010
  • 28. Thank You For Listening Slides will be available at http://ilia.ws 28Friday, October 29, 2010