Lead Image © MIR, Fotolia.com

Lead Image © MIR, Fotolia.com

New features in PHP 7.3

Prime Numbers

Article from ADMIN 51/2019
By
The new PHP 7.3 simplifies string handling, supports PCRE version 2, adds LDAP controls, improves logging, and deprecates some features, functions, and syntax elements.

PHP version 7.3 [1] became available at the end of 2018. At first glance, the innovations do not appear spectacular, but they could disrupt existing scripts. That said, with deprecations and end of support for older PHP versions, website owners might want to consider switching to the new version as soon as possible.

PHP 7.3 not only throws some ballast overboard, it also introduces syntax changes. In everyday life, programmers may particularly notice the switch to PCRE2 (Perl-compatible regular expressions, version 2), the changed behavior in multibyte string functions, and the more flexible Heredoc and Nowdoc syntax.

The Here and Now

The Heredoc syntax simplifies the assignment and output of longer text by replacing strings in double quotation marks with text between delimiters. For example, if $name = "Hans Hansen";, the Heredoc

$output = <<<EOT
My name is: "$name".
EOT;

would output My name is: Hans Hansen. In a Heredoc, the <<< operator is followed by an identifier that signals the beginning of text. The text continues until the identifier appears again to mark the end of the Heredoc.

Nowdoc syntax was introduced in PHP 5.3.0. It behaves like text in single quotes, which PHP does not interpret. If you change the first line of the example to

$output = <<<'EOT'

$output would display the text My name is: "$name".

In older PHP versions, a semicolon and a blank line always followed the second identifier at the end of the string. The expression EOT; echo $output; was not allowed, for example. In PHP 7.3, this constraint has been eliminated for both Heredoc and Nowdoc. Moreover, developers can finally indent the text and the identifier:

 ...
	
Use Express-Checkout link below to read the full article (PDF).

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy ADMIN Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Lua for Apache

    Lua is a small, lean, and fast scripting language – ideal for working with web servers. Version 2.4 of the Apache web server is the first to offer a matching module that has a few quirks – and pitfalls, if you dig more deeply.

  • Innovations in PowerShell 5
    Windows 10 brings an updated, fifth release of PowerShell that vastly simplifies the task of managing modules and software packages. The scripting language now also handles various formatted output from commands and selection lists.
  • The Lua scripting language
    The Lua scripting language is built in to a variety of programs. In this article, we provide an insight into the Lua cosmos.
  • The Lua Scripting Language

    Is this powerful but simple scripting language big enough for Big Data?

  • Data Analysis with Panda

    The Python Data Analysis Library, or Pandas, is built on top of the fast math library NumPy and makes analysis of large volumes of data an easy and efficient experience.

comments powered by Disqus