note 89711 deleted from function.strlen by cmb
| From: | cmb@php.net | Date: | Sun, 25 Jul 2021 14:15:51 +0000 |
| Subject: | note 89711 deleted from function.strlen by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-216648@lists.php.net to get a copy of this message | ||
Note Submitter: Amaroq
----
When dealing with submitted forms that you've imposed a character limit on, you must remember
that functions that count characters consider "\r\n" to be two characters.
<?php
//These will both output 2.
echo strlen("\r\n");
echo mb_strlen("\r\n");
?>
If I had thought of this starting out, I would have saved myself several hours of trouble trying to
get php to cut a message to the same length that my auxiliary javascript validation imposed on it.