我的代码无效:在COMMENTS框中计算值是否正确?
//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 :(得分: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
是字符串。