Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

PHP 5.6 New and Deprecated Features

2,746 views

Published on

With PHP 5.6 there are some great new features. We'll go over some of these features and how to use them. This includes variadic functions, constant scalar expressions, exponentiation, splat operator, use const/function, php input, phpdbg, and more. We will also cover deprecated features in PHP 5.6. Want to get involved with upcoming release? I'll show you how you can 'make_test' to start helping out.

Published in: Software
  • Be the first to comment

PHP 5.6 New and Deprecated Features

  1. 1. PHP 5.6: New and Deprecated Features Mark Niebergall https://joind.in/13884
  2. 2. About Mark Niebergall ● Developing in PHP since 2005 ● Masters degree in Information Systems ● Senior Software Engineer and Team Lead ● Occupational health screening project ● Security: SSCP, CSSLP Certified ● PHP, databases, JavaScript ● Enjoy being outdoors
  3. 3. Supported Versions See http://php.net/supported-versions.php
  4. 4. State of PHP ● PHP 5.3.29 EOL for PHP 5.3 release August 14, 2014 ● PHP 5.4.40 released April 16, 2015, aging but still heavily used ● PHP 5.5.24 is current, many servers running PHP 5.5.X ● PHP 5.6.8 released April 16, 2015 ● PHP 5.6.0 available since August 28, 2014 ● PHP 5.7 is under development ● PHP 7.0 is under development o PHP 6 unicode, branched but will never have production release o Vote for version 6 vs 7, decided on 7 o Focused on performance o More compact data structures - easier for JIT compiler o Improved variable syntax (see https://wiki.php.net/rfc/uniform_variable_syntax)
  5. 5. Live Demo Setup ● 2 vagrant virtual machines with puppet o 1 with PHP 5.5.8 o 1 with PHP 5.6.0 o Automatic code sync so same code resides on both web servers See https://qa.php.net/howtohelp.php
  6. 6. PHP 5.6 Incompatible Out With The Old ● Array keys won't be overwritten when defining an array as a property of a class via an array literal Source: http://us1.php.net/manual/en/migration56.incompatible.php
  7. 7. PHP 5.6 Incompatible Out With The Old ● json_decode strictness ● Stream wrappers now verify peer certificates and host names by default when using SSL/TLS ● GMP (GNU Multiple Precision Arithmetic Library) resources are now objects ● Mcrypt functions now require valid keys and initialization vectors Source: http://us1.php.net/manual/en/migration56.incompatible.php
  8. 8. PHP 5.6 Deprecated On the way Out ● Calling a method from an incompatible context
  9. 9. PHP 5.6 Deprecated On the way Out ● $HTTP_RAW_POST_DATA and always_populate_raw_post_data o use php://input instead (file_get_contents('php://input')) o php://input is now reusable Source: http://us1.php.net/manual/en/migration56.deprecated.php
  10. 10. PHP 5.6 Deprecated On the way Out ● iconv and mbstring encoding settings o default_charset with UTF-8 as default value o iconv.input_encoding, iconv.output_encoding, iconv.internal_encoding o mbstring.http_input, mbstring.http_output, mbstring.internal_encoding Source: http://us1.php.net/manual/en/migration56.deprecated.php
  11. 11. PHP 5.6 Changed Changed functionality ● crypt() will now raise an E_NOTICE error if no salt parameter
  12. 12. PHP 5.6 Changed Changed functionality ● substr_compare() will now accept 0 for its length parameter
  13. 13. PHP 5.6 Changed Changed functionality ● unserialize() will now fail if passed serialized data that has been manipulated to attempt to instantiate an object without calling its constructor ● cURL @file vs CURLFile ● Mcrypt source default value for mcrypt_create_iv ● PostgreSQL functions no longer experimental (ex: pg_insert) ● PostgreSQL pg_send_* no longer block until query write completion ● ReflectionClass::newInstanceWithoutConstructor() now allows non-final internal classes to be instantiated ● XMLReader::getAttributeNs() and XMLReader::getAttributeNo() now return NULL if the attribute could not be found, like XMLReader::getAttribute() Source: http://us1.php.net/manual/en/migration56.changed-functions.php
  14. 14. PHP 5.6 New Functions New functions ● GMP: gmp_root(), gmp_rootrem() ● LDAP: ldap_escape(), ldap_modify_batch() ● MySQLi: mysqli_get_links_stats() ● OCI8: oci_get_implicit_resultset() ● OpenSSL: openssl_get_cert_locations(), openssl_x509_fingerprint(), openssl_spki_new(), openssl_spki_verify(), openssl_spki_export_challenge(), openssl_spki_export() Source: http://us1.php.net/manual/en/migration56.new-functions.php
  15. 15. PHP 5.6 New Functions New functions (continued) ● PostgreSQL: pg_connect_poll(), pg_consume_input(), pg_flush(), pg_socket() ● PDO_PGSQL: PDO::pgsqlGetNotify(), PDO::pgsqlGetPid() ● Zip: ZipArchive::setPassword() Source: http://us1.php.net/manual/en/migration56.new-functions.php
  16. 16. PHP 5.6 New Features New stuff ● Constant scalar expressions
  17. 17. PHP 5.6 New Features New stuff ● Variadic functions
  18. 18. PHP 5.6 New Features New stuff ● Argument unpacking using … ● AKA Splat
  19. 19. PHP 5.6 New Features New stuff ● Exponentiation via **
  20. 20. PHP 5.6 New Features New stuff ● use const and use function
  21. 21. PHP 5.6 New Features New stuff ● Upload file > 2GB o Sorry, not going to show this one
  22. 22. PHP 5.6 New Features New stuff ● GMP now supports operator overloading
  23. 23. PHP 5.6 New Features New stuff ● hash_equals: Timing attack safe string comparison
  24. 24. PHP 5.6 New Features New stuff ● Magic method __debugInfo: Define output for var_dump of class
  25. 25. Testing PHP builds PHP QA ● Testing overview at https://qa.php.net/ ● Test a build o wget http://downloads.php.net/tyrael/php-5.6.9RC1.tar.gz o tar xvzf php-5.6.9RC1.tar.gz o cd php-5.6.9RC1 o ./configure o make test ● Write testcases ● Give PHP QA team server time See https://qa.php.net/howtohelp.php
  26. 26. Testing PHP builds PHP QA
  27. 27. Testing PHP builds PHP QA
  28. 28. Questions? ● https://joind.in/13884

×