PDA

View Full Version : خبر: PHP 5.4



taknegaar
جمعه 13 آبان 1390, 23:38 عصر
PHP 5.4.0:
_________________________________________________

built-in web server:
localhost:8000

As of PHP 5.4.0, the CLI SAPI provides a built-in web server.
This web server is designed for developmental purposes only,
and should not be used in production.
http://php.net/manual/en/features.commandline.webserver.php

_________________________________________________

Trait:
Horizontal Reuse for PHP

<?php class Base { public function sayHello() { echo 'Hello '; } } trait SayWorld { public function sayHello() { parent::sayHello(); echo 'World!'; } } class MyHelloWorld extends Base { use SayWorld; } $o = new MyHelloWorld(); $o->sayHello(); // echos Hello World! ?>

...
More:
https://wiki.php.net/rfc/horizontalreuse

_________________________________________________


Arrays improvements:
syntax and dereferencing

$b = ['foo': 'orange', 'bar': 'apple', 'baz': 'lemon'];

And:

$object->method()[0]->otherMethod();


https://wiki.php.net/rfc/shortsyntaxforarrays

_________________________________________________

Closures

$callback = array($object, 'methodName');

$callback(); // prior to PHP 5.4 you need call_user_func()


AND:

$that = $this;

$closure = function (...) use ($that) { ... };


https://wiki.php.net/rfc/indirect-method-call-by-array-var

_________________________________________________

Upload progress:

http://schlueters.de/blog/archives/151-Upload-Progress-in-PHP-trunk.html
______________________________

Added

ReflectionClass::newInstanceWithoutConstructor()

to create a new instance of a class without invoking its constructor.
______________________________

Added new json_encode() option JSON_UNESCAPED_UNICODE.
______________________________

Added binary numbers format (0b001010).
______________________________

Changed E_ALL to include E_STRICT.
______________________________

Changed default value of "default_charset" php.ini option from ISO-8859-1 to UTF-8.
______________________________

Added multibyte support by default.
______________________________

<?= is now always available regardless of the short_open_tag setting.
______________________________

Added http_response_code() function.
______________________________

Added header_register_callback().
______________________________

Added iterator support in MySQLi.
mysqli_result implements Traversable.
______________________________

Session:
. Fixed bug #55267 (session_regenerate_id fails after header sent).
______________________________

Changed $_SERVER['REQUEST_TIME'] to include microsecond precision.
______________________________

... (http://php.net/releases/NEWS_5_4_0_beta2.txt)

_________________________________________________

Phar:

<?php
include 'phar:///path/to/myphar.phar/file.php';
?>

<?php
include './myphar.phar';
?>

The Phar extension is built into PHP as of PHP version 5.3.0.
The phar extension provides a way to put entire PHP applications into a single file called a "phar" (PHP Archive) for easy distribution and installation.
The word phar is a contraction of PHP and Archive and is based loosely on the jar (Java Archive) familiar to Java developers.

http://www.php.net/manual/en/intro.phar.php

_________________________________________________

PHP 5.4 beta2 released

Complete list of changes:
http://php.net/releases/NEWS_5_4_0_beta2.txt

Download:
http://www.php.net/archive/2011.php#id2011-10-26-1