1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to properly handle apostrophes & \r\n in mail function?

Discussion in 'PHP' started by irfandayan, Jul 18, 2012.

  1. #1
    I have mail function which gets mail message from a textarea. But whenever there is apostrophes and new line it show it like below.

    Example Output: Comments: You\\'re mailing address was wrong. Couldn\\'t you provide an other? Survey Answers: item : You\\'re making it well. Isn\\'t it?\nitem2 : It\\'d better to have a cup of tea?\n

    1) There are three slashes added along with apostrophes. Is it likely something to do with magic escaping? is the stripslashes function the better option to remove it?

    2) New line converted to \r\n. The issue is the \r\n might be a windows artifact. On a Linux server it might be \n only. Is it would be enough to use str_replace('\r\n', "\n", $message); ? Then str_replace("\n", "
    ", $message); ?
     
    irfandayan, Jul 18, 2012 IP