Category: 10. PHP
-
Strings
A string is a sequence of characters, like ‘PHP supports string operations.’ A string in PHP as an array of bytes and an integer indicating the length of the buffer. In PHP, a character is the same as a byte. This means that PHP only supports a 256-character set, and hence does not offer native…
-
Type Juggling
PHP is known as a dynamically typed language. The type of a variable in PHP changes dynamically. This feature is called “type juggling” in PHP. In C, C++ and Java, you need to declare the variable and its type before using it in the subsequent code. The variable can take a value that matches with…
-
Type Casting
The term “Type Casting” refers to conversion of one type of data to another. Since PHP is a weakly typed language, the parser coerces certain data types into others while performing certain operations. For example, a string having digits is converted to integer if it is one of the operands involved in the addition operation.…
-
Data Types
The term “data types” refers to the classification of data in distinct categories. PHP has a total of eight data types that we use to construct our variables − The first five are simple types, and the next two (arrays and objects) are compound types. The compound types can package up other arbitrary values of…
-
Magic Constants
The magical constants in PHP are predefined constants. They are available to any script on which they run, and they change depending on where they are used. All these “magical” constants are resolved at compile time, unlike regular constants, which are resolved at runtime. There are nine magical constants in PHP. These special constants are…
-
Constants
A constant in PHP is a name or an identifier for a simple value. A constant value cannot change during the execution of the PHP script. Examples of Valid and Invalid Constant Names in PHP Here are some examples of valid and invalid constant names in PHP − Difference between Constants and Variables in PHP…
-
$ and $$ Variables
We know that PHP uses the convention of prefixing the variable names by the “$” symbol. PHP also has the provision of declaring dynamic variables by prefixing two dollar symbols ($$) to the name. A variable variable (or a dynamic variable) can be set and used dynamically. The declaration of a normal variable is like…
-
PHP var_dump() Function
ne of the built-in functions in PHP is the var_dump() function. This function displays structured information such as type and the value of one or more expressions given as arguments to this function. This function returns all the public, private and protected properties of the objects in the output. The dump information about arrays and…
-
Echo/Print
In PHP, both echo and print statements are used to render the output either on the browser or the PHP console. Both of them are not functions but they are language constructs. Hence, parentheses should not be used with either of them. The “echo” Statement in PHP The echo statement is used with following syntax − The echo statement outputs one or more…
-
Variables
A variable in PHP is a named memory location that holds data belonging to one of the data types. Variables are assigned with the “=” operator, with the variable on the left hand side and the expression to be evaluated on the right. No Need to Specify the Type of a Variable PHP is a…