Tuesday, 9 June 2020

php operators

$y = $x + 5;
$x += 5;
decriment
$x -= 5;
incriment
$x = 15;
less than operator
if ($x < 10){
echo 'true';
} else {
echo 'false';
}
?>
<=

==
!=
>=
<=
> 
< 
arithmetic operators
+
-
*
/
%
modulous( remainder)
++
--
$a = 1;
$b = 2;
$c = $a + $b;
3
echo 'result' '.$c;
$c++;
locgical opertors
&&
||
lesson 6
loops ,do while for loop
<? Php
//loops
loop - a work have to do repeateldy
if it is 5 times we can write, but if we need 10000 times we cant write because it is a time waste

for that purpose we will use loops
echo 'hello vamsi "<br"';
echo 'hello vamsi "<br"';
echo 'hello vamsi "<br"';
echo 'hello vamsi "<br"';
echo 'hello vamsi "<br"';
?>

<?php
$counter = 1;
while($counter <=5){
after prints , it incrimetns counter, then go to check conditon ,
echo ' hello php <br/>';
counter++;
?>
echo $counter.' hello php <br>';
it prints counter value with text
<?php
for ($c=1; $c <= 10; $c++){
initilisation value, condiiton, modifier
echo 'pho tytorials </br.';
}
?>
do while
without checking condition , ist prints then check conditon
do{
echo $counter.' hello telug computer world <br>;
$counter++;
} while(counter <= 10);
$counter += 2;
counter= counter+2
switch statement lesson 7
<?php
$num = 1;
switch ($num){
case 1: echo 'one;
break;
case 2: echo 'two';
break;
default: echo 'number not found';
if any swithc statement not true, finally it will execute
}
?>
how to write a programm accessed by two users only
$name = 'sameer' ;
switch ($name){
case 'sameer' :
case 'vicky' :
echo 'u can enter'
break;
default;
echo 'you cant enter';
}
string operators
concatenation .   $a . $b
concatenation and assignment
.=
$a .= $b


$a = $a.$b;

while
for
do while
var+=2
switch

how to addd number to variable
how to compare using greater 
how to add 
incrimetn 
whats the use of loop
how to print one value in 100 times using single statement
how to print one statement in unlimited time using condition
whats the use of do while loop
how to execute only one statement based on the answer
how to share the resources only two person if they entered valuable names
php operators



arithmetic
(+,-,*,/,%,**)
assignment
(=,+=,-=,*=,/=,%=)
bitwise opearators
(&,|,^,~,<<,>>)
comparision opearators
(==,===,!==,!=,<>,<,>,<=,>=,<=>)
<=>
Spaceship
$a <=>$b
Return -1 if $a is less than $b
Return 0 if $a is equal $b
Return 1 if $a is greater than $b


incrimenting operators
incriment ++
decrement --
++$a
Increment the value of $a by one, then return $a
$a++
Return $a, then increment the value   of $a by one
--$a
Decrement the value of $a by one, then return $a
$a--
Return $a, then decrement the value of $a by on
logical opearators
and, or , xor, !, &&, ||
string operators
concatenation (.)
$a . $b
Concatenate both $a and $b
concatenation and assignment
(.=)
$a .= $b
First concatenate $a and $b, then assign the concatenated string to $a, e.g. $a = $a . $b

array operators
+
Union
$a + $y
Union of $a and $b
==
Equality
$a == $b
Return TRUE if $a and $b have same key/value pair
!=
Inequality
$a != $b
Return TRUE if $a is not equal to $b
===
Identity
$a === $b
Return TRUE if $a and $b have same key/value pair of same type in same order
!==
Non-Identity
$a !== $b
Return TRUE if $a is not identical to $b
<> 
Inequality
$a <> $b
Return TRUE if $a is not equal to $b






instance of
to find it is a object or not
The type operator instanceof is used to determine whether an object, its parent and its derived class are the same type or not. Basically, this operator determines which certain class the object belongs to. It is used in object-oriented programming
<?php  
//class declaration  
class Developer  
{}  
class Programmer  
{}  
//creating an object of type Developer  
$charu = new Developer();  
//testing the type of object  
if( $charu instanceof Developer)  
{  
echo "Charu is a developer.";  
}  
else  
{     
echo "Charu is a programmer.";  
}  
echo "</br>";  
var_dump($charu instanceof Developer);           //It will return true.  
var_dump($charu instanceof Programmer);       //It will return false.  
?>  
Charu is a developer.
bool(true) bool(false)




No comments:

Post a Comment