You are here: Daniel Dumas » Blog, PHP »

PHP Operators: The === Operator

PHP Operators: The === Operator

PHP’s === Operator enables you to compare or test variables for both equality and type. Refer below for example.

<?php
//define variables..
$str = '9';
$int = 9;

//Returns true since both variable contains the same value..
$res = ($str==$int);

//Returns false since the two variables are not of the same type..
$res = ($str===$int);
?>

Discussion

  1. Domy Gryfino says:

    That’s actualy a pretty useful operator. You’d think that there’s not much you can do with that but in reality it has so many uses you wouldn’t belive it…

    Domy Gryfino’s last blog post..Sprzedaż kawalerki w Gryfinie

  2. Jox says:

    Indeed this is a very useful PHP operator!

  3. Thanks for pointing out the === operator. At first I thought you had a typo! :) But, I see many uses for this! Keep up the good work with your tips and advice!

    Free Games Gallery’s last blog post..Witchdance | Hexentanz

  4. GLenn says:

    para ako nagbabasa ng php book ah.. astig.

    GLenn’s last blog post..Nature Shine WordPress Theme

  5. Rein Valdez says:

    Really nice presentation of operator ===.
    I don’t know yet the enviroment of PHP but know some basic programming also like C.

    Good Luck. Hopefully you could update your blog regularly. :)

    Rein Valdez’s last blog post..Happy Reality and Facts

  6. ang hirap intindihin nitong PHP. hehe. paturo naman jan :)

  7. I usually use the double equal sign == to test equality and never used this triple equal. Maybe because there’s no situation that requires it but thank you for pointing this one.

  8. I always get lost when it comes to those “=” “==” “===” operators. Had no idea there even was a “===” one.

    Hurtownia Tkanin’s last blog post..Jedwab

  9. I use == to and not === but ill try with this also. I had heard about this long back but never tried. Thanks for reminding me..

  10. Yup! This PHP Operator is very great and very useful in the Website Development…

  11. Wow a very useful operator! Thanks Daniel

  12. karl says:

    very useful operator
    karl recently posted..Free Icons: Smileys/Emoticons Up for Grabs

  13. ChintooKhaade says:

    Hello Everyone,
    Operators are used to operate on value. I.e. with the help of operator we can perform different types of actions on values such as increment, decrement, subtraction, division etc……….. for more details please check out the following link.
    http://mindstick.com/Articles/5e80879e-779b-4680-9a41-d66a0c7931a8/?PHP%20Operators

    Thanks !!!!!!

Leave a Reply





CommentLuv badge