douzen1896 2016-01-18 09:09
浏览 29
已采纳

在php if语句中识别运算符

I need my code to spot two conditions on is if the url ends in 'easy' and the other if the url ends in a question mark. My if statement looks like this:

if (in_array(basename($_SERVER["REQUEST_URI"]), array("easy","?"))) { . . . }

This catches 'easy' but not '?'. How can I get it to spot the question mark as well?

  • 写回答

2条回答 默认 最新

  • dqtm8504 2016-01-18 09:23
    关注

    the url ends in 'easy' [or] in a question mark

    The most concise way to express that is with a regular expression:

    if (preg_match('/(easy|\\?)$/', $_SERVER['REQUEST_URI']))
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 如何使用canvas在图片上进行如下的标注,以下代码不起作用,如何修改
  • ¥15 Windows 系统cmd后提示“加载用户设置时遇到错误”
  • ¥50 vue router 动态路由问题
  • ¥15 关于#.net#的问题:End Function
  • ¥15 无法import pycausal
  • ¥15 VS2022创建MVC framework提示:预安装的程序包具有对缺少的注册表值的引用
  • ¥15 weditor无法连接模拟器Local server not started, start with?
  • ¥20 6-3 String类定义
  • ¥15 嵌入式--定时器使用
  • ¥20 51单片机学习中的问题