πŸš€ DevOps & SRE Certification Program πŸ“… Starting: 1st of Every Month 🀝 +91 8409492687 πŸ” Contact@DevOpsSchool.com

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started Now!

PHP 7 Essential Guide – PHP Operators for beginners

PHP operators are used to performing operations on variables and values.

  • Maths Operators
  • Assignment operators
  • Logical Operators
  • Increment and Decrement Operators
  • String Operators

Maths Operators:-
arithmetic operators are used with numerice values to perform arithmetic operators like as addition, subtraction, multiplication, division or etc.
ex:-

<?php
//Maths operators
echo 4+5;
echo 5-2;
echo 4*9;
echo 25/5;
?>

Assignment operators:-
Assignment operators are used to write a numeric value to a variable values.

ex:-

<?php
//assignment operators
$num = 25;
$num1 = 25;
$num2 = 25;
echo $num;
echo $num1;
echo $num2;
$num = $num1 = $num2 = 25;
echo $num. "<br>";
echo $num1;
echo $num2;
?>

Logical Operators:-
Logical operators are used to write combine conditional operators.
ex:-

<?php
/*
and And $a and $b True if both $a and $b are true
or Or $a or $b True if either $a or $b is true
xor Xor $a xor $b True if either $a or $b is true, but not both
&& And $a && $b True if both $a and $b are true
|| Or $a || $b True if either $a or $b is true
! Not !$a True if $a is not true */
if ((5>4) && (2<1))
{
echo "this is true <br>";
}
else
{
echo "this is wrong <br>";
}
//output this is wrong
if ((9>8) and (2<6))
{
echo "this is true <br>";
}
else
{
echo "this is wrong <br>";
}
//output this is true
if ((9>8) or (2<6))
{
echo "this is true <br>";
}
else
{
echo "this is wrong <br>";
}
//output this is true
if ((9>8) xor (2<6))
{
echo "this is true <br>";
}
else
{
echo "this is wrong <br>";
}
//output this is wrong
if ((9>8) || (2<6))
{
echo "this is true <br>";
}
else
{
echo "this is wrong <br>";
}
//output this is true
?>

Increment and Decrement Operators:-
Increment and Decrement operators are used to increment and decrement a variable’s values to print.
ex:-

<?php
/*
++$a Pre-increment Increments $a by one, then returns $a
$a++ Post-increment Returns $a, then increments $a by one
--$a Pre-decrement Decrements $a by one, then returns $a
$a-- Post-decrement Returns $a, then decrements $a by one*/
$a = 3;
echo ++$a;
// echo $d--;
echo "<br>";
$a = 5;
echo ++$a;
// echo --$c;
echo "<br>";
$c = 9;
echo --$c;
echo "<br>";
$d = 11 + 12;
echo $d--;
echo "<br>";
$e = $a + $c;
echo $e;
echo "<br>";
?>

String Operators:-
String operators are used to combine variable and values this called as Concatenation and Concatenation assignment.
ex:-

<?php
/*. Concatenation $txt1 . $txt2 Concatenation of $txt1 and $txt2
.= Concatenation assignment $txt1 .= $txt2 Appends $txt2 to $txt1*/
$name = "devops ";
$name1 = "school ";
echo $name , $name1; //PHP Important Operators for beginners
echo "<br>";
$num = "this is ";
$num2 = "operators ";
echo $num, $num2, "examples";
?>

Certification Courses

DevOpsSchool has introduced a series of professional certification courses designed to enhance your skills and expertise in cutting-edge technologies and methodologies. Whether you are aiming to excel in development, security, or operations, these certifications provide a comprehensive learning experience. Explore the following programs:

DevOps Certification, SRE Certification, and DevSecOps Certification by DevOpsSchool

Explore our DevOps Certification, SRE Certification, and DevSecOps Certification programs at DevOpsSchool. Gain the expertise needed to excel in your career with hands-on training and globally recognized certifications.