VARIABLES:
Variables represent data. For example,
The variable “city” holds the literal value “Kathmandu” when appearing in your script as: $city = “Kathmandu”;
Variables in PHP are represented by a dollar sign followed by the name of the variable.
PHP supports the basic data types of strings, integers, double precision floating point numbers, etc. Variables are not tied to a specific data type, and may take any of the data types.
OPERATORS:
Using different types of operators we values are assigned to variables. Different types of operators are as follows:
Variables represent data. For example,
The variable “city” holds the literal value “Kathmandu” when appearing in your script as: $city = “Kathmandu”;
Variables in PHP are represented by a dollar sign followed by the name of the variable.
PHP supports the basic data types of strings, integers, double precision floating point numbers, etc. Variables are not tied to a specific data type, and may take any of the data types.
OPERATORS:
Using different types of operators we values are assigned to variables. Different types of operators are as follows:
a. Arithmetic operator:
+, -, *, /, and % are assignment operators.
+, -, *, /, and % are assignment operators.
b. Assignment operator:
The basic assignment operator is (=) sign.
The basic assignment operator is (=) sign.
c. Comparison operator:
This operator is used to compare to values. Most of the comparison operators are:
== equal to
!= not equal to
> greater than
< less than
>= greater than or equal to
<= less than or equal to
This operator is used to compare to values. Most of the comparison operators are:
== equal to
!= not equal to
> greater than
< less than
>= greater than or equal to
<= less than or equal to
d. Logical operator:
This operator allows your script to determine the status of the conditions. Mostly this operator is used in if.... else and while control statements.
Following are the logical operators:
! -> not
Example: !$x. This means TRUE if $x is not true.
&& -> and
Example: $x && $y. This means TRUE if $x and $y are true.
|| -> or
Example: $x || $y. This means TRUE if either $x or $y is true.
e. Increment or decrement operator:
This operator adds or subtracts from a variable.
Pre-increment: ++$x
It means increment by 1 and returns $x
Post-increment: $x++
It means return $x and then increment $x by 1
Pre-decrement: --$x
It means decrement by 1 and returns $x
Post-decrement: $x--
It means return $x and then decrement $x by 1
This operator allows your script to determine the status of the conditions. Mostly this operator is used in if.... else and while control statements.
Following are the logical operators:
! -> not
Example: !$x. This means TRUE if $x is not true.
&& -> and
Example: $x && $y. This means TRUE if $x and $y are true.
|| -> or
Example: $x || $y. This means TRUE if either $x or $y is true.
e. Increment or decrement operator:
This operator adds or subtracts from a variable.
Pre-increment: ++$x
It means increment by 1 and returns $x
Post-increment: $x++
It means return $x and then increment $x by 1
Pre-decrement: --$x
It means decrement by 1 and returns $x
Post-decrement: $x--
It means return $x and then decrement $x by 1
No comments: