
Welcome to this course, I'll first introduce myself and why you should want to take this course. Also give you some knowledge about what you'll need to take this course.
Before we being lets take a look at XAMPP where we want to setup PHP7 which you must download the correct version to take this course.
Scalar is a popular language that has some type declarations for arguments; now this is available in PHP. This will make your functions more structured and coerce the parameter data types to be what you want.
This lecture will cover type coercion of object data passed to our functions arguments.
PHP 7 supports data type declarations for values returned from a function. Similar to argument type declarations, return type declarations specify the type of the value that will be returned from a function.
Some lovely sugar syntax for PHP developers. Instead of if statements and writing unnecessary code but rather in one line we can optionally define the value of variable.
The spaceship operator is good for doing a comparison of two numbers and returns differing values depending on the comparison.
Array constants can now be defined with define(). In PHP 5.6, they could only be defined with const.
Support for anonymous classes has been added via new class. These can be used in place of full class definitions for throwaway or framework objects.
PHP7 now lets you use unicode characters escaped by UTF-8 in the hexadecimal format.
Your function's can be invoked with a predefined value for the this context; set by the call method. This is very similar to JavaScripts call method and works in the same way.
This feature seeks to provide better security when unserializing objects on untrusted data. It prevents possible code injections by enabling the developer to whitelist classes that can be unserialized.
Classes, functions and constants being imported from the same namespace can now be grouped together in a single use statement.
The new intdiv() function performs an integer division of its operands and returns it.
The session start function now accepts an array of options that override the session configuration directives normally set in php ini file.
The new preg_replace_callback_array() function enables code to be written more cleanly when using thepreg_replace_callback() function. Prior to PHP 7, callbacks that needed to be executed per regular expression required the callback function to be polluted with lots of branching.
Generator functions are a new way of programming. They allow us to control the execution of a function and even change the state of the function in mid execution.
We've discovered generator functions allow you to pause and give way to other processing providing flexibility in programming. Lets delve into the syntax of generators and see how PHP works with them.
Generators allow for yielding values so that you can evaluate and use that value outside of the generator function.
Next we want to take a look at all the different primitive types like string, integer, float or bool and objects such as a class object, array or associative array.
Generators where introduced in PHP5.5 but in PHP7 and above there are new features we can work with. Such as return statements and yielding from other yield functions.
[DEPRICTAED] Style constructors
PHP 4 style constructors (methods that have the same name as the class they are defined in) are deprecated. PHP 7 will return an E_DEPRECATED please only use the __construct() method.
[DEPRICATED] Static calls to non-static methods
Static calls to methods that are not declared static are deprecated, and may be removed in the future.
[DEPRICATED] Password hash
The salt option for the password_hash() function has been deprecated to prevent developers from generating their own (usually insecure) salts. The function itself generates a cryptographically secure salt when no salt is provided by the developer - therefore custom salt generation should not be needed.
[DEPRICATED] Capture session meta data
The capture_session_meta SSL context option has been deprecated. SSL metadata is now available through thestream_get_meta_data() function.
Thank you for taking this course and I hope to see you using PHP 7 at its best in the future.
Check out some bonus content.
PHP7 is the newest edition of the language to hit the server side in 2016. This well established and much loved language is providing significant performance improvements, providing new features and improving security. PHP has always been the goto language when it comes to server side database interactivity and data integrity with simplicity and ease of use.
The first and most prominent speed increase is the PHP7 engines speed which is nearly double the performance of the previous PHP 5.6 engine. This alone should be coveted by developers who don't even need to optimise their code but just to run it in the new engine and see massive performance increases. Wordpress, Joomla and other popular CMS's have been run out of the box with no code changes and huge performance increases have been seen with no optimisation needed at all.
But what about the other features and your script's, Will they work? Well to find out I'll be showing you additional features which may not be that dramatic after all. New features are always fun to learn but some new features will just be a simple parameter being passed into an already existing function. For example the unserialise function will now accept another optional parameter to only unserialise an object that came from a particular class; making it a little more secure. Also as we're on the topic of security and parameters the existing password hash function will no longer accept a salt but rather it will automatically generate a secure salt for you.
The new PHP version is a nice addition to the PHP family with refined features all round. PHP will still be around despite what developers say. It's still currently the best and most secure language for database interaction with PDO, scalar data validation, prepared statements, secure password hashing and salting. It really is still the king pin! Every language has it's place and PHP is firmly settled in on the server side and despite being a Javascript developer it's still is a very established language.