Author: saqibkhan
-
PEAR
PEAR is an acronym for PHP Extension and Application Repository. It is a repository of PHP packages or extensions. You can freely incorporate any of these extensions from PEAR in your code. The PEAR project was established by Stig S. Bakken in 1999. Most of the precompiled distributions of PHP such as XAMPP already have PEAR…
-
Removed Extensions & SAPIs
With each new version of PHP, new functionality is added and at the same time certain obsolete functionality is removed. PHP version 7 is a major version when a number of PHP extensions and SAPIs (Server-side Application Programming Interface) were removed. In the subsequent PHP 8 version also, a few more extensions have been removed.…
-
Deprecated Features
As some new features are added with each new version, some features are also removed as they are deemed to be obsolete. In this chapter, we have a look at deprecated features after PHP version 5. Deprecated in PHP Ver 7 PHP 4 Style Constructors PHP 4 style Constructors are methods having same name as…
-
The “use” Statement
The “use” keyword in PHP is found to be associated with multiple purposes, such as aliasing, inserting traits and inheriting variables in closures. Aliasing Aliasing is accomplished with the use operator. It allows you to refer to an external fully qualified name with an alias or alternate name. Example Take a look at the following…
-
Expectations
Expectations are a backwards compatible enhancement to the older assert() function. Expectation allows for zero-cost assertions in production code, and provides the ability to throw custom exceptions when the assertion fails. assert() is now a language construct, where the first parameter is an expression as compared to being a string or Boolean to be tested. Configuration Directives for…
-
CSPRNG
The acronym CSPRNG stands for Cryptographically Secure Pseudorandom Number Generator. PHP function library includes many functions that generate random numbers. For example − Example The following code shows how you can use the function mt_rand() to generate random numbers − Open Compiler It will produce the following output − Note that the output may vary every time the code…
-
IntlChar
In PHP7, a new IntlChar class has been introduced. It provides access to a number of utility methods that can be used to access information about Unicode characters. There are a number of static methods and constants in Intl class. They adhere closely to the names and behavior used by the underlying ICU (International Components…
-
Filtered unserialize()
In PHP, the built-in function unserialize() is available from PHP version 4 onwards. With PHP 7, a provision to pass a list of allowed classes has been added. This allows the untrusted source to be filtered out. The unserialze() function unserializes the data from only the trusted classes. In PHP, serialization means generation of a…
-
Closure::call()
In PHP, a closure is an anonymous function that has access to the variables in the scope in which it was created, even after that scope has closed. You need to specify use keyword in it. Closures are objects that encapsulate the function code and the scope in which they were created. With PHP 7, a new closure::call() method…
-
Swapping Variables
PHP doesn’t provide any built-in function with which you can swap or interchange values of two variables. However, there are a few techniques which you can use to perform the swap. One of the most straightforward approaches is to use a third variable as a temporary place holder to facilitate swapping. Using the arithmetic operators…