ad

Wednesday, March 6, 2024

PHP Increment/ Decrement operators


PHP Increment/ Decrement operators

PHP Increment/ Decrement operators



Increment/Decrement Operators :-

  • Increment (++)
  • Decrement (--)

PHP Increment/ Decrement operators

Example :-


<?php
// Example of increment operator
$a = 5;
echo "Original value of \$a: $a <br>";

$a++; // Increment $a by 1
echo "Value of \$a after incrementing: $a <br>";

// Example of decrement operator
$b = 10;
echo "Original value of \$b: $b <br>";

$b--; // Decrement $b by 1
echo "Value of \$b after decrementing: $b <br>";
?>

PHP Increment/ Decrement operators

Output :-

php increment /Decrement operators example/output



Related Post :-

php program to print alphabet pattern I

javascript logical operator

javascript do while loop

PHP String Operators

 PHP String Operators 

PHP string operators



PHP String Operators:

  • Concatenation (.)
  • Concatenation assignment (.=)


PHP String Operators:

Example :-

<?php
// Concatenation operator (.)
$string1 = "Hello";
$string2 = "World";

$result = $string1 . " " . $string2;

echo $result;
?>
PHP String Operators

Output :-

PHP String Operators EXAMPLE /Output


Related Post :-


Tuesday, March 5, 2024

PHP logical operators

   PHP logical operators 

PHP logical operators



Logical Operators:

  • AND (&& or and)
  • OR (|| or or)
  • NOT (! or not)
  • XOR (exclusive OR) (xor)

 PHP logical operators 

Example :-


<?php
$a=10;
$b=5;
$c=20;
$d=20;
var_dump(($a<$c)&&($c==$d)&&($b<$c));//true
var_dump(!(($a<$c)&&($c==$d)&&($b<$c)));//false
var_dump(($a>$d)||($b<$c));//true
?>

 logical operators php

Output

logical operators php/output









Related Post :-

registration form

php program to print heart star pattern

html button tag

PHP Arithmetic Operators

 PHP Arithmetic Operators 

PHP Arithmetic operators


Arithmetic Operators:

  • Addition (+)
  • Subtraction (-)
  • Multiplication (*)
  • Division (/)
  • Modulus (%)
  • Exponentiation (**)

Arithmetic Operators php

Example :-

<?php
$no1 = 20;
$no2 =5;
//ope
$add =$no1 + $no2;
$sub= $no1 - $no2;
$multi= $no1 *$no2;
$divi =$no1 / $no2;
$remainder = $no1 % $no2;

//out
echo "Addition =".$add;
echo"<br>subtraction =".$sub;
echo "<br> multiplication =".$multi;
echo "<br> division=".$divi;
echo"<br> remainder = ".$remainder;
?>

Arithmetic Operators php

Output :-

Addition =25
subtraction =15
multiplication =100
division=4
remainder = 0

Related post :-

Classes in javascript

get method php

change password form

PHP Assignment Operators

 PHP Assignment Operators

PHP Assignment Operators


PHP Assignment Operators

  • Assignment (=)
  • Addition assignment (+=)
  • Subtraction assignment (-=)
  • Multiplication assignment (*=)
  • Division assignment (/=)
  • Modulus assignment (%=)


php Assignment Operators :


Example:-



<?php

// Assignment Operations in PHP

// Addition
$x = 5;
$y = 3;
$x += $y; // Equivalent to: $x = $x + $y;
echo "Addition :  = $x\n";

// Subtraction
$x = 10;
$y = 4;
$x -= $y; // Equivalent to: $x = $x - $y;
echo "Subtraction: = $x\n";

// Multiplication
$x = 6;
$y = 2;
$x *= $y; // Equivalent to: $x = $x * $y;
echo "Multiplication : = $x\n";

// Division
$x = 16;
$y = 4;
$x /= $y; // Equivalent to: $x = $x / $y;
echo "Division : = $x\n";

// Modulus
$x = 17;
$y = 5;
$x %= $y; // Equivalent to: $x = $x % $y;
echo "Modulus : = $x\n";

// Concatenation(for strings)
$str1 = "Hello, ";
$str2 = "World!";
$str1 .= $str2; // Equivalent to: $str1 = $str1 . $str2;
echo "Concatenation : $str1\n";

?>


Assignment Operators php :


Output :-
Assignment operators php/output



Related  Post :-

html button tag

registration form in php

about us page design template