beispiel.php

<?php
function strlng_limit($str,$lim){
 if(!empty($str) && !empty($lim)){
  if(strlen($str) > $lim){
   $ret = 'false';
  }else{
   $ret = 'true';
  }
 }else{
  $ret = 'param';
 }
 return $ret;
}

$chk = strlng_limit('php function string länge check', 20);
if($chk == 'param'){
 echo 'Parameter pruefen.';
}
elseif($chk == 'false'){
 echo "Text ist zu lang.";
}
elseif($chk == 'true'){
 echo 'Text laenge ist OK.';
}
?>
    

Kopieren