How do exposed views filters make their queries URL safe? I'm creating my own search form in D7, and I need to sanitize the search text so that it is URL safe. I need to mimic the way that the views module does it because I'm using the search_api module and views.

In short, I need to make this:

"what is going on around here, anyway?"

look like this:

what+is+going+on+around+here%2C+anyway%3F

How do I do that?
Use the url() function to encode your URLs.

url("what is going on around here, anyway?");


this will return the string '/what%20is%20going%20on%20around%20here%2C%20anyway%3F'

You could also use this to get the full, absolute URL.

url("what is going on around here, anyway?", array('absolute' =&gt; TRUE));


You may also be interested in the l() function if you need html output.