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:


  • 1
    ENT_DISALLOWED



  • 1
    ENT_HTML401



  • 1
    ENT_HTML5



  • 1
    ENT_SUBSTITUTE



  • 1
    ENT_XML1



  • 1
    ENT_XHTML



  • 1
    IPPROTO_IP



  • 1
    IPPROTO_IPV6



  • 1
    IPV6_MULTICAST_HOPS



  • 1
    IPV6_MULTICAST_IF



  • 1
    IPV6_MULTICAST_LOOP



  • 1
    IP_MULTICAST_IF



  • 1
    IP_MULTICAST_LOOP



  • 1
    IP_MULTICAST_TTL



  • 1
    MCAST_JOIN_GROUP



  • 1
    MCAST_LEAVE_GROUP



  • 1
    MCAST_BLOCK_SOURCE



  • 1
    MCAST_UNBLOCK_SOURCE



  • 1
    MCAST_JOIN_SOURCE_GROUP



  • 1
    MCAST_LEAVE_SOURCE_GROUP


Curl:


  • 1
    CURLOPT_MAX_RECV_SPEED_LARGE



  • 1
    CURLOPT_MAX_SEND_SPEED_LARGE


LibXML:


  • 1
    LIBXML_HTML_NODEFDTD



  • 1
    LIBXML_HTML_NOIMPLIED



  • 1
    LIBXML_PEDANTIC


OpenSSL:


  • 1
    OPENSSL_CIPHER_AES_128_CBC



  • 1
    OPENSSL_CIPHER_AES_192_CBC



  • 1
    OPENSSL_CIPHER_AES_256_CBC



  • 1
    OPENSSL_RAW_DATA



  • 1
    OPENSSL_ZERO_PADDING


Output buffering:


  • 1
    PHP_OUTPUT_HANDLER_CLEAN



  • 1
    PHP_OUTPUT_HANDLER_CLEANABLE



  • 1
    PHP_OUTPUT_HANDLER_DISABLED



  • 1
    PHP_OUTPUT_HANDLER_FINAL



  • 1
    PHP_OUTPUT_HANDLER_FLUSH



  • 1
    PHP_OUTPUT_HANDLER_FLUSHABLE



  • 1
    PHP_OUTPUT_HANDLER_REMOVABLE



  • 1
    PHP_OUTPUT_HANDLER_STARTED



  • 1
    PHP_OUTPUT_HANDLER_STDFLAGS



  • 1
    PHP_OUTPUT_HANDLER_WRITE


Sessions:


  • 1
    PHP_SESSION_ACTIVE



  • 1
    PHP_SESSION_DISABLED



  • 1
    PHP_SESSION_NONE


Streams:


  • 1
    STREAM_META_ACCESS



  • 1
    STREAM_META_GROUP



  • 1
    STREAM_META_GROUP_NAME



  • 1
    STREAM_META_OWNER



  • 1
    STREAM_META_OWNER_NAME



  • 1
    STREAM_META_TOUCH


Zlib:


  • 1
    ZLIB_ENCODING_DEFLATE



  • 1
    ZLIB_ENCODING_GZIP



  • 1
    ZLIB_ENCODING_RAW


Intl:


  • 1
    U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR



  • 1
    IDNA_CHECK_BIDI



  • 1
    IDNA_CHECK_CONTEXTJ



  • 1
    IDNA_NONTRANSITIONAL_TO_ASCII



  • 1
    IDNA_NONTRANSITIONAL_TO_UNICODE



  • 1
    INTL_IDNA_VARIANT_2003



  • 1
    INTL_IDNA_VARIANT_UTS46



  • 1
    IDNA_ERROR_EMPTY_LABEL



  • 1
    IDNA_ERROR_LABEL_TOO_LONG



  • 1
    IDNA_ERROR_DOMAIN_NAME_TOO_LONG



  • 1
    IDNA_ERROR_LEADING_HYPHEN



  • 1
    IDNA_ERROR_TRAILING_HYPHEN



  • 1
    IDNA_ERROR_HYPHEN_3_4



  • 1
    IDNA_ERROR_LEADING_COMBINING_MARK



  • 1
    IDNA_ERROR_DISALLOWED



  • 1
    IDNA_ERROR_PUNYCODE



  • 1
    IDNA_ERROR_LABEL_HAS_DOT



  • 1
    IDNA_ERROR_INVALID_ACE_LABEL



  • 1
    IDNA_ERROR_BIDI



  • 1
    IDNA_ERROR_CONTEXTJ


Json:


  • 1
    JSON_PRETTY_PRINT



  • 1
    JSON_UNESCAPED_SLASHES



  • 1
    JSON_NUMERIC_CHECK



  • 1
    JSON_UNESCAPED_UNICODE



  • 1
    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

更多
One Response Post a comment
  1. 潜行者m

    好吧,我承认我php技术太差了,上面的东西都没怎么看懂

Leave a Reply

Note: You may use basic HTML in your comments. Your email address will not be published.

Subscribe to this comment feed via RSS