Upgrade to Pro — share decks privately, control downloads, hide ads and more …

PHP73.pdf

 PHP73.pdf

Christian Leo-Pernold

November 05, 2018
Tweet

More Decks by Christian Leo-Pernold

Other Decks in Technology

Transcript

  1. Array Functions ! $arr = [ 'a' => 'bob', 'b'

    => 'jane', 'c' => 'john', ]; array_key_first($arr); // a array_key_last($arr); // c 5/23
  2. is_countable() ! $a = 'not-an-array'; count($a); // gives warning if

    (is_countable($a)) { // better count($a); } 6/23
  3. High-Resolution Time ⏱ $timeAsInt = hrtime(); /* array(2) { [0]=>

    int(27310) [1]=> int(349104398) } */ $timeAsArray = hrtime($asInteger = true); // int(27310349207961) 7/23
  4. Releaxed Heredoc / Nowdoc Syntax $awesomeText = <<<HOBBIT In a

    hole in the ground there lived a hobbit. Not a nasty, dirty, wet hole, filled with the ends of worms and an oozy smell, nor yet a dry, bare, sandy hole with nothing in it to sit down on or to eat: it was a hobbit-hole, and that means comfort HOBBIT // finally some indentation 8/23
  5. Trailing Commas In Function/Method Calls $bitcoins = mineForBitcoins(2.500, 8, );

    // here function mineForBitcoins($amount, $cores) { // but not here ... } 9/23
  6. json_encode()/json_decode() Can Throw Exceptions try { json_decode("{", $assoc = false,

    $depth = 512, JSON_THROW_ON_ERROR); } catch (\JsonException $exception) { echo $exception->getMessage(); // "Syntax error" } 10/23
  7. References in list() ! $array = ['bob', 'jane']; list($a, &$b)

    = $array; $b = 'john'; echo $array[1]; // "john" 11/23
  8. PCRE2 ! preg_match('/[\w-.]+/', ''); // throws compilation failed error //

    we need to escape the hyphen too preg_match('/[\w\-.]+/', ''); // ok 12/23
  9. Argon2 Password Hash Enhancements ✳✳✳✳✳ Argon2id is a hybrid of

    Argon2i and Argon2d. password_hash('super-secret', PASSWORD_ARGON2ID, $options = []); 13/23
  10. String search functions with integer needles $str = 'In a

    hole in the ground there lived 1 hobbit.'; strpos($str, '1'); // int(36) strpos($str, 1); // bool(false) 17/23
  11. Depracate case-insensitive constants define('Foo', 'Bar', $caseInsensitive = true); // throws

    a depracation notice define('Foo', 'Bar'); echo Foo; // 'Bar' echo foo; // throws a depracation notice // By convention, constants should be all UPPERCASE 18/23
  12. Depracate FILTER_FLAG_SCHEME_REQUIRED and FILTER_FLAG_HOST_REQUIRED with FILTER_VALIDATE_URL filter_var( $var, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED,

    FILTER_FLAG_HOST_REQUIRED ) // throws depracation warning // fix filter_var($var, FILTER_VALIDATE_URL); 19/23
  13. pdo_odbc.db2_instance_name directive As of PHP 5.1.1 pdo_odbc.db2_instance_name was marked as

    deprecated in the manual, promising removal in a future version of PHP. This ini directive modifies the DB2INSTANCE environment variable for non Windows operating systems, allowing pdo_odbc to make cataloged connections to a DB2 database. 20/23
  14. Release Schedule ! Date Release Jun 07 2018 Alpha 1

    ... ... Jul 31 2018 PHP 7.3 branched/Feature freeze Aug 02 2018 Beta 1 ... ... Sep 13 2018 RC 1 ... ... Nov 08 2018 RC 5 Nov 20 2018 PHP 7.3.0 branched Nov 22 2018 RC 6 Dec 13 2018 GA 21/23