Category: PHP
-
Call by Value
By default, PHP uses the “call by value” mechanism for passing arguments to a function. When a function is called, the values of actual arguments are copied to the formal arguments of the function’s definition. During the execution of the function body, if there is any change in the value of any of the formal arguments,…
-
Function Parameters
Function Parameters in PHP A function in PHP may be defined to accept one or more parameters. Function parameters are a comma-separated list of expressions inside the parenthesis in front of the function name while defining a function. A parameter may be of any scalar type (number, string or Boolean), an array, an object, or…
-
Functions
Like most of the programming languages, a function in PHP is a block of organized, reusable code that is used to perform a single, related action. Functions provide better modularity for your application and a high degree of code reuse. PHP supports a structured programming approach by arranging the processing logic by defining blocks of…
-
Constant Arrays
In PHP, an array is a collection of elements that can have several values under a single name. Normally, arrays in PHP are mutable, which means you can add, remove or change elements after they are generated. Constant arrays, on the other hand, are useful when you want an array with values that never change…
-
Array Functions
PHP Array Functions allow you to interact with and manipulate arrays in various ways. PHP arrays are essential for storing, managing, and operating on sets of variables. PHP supports simple and multi-dimensional arrays and can be either user created or created by another function. You can use these functions to modify, sort, add, remove or search…
-
Multidimensional Array
A multidimensional array is an array of arrays. In a PHP array, each element can be another array. If the array consists of values or key-value pairs with values being of singular scalar types, it is a one-dimensional array. If each element in an array is an array of one or more scalar values, it…
-
Associative Array
If each element in a PHP array is a key-value pair, such an array is called an associative array. In this type of array, each value is identified by its associated key and not an index. Associative arrays are used to implement data structures such as dictionary, maps, trees, etc. In PHP, the “=>” symbol is…
-
Indexed Array
In PHP, the array elements may be a collection of key-value pairs or it may contain values only. If the array consists of values only, it is said to be an indexed array, as each element is identified by an incrementing index, starting with “0”. Creating an Indexed Array An indexed array in PHP may…
-
Arrays
An array is a data structure that stores one or more data values having some relation among them, in a single variable. For example, if you want to store the marks of 10 students in a class, then instead of defining 10 different variables, its easy to define an array of 10 length. Arrays in…
-
Continue Statement
Like the break statement, continue is another “loop control statement” in PHP. Unlike the break statement, the continue statement skips the current iteration and continues execution at the condition evaluation and then the beginning of the next iteration. The continue statement can be used inside any type of looping constructs, i.e., for, for-each, while or do-while loops. Like break, the continue keyword is also normally used conditionally. Syntax of Continue Statement The…