PHP syntax and semantics

[3] Some keywords represent things that look like functions, some look like constants, but they are actually language constructs.

[4] PHP generally follows C syntax, with exceptions and enhancements for its main use in web development, which makes heavy use of string manipulation.

The purpose of the delimiting tags is to separate PHP code from non-PHP data (mainly HTML).

[9] These recommended delimiters create correctly formed XHTML and other XML documents.

[10] This may be helpful if the source code documents ever need to be processed in other ways during the life of the software.

PHP treats newlines as whitespace, in the manner of a free-form language.

[19] The match expression is conceptually similar to a switch statement and is more compact for some use cases.

An example of the syntax for an if/elseif statement is as follows: This style is sometimes called template syntax, as it is often found easier to read when combining PHP and HTML or JavaScript for conditional output: Runtime exception handling method in PHP is inherited from C++.

[23] PHP supports four scalar types: bool, int, float, string.

Using the Boolean type conversion rules, non-zero values are interpreted as true and zero as false, as in Perl.

[26] Integer variables can be assigned using decimal (positive and negative), octal, hexadecimal, and binary notations.

[24] PHP supports four compound types: array, object, callable, iterable.

Arrays can contain mixed elements of any type, including resources, objects.

[32] It can be any array or generator or object that implementing the special internal Traversable[33] interface.

[36] Some core PHP developers have publicly expressed disappointment with this decision.

And typed variadic arguments: Using generators, we can write code that uses foreach to iterate over a dataset without having to create an array in memory, which can result in memory overhead or significant processing time for generation.

[41] Object handling was completely rewritten for PHP 5, expanding the feature set and enhancing performance.

[42] In previous versions of PHP, objects were handled like primitive types.

The static method and class variable features in Zend Engine 2 do not work the way some would expect.

There is no virtual table feature in the engine, so static variables are bound with a name instead of a reference at compile time.

If the developer creates a copy of an object using the reserved word clone, the Zend engine will check if a __clone() method has been defined or not.

For convenience, the engine will supply a function that imports the properties of the source object, so that the programmer can start with a by-value replica of the source object and only override properties that need to be changed.

[44] This example uses a trait to enhance other classes: This allows simulating aspects of multiple inheritance: