note 89715 added to function.mail

From: Date: Fri, 20 Mar 2009 08:20:35 +0000
Subject: note 89715 added to function.mail
Groups: php.notes 
Request: Send a blank email to php-notes+get-152182@lists.php.net to get a copy of this message
If you're using mail() to process user-submitted forms that have an imposed character limit, you must remember that php treats "\r\n" as two characters, while javascript treats it as one. <?php $accurately_trimmed_str = substr(str_replace("\r\n", "\n", $initial_str), $start, $imposed_length); ?> This is important if you have a javascript counter tracking how many characters the user has left. Using the above example, your php will trim multi-lined messages to the exact same length javascript validated them as. 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. ---- Server IP: 208.69.120.35 Probable Submitter: 76.16.128.198 ---- Manual Page -- http://www.php.net/manual/en/function.mail.php Edit -- https://master.php.net/note/edit/89715 Del: integrated -- https://master.php.net/note/delete/89715/integrated Del: useless -- https://master.php.net/note/delete/89715/useless Del: bad code -- https://master.php.net/note/delete/89715/bad+code Del: spam -- https://master.php.net/note/delete/89715/spam Del: non-english -- https://master.php.net/note/delete/89715/non-english Del: in docs -- https://master.php.net/note/delete/89715/in+docs Del: other reasons-- https://master.php.net/note/delete/89715 Reject -- https://master.php.net/note/reject/89715 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#152182) next »