Sign Up or Log In
Privacy and TOS
Contact Us

DejanG

Introduction to PHP 5.3

Provided by : DejanG » Folder : Documents » Category : Document » Slideshow

"INTRODUCING PHP 5.3 PHP Quebec 2008 - Ilia Alshanetsky 1 EVOLUTIONARY RELEASE Old code will still work Focus on mainly improvement of existing functionality Fewer bugs Faster release cycle 2 Namespaces Biggest addition in 5.3 code base Feature complete implementation of namespaces Majority of functionality implemented at compile time Simplifies naming conventions 3 Cleaner Code Without Namespaces function MY_wrapper() {} class MY_DB { } define('MY_CONN_STR', ''); With Namespaces namespace MY; function wrapper() {} class DB { } + MY_wrapper(); new MY_DB(); MY_CONN_STR; = const CONN_STR = ''; use MY AS MY; wrapper(); new DB(); CONN_STR; 4 Multiple Namespaces Per File namespace LIB; class MySQL {} class SQLite {} $b = new SQLite(); namespace LIB_EXTRA; class MScrypt {} $a = new MScrypt(); string(18) "LIB_EXTRA::MScrypt" string(11) "LIB::SQLite" var_dump(         get_class($a),         get_class($b) ); 5 Namespace Hierarchy namespace foo; function strlen($foo) { return htmlentities($foo); } echo strlen("test"); // test  echo ::strlen("test"); // 4 echo namespace::strlen("test"); // test Function, class and constant references inside a namespace refer to namespace first and global scope later. 6 Namespaces & autoload function __autoload($var) { var_dump($var); } // LIB::foo require "./ns.php"; /*         <?php                 namespace LIB;                 new foo(); */ __autoload() will be passed namespace name along with class name. autoload will only be triggered if class does not exist in namespace and global scope __autoload() declared inside a namespace will not be called! 7 Other NS Syntactic Sugar namespace really::long::pointlessly::verbose::ns;   __NAMESPACE__; // current namespace name        class a{}    get_class(new a()); // really::long::pointlessly::verbose::ns::a use really::long::pointlessly::verbose::ns::a AS b; Reference class from a namespace 8 Improved Performance md5() is roughly 10-15% faster Better stack implementation in the engine Constants moved to read-only memory Improve exception handling (simpler & less opcodes) Eliminate open(2) call on (require/include)_once Smaller binary size & startup size with gcc4 Overall Improvement 5-15% 9 New Language Features 10 __DIR__ Introduced __DIR__ magic constant indicating the directory where the script is located. echo dirname(__FILE__); // < PHP 5.3     /* vs */ echo __DIR__; // >= PHP 5.3 11 ?: Operator 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 12 __callStatic() __call() equivalent, but for static methods. class helper {         static function __callStatic($name, $args) {                 echo $name.'('.implode(',', $args).')';         } } helper::test("foo","bar"); // test(foo,bar) ✴ Dynamic function/method calls are kinda slow... 13 Dynamic Static Calls PHP now allows dynamic calls to static methods class helper {         static function foo() { echo __METHOD__; } } $a = "helper"; $b = "foo"; $a::$b(); // helper::foo ✴ Dynamic function/method calls are kinda slow... 14 Late Static Binding Processing of static events has been extended into execution time from compile time. class A {    public static function whoami() {     echo __CLASS__;    }    public static function identity() {      self::whoami();    } } class B extends A {    public static function whoami() {       echo __CLASS__;    } } B::identity(); // A <-- PHP < 5.3 ✴ ✴ class A {    public static function whoami() {       echo __CLASS__;    }    public static function identity() {       static::whoami();    } } class B extends A {    public static function whoami() {       echo __CLASS__;    } } B::identity(); // B <-- >= PHP 5.3 Beware if you use an opcode cache Not backwards compatible 15 MySQLInd Specialized, high speed library to interface with MySQL designed specifically for PHP mysql_fetch_assoc("..."); ext/mysql ext/mysql Copy of data in PHP Copy on Write in mysqlind Row Data Row Data Row Data Copy in libmysql Row Data Row Data Row Data MySQL Database 16 MySQLInd Better performance Improved memory usage Ability to fetch statistics for performance tuning Built-in driver (no external decencies once again) Many future options due to tight integration with PHP No PDO_MySQL support yet, mysql(i) only for now 17 INI Magic Support for “.htaccess” style INI controls for CGI/ FastCGI Per-directory INI settings inside php.ini via [PATH=/var/www/domain.com] not modifiable by the user. Improve error handling Allow use of INI variables and constants from virtually everywhere in the INI files Several other minor improvements 18 INI Magic Name for user-defined php.ini (.htaccess) files. Default is ".user.ini" user_ini.filename = ".user.ini" To disable this feature set this option to empty value user_ini.filename = TTL for user-defined php.ini files (time-to-live) in seconds. Default is 300 seconds (5 minutes) user_ini.cache_ttl = 300 [PATH=/var/www/domain.com] variables_order = GPC safe_mode = 1 [my variables] somevar = “1234” anothervar = ${somevar} ; anothervar == somevar [ini arrays] foo[bar] = 1 foo[123] = 2 foo[] = 3 19 Extra OpenSSL Functions Access to OpenSSL Digest Functions foreach (openssl_get_md_methods() as $d) {// MD4, MD5, SHA512... (12 all in all)   echo $d." - ".openssl_digest("foo", "md5"); //acbd18db4cc2f85cedef654fccc4a4d8 } Access to OpenSSL Cipher Functions // BF-CBC, AES-256 CFB1... (54 all in all) foreach(openssl_get_cipher_methods() as $v) { $val = openssl_encrypt("value", $v, "secret");   openssl_decrypt($val, $v, "secret"); // value    } Extend openssl_pkey_new() and openssl_pkey_get_details() functions to allow access to internal DSA, RSA and DH keys. The goal was to simply OpenID implementation in PHP 20 SPL Improvements Improve nested directory iterations via FilesystemIterator Introduced GlobIterator Various data structure classes: SplDoublyLinkedList, SplStack, SplQueue, SplHeap, SplMinHeap, SplMaxHeap, SplPriorityQueue Several other tongue twister features 21 Date Extension Additions Controllable strtotime() via date_create_from_format() $date = strtotime("08-01-07 00:00:00"); var_dump(date("Y-m-d", $date)); // string(10) "2008-01-07" $date = date_create_from_format("m-d-y", "08-01-07"); var_dump($date->format('Y-m-d')); // string(10) "2007-08-01" Added date_get_last_errors() that returns errors and warnings in date parsing. array(4) {   ["warning_count"] => int(0)   ["warnings"] => array(0) { }   ["error_count"] => int(2)   ["errors"]=>   array(2) {     [2]=> string(40) "The separation symbol could not be found"     [6]=> string(13) "Trailing data"   } } 22 getopt() Improvements Works on Windows Native implementation not dependent on native getopt() implementation. Cross-platform support for longopts (--option) // input: --a=foo --b --c var_dump(getopt("", array("a:","b::","c"))); /* output: array(3) {   ["a"]=>   string(3) "foo"   ["b"]=>   bool(false)   ["c"]=>   bool(false) } */ 23 XSLT Profiling Introduction of Xslt Profiling via setProfiling() $xslt = new xsltprocessor();  $xslt->importStylesheet($xml);  $xslt->setProfiling("/tmp/profile.txt");  $xslt->transformToXml($dom); Resulting In: number 0 match date Total name mode Calls Tot 100us Avg 5 5 58 58 11 24 E_DEPRECATED What would a PHP release be without a new error mode? deprecated Used to designate deprecated functionality that maybe, sometime in a far future will get removed, maybe. 25 Garbage Collector Memory cleanup for Über-complex and long scripts that need to free-up memory before the end of execution cycle. (!amework folks, this is for you) gc_enable(); // Enable Garbage Collector var_dump(gc_enabled()); // true var_dump(gc_collect_cycles()); // # of elements cleaned up gc_disable(); // Disable Garbage Collector 26 NOWDOC A HEREDOC where no escaping is necessary HEREDOC $foo = <<<ONE this is $fubar ONE;      /* string(10) "this is" */ NOWDOC $bar = <<<‘TWO’ this is $fubar TWO; /* string(16) "this is $fubar" */ 27 Miscellaneous Improvements SQLite Upgraded to 3.5.6 Over 40 bug fixes CGI/FastCGI SAPI Improvements Various stream improvements More things to come ... 28 Thank You For Listening Questions? These slides can be found on: http://ilia.ws 29 ..."

You need to upgrade your Flash Player , or try to enable javascript in order see this document properly.

Introduction to PHP 5.3

The slides are Ilia Alshanetsky's talk at PHP Quebec on the upcoming PHP 5.3 release . PHP php5 ILIA namespace Alshanetsky php5.3 Technology-Internet Internet & Technology...
more

File Name: Introduction-to-PHP-5.3-.pdf
Provided by: DejanG
Folder: Documents (Books, presentations, magazines, newspapers etc)
Category: Document » Slideshow
Size: 2109.02 kb
Extension: pdf
Rating: 0
Views: 530
Downloads: 39
Uploaded: 07/04/09 06:52
Tags: PHP php5 ILIA namespace Alshanetsky php5.3 Technology-Internet Internet & Technology


Embed:
Link:
Forum:

Submit to digg
digg stumble reddit Submit to del.icio.us delicio furl facebook
comments Comments : 0
No comments yet..

Add comment: (Sing Up or Log In)

Computer & Internet Basics Training - How-to-Guides & Manuals, Technology, and Internet (pdf document)
Computer & Internet Basics Training - How-to-Guides & Manuals,
overview of computers, hardware, software, www, internet, isp, google,...
pdf document From: koled
Flash-PHP-MySQL Communication Tutorials Intro ActionScript 3 (flv video)
Flash-PHP-MySQL Communication Tutorials Intro ActionScript 3
Adam Explains Flash PHP and MySQL communication basics
flv video From: Lenjivica
the Future of the Internet (pdf document)
the Future of the Internet
The future of internet and how to stop it Internet Technology-Interne...
pdf document From: Husky
PHP Architect | Volume 6 - Issue 5 (pdf document)
PHP Architect | Volume 6 - Issue 5
PHP Architect | Volume 6 - Issue 5 The Magazine For PHP Professionals...
pdf document From: sintetik
Building A Permanent Magnet Generator (PMG) For Wind Energy Systems (pdf document)
Building A Permanent Magnet Generator (PMG) For Wind Energy Systems
This research on small wind energy systems for battery charging is the...
pdf document From: koled
Guide: Computer to Computer Connection via Ethernet - How-to-Guides & Manuals, Computer, and Network (pdf document)
Guide: Computer to Computer Connection via Ethernet - How-to-Guides &a
How to Configure & Connect two Computers using a Ethernet Wire. C...
pdf document From: koled
The Beretta 90-two pistol (pdf document)
The Beretta 90-two pistol
The Beretta 90-two pistol. Technology-Military Internet & Technol...
pdf document From: koled
Sten Gun Mk2 (pdf document)
Sten Gun Mk2
Sten Gun Mk2 gun Sten Mk2 Technology-Military Internet & Technolo...
pdf document From: koled
How to transfer iTunes library to Microsoft Zune (pdf document)
How to transfer iTunes library to Microsoft Zune
iTunes to Zune, transfer iTunes to Zune, M4P to Zune, M4P to MP3, M4P ...
pdf document From: Husky
How to Convert DRM Protected iTunes M4P to MP3 WAV WMA with TuneClone - How-to-Guides & Manuals, iTunes, and m4p to mp3 (pdf document)
How to Convert DRM Protected iTunes M4P to MP3 WAV WMA with TuneClone
Step by step to convert DRM protected iTunes M4P to MP3, WAV and unpro...
pdf document From: Husky
Do you Watch "TV" on the Internet? (flv video)
Do you Watch "TV" on the Internet?
http://live.pirillo.com - Are you watching TV right now? Seriously, is...
flv video From: IronMan
The Internet Celebrity - You Are A Stalker  (mp4 video)
The Internet Celebrity - You Are A Stalker
Mr Pregnant Has been featured on VH1 TOP 40 INTERNET SUPERSTARS.http:/...
mp4 video From: hater2009
VH1 Internet Superstar - Mr Pregnant Prank Calls A Gynaecologist  (mp4 video)
VH1 Internet Superstar - Mr Pregnant Prank Calls A Gynaecologist
Mr Pregnant Has been featured on VH1 TOP 40 INTERNET SUPERSTARS.http:/...
mp4 video From: hater2009
VH1 Internet Superstar - You Are A Stalker (mp4 video)
VH1 Internet Superstar - You Are A Stalker
Mr Pregnant Has been featured on VH1 TOP 40 INTERNET SUPERSTARS.http:/...
mp4 video From: hater2009
VH1 Internet Superstar - Mr Pregnant Prank Calls A Female Escort  (mp4 video)
VH1 Internet Superstar - Mr Pregnant Prank Calls A Female Escort
Mr Pregnant Has been featured on VH1 TOP 40 INTERNET SUPERSTARS.http:/...
mp4 video From: hater2009
The Internet Celebrity - Zap  (mp4 video)
The Internet Celebrity - Zap
Mr Pregnant Has been featured on VH1 TOP 40 INTERNET SUPERSTARS.http:/...
mp4 video From: hater2009
VH1 Internet Superstar - Why I Love Bush  (mp4 video)
VH1 Internet Superstar - Why I Love Bush
Mr Pregnant Has been featured on VH1 TOP 40 INTERNET SUPERSTARS.http:/...
mp4 video From: hater2009
VH1 Internet Superstar - Mr Pregnant Prank Calls A Chinese  (mp4 video)
VH1 Internet Superstar - Mr Pregnant Prank Calls A Chinese
Mr Pregnant Has been featured on VH1 TOP 40 INTERNET SUPERSTARS.http:/...
mp4 video From: hater2009
VH1 Internet Superstar - Zap  (mp4 video)
VH1 Internet Superstar - Zap
Mr Pregnant Has been featured on VH1 TOP 40 INTERNET SUPERSTARS.http:...
mp4 video From: hater2009
VH1 Internet Superstar - When Nature Calls  (mp4 video)
VH1 Internet Superstar - When Nature Calls
Mr Pregnant Has been featured on VH1 TOP 40 INTERNET SUPERSTARS.http:/...
mp4 video From: hater2009

© 2009 Fliiby LLC