Re[7]: Need a more elegant way of bitwise ORing values

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi tedd,

Saturday, June 16, 2007, 1:18:58 PM, you wrote:

> How about?

> switch (1)
>         {
>         case $allow_fraction:
>         $filter['flags'] = FILTER_FLAG_ALLOW_FRACTION;
>         break;

>         case $allow_thousand:
>         $filter['flags'] = FILTER_FLAG_ALLOW_THOUSAND;
>         break;

>         case  $allow_scientific:
>         $filter['flags'] = FILTER_FLAG_ALLOW_SCIENTIFIC;
>         break;
>         }

> Would that not work?

Sorry but no because it doesn't allow for multiple flags to be set.
It's perfectly valid to have one, two or all three flags active on the
filter_var call. Even if the switch statement was re-run again, it
wouldn't bitwise OR the values together, it'd just replace them.

Cheers,

Rich
-- 
Zend Certified Engineer
http://www.corephp.co.uk

"Never trust a computer you can't throw out of a window"

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux