Top Banner
What’s New In PHP 5.3? PHP UK February 2009 Scott MacVicar Friday, 27 February 2009
45
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: PHP 5.3

What’s New InPHP 5.3?

PHP UK February 2009Scott MacVicar

Friday, 27 February 2009

Page 2: PHP 5.3

Feature Release

All PHP 5 code should still works

Backports everything except Unicode from 6

Bug fixes from PHP 5.2

Friday, 27 February 2009

Page 3: PHP 5.3

Namespaces

Mostly done at compile time

Saves extra long prefixes (Yay framework developers)

Zend_Search_Lucene_Analysis_Analyzer_

Reduces class name conflicts

Multiple namespaces per file

Friday, 27 February 2009

Page 4: PHP 5.3

Namespace Usage

Can Contain:

classes

functions

constants with the same name

Defined by statement namespace <x>;

Friday, 27 February 2009

Page 5: PHP 5.3

\ as separatorFriday, 27 February 2009

Page 6: PHP 5.3

You used \?!? WTF?

Symbol Use Symbol Use

% Modulus + Plus

^ Xor - Minus

* Multi / Division

~ Not \ ???

| Or : Else

& And ` Exec

Friday, 27 February 2009

Page 10: PHP 5.3

Other Namespace Things

__NAMESPACE__

global scope \

__autoload(), get_class() and get_parent_class() now return a full qualified classname

Resolves internally then externally

Friday, 27 February 2009

Page 12: PHP 5.3

Late Static Binding

Static references use to be resolved at compile time

Static constants would correspond to where they were defined

static:: is now resolved at runtime

Friday, 27 February 2009

Page 15: PHP 5.3

Lambda Functions and Closures

Functions on the fly

Ideal for things that require a callback

create_function() is runtime based

__invoke method for Classes

Friday, 27 February 2009

Page 18: PHP 5.3

Garbage Collector

GSoC 2007 Project

Looks for cyclic references

Increases overall memory usage slightly

Good for long running scripts

Friday, 27 February 2009

Page 22: PHP 5.3

Improved ini handling

Change PHP settings similarly to .htaccess when using FCGI

Per-directory ini settings

INI constants / variables

Friday, 27 February 2009

Page 24: PHP 5.3

__callStatic

__callStatic($name, $arguments)

Identical to __call but for static methods

Friday, 27 February 2009

Page 26: PHP 5.3

Limited goto

goto is a bad idea™

PHP provides goto <label>

Can only jump out of a structure

Friday, 27 February 2009

Page 29: PHP 5.3

SPL ImprovementsDualIterator

RecursiveTreeIterator

SplArrayReference

DirectoryIterator implements ArrayAccess

SplStack

SplQueue

SplHeap

SplFixedArray

Friday, 27 February 2009

Page 31: PHP 5.3

enchant

Speel Cheking

Wraps around existing libraries

Supports platform dictionaries

HunSpell (Firefox, OpenOffice)

AppleSpell (OS X default)

Friday, 27 February 2009

Page 32: PHP 5.3

fileinfo

Guess content type and encoding

Looks for magic byte sequences

Previously required external library

Provides mime_content_type() support

Friday, 27 February 2009

Page 33: PHP 5.3

intl

Wrapper around IBM’s ICU library

Provides collation, normalization, datetime and number / currency formatting

IDN Support

Friday, 27 February 2009

Page 34: PHP 5.3

MySQLnd

Developed by MySQL

Replaces libmysql and is bundled

Faster and uses less memory

Statistics

Friday, 27 February 2009

Page 35: PHP 5.3

phar

Similar to Java’s JAR

PHP 5.3 can open and read phars

Can mount internal phar directoriesPhar::mount(“cache/”, “/tmp/cache”);

Works with OPCode caches

Friday, 27 February 2009

Page 37: PHP 5.3

Using Phar

Make a stub file

Build archive

Rejoice

Friday, 27 February 2009

Page 38: PHP 5.3

SQLite3

OO API

Replaces old SQLite class

Bundles full text search

SQLite 3.6.11

Friday, 27 February 2009

Page 39: PHP 5.3

Extensions removeddbase

fbsql

fdf

ncurses

ming

pspell

sybase

Friday, 27 February 2009

Page 40: PHP 5.3

New Constants__DIR__

PHP_MAJOR_VERSION

PHP_MINOR_VERSION

PHP_RELEASE_VERSION

PHP_VERSION_ID

PHP_DEBUG

PHP_MAXPATHLEN

Friday, 27 February 2009

Page 41: PHP 5.3

Improved Performance

New scanner based on re2c

md5() now faster

require_once / include_once faster on second usage

Improved memory usage due to constants being marked as read only

Friday, 27 February 2009

Page 42: PHP 5.3

Improved Performance

Improved engine stack implementation

Removed direct executor recursion

Use fastcall calling convention on x86

Various opcode optimisations

Friday, 27 February 2009

Page 43: PHP 5.3

MiscellaneousOver 180 bug fixes

PCRE upgrade

SQLite upgrade

Stream improvements

OpenSSL improvements

Make JSON suck less

Friday, 27 February 2009

Page 44: PHP 5.3

Beers for Bugs

Friday, 27 February 2009

Page 45: PHP 5.3

Questions?

Go download and test!

http://qa.php.net/

http://windows.php.net/downloads.php

Slides

http://talks.macvicar.net

Friday, 27 February 2009