My Blog

My WordPress Blog

My Blog

My WordPress Blog

Day: October 5, 2024

$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 […]

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 […]

Type Hints

PHP supports using “type hints” at the time of declaring variables in the function definition and properties or instance variables in a class. PHP is widely regarded as a weakly typed language. In PHP, you need not declare the type of a variable before assigning it any value. The PHP parser tries to cast the […]

Scroll to top