由于逗号而导致Php逻辑语句synatx错误

由于逗号而导致Php逻辑语句synatx错误,php,Php,有人能帮忙吗 <?php if(((count( $replies ) > 6) and (count( $replies ) <= 12)) and ($replyNumber == '3','4','5')) { ?> <execute code......> <?php } ?> 为什么由于使用逗号(在replynumber中为3,4,5)而导致代码中出现错误请按以下方式更改代码: <?php $varArray = ar

有人能帮忙吗

<?php 
if(((count( $replies ) > 6) and 
(count( $replies ) <= 12)) and 
($replyNumber == '3','4','5'))
{ ?>
<execute code......>
<?php } ?>


为什么由于使用逗号(在replynumber中为3,4,5)而导致代码中出现错误

请按以下方式更改代码:

<?php 
$varArray = array('3','4','5');
if( ((count( $replies ) > 6) && (count( $replies ) <= 12)) && (in_array($replyNumber,$varArray)) )  { ?>
    <execute code......>
<?php } ?>

您的代码中有错误

($replyNumber == '3','4','5'))
可能是

($replyNumber == '3' && $replyNumber == '4' && $replyNumber == '5'))
在代码中

'and' 
应转换为 php中不允许使用
'&&
作为
'和'

完整的代码应该是这样的

<?php 
 if(((count( $replies ) > 6) &&
  (count( $replies ) <= 12)) && 
  ($replyNumber == '3' && $replyNumber == '4' && $replyNumber == '5'))
{ ?>
<execute code......>
<?php } ?>

您有一个
语法错误,是逗号的
和(您必须对
$replyNumber
值使用


注意:

  • &
    |
    或逻辑运算符
Ex:
如果$x或$y为True,则为True

Ex:
$x | |$y
如果$x或$y为True,则为True

  • &
    &
    和逻辑运算符
Ex:
如果$x和$y都为真,则为真


Ex:
$x&&$y
如果$x和$y都为真,则为真

我认为应该存在这样的或条件:$replyNumber=='3'| |$replyNumber=='4'是,使用带OR条件的Pritam解决方案有效。谢谢你们两位you@Ruchika…我认为你必须在计算两个值之后和之前使用
e$replyNumber??
<?php

if( ((count($replies)>6) or (count($replies)<=12)) and $replyNumber=='3' or $replyNumber=='4' or $replyNumber=='5' )     
{

// your execute code here

}
?>