get 还是 basename() 更有效?
以下哪项更有效率?
对令牌(随机)使用 get 函数,例如:
http://www.example.com/category/subcategory/subsubcategory?value=random $_GET['value']
将令牌作为 URL 的一部分并对其进行解析,例如:
$url="http://www.example.com/category/subcategory/subsubcategory/random" basename($url)
实际上,basename 比使用explode 或substr(strrchr()) 更有效吗?
which of the following is more efficient?
Using a get function on a token (random), for example:
http://www.example.com/category/subcategory/subsubcategory?value=random
$_GET['value']Make the token part of the URL and parse it, for example:
$url="http://www.example.com/category/subcategory/subsubcategory/random"
basename($url)
And actually, is basename more efficient than using explode or substr(strrchr())
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
$_GET 显然更高效,因为它不计算任何东西
。不过,除非您计划在脚本中调用它几千次,否则它可以忽略不计,因此请使用您认为更有效的方法。
$_GET is obviously more efficient, since it doesn't compute anything
Still, unless you plan on calling that a few thousand times in your script, it's negligible so use whatever you feel works better.
使用
基本名称
。无需创建另一个已有的功能。同样在这种情况下,性能完全无关紧要
Use
basename
. There is no need to make another function that you already have.Also in this case performance is completly insignificant