🟢 Foundation · Lesson 06
Operators in PHP
Operators in PHP
PHP Operators
Operators perform actions on values. PHP groups them into arithmetic, assignment, comparison, logical and string operators.
Arithmetic & String
<?php
$a = 10; $b = 3;
echo $a + $b; // 13
echo $a % $b; // 1
$first = "Code"; $second = "Funda";
echo $first . $second; // CodeFunda (dot joins strings)
?>
Comparison & Logical
<?php
var_dump(5 == "5"); // true (loose)
var_dump(5 === "5"); // false (strict, checks type)
var_dump(true && false); // false
?>
== vs ===
== compares values only; === compares value AND type. Use === to avoid surprises.Summary
- Arithmetic: + - * / %; string join with
.(dot). ==loose,===strict (value + type).
PHP Operators
Operators values पर actions करते हैं। PHP इन्हें arithmetic, assignment, comparison, logical और string operators में बाँटती है।
Arithmetic और String
<?php
$a = 10; $b = 3;
echo $a + $b; // 13
echo $a % $b; // 1
$first = "Code"; $second = "Funda";
echo $first . $second; // CodeFunda (dot strings जोड़ता है)
?>
Comparison और Logical
<?php
var_dump(5 == "5"); // true (loose)
var_dump(5 === "5"); // false (strict, type check)
var_dump(true && false); // false
?>
== बनाम ===
== सिर्फ values compare करता है; === value और type दोनों। surprises से बचने को === use करें।सारांश
- Arithmetic: + - * / %; string join
.(dot) से। ==loose,===strict (value + type)।