开发者

When should I call rawurlencode and rawurldecode?

I'm writing a basic file browser in PHP as a homework assignment. I've got the whole thing working nicely and haven't really run into any problems - it's pretty simple. Open a directory, show directories and up-one-level as links, show files as plain-old-text.

I've read about rawurlencode and rawurldecode, and I was wondering when I should use them specifically, or if they're needed at all in this case.

Do PHP functions like opendir() work on encoded URLs, or should I decode URLs before passing them to the function?

Should I call rawurlencode() on the path I put in my hyperlinks to othe开发者_运维知识库r directories?

Any suggestions are more than welcome, and let me know if I'm just barking up the wrong tree! :)


If you're passing the directory path to open through the URL, then yes, it would be a good idea to use rawurlencode in that. Then use rawurldecode when passing the parameter to opendir. Or, before doing that, check that the directory exists first with is_dir.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜