PHP Operators

From Techotopia
Revision as of 19:21, 29 May 2007 by Neil (Talk | contribs) (Assignment Operators)

Jump to: navigation, search

Opertors in PHP, and any other prgramming language for that matter, enable us to perfrom tasks on variables and values such as assign, multiply, add, subtract and concatenate them. Operators take the form of symbols (such as + and -) and combinations of symbols (such as ++ and +=).

Operators in PHP work with operands that specify the variables and values that are to be used in the particalar operation. The number and location of tyhese operands in relate to the operators (ie before and/or after the operator) depends on the type of operator in question. In this chapter of PHP Essentials we will exlore each type of operator and explain how they are used in relation to their operands.

Assignment Operators

The assignment operator is used to assign a value to a variable and is represented by the equals (=) sign. The assignment operator can be combined with arithmetic operators to combine an assignment with a mathemtatical operation (for example to multiple one value by another and assigning the result to the variable.

The following table lists the seven assigmnet operators available in PHP, togetehr with descriptions and examples of their use:

OperatorTypeDescriptionExample =AssignmentSets the value of the left hand operand to the value of the right $myVar = 30;