Slide 1

Slide 1 text

Juliette Reinders Folmer @jrf_nl WordCamp Netherlands 2015 Essential PHP 7

Slide 2

Slide 2 text

Who Am I? Independent Consultant Contributor to LimeSurvey, WordPress and more Plugin author & contributor to many more

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

What Happened to PHP 6 ? • Unicode – ICU • Publications

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

How Fast ?!?!? Benchmarks courtesy of Zend Technologies

Slide 8

Slide 8 text

How Fast ?!?!? Benchmarks courtesy of Rasmus Lerdorf

Slide 9

Slide 9 text

What Can You Expect ? New features! Less BC breaks than upgrading to 5.4! PHPNG (PHP Next-Gen) Speed !

Slide 10

Slide 10 text

When ? 12 November 2015 Currently on RC3

Slide 11

Slide 11 text

What will change ?

Slide 12

Slide 12 text

So Long And Thanks For All The Fish MySql extension Ereg Posix Regex PHP 5.4 and lower

Slide 13

Slide 13 text

• dl() on fpm-fcgi • set_magic_quotes_runtime() • set_socket_blocking() • mcrypt_generic_end() • mcrypt_ecb() • mcrypt_cnc() • mcrypt_cfb() • datefmt_set_timezone_id • IntlDateFormatter::setTimeZoneID • call_user_method() • call_user_method_array() Removed Functions

Slide 14

Slide 14 text

• xsl.security_prefs • Input encoding: – iconv.input_encoding – Iconv.internal_encoding – mbstring.http_input – mbstring.http_output – mbstring.internal_encoding Removed ini Options

Slide 15

Slide 15 text

What Will Break ? preg_replace /e Static vs $this new ... by reference Multiple default: Division by zero Numeric Hex strings Some Variable Variables Alternative PHP tags

Slide 16

Slide 16 text

But WordPress.....

Slide 17

Slide 17 text

Being Forward Compatible can be as Important as Being Backwards Compatible

Slide 18

Slide 18 text

Cross-version bootstrap.php version_compare() function_exists() class_exists() method_exists() defined()  class-php53-code.php  class-php70-code.php  class-php-compat.php

Slide 19

Slide 19 text

In 2025..... (or thereabouts)

Slide 20

Slide 20 text

Goodies! Spaceship Unicode Escapes Strict Typing More Exception Types More Catchable Errors Uniform Variable Syntax Null Coalesce Scalar Type Hints & Return Type Hints

Slide 21

Slide 21 text

Uniform Variable Syntax Syntax Old Interpretation New Interpretation $$var[‘key1’][‘key2’] ${$var[‘key1’][‘key2’]} ($$var)[‘key1’][‘key2’] $var->$prop[‘key’] $var->{$prop[‘key’]} ($var->$prop)[‘key’] $var->$prop[‘key’]() $var->{$prop[‘key’]}() ($var->$prop)[‘key’]() Class::$var[‘key’]() Class::{$var[‘key’]}() (Class::$var)[‘key’]()

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

Combined Comparison Operator $b ) ? 1 : 0 ); } // PHP7+ function sort_order( $a, $b ) { return $a <=> $b; }

Slide 24

Slide 24 text

Unicode Codepoint Escape Syntax

Slide 25

Slide 25 text

Null Coalesce Operator // Pre PHP 7 $post = ( ( isset( $post ) ? $post : ‘default’ ); // PHP7+ $post = $post ?? ‘default’;

Slide 26

Slide 26 text

Scalar Type Hints

Slide 27

Slide 27 text

Scalar Type Hints & Strict Typing

Slide 28

Slide 28 text

Return Type Hints post_type ); }

Slide 29

Slide 29 text

More Goodies! Session options Preg_replac e_callback_ array() intdiv() Expectations Closure call() Filtered unserialize() Exceptions on Fatals IntlChar Class

Slide 30

Slide 30 text

PHP5.3+ on Steriods Bind Closure on Call Group Use Declarations Anonymous Classes Generator Enhancements Assertions

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

• Are the PHP Extensions Ready ? – http://gophp7.org/ – https://github.com/gophp7/gophp7-ext/wiki/extensions- catalog • PHP 7 Compatibility Checker – https://github.com/sstalle/php7cc • PHP Compatibility – https://github.com/wimg/PHPCompatibility/ • Need a Dev Box ? – https://github.com/rlerdorf/php7dev Useful

Slide 33

Slide 33 text

Slides will be posted to http://speakerdeck.com/jrf Thank you ! Essential PHP 7