eBook - PHP 7 Explained

What you will learn:

  • Why the successor of PHP 5 is version 7
  • How to migrate with ease
  • Why PHP 7 is the fastest PHP ever
  • How to use all new features
  • What is planned for future versions
  • How PHP 7 will change how you write code

Sample Pages

Table of Contents

  • Introduction
    • The Road to PHP 7
    • The Modernization of PHP
    • What You Get
    • Windows
    • Behind the Scenes
      • Compiler
        • Lexical Analysis
        • Syntactic Analysis
        • Bytecode Generation
      • Bytecode Execution
      • Bytecode Caching
      • Bytecode Optimization
      • Debugger
    • Getting PHP 7
      • RHEL and CentOS
      • Fedora
      • Debian
      • Ubuntu
      • macOS
        • Homebrew
        • MacPorts
      • Microsoft Windows
      • A Note on PEAR
  • Backward Incompatible Changes
    • Removed Features
      • Operating System and Web Server
        • Server APIs (SAPIs)
        • Support for Outdated Windows Versions
        • Support for NetWare
        • Dynamic Extension Loading in PHP-FPM
      • Language Features
        • Magic Quotes
        • Assigning the Result of new by Reference
        • Static Calls of Instance Methods
        • ASP Tags
        • call_user_method()
        • Removed set_socket_blocking()
        • Removed XSL ini Option xsl.security_prefs
        • wddx is Gone
      • Regular Expressions
        • Removed /e modifier of preg_replace()
        • Removed eval Option for mb_ereg_replace()
        • Removed split()
      • Internationalisation and Unicode
        • Removed setlocale() String Category Support
        • Deprecated Aliases Removed from intl Extension
        • recode Extension Unbundled
      • I/O and Filesystem
        • Accessing Raw POST Data
        • Hash-Sign Comments in ini Files
        • json_decode() with JSON_OBJECT_AS_ARRAY option
        • Safe Uploads in curl Extension
        • sql.safe_mode Configuration Directive
        • PDO, PostgreSQL, and Prepared Statements
        • MySQLi Embedded Server
      • Graphics
        • Removed Support for PostScript Type1 Fonts from gd Extension
    • Changed Semantics
      • Strings
        • Changes to String Handling
        • Return Value of substr() Changed in an Edge Case
        • Operators and Invalid Strings
        • Case Mapping and Folding in mbstring
        • Named Captures in mb_ereg_replace()
      • XML
        • Empty $childNodes Property
        • SimpleXML and Mathematical Operations
      • Arrays
        • foreach
        • Invalid list() Usage
        • Parsing Invalid Octal Numbers
        • Changed Order for list() when Assigning to Array
        • [] Operator and Empty Strings
        • Invalid Array Read Access
        • compact()
      • Mathematics
        • Casting INF and NAN to Integer
        • Division by Zero
        • Architecture-Independent Bit Shifting
        • Negative Index for gmp_setbit() and gmp_clrbit() Return false
        • More Precise Float Value Handling
        • bcmod() and Fractional Numbers
        • Changes to Random Number Generation
      • Session
        • Cleanup of the session extension
      • I/O and Filesystem
        • Nested Output Buffers and Callbacks
        • New Implementation for JSON Encoding and Decoding
      • Graphics
        • Changed MIME type for getimagesize()
      • Operating System
        • stream_socket_get_name() and IPv6
        • Stream Wrappers
      • Security
        • IMAP and RSH/SSH Connections
        • openssl_random_pseudo_bytes() Throws Exceptions
      • Language Features
        • New Reserved Words
        • Uniform Variable Syntax
        • Parameter Handling
        • Calling Functions and Methods with too few Arguments
        • Variable Variables are no Longer Allowed in global Declarations
        • instanceof and Literals
        • Traits with Default Property Values
        • DateTime, DateTimeImmutable, and Microseconds
        • Comparison of DateInterval Objects
        • Dynamic Calls to Scope Introspection Functions
        • Static Methods and ReflectionMethod::invoke()
        • Removed PHP Extensions
        • Optional Parameter of mktime() Removed
        • stdClass Objects and var_export()
        • Heredoc and Nowdoc Syntax
      • Facepalms and WTF Moments
        • No More Cheating Using Parentheses
        • Identical Parameter Names are no Longer Allowed
        • Multiple Default Blocks in switch Statements
        • Abusing $this
        • Using get_class() on null
        • Inheritance Loophole for Static Properties
        • parent and classes without a parent
        • Static versus Non-Static Access
        • Only Variables should be Assigned or Passed by Reference
        • setcookie() and Empty Names
        • Counting of Non-Countable Objects
        • Bareword (Unquoted) Strings
        • Using Resources as Keys
        • Working with References
    • Deprecated Features
      • Strings
        • parse_str() without Result Argument
        • String Search and Non-String Needles
        • Curly Brace Syntax
        • Concatenation Precedence
        • Deprecate hebrevc()
        • Deprecate convert_cyr_string()
        • Deprecate FILTER_SANITIZE_MAGIC_QUOTES
        • Deprecate strip_tags Filter for Streams, and fgetss()
        • Deprecate Non-String Needles in Search Functions
      • Arrays
        • Loops with each
        • Curly Brace Syntax
        • Using array_key_exists() on Objects
        • Deprecate wrong parameter order for implode()
      • Graphics
        • png2wbmp() and jpegwbmp()
      • Internationalisation and Unicode
        • The mbstring.func_overload Configuration Directive
        • Third Parameter to mb_strrpos()
        • Deprecate money_format()
        • Deprecate Undocumented Aliases of mbstring extension
        • Deprecate Normalizer::NONE
      • Language Features
        • Global __autoload() Function
        • create_function()
        • assert() with String Argument
        • PHP 4-Style Constructors
        • track_errors Configuration Directive
        • Non-Static Closures and $this Unbinding
        • break and continue Outside Loops
        • Default Object Creation and Empty Values
        • Serialization of Reflection Objects
        • Traversable and Argument Unpacking
        • ArrayAccess and Type Conversion of Keys
        • Option to configure remote includes now deprecated
        • is_real() and (real)
        • Deprecate restore_include_path()
      • Security
        • Deprecate Salt Option of password_hash()
      • Extensions
        • LDAP
      • More Facepalms
        • The (unset) Cast
        • Deprecated ezmlm_hash()
        • Nested Ternary Operators Need Parentheses
        • Non-String Arguments to mb_ereg_replace()
        • Case-Insensitive Constants
        • Impossible URL Filters
        • Are you Using PDO to Connect to DB2 via ODBC?
  • New and Extended Functionality
    • Error Handling
      • Engine Exceptions
      • Parse Errors
      • Parse Errors in evaluated Code
      • Recoverable Fatal Errors
      • Method Call on Non-Object
      • CompileError
      • Errors in Extensions
      • Constructors of Internal Classes
      • Better syslog support with error_log
      • error_clear_last()
      • Changed E_STRICT Notices
      • __toString() and Exceptions
      • Chained Autoloaders and Exceptions
      • Stack Traces and Arguments
      • JSON_THROW_ON_ERROR
      • Handling Multiple Exception Types with one catch Statement
    • Type System
      • Scalar Type Declarations
        • History
        • Coercive Interpretation
        • Strict Interpretation
      • Nullable Types
      • Return Type Declarations
      • Typed Properties
      • Inheritance
        • Method Compatibility
        • Constructor Access
      • The object Type
      • The Iterable Type
      • Type Casting to array or object
      • MySQL and Native Types
        • mysqli
        • pdo_mysql
      • Typed Values from ini Files
      • Changed Error Messages
    • Language Features
      • Preloading
      • Foreign Function Interface (FFI)
      • Arrow Functions
      • Generators
        • Generator Return Expressions
        • Generator Delegation
        • yield in Expression Context
      • Anonymous Classes
      • Assertions
      • Group Use Declarations
      • Countable Interface and Internal Classes
      • is_countable()
      • Asynchronous Signal Handling
      • spl_object_id()
      • get_mangled_object_vars()
      • gettype and resources
      • Custom Object Serialization
      • is_object() and Incomplete Classes
      • Null Coalesce Operator
      • Null Coalescing Assignment Operator
      • Combined Comparison Operator
      • Weak References
      • Numeric Literal Separator
      • Trailing Commas in Function and Method calls
    • Constants
      • New Global Constants
        • Constants Related to Floating-Point Numbers
        • The PHP_OS_FAMILY Constant
        • The PHP_INT_MIN Constant
      • Arrays as Constant Values
      • Class Constant Visibility
    • Strings
      • Negative String Offsets
    • Arrays
      • Short List Syntax
      • list() and the ArrayAccess Interface
      • Specifying Keys in list()
      • list() and References
      • The array_column() Function
      • array_merge() and array_merge_recursive()
      • array_push() and array_unshift()
      • array_key_first() and array_key_last()
      • Spread Operator in Array Expressions
    • Mathematics
      • Consistent 64-bit Support
      • Integer Division
      • gmp_random_seed()
      • gmp_binomial()
      • gmp_kronecker()
      • gmp_lcm()
      • gmp_perfect_power()
    • Graphics
      • New GD Functions
      • WebP Support in imagecreatefromstring()
    • Internationalisation and Unicode
      • Unicode Code Point Escape Syntax
      • Improvements to mbstring
      • Splitting Multibyte Strings with mb_str_split
      • New Constants for Spoofchecker
      • Added Normalizer::getRawDecomposition() Method
      • New Functions mb_chr() and mb_ord()
      • New Function mb_scrub()
      • Array Argument for mb_convert_encoding()
    • Regular Expressions
      • JIT Support for Regular Expressions
      • PCRE 2
      • preg_quote() and the # Character
      • preg_replace_callback_array()
      • Flags for preg_replace_callback() and preg_replace_callback_array()
    • Session Management
      • session_start()
      • Session ID without Hashing
      • Session Garbage Collection
    • I/O and Filesystem
      • Support for VT100 Console Mode
      • Optional Level Parameter for dirname()
      • Specifying the zip Compression Method
      • Stream-Based Compression
      • Output Buffering and ignore_user_abort()
      • New function stream_isatty()
      • Stream Context Option on Windows
      • Debugging PDO Prepared Statement Emulation
      • proc_open() on Windows
      • proc_nice() on Windows
      • getrusage() on Windows
      • memory_limit on Windows
      • File Deletion on Windows
      • Username and Password in PDO DSN
      • New Function fpm_get_status() in PHP-FPM
      • getallheaders() Available in PHP-FPM
      • New Configuration Settings in PHP-FPM
    • Cryptography and Security
      • New Hashing Algorithm for Passwords
      • crc32c Hashing Algorithm
      • mail() and mb_send_mail() Hardened Against Header Injections
      • Secure unserialize()
      • max_depth Option for unserialize()
      • Better random source for uniqid()
      • Improved SSL/TLS
      • Enhanced Cryptography Features
      • OpenSSL
      • Cryptographically Secure Pseudo-Random Number Generator (CSPRNG)
      • Filtering Syslog Messages
      • Same-Site Cookies
    • Reflection API
      • Scalar Type Declarations
      • Generators
      • References
    • Date and Time
      • DateTime::createFromImmutable()
      • High-Resolution Monotonic Timer
      • MySQL, Prepared Statements, and Fractional Seconds
    • LDAP
  • Beyond PHP 7.4
    • Just-in-Time Compiler (JIT)
    • Attributes
    • Union Types
    • mixed Type
    • Constructor Property Promotion

ChangeLog

2020-11-26

Added

Coverage of PHP 7.3 and PHP 7.4

Changed

Fundamental overhaul of content and structure for better read flow

2018-04-19

Changed

  • Updated installation instructions for Debian, Ubuntu, and macOS

Fixed

  • Fixed example in “Strict Types and Indirect Invocation” section
  • Fixed example in “Using Resources as Keys” section

2018-01-31

Added

Coverage of PHP 7.2

2017-02-07

Added

  • [] Operator and Empty Strings” section
  • DateTime, DateTimeImmutable, and Microseconds” section
  • Explanation of how inheritance affects nullable parameter type declarations
  • Explanation of nullable return type declarations
  • Information on PHP 7.1 support timeline

Changed

  • Moved discussion of inheritance rules affecting the nullability of return types after the introduction of return type declarations
  • Consistent use of stdClass instead of StdClass
  • Consistent use of “macOS” instead of “MacOS X”

Fixed

  • Discussion of coercive and strict interpretation of return type declarations
  • Type error in the example in the asynchronous signal handling section
  • Spelling mistakes

2016-11-14

Added

  • Example for ReflectionParameter::allowsNull()
  • Explanation of the difference between direct queries and prepared statements in the section on MySQL and native types

Changed

  • Examples for Reflection API related to nullable types

Fixed

  • Example in the section on the iterable super-type
  • Spelling mistakes

2016-10-04

Initial release

Authors

Book

Reviews

Buy

Download