I’m making a search page, where you type a search query and the form is submitted to search.php?query=your query. What PHP function is the best and that I should use for encoding/decoding the search query?
I’m making a search page, where you type a search query and the form
Share
For the URI query value use
urlencode/urldecode; for anything else userawurlencode/rawurldecode.To create entire query string use http_build_query()
The difference between
urlencodeandrawurlencodeis thaturlencodeencodes according to application/x-www-form-urlencoded (space is encoded with+) whilerawurlencodeencodes according to the plain Percent-Encoding (space is encoded with%20).