2016-04-06 22 views
-2

Kodum çalışmıyor: Değerleri COMMENTS kutusuna saymak doğru mu?Nasıl charectors uzunluklarını IF (COUNT()) düzeltmek için

//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" değişkeninin türü nedir - dizi veya dizgi? – mitkosoft

+0

@HankyPanky evet haklısınız, yazım hatası –

cevap

0

count() dizisi için kullandığı, çok doğru sözdizimi olmalıdır:

<?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 dizesi olduğunu varsayarsak.

+0

Çok teşekkürler canım arkadaşlarım. 'strlen' yerine 'sayım' kullandım. –

İlgili konular