Dynamic Comparison Operators in PHP

Posted by BenTheDesigner on Stack Overflow See other posts from Stack Overflow or by BenTheDesigner
Published on 2010-05-27T07:22:24Z Indexed on 2010/05/27 7:31 UTC
Read the original article Hit count: 275

Filed under:
|
|

Hi All

Is it possible, in any way, to pass comparison operators as variables to a function? I am looking at producing some convenience functions, for example (and I know this won't work):

function isAnd($var, $value, $operator = '==')
{
    if(isset($var) && $var $operator $value)
        return true;
}

if(isAnd(1, 1, '===')) echo 'worked';

Thanks in advance.

© Stack Overflow or respective owner

Related posts about php

Related posts about variable