NiPS Institute is IGNOU Best coaching institute for BCA MCA Program Provides PHP Q/A for IGNOU Students
What are the Operators in php
Php applications use operators to process the data that entered by a user or fetch from the database. Operators like + and – are used to process variables and return a value. It is used for computations or comparisons and it may contain one or more characters. Operators can transform one or more data values called operands, into a new data value.
Consider the following example:
$a+$b
The preceding example uses two operands and an operator to add the values stored in the variables.
Following operators used in php
1. Arithmetic operators
2. Assignment operators
3. Unary operators
4. Comparison operators
5. Logical operators
6. Array operators
Arithmetic operators
These operators are the symbols that are used to perform arithmetic operations on the php variables. The following table describes the commonly used arithmetic operators.
Operators
|
Description
|
Example
|
+
|
Used to add to numbers
|
$a = $b+$c;
If $b is equal to 10 and $c is equal to 5,Then $a will be 15
|
-
|
Used to subtract two numbers
|
$a = $b-$c;
If $b is equal to 10 and $c is equal to 3,Then $a will be 12
|
*
|
Used to multiple two numbers
|
$a = $b*$c;
If $b is equal to 8 and $c is equal to 5,Then $a will be 40
|
/
|
Used to divide one number by another
|
$a = $b/$c;
If $b is equal to 8 and $c is equal to 2,Then $a will be 4
|
%
|
Used to divide two numbers and return the reminder
|
$a = $b%$c;
If $b is equal to 21 and $c is equal to 2,Then $a will be 1
|
No comments:
Post a Comment