Create human readable URL search strings
I just implemented a search function into my program. If a search string is sent, the program dose this:
if (isset($_GET['s'])) {
header('Location: /search/'.rawurlencode($_GET['s']));
exit;
}
The only problem I have is that the resulting search string URL isn't really human readable, e.g. the search term is 500€ a lot of money results into is%20500€%20a%20lot%20of%20money. I would like to build a more human readable search URL, e.g. is+500€+a+lot+of+money.
Is there a simple way of doing this or do you have to encode the strin开发者_JAVA百科g manually, e.g. look for spaces, etc. and replace them.
Use urlencode instead of rawurlencode. This uses + for spaces rather than %20.
加载中,请稍侯......
精彩评论