PHP 5.4 的改变 » 荒野无灯weblog

Keep It Simple, Stupid.

荒野无灯weblog

PHP 5.4 的改变

PHP 5.4.0 于2012年3月1日发布。

5.4新增加了一种称为traints的东西,此外还引进了简洁数组语法(如$a = [1, 2, 3, 4];),增加了函数数组解引用支持(如foo()[0]),<?=总是可用,不受short_open_tag配置的影响。添加在类被实例化时访问类成员的支持(如(new Foo)->bar()),Class::{expr}() 的语法现在被支持,新增加二进制数据类型(如0b001001101),session扩展现在已经可以跟踪上传状态(这一点真的来得太迟了),命令行模式下内置web服务器。

php.ini 配置文件

见:http://cn.php.net/manual/en/migration54.ini.php
以下指令已经被移除:


  • register_globals and register_long_arrays

  • magic_quotes_gpc, magic_quotes_runtime,
    and magic_quotes_sybase

  • allow_call_time_pass_reference

  • define_syslog_variables and all related functions

  • highlight.bg

  • session.bug_compat_42 and session.bug_compat_warn

  • y2k_compliance

  • safe_mode and all related parameters

  • zend.ze1_compatibility_mode

新增加了以下指令:


  • cli.pager and cli.prompt for CLI SAPI using readline
    in interactive mode.

  • max_input_vars – specifies how many GET/POST/COOKIE input variables may be
    accepted.

  • zend.multibyte – to control the new multibyte support.

  • session.upload_progress.enabled, session.upload_progress.cleanup,
    session.upload_progress.prefix, session.upload_progress.name,
    session.upload_progress.freq, session.upload_progress.min_freq

  • enable_post_data_reading – When it’s disabled, the POST data is not read (and processed)

  • windows_show_crt_warning

The following ini directives have been changed:

session.entropy_file now defaults to /dev/random or /dev/urandom depending on what has been guessed at compile time.
session.entropy_length now defaults to 32.


新增加的全局常量

http://cn.php.net/manual/en/migration54.global-constants.php

PHP Core:


  • ENT_DISALLOWED

  • ENT_HTML401

  • ENT_HTML5

  • ENT_SUBSTITUTE

  • ENT_XML1

  • ENT_XHTML

  • IPPROTO_IP

  • IPPROTO_IPV6

  • IPV6_MULTICAST_HOPS

  • IPV6_MULTICAST_IF

  • IPV6_MULTICAST_LOOP

  • IP_MULTICAST_IF

  • IP_MULTICAST_LOOP

  • IP_MULTICAST_TTL

  • MCAST_JOIN_GROUP

  • MCAST_LEAVE_GROUP

  • MCAST_BLOCK_SOURCE

  • MCAST_UNBLOCK_SOURCE

  • MCAST_JOIN_SOURCE_GROUP

  • MCAST_LEAVE_SOURCE_GROUP

Curl:


  • CURLOPT_MAX_RECV_SPEED_LARGE

  • CURLOPT_MAX_SEND_SPEED_LARGE

LibXML:


  • LIBXML_HTML_NODEFDTD

  • LIBXML_HTML_NOIMPLIED

  • LIBXML_PEDANTIC

OpenSSL:


  • OPENSSL_CIPHER_AES_128_CBC

  • OPENSSL_CIPHER_AES_192_CBC

  • OPENSSL_CIPHER_AES_256_CBC

  • OPENSSL_RAW_DATA

  • OPENSSL_ZERO_PADDING

Output buffering:


  • PHP_OUTPUT_HANDLER_CLEAN

  • PHP_OUTPUT_HANDLER_CLEANABLE

  • PHP_OUTPUT_HANDLER_DISABLED

  • PHP_OUTPUT_HANDLER_FINAL

  • PHP_OUTPUT_HANDLER_FLUSH

  • PHP_OUTPUT_HANDLER_FLUSHABLE

  • PHP_OUTPUT_HANDLER_REMOVABLE

  • PHP_OUTPUT_HANDLER_STARTED

  • PHP_OUTPUT_HANDLER_STDFLAGS

  • PHP_OUTPUT_HANDLER_WRITE

Sessions:


  • PHP_SESSION_ACTIVE

  • PHP_SESSION_DISABLED

  • PHP_SESSION_NONE

Streams:


  • STREAM_META_ACCESS

  • STREAM_META_GROUP

  • STREAM_META_GROUP_NAME

  • STREAM_META_OWNER

  • STREAM_META_OWNER_NAME

  • STREAM_META_TOUCH

Zlib:


  • ZLIB_ENCODING_DEFLATE

  • ZLIB_ENCODING_GZIP

  • ZLIB_ENCODING_RAW

Intl:


  • U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR

  • IDNA_CHECK_BIDI

  • IDNA_CHECK_CONTEXTJ

  • IDNA_NONTRANSITIONAL_TO_ASCII

  • IDNA_NONTRANSITIONAL_TO_UNICODE

  • INTL_IDNA_VARIANT_2003

  • INTL_IDNA_VARIANT_UTS46

  • IDNA_ERROR_EMPTY_LABEL

  • IDNA_ERROR_LABEL_TOO_LONG

  • IDNA_ERROR_DOMAIN_NAME_TOO_LONG

  • IDNA_ERROR_LEADING_HYPHEN

  • IDNA_ERROR_TRAILING_HYPHEN

  • IDNA_ERROR_HYPHEN_3_4

  • IDNA_ERROR_LEADING_COMBINING_MARK

  • IDNA_ERROR_DISALLOWED

  • IDNA_ERROR_PUNYCODE

  • IDNA_ERROR_LABEL_HAS_DOT

  • IDNA_ERROR_INVALID_ACE_LABEL

  • IDNA_ERROR_BIDI

  • IDNA_ERROR_CONTEXTJ

Json:


  • JSON_PRETTY_PRINT

  • JSON_UNESCAPED_SLASHES

  • JSON_NUMERIC_CHECK

  • JSON_UNESCAPED_UNICODE

  • JSON_BIGINT_AS_STRING

新增函数

http://cn.php.net/manual/en/migration54.functions.php

PHP Core:

SPL:

Session:

Mysqli:

Libxml:

LDAP:

Intl:

Zlib:


New Classes and Interfaces

http://cn.php.net/manual/en/migration54.classes.php


5.4 新功能

http://cn.php.net/manual/en/migration54.new-features.php


  • Support for traits has been added.

  • Short array syntax has been added, e.g. $a = [1, 2, 3, 4]; or
    $a = ['one' => 1, 'two' => 2, 'three' => 3, 'four' => 4];.

  • Function array dereferencing has been added, e.g. foo()[0].

  • Closures now support $this.

  • <?= is now always available, regardless of the
    short_open_tag ini option.

  • Class member access on instantiation has been added,
    e.g. (new Foo)->bar().

  • Class::{expr}() syntax is now supported.

  • Binary number format has been added, e.g. 0b001001101.

  • Improved parse error messages and improved incompatible arguments warnings.

  • The session extension can now track the upload progress of files.

  • Built-in web server in CLI mode.

php 5.4 向后不兼容的地方官

http://cn.php.net/manual/en/migration54.incompatible.php


从5.3 迁移到5.4

http://cn.php.net/migration54

Tagged in :

All Comments (0)
Gravatar image
No Comments