| PHP |
The first thing to keep in mind about PHP is the fact that all variable names must start with the dollar sign ($). If you try to use, define, or declare a variable in any other way, an error will occur on that line. If you have an error that you can't seem to find on a specific line, you may often find that it stems from the fact that you forgot to place a dollar sign in front of the variable name.
Unlike other programming and scripting languages, PHP is both case-sensitive and case-insensitive. All functions in PHP are case-insensitive while all variables are case-sensitive. Below you can see an example function in PHP:
function modof($operand, $OpErAnD)
{
return $operand % $OpErAnD;
}
The above function will take two parameters and return the result of modding the first parameter by the second. In the case of use the mod operator, order of operations does matter. Notice that both parameters are spelled the same but the casing is different. If the language used case-insensitive variables, either an error would be thrown or the results of using this function would not always be correct. On the other hand, since function names are case-insensitive, one could call this function in any of the following ways with the same result:
Arrays can be indexed in two distinct ways. The first way is to use numerical values as indices. This is the traditional way that arrays are used in many programming languages. This type of array is referred to as a numeric array. Numeric arrays are zero-based. The second way is to use string values as indices. This type of array is referred to as an associative array.
If you have an array of N elements and you would like to add one more, you can use one of the following formats:
There are many other things that you can do with arrays as well. At times you may want to slice or splice arrays. Click here to see a list of the different array functions available in in PHP.
Powered by jPaq.