This is a more important issue for executing PHP.
What are the positives or negatives for the following two methods for limiting row size?
function max_length($string, $length) {
return (strlen($string) > $length)?substr($string, 0, $length):$string;
}
substr($string, 0, $length);
The case I'm worried about is when the string is less than the required length. Could this cause buffer overflow errors? Extra spaces? Repeated characters?
The only thing I know is speed, substrat least 2x faster than the provided custom function.
source
share