Presentation Transcript
PHP 5.3 – Part 1 :PHP 5.3 – Part 1 Introduction to PHP 5.3 A Sydney PHP Group Presentation
4th September 2008
By Timothy Chandler
So what’s the big deal!? :So what’s the big deal!? PHP 5.3 = PHP 6 - Unicode + MORE!
Tomorrow’s PHP Today.
Forwards Compatibility.
So what’s new? :So what’s new? New Syntax
New Functions & Methods
New Extensions
Namespaces
Lambda Functions & Closures
Late Static Binding
Lots of important changes
A few gotchas.
Important Changes & Gotchas :Important Changes & Gotchas Functions
Array functions “next()” & “current()” no longer work with objects.
“session_start()” will now return a Boolean response “false” if it fails to start a session.
By default, “clearstatcache()” will no longer clear “realpath()” cache. Backwards Compatibility
Important Changes & Gotchas :Important Changes & Gotchas Backwards Compatibility Magic Methods
All magic methods must now be declared as “public”. “static” declarations are no longer allowed.
“__toString()” will no longer accept any parameters.
Important Changes & Gotchas :Important Changes & Gotchas Backwards Compatibility New Reserved Words
“namespace”
“goto”
New Reserved Classes
“Closure”
Important Changes & Gotchas :Important Changes & Gotchas Backwards Compatibility Depreciations
Ticks
This includes “register_tick_function()”
Undepreciations
“is_a()”
Important Changes & Gotchas :Important Changes & Gotchas Backwards Compatibility Windows
Any Windows OS prior to Windows 2000 is no longer supported.
Important Changes & Gotchas :Important Changes & Gotchas Extensions Removed
ncurses
fpdf
sybase
dbase
fbsql Added
Phar
Internationalization (Intl)
File Information (Fileinfo)
SQLite3
Important Changes & Gotchas :Important Changes & Gotchas Extensions Not allowed to disable.
PCRE
Reflections
SPL
Important Changes & Gotchas :Important Changes & Gotchas The PHP INI File More powerful ini.
A whole slew of changes which may or may not affect you.
New Syntax :New Syntax NOWDOC It’s like HEREDOC, but it doesn’t evaluate it’s contents.
Syntax:
NOWDOC;
“NOWDOC”, like “HEREDOC”, can be replaced with any non-reserved word.
New Syntax :New Syntax Ternary Operator The Ternary Operator has been given a shortcut.
Testing for only “true” or “false” is now possible.
Syntax:
$foo=true;
!$foo?:print '$foo is True';
$bar=false;
$bar?:print '$bar is False';
New Syntax :New Syntax Unset Casting You can now cast a variable to NULL while using it and remove it from memory in one fell swoop.
Syntax:
$foo='foo';
$foo=(unset)print $foo;
New Syntax :New Syntax goto The new “goto” keyword is useful for controlling breaks in loops and switches.
Not recommended outside of loops and switches.
Easy to abuse – be careful with your GCP.
Syntax:
print 1;
goto label1;
print 2;
print 3;
label1:
print 4;
New Functions & Methods :New Functions & Methods Too many for this presentation.
They include:
Array
Date
GMP
Hash
Image
Math
Mcrypt
Network
PCNTL
PHP Core
SHM
SPL
Streams
Strings
New Functions & Methods :New Functions & Methods Array Functions “array_replace()” – Finds and replaces based on key and merges the remainder.
“array_replace_recursive()” – Recursively finds and replaces based on key and merges the remainder.
New Functions & Methods :New Functions & Methods Date Functions “date_add()” – Adds an amount of days, months, years, hours, minutes and seconds to a DateTime object.
“date_sub()” – Subtracts an amount of days, months, years, hours, minutes and seconds from a DateTime object
“date_diff()” – Takes two DateTime Objects and calculates the difference.
New Functions & Methods :New Functions & Methods PHP Core “class_alias()” – Creates an alias of a class name.
“forward_static_call()” and “forward_static_call_array()” – Related to Late Static Binding. This will be discussed in another presentation.
Coming Up :Coming Up October
Part 2 – New PHP Internals
Lambda Functions and Closures
Namespaces – maybe?
November
Part 3 – New PHP Extensions
Internationalization
Phar