Since PHP 8.2, classes can be declared as readonly. This means that all class properties automatically becomes readonly. The readonly properties were introduced in PHP 8.1. These properties can be...
PHP supports various regular expression modifiers that can be used with preg_* functions (e.g. preg_match). For example, the i modifier can be used for case-insensitive match. Since PHP 8.2, we...
Some of the PHP INI directives also accepts shorthand byte values, such as 1K for 1 kilobyte, or 10M for 10 megabytes, etc. 1K equals 1024 bytes. Available options are...
PHP provides the memory_get_peak_usage function that allows to get the absolute peak memory usage, in bytes, allocated by PHP script. However, without reset the memory usage, it is hard to...
Traits provide a way to reuse code in classes without using inheritance. All properties and methods declared in trait are available within the class. Since PHP 8.2, we can use...
Since PHP 8.0, we can use union types, where the value should be one of the specified types. Since PHP 8.1, we can use intersection types, where the value should...
Since PHP 8.2, the error_log_mode INI directive can be used to set permissions for an error log file, which configured with the error_log directive. Default value is 0644. It means...
Stack traces in exceptions can be useful for testing and debugging purposes. The stack trace contains the function names and parameters for each stack frame. It allows seeing what data...
PHP has OpenSSL extension that provides various functions related with cryptography, such as symmetric and asymmetric encryption and decryption, private and public key pair generation, etc.
Since PHP 8.2, we...
PHP has a function str_split that can be used to convert a string to an array. In PHP versions before 8.2, the str_split function returns an array with a single...