Why doesn't PHP auto html decode my POST?
I'm using Zend Framework for a project. Why when I make POST request and get the params in my controller by $this->_request->getParams()
it shows undecoded values? For example a string lik开发者_StackOverflowe Speakers & keyboards
in my HTML form is retrieved as Speakers & keyboards
from getParams() within PHP.
Doesn't PHP autodecode every posted value?
Hi John, thanks for the hint! I think that's the problem really as I'm making an AJAX POST request and it takes data from the page HTML. So I better use something like urlDecode() before sending the request... What do you think?
The problem then, is that you are sending HTML and you want text.
When you grab the content from the page, get text instead of HTML. So don't use innerHTML
or jQuery's .html()
. Get a textNode and read its data
property, or use jQuery's .text()
.
Because there is no reason to do so.
Data is encoded for transport, and then decoded again. HTML isn't an encoding used for transport.
The only reason to expect to receive HTML is if HTML was sent, and if HTML is sent then (presumably) HTML is desired. Converting to text wouldn't often be a desired thing to happen next.
PHP autodecodes the escaped content, not content which is in HTML entities.
精彩评论