> Online tutorial : php operator
Showing posts with label php operator. Show all posts
Showing posts with label php operator. Show all posts

conditional operator

The ? operator is equivalent to an if statement.it os called a terary operator because it takes three parameters an expression :an expression that is evaluated to be TRUE and FALSE an expression that is evaluates if it tree and expression evaluated if the first is FALSE

Syntax
(expr1)?(expr2):(expr3);
Example

?php
$n=6;
$b=7;
$val=($num 1>b)?$n:$b;
echo "The greatest value is $val";

?
output

Comparison Operators in php


Comparison Operators
Comparisons are used to check the relationship between variables and/or values. If you would like to see
a simple example of a comparison operator in action, check out our If Statement Lesson. 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; 


Operator English ExampleResult
== Equal To $x == $y false
!= Not Equal To $x != $y true
< Less Than $x < $y true
>Greater Than $x > $y false
<= Less Than and Equal To $x <= $y true
>= Greater Than and Equal To $x >= $y false


Php operator

Operators in PHP

In all programming languages, operators are used to manipulate or perform operations on variables and
values. You have already seen the string concatenation operator "." in the Echo Lesson and the assignment
operator "=" in pretty much every PHP example so far.
  There are many operators used in PHP, so we have separated them into the following categories to make
it easier to learn them all.
Concatenation operator
Assignment Operators
Arithmetic Operators
String operator