বুধবার, ১৭ ফেব্রুয়ারী, ২০১০

পি এইচ পি এর ধারাবাহিক টিউটোরিয়াল:পর্ব-৫(অপারেটরস)

টিউন করেছেন : রেজওয়ান | প্রকাশিত হয়েছে : ১৩ ফেব্রুয়ারি, ২০১০ |

অপারেটরস ভ্যালু বা ভ্যারিয়েবলকে manipulate করতে ব্যাবহৃত হয়।৩ ধরনের অপারেটর আছে

১.Unary – একটা ভ্যালু বা ভ্যারিয়েবলকে(operand) নিয়ে কাজ করে।

২.Binary-দুটি ভ্যালু বা ভ্যারিয়েবলকে নেয়।

৩.Ternary- ৩টি ভ্যালু বা ভ্যারিয়েবলকে নিয়ে থাকে।

এর পাশাপাশি আমরা Operator গুলোকে অনেকভাবে শ্রেনীবদ্ধ করতে পারি যেমন-Arithmetic, Assignment, Comparison Operator etc.

Assignment Operator: এ Operators গুলো একটা ভ্যালু বা ভ্যারিয়েবলকে অন্য একটা ভ্যালু বা ভ্যারিয়েবলের সমান করতে ব্যাহৃত হয়।

$my_var = 4;

$another_var = $my_var;

এখন $my_var ও $another_var উভয়েরই মান হল ৪.

Operator


English


Example

+


Addition


2+4

-


Subtraction


6-2

*


Multiplication


5*3

/


Division


15/3

%


Modulus


43%10

PHP Code

$addition = 2 + 4;

$subtraction = 6 – 2;

$multiplication = 5 * 3;

$division = 15 / 3;

$modulus = 5 % 2;

echo “Perform addition: 2 + 4 = “.$addition.”
”;

echo “Perform subtraction: 6 – 2 = “.$subtraction.”
”;

echo “Perform multiplication: 5 * 3 = “.$multiplication.”
”;

echo “Perform division: 15 / 3 = “.$division.”
”;

echo “Perform modulus: 5 % 2 = ” . $modulus

সেভ করে রান করান এমন দেখাবে-

Perform addition: 2 + 4 = 6
Perform subtraction: 6 – 2 = 4
Perform multiplication: 5 * 3 = 15
Perform division: 15 / 3 = 5
Perform modulus: 5 % 2 = 1.

Comparison Operator

এই Operator ভ্যালু বা ভ্যারিয়েবল এর মধ্যে relationship চেক করে।এই Operator কন্ডিশনাল statement এর ভিতর থাকে আর নির্নয় করে statement true নাকি false.

এখানে বহুল ব্যাবহৃত কিছু Comparison Operator দেয়া হল-

$x=4 ও $y=5 ধরে

Operator


English


Example


Result

==


Equal to


$x=$y


False

!=


Not equal to


$x!=$y


True

<


Less than


$x<$y


True

>


Greater than


$x>$y


False

<=


Less than equal to


$x<=$y


True

>=


Greater than equal to


$x>=$y


False

String Operator

এটাতো আগেই আমরা দেখেছি আর ব্যাবহারও করেছি-“”, ‘’

Arithmetic এবং Assignment Operator এর Combination

Programming এ একটা পরিচিত কাজ হচ্ছে একটা ভ্যারিয়েবলকে নির্দিষ্ট হারে বাড়ানো,যেমন গননার ক্ষেত্রে।আমি যদি ১ করে বাড়াতে চাই তাহলে

$counter=$counter+1;

যাহোক সংক্ষেপে এভাবে লেখে

$counter+=1;

Pre/Post-Increment & Pre/Post-Decrement:

উপরেরটা একটু অদ্ভুত মনে হতে পারে,এটার আরেকটা সর্টকাট মেথড আছে কোন ভ্যরিয়েবল থেকে ১ করে বাড়ানো বা কমানোর

$x++ যেটা $x += 1; or $x = $x + 1 এর সমান।

আর কমানোর ক্ষেত্রে শুধু “-” অপারেটরটা ব্যাবহৃত হবে।

Logical Operator
Operator Description Example
&& and x=6
y=3(x < 10 && y > 1) returns true
|| or x=6
y=3(x==5 || y==5) returns false
! not x=6
y=3!(x==y) returns true

চলবে………

পরবর্তী টিউটোরিয়াল Conditional Statement(if,elseif etc.)

1 টি মন্তব্য:

  1. Best contents in your blogs.

    One of the quality Digital Marketing corporations in Gurgaon, with a verified music file of 13+ Years.
    We offer incredible net design & virtual advertising and marketing offerings to your enterprise or campaign,
    Digital Marketing Agency in Gurgaon offering Web design, SEO, Social Media, Inbound Marketing, Content Marketing, Apps & so on.For more details contact.
    Contact us website.

    Website contact us page: https://techfaktory.com/contact/

    উত্তরমুছুন