2016-04-06 4 views
-2

コードが機能していません:COMMENTSボックスの値を数えるのは正しいですか?IF(COUNT())でCharectorの長さを修正する方法

//function to count the entered text in COMMENTS section 

function isEligible($comments) 
{ 
    if(count($comments <12 && $comments > 40)) 
    { 
    print "Plz enter the value between 12_40"; 
    return false; 

    } 

return true; 
} 
+0

[strlen](http://www.php.net/manual/en/function.strlen.php) –

+1

'$ comments'変数の型は何ですか?配列または文字列ですか? – mitkosoft

+0

@HankyPankyはい、あなたは正しいです。タイプミス –

答えて

0

count()は、アレイのために使用されているので、右の構文は次のようになります。

<?php 
    //function to count the entered text in COMMENTS section 
    function isEligible($comments) { 
     if (strlen($comments) < 12 || strlen($comments) > 40) { 
      print "Plz enter the value between 12 and 40 characters"; 
      return false; 
     } 
     return true; 
    } 
?> 

$commentsが文字列であると仮定すると。

+0

おかげさまで大変感謝しています。私は 'strlen'の代わりに 'count'を使用しました。 –

関連する問題