What about if I want to use “…” at the end of the title?
<?php echo substr(the_title($before = '', $after = '...', FALSE), 0, 40); ?>
Unfortunately “…” are characters put at the end of the title, so if your title is more then 40 the “…” fall off. You can use the $before and place something like », but nothing at the end.