PHP provides functions that allow to sort an array using a user-defined comparison function. The comparison function must return an integer greater than zero if first element is larger than...
PHP allows defining optional parameters in function and method signatures. These parameters have a default value, which can be specified by using an equals (=) sign. If no argument is...
The new keyword allows creating an instance of a class. In versions prior to PHP 8.0, the new keyword can only be used with identifiers.
Let's say we have a...
The instanceof operator allows checking if an object is an instance of a class or that class implements an interface. In versions prior to PHP 8.0, the instanceof operator can...
PHP has built-in web server that designed to use for testing, development or application demonstration purposes. Since 8.0, the built-in web server allows to bind to port 0. It will...
Resource is a type of variable that contains a reference to an external resource. It can be database connection, file handle, cURL handle, etc.
Each resource is identified by a...
Traits can have abstract methods. Any class that uses a trait with an abstract method must implement that method. In versions prior to PHP 8.0, the signature of an abstract...
An old-style constructor is a method which has the same name as the class. Old-style constructors were used in PHP 4.
In PHP 5 and PHP 7, we can use...
PHP allows defining type declarations for parameters, return values, and properties. In PHP 7.0 and newer versions, we can use self and parent return types for class methods. Since PHP...
The PCRE extension provides functions that allow to perform a regular expression (regex) matching operations. A regular expression is defined using the same syntax as Perl 5. This extension is...