php is incorrectly converting ¬ in strings to ¬

前端 未结 1 1664
傲寒
傲寒 2021-01-29 12:42

I need to make up a simple string in PHP which is a string of data to be posted to another site.

The problem is that one of the fields is \'notify_url=..\' and when I u

1条回答
  •  广开言路
    2021-01-29 13:11

    PHP isn't doing that, it's your browser interpreting HTML entity notation. & has a special meaning in HTML as the start of an HTML entity, and ¬ happens to be a valid HTML entity. You need to HTML-encode characters with special meanings:

    echo htmlspecialchars($string);
    // field1=1234&field2=this&notify_url=http
    

    0 讨论(0)
提交回复
热议问题