Download - PHP 5.3 And PHP 6 A Look Ahead
What is new in PHP 5.3?
Stefan Priebsch, e-novative GmbH
Disclaimer
First Plans for PHP 6
Paris Developer Meeting
Derick's Meeting Minutes
www.php.net/~derick/meeting-notes.html
First Release Candidate late 2006
First Plans for PHP 6
Paris Developer Meeting
Derick's Meeting Minutes
www.php.net/~derick/meeting-notes.html
First Release Candidate late 2007
First Plans for PHP 6
Paris Developer Meeting
Derick's Meeting Minutes
www.php.net/~derick/meeting-notes.html
First Release Candidate ... some day
And PHP 6 ...
... became PHP 5.3 ...
... almost
Unicode
Unicode
One Standard to rule them all
PHP 6's killer feature
One character != one byte
Garbage Collection
Garbage Collection
Free memory while script is running
gc_enable();
gc_disable();
SPL Improvements
SPL Improvements
SplDoublyLinkedList
SPLStack
SPLQueue
SplPriorityQueue
SPL Stack
$stack = new SplStack();
$stack->push('a');
$stack->push('b');
$stack->push('c');
echo $stack->pop();
echo $stack->pop();
echo $stack->pop();
SPL Stack
$stack = new SplStack();
$stack->push('a');
$stack->push('b');
$stack->push('c');
echo $stack->pop();
echo $stack->pop();
echo $stack->pop();
-> cba
Magic Static Calls
Magic Calls
class Foo
{
public function __call($aName, $aParameters)
{
var_dump($aName);
var_dump($aParameters);
}
}
$foo = new Foo();
$foo->test('something');
Magic Calls
class Foo
{
public function __call($aName, $aParameters)
{
var_dump($aName);
var_dump($aParameters);
}
}
$foo = new Foo();
$foo->test('something');
->
string(4) "test"
array(1) {
[0]=> string(9) "something"
}
Magic Calls
Strict standards: Non-static method Foo::test() should not be
called statically
Magic Static Calls
class Foo
{
public static function __callStatic($aName, $aParameters)
{
...
}
}
Foo::doSomething(...);
Late Static Binding
Late Static Binding
class Foo
{
protected static $foo = 'Test';
public static function getFoo()
{
return self::$foo;
}
}
var_dump(Foo::getFoo());
Late Static Binding
class Foo
{
protected static $foo = 'Test';
public static function getFoo()
{
return self::$foo;
}
}
var_dump(Foo::getFoo());
-> Test
Late Static Binding
class Foo
{
protected static $foo = 'Test';
public static function getFoo()
{
return self::$foo;
}
}
class MyFoo extends Foo
{
protected static $foo = 'MyTest';
}
var_dump(Foo::getFoo());
var_dump(MyFoo::getFoo());
Late Static Binding
class Foo
{
protected static $foo = 'Test';
public static function getFoo()
{
return self::$foo;
}
}
class MyFoo extends Foo
{
protected static $foo = 'MyTest';
}
var_dump(Foo::getFoo());
var_dump(MyFoo::getFoo());
-> string(4) "Test" string(4) "Test"
Late Static Binding
class Foo
{
protected static $foo = 'Test';
public static function getFoo()
{
return static::$foo;
}
}
class MyFoo extends Foo
{
protected static $foo = 'MyTest';
}
var_dump(Foo::getFoo());
var_dump(MyFoo::getFoo());
Late Static Binding
class Foo
{
protected static $foo = 'Test';
public static function getFoo()
{
return static::$foo;
}
}
class MyFoo extends Foo
{
protected static $foo = 'MyTest';
}
var_dump(Foo::getFoo());
var_dump(MyFoo::getFoo());
-> string(4) "Test" string(6) "MyTest"
Namespaces
class File
{
...
}
Namespaces
class File
{
...
}
// somewhere else
class File
{
...
}
Namespaces
class my_Web_Framework_Foo_Bar_Baz
{
...
}
Namespaces
namespace my::Web::Framework::Foo::Bar;
class Baz
{
...
}
Namespaces
namespace my::Web::Framework::Foo::Bar;
class Baz
{
...
}
// somewhere else:
$baz = new my::Web::Framework::Foo::Bar::Baz();
Namespaces
use my::Web::Framework::Foo::Bar::Baz as MyBaz;
$baz = new myBaz();
Namespaces
namespace crypt;
function gnupg_decrypt($aText, $aKeyFile)
{
return 'some plaintext';
}
Namespaces
namespace crypt;
function gnupg_decrypt($aText, $aKeyFile)
{
return 'some plaintext';
}
var_dump(gnupg_decrypt('sa45hzq734hrq243rwaefsd80', 'my.key'));
Namespaces
namespace foo;
class bar
{
static public function baz()
{
return 'baz method';
}
}
var_dump(foo::bar::baz());
Namespaces
namespace foo;
class bar
{
static public function baz()
{
return 'baz method';
}
}
var_dump(foo::bar::baz());
-> string(10) "baz method"
Namespaces
namespace foo::bar;
function baz()
{
return 'baz function';
}
namespace foo;
class bar
{
static public function baz()
{
return 'baz method';
}
}
var_dump(foo::bar::baz());
Namespaces
Namespaces
Access built-in functions/classes by prefixing ::
some_fn(...) vs. ::some_fn(...)
__NAMESPACE__ constant
Multiple namespaces per file
More New Features
ifsetor
OpenID support
SQLite3
getopt() works on Windows
__DIR__ = dirname(__FILE__)
Error Handling
Error Handling
New error class E_DEPRECATED
E_ALL includes E_STRICT
Future-Proofing
Regular Expressions
ereg will move to PECL
replace ereg_* by preg_*
by the way, ereg is not binary safe
Deprecated php.ini Settings
short open tags
magic quotes
register_globals
register_long_arrays
ze1.compatibility_mode
allow_call_time_pass_reference
safe_mode
Blatant Advertisement
Thank you.
http://www.priebsch.de (de)
http://inside.e-novative.de (en)
[email protected]
Klicken Sie, um das Format des Titeltextes zu bearbeiten
Text