cfif 中的正则表达式检查 URL 中是否有参数?

发布于 2024-12-18 04:42:08 字数 113 浏览 2 评论 0原文

我试图仅在参数 ?staff 附加到 URL 时才显示代码块,例如:

仅当当前 URL 加载了 www.blank.com/folder/?staff 时才显示链接

有什么想法吗?

I'm trying to display a block of code only if the parameter ?staff is appended to URL, e.g.:

display Link only if the current URL was loaded with www.blank.com/folder/?staff

Any thoughts?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

南七夏 2024-12-25 04:42:08

我不认为存在任何性能差异,但对我来说,最佳实践是使用 StructKeyExists(url,'staff') 而不是 isDefined("url.staff")< /代码>。不过,任何一个都肯定能完成工作。

I don't believe there is any kind of performance difference, but to me it's best practices to use StructKeyExists(url,'staff') rather than isDefined("url.staff"). Either one will definitely get the job done though.

感情旳空白 2024-12-25 04:42:08

您不需要使用正则表达式解析 url,如果已定义,它应该已经在 url 变量中

<cfif IsDefined("URL.staff")>

You don't need to parse the url with a regex, It should be in the url variable already if defined

<cfif IsDefined("URL.staff")>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文