RE: [PHP] Re: Using Logical OR operator in IF statement???
| From: | Martin Towell | Date: | Thu, 25 Oct 2001 01:29:10 +0000 |
| Subject: | RE: [PHP] Re: Using Logical OR operator in IF statement??? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-72191@lists.php.net to get a copy of this message | ||
>> if ((substr($sString,(strlen($sString)-1)!="-")) or
Looks to me that the bracketing is wrong...
try:
if ((substr($sString,(strlen($sString)-1))!="-") or
-----Original Message-----
From: Mark [mailto:maggelet@mminternet.com]
Sent: Thursday, October 25, 2001 11:12 AM
To: php-general@lists.php.net
Subject: Re: [PHP] Re: Using Logical OR operator in IF statement???
>> if (substr($sString,(strlen($sString)-1)!="-")) {
I think you meant either
substr($sString,strlen($sString)-2)
or
substr($sString,-1)
>> print "You can't have a dash at the end of your string.";
>> }
>>
>> and this works:
>> if (substr($sString,0,1)!="-") {
>> print "You can't have a dash at the beginning of your string.";
>> }
>>
>> But, this doesn't work for any case:
>> if ((substr($sString,(strlen($sString)-1)!="-")) or
>> (substr($sString,0,1)!="-")) {
>> print "you can't have a dash at the beginning or end of your
>>string.";
>> }
>>
>> What could be wrong? I've used a logical OR operator in the
>>middle of an
>IF
>> statement like this before, but for some reason, this just isn't
>>working.
>> Anyone got any ideas? I suppose I can just evaluate this with two
>different
>> IF statements, but it seems like I shoud be able to do it in one
>>and
>reduce
>> duplicate code. Thanks very much in advance.
>>
>> .....Brad
>>
>>
>>
>
>
>
--
Mark, maggelet@mminternet.com on 10/24/2001
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net