donglu5728 2015-11-04 10:41
浏览 52
已采纳

用于字符串的Smarty通配符选择器

Quick and simple, I have an app that works entirely on Smarty; basically I have {if} statement to determine what URI is user currently viewing so I can decide what to serve, it looks like:

    $GLOBALS.user_page_uri == '/private-messages/contacts/'

That opens all contacts, and when you click on some you open /private-messages/contacts/ID So I need some kind of wildcard that will go at the end of code above so it only looks for "/private-messages/contacts/" and ignores everything after, I tried "*" and "%" but to no avail.

  • 写回答

1条回答 默认 最新

  • dongpao1918 2015-11-04 12:10
    关注

    After few hours of knocking around (I'm not an PHP/smarty expert) I managed to find solution, instead of $string = 'something' I used preg_match()

    So I got it working by giving:

    preg_match("/\/private-messages\/contacts.*/s", $GLOBALS.user_page_uri);
    

    Hope someone finds this helpful, I know it saved me a lot.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?