Author: Awais Farooq

  • $_POST

    $_POST is one of the predefined or superglobal variables in PHP. It is an associative array of key-value pairs passed to a URL by the HTTP POST method that uses URLEncoded or multipart/form-data content-type in the request. Assuming that the URL in the browser is “http://localhost/hello.php”, method=POST is set in a HTML form “hello.html” as…

  • $_REQUEST

    In PHP, $_REQUEST is a superglobal variable. It is an associative array which is a collection of contents of $_GET, $_POST and $_COOKIE variables. $_REQUEST with GET Method Save the following script in the document folder of the Apache server. If you are using XAMPP server on Windows, place the script as “hello.php” in the…

  • $_SERVER

    $_SERVER is a superglobal in PHP. It holds information regarding HTTP headers, path and script location, etc. The following table lists some of the important server variables of the $_SERVER array followed by the description of their values. Sr.No Server Variables & Description 1 PHP_SELFStores filename of currently executing script. 2 SERVER_ADDRThis property of array…

  • $GLOBALS

    $GLOBALS is one of the “superglobal” or “automatic global” variables in PHP. It is available in all scopes throughout a script. There is no need to do “global $variable;” to access it within functions or methods. $GLOBALS is an associative array of references to all globally defined variables. The names of variables form keys and…

  • Superglobals

    The PHP parser populates the current script with a number of predefined variables in its global namespace. The predefined variables are known as “PHP superglobals“. Most of the superglobals in PHP are associative arrays, and the web server populates them. Hence, if a script is run in the command-line environment, some of the superglobals may…

  • Global Variables

    In PHP, any variable that can be accessed from anywhere in a PHP script is called as a global variable. If the variable is declared outside all the functions or classes in the script, it becomes a global variable. While global variables can be accessed directly outside a function, they aren’t automatically available inside a function.…

  • Local Variables

    Scope can be defined as the range of availability a variable has to the program in which it is declared. PHP variables can be one of four scope types − Local Variables A variable declared in a function is considered local; that is, it can be referenced solely in that function. Any assignment outside of…

  • Variable Handling Functions

    PHP Variable Handling Functions are the inbuilt PHP library functions that enable us to manipulate and test php variables in various ways. Installation There is no installation needed to use PHP variable handling functions; they are part of the PHP core and comes alongwith standard PHP installation. Runtime Configuration This extension has no configuration directives defined…

  • Arrow Functions

    Arrow functions were introduced in PHP 7.4 version. Arrow functions provide a simpler and more concise syntax for writing anonymous functions. With PHP 7.4, a keyword “fn” has been introduced for defining arrow functions, instead of the conventional use of the “function” keyword. Example The following example demonstrates how you can use the arrow function…

  • Anonymous Functions

    What are Anonymous Functions? PHP allows defining anonymous functions. Normally, when we define a function in PHP, we usually provide it a name which is used to call the function whenever required. In contrast, an anonymous function is a function that doesn’t have any name specified at the time of definition. Such a function is also called closure or lambda…