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..

Leave a Reply





Spam protection by WP Captcha-Free