Assignment operators are used to set a variable equal to a value or set a variable to another variable's value. Such an assignment of value is done with the "=", or equal character. Example:
- $my_data = 2;
- $another_data = $my_data
Now both $my_data and $another_data contain the value 2. Assignments can also be used in conjunction with arithmetic operators.
Arithmetic operators are used to perform mathematical operations like addition, subtraction, multiplication, division and Modulus.
Comparison operator: Comparisons are used to check the relationship between variables and/or values. Comparison operators are used inside conditional statements and evaluate to either true or false. Here are the most important comparison operators of PHP. Assume: $x = 4 and $y = 5;
String Operators: As we have already seen in the Echo statement, the period "." is used to add two strings together, or more technically, the period is the concatenation operator for strings. By the following program you can see the function of string operator.
The Concatenation Operator
There is only one string operator in PHP. The concatenation operator (.) is used to put two string values together. To concatenate two string variables together, use the concatenation operator:
echo $txt1 . " " . $txt2; ?>
The output of the code above will be:
Hello World! Distance education!
- answered 3 years ago
- B Butts