On Fri, Sep 4, 2009 at 3:16 PM, James Colannino<ja...@colannino.org> wrote:
> Hey everyone.  I ran into a really weird issue that I was hoping I could
> find some clarification on.  In short, I have javascript functions that
> operate on hidden text values.  Those values may be posted, in which
> case PHP then prints them back to the page via what comes in on $_POST.
> The weird thing is, I was no longer able to match substrings inside
> those hidden text values after posting via Javascript.  I banged my head
> over this for a couple hours, until I realized that the string's length
> was being increased by one after posting (I found this out in
> javascript).  Upon further investigation, I found that all instances of
> "substring\n" were being replaced by "substring(carriage return)\n"
> after post.
> For now, I'm simply doing str_replace(chr(13), "", $_POST['value'])
> before re-inserting it into the HTML, but I was wondering why PHP is
> inserting those extra characters.
> Thanks!
> James

Are you sure it is PHP? Just a couple ideas...

Javascript interpolates \n as a newline character inside both double
and single quotes unlike PHP that only interpolates inside double
quotes. If the client browser is running under Windows, it may even be
possible that the \n is recognized by the browser as a line terminator
and converted to the Windows line terminator sequence (\r\n) either
inside the form element itself or in the Javascript you are using to
post back to the web server.


PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to