Codice PHP:
$maxCaratteri 50;
if (
strlen($stringa) <= $maxCaratteri)
  echo 
$stringa;
else
  echo 
substr($stringa,0,($maxCaratteri 3))."..."