Re: Q: Logical assignment with strstr( )
| From: | Robert Cummings | Date: | Fri, 23 Feb 2007 11:29:07 +0000 |
| Subject: | Re: Q: Logical assignment with strstr( ) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-249278@lists.php.net to get a copy of this message | ||
On Fri, 2007-02-23 at 12:24 +0100, rgx@gmx.de wrote:
> Dear list,
>
> strstr returns a string (in case the needle is found),
> but a boolean if there is no needle in the haystack.
>
> I am trying to make a readable evaluation of some tests, but this fails
> to work as supposed because of
> - undefined results when "OR"ing strings with possible string (?)
> - use of bitwise OR operator ("|") where I am uncertain if I can
> write anything like $a ||= $b;
>
> Please read this snippet and tell me your ideas ;)
> Thanks
> Ralf
>
<?php
$oLen = strlen( $commentary );
$isSpam = strstr( $_POST['Name'], ' ' ) === false;
$isSpam |= strlen( str_replace( 'http://', '',
$commentary ) ) < $oLen;
$isSpam |= strstr( $_POST['Name'], '@' ) !== false;
$isSpam |= stristr( $_POST['Name'], 'Casino' ) !== false;
?>
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com
|
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'