Tag

PHP

Variable Scope

The variable in the PHP scope can be defined as the variable that already defined in anywhere and can be accessed from another place. The all PHP variable works with a single scope which allow you to access the variables from another PHP file. Anyway, There are three scopes in PHP, which are local scope,

Variable Function

The variable function refers to the variable that has parentheses ( .. ) and assign a function name in PHP. That leads the PHP translator to check if this variable is storing a callback or a callable function. Otherwise, it will produce an error. Let’s see examples. How to Assign a Function to Variable using

Anonymous Functions

The PHP anonymous functions are the functions that have no names. So there is no identifier for the function. Usually the PHP anonymous functions can be written without names like the below example. That means there is no calling for this function. Let’s see more examples. Basic Examples for Anonymous Function The anonymous function can

Type Hinting

The PHP type hinting can be defined as the expected values of PHP data types that can be passed into the PHP arguments. When you define a function in PHP you don’t need to specify the data type of parameters because PHP is typed language, It is adding the data types as a dynamic when

array_filter()

The PHP array_filter can be written like this syntax: The output: Array ( [0] => 1 [1] => 2 [3] => 3 [4] => 4 [6] => 5 ) PHP array_filter is a built-in PHP function designed to filter the array elements through a callback and that can be done using a condition inside this

array_map()

The PHP array_map function would be written as the following example. This example will print the below result. Array ( [0] => 10 [1] => 15 [2] => 11 [3] => 18 (✓) [4] => 17 (✓) [5] => 15 [6] => 16 (✓) [7] => 35 [8] => 30 [9] => 20 (✓) [10]

array_merge()

The basic expression for the PHP array_merge function would be like the below. The output: Array ( [0] => value 1 [1] => value 2 [2] => value 3 [3] => value 4 ) The PHP array_merge is a built-in PHP function which used to collect and merge two or more arrays together, then return

Multidimensional Array

The PHP multidimensional array refers to arrays inside another arrays, which means the ability to design a big tabular by arrays. For example. The following image shows you an image contains tables which are designed to expose the data inside the above example. As you see in the above image, It shows you the number

Associative Arrays

The PHP associative arrays are lists or groups that already have multiple values grouped by indexes or serials. The basic array syntax would be like the below. array( … ); // or [ … ] PHP Associative Arrays Overview The associative array contains a list of values grouped by labels. So each value inside the

Spread Operator

The first appearance for PHP spread operator was in PHP7.4, it used to unpack data from function arguments, and arrays. The expression of PHP spread operator is written as three dots … which allows to extract the data from the arrays or function arguments. So the basic syntax for the spread operator as the below.