Category: 13. Advanced

  • PDO Extension

    PDO is an acronym for PHP Data Objects. PHP can interact with most of the relational as well as NOSQL databases. The default PHP installation comes with vendor-specific database extensions already installed and enabled. In addition to such database drivers specific to a certain type of database, such as the mysqli extension for MySQL, PHP…

  •  FastCGI Process

    PHP FastCGI Process Manager (PHP-FPM) is an efficient alternative to traditional CGI-based methods for handling PHP requests, particularly in high-traffic environments. PHP-FPM has a number of important features. These features are as follows − Reduced Memory Consumption With the help of a pool of worker processes to handle requests PHP-FPM significantly reduces memory overhead compared…

  • CSRF

    The acronym “CSRF” stands for Cross-Site Request Forgery. CSRF is an Internet exploit that involves a trusted website user issuing unauthorized commands. Providing adequate protection to a PHP web application against this attack can be achieved by taking the measures explained in this chapter. By default, the browser uses the “GET” request method to send…

  • 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…

  • Integer Division

    PHP has introduced a new function intdiv(), which performs integer division of its operands and return the division as int. The intdiv() function returns integer quotient of two integer parameters. If “a/b” results in “c” as division and “r” as remainder such that − In this case, intdiv(a,b) returns r − The $x and $y are the numerator and…

  • 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 − It will produce the following output − Note that the output may vary every time the code is executed.…