
Discover the PHP 7 upgrade, featuring faster performance, lower memory use, and few backward compatibility breaks, plus hands on coverage of new operators, return type declarations, and error reporting.
Meet David Powers, a British web developer and author with decades of PHP experience, a Zend-certified engineer for PHP 5.3, and a prolific trainer as the course opens.
Set up a hands-on test environment with PHP 7 on one web server and PHP 5.6 on a different port to compare code behavior, enabling display_errors and E_ALL via php.ini or htaccess.
Upgrade to PHP 7 boosts performance, reduces memory, and introduces internal changes like an abstract syntax tree and uniform variable syntax for faster, greener server hosting.
Explore changes to existing features in php 7, including fatal errors now thrown as exceptions and unified handling of invalid arguments. Be aware of variable variables and Jason code changes.
Cover php 7 removals, including the original masc. extension, posix regex functions, deprecated magic quotes, and asp or html tags; migrate to mysqli or pdo and perl-compatible regex.
Explore the PHP 7 spaceship operator to compare two values and return minus one, zero, or one for custom sorting with usort, including its ability to compare arrays or objects.
Learn the PHP 7 null coalesce operator, two question marks that return the left value if it exists or a default if not, avoiding undefined index errors with user input.
Learn how PHP 7 introduces a unicode code point escape syntax, using backslash u followed by hex digits in curly braces, enabling four- or five-digit code points and readability.
Generate cryptographically strong random bytes in PHP 7 with the random_bytes function. It takes the number of bytes as input and can be hex-encoded with bin2hex for cookies or tokens.
Explore how the PHP 7 random function uses a cryptographically strong RNG to generate integers between a minimum and maximum, validating integers or convertible strings and rounding floats down.
Explains using preg_replace_callback_array in PHP 7 to perform multiple regex replacements via patterns and callbacks for Perl compatible regular expressions that transform a subject string.
Learn how PHP 7 introduces optional return type declarations for compound types such as arrays and objects, with safeguards against mismatched return values and inheritance conflicts.
Explore PHP 7 scalar type hints for bool, int, float, and string, with optional usage, weak mode, and strict mode enforcing per-file types and return types after function signature colon.
Explore how scalar return type declarations differ in strict and weak mode, where the return value must match the declared type or be cast accordingly.
Explore scalar parameter declarations in PHP 7, showing how weak and strict modes affect parameter type hints, with type juggling or fatal errors depending on the caller file.
Demonstrates how combining scalar type hints for parameters and return types in PHP 7 interacts with weak and strict modes, revealing casting and enforcement effects.
Explore how strict mode enforces strict type checking for scalar hints and affects built-in PHP functions, causing return type and argument errors unless you cast or adjust types.
learn how scalar type hints with user input in PHP 7, comparing strict and weak modes, and how form data is converted to integers or strings.
Explore scalar type hinting in PHP 7, comparing strict and weak modes, and learn strategies for declaring strict types or keeping weak mode to balance parameters and return values.
Explore anonymous classes in PHP 7, showing how to extend SPL heap and filter iterators, assign to variables, and use for unit testing and single-use code.
Learn how PHP 7 enables generators to return a value, access it with the getReturn method, and why a generator must finish iterating before retrieving that return value.
Explore how PHP 7 generators delegate work to sub-generators or traversable objects using yield from, the getReturn method, and array literals in delegation.
Learn how to bind closures to objects in PHP 7 using the call method, replacing the older bind approach and executing closures immediately with the object context.
Group use declarations in PHP 7 to import multiple classes from the same namespace with a single statement, and extend grouping to constants and functions using curly braces and aliases.
Explore how php 7 redefines fatal errors as a distinct error class, enabling final resource cleanup via destructors and finally blocks, and how to catch and log them.
PHP 7 now throws fatal errors like exceptions via the throwable interface, with TypeError, ParseError, and AssertionError as subclasses of the error class, and can be caught in catch blocks.
Explore how PHP 7 handles fatal errors by catching type and parse errors with try-catch and finally, and examine error objects for file name, line, and message.
Explore how PHP 7 reclassifies E_STRICT errors, turning some into notices or warnings, deprecates non-static calls, and flags trait conflicts and signature mismatches for forward compatibility.
PHP 7 introduces 11 new reserved words that cannot be used to name a class, interface, or namespace, while integer, double, and boolean remain unreserved.
Discover how PHP 7 removes date.timezone warnings by silently setting UTC when no time zone is configured, and learn to specify a proper time zone with date_default_timezone_set.
Explore how PHP 7 enforces a single default clause in switch statements, causing a compile error when multiple defaults appear.
Block PHP object injection in PHP 7 by filtering unserialize input with a whitelist of allowed classes, or set the second argument to false to disallow objects.
Learn to preserve zero fractions when encoding data as json by using the PHP constant JSON_PRESERVE_ZERO_FRACTION, optionally with pretty print and other adjacent encode options.
Php7 introduces a context sensitive lexer that relaxes reserved words, letting semi-reserved terms be used as constants and method names in user defined classes, reducing global name clashes.
Explore how PHP 7's uniform variable syntax standardizes variable interpretation, enabling left-to-right dereferencing of expressions, IIFE and anonymous functions, and static property or method access from complex expressions.
Explore how uniform variable syntax affects variable variables in PHP 7, with practical examples showing when curly braces are needed to disambiguate complex expressions and the edge-case backward-incompatible changes.
Learn how PHP 7's assertion API enhances debugging by using assert with optional messages, configure Zend assertions and assert exception for development versus production, and handle errors with try/catch.
Assess PHP 7's features and changes, highlighting threefold speed gains, memory efficiency, and fewer backward-compatibility breaks, alongside anonymous classes, spaceship and null coalesce operators, and improved error handling.