Saw this online in one PHP snippet here.
/**
* @param string $str subject of test for integerness
* @return bool true if argument is an integer string
*/
function intStr($str) {
return !!preg_match('/^\d+$/', $str);
}
Running this code snippet produces:
> var_dump( intStr("abc") );
bool(false)
> var_dump( intStr("123") );
bool(true)
Questions:
Is the dual exclamation mark a a valid operator, or is it just the same as a "not-not", which negates itself?
Also, why is this operator used in-conjunction with the
preg_match
function?