duanruinong0619 2014-01-26 03:20
浏览 82
已采纳

preg_match()分隔符错误(略有不同)

having a problem with a delimiter. I'm a noob with PHP, so I'm sorry if this is a really simple fix. I was using eregi() before, but I checked on here for a "deprecated" error, and I found out that I had to use preg_match. Anyways, here's the error:

Warning: preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash in /home/legitstr/public_html/members/includes/functions.php on line 4

And here's my code: (I've checked on other threads before, but no one seems to have similar code to mine)

$file = basename(__FILE__);
if(preg_match($file,$_SERVER['REQUEST_URI'])) {
die("Sorry but you cannot access this file directly for security reasons.");

Please help me out, and thank you!

  • 写回答

2条回答 默认 最新

  • dongliang7545 2014-01-26 03:26
    关注

    try:

    $file = basename(__FILE__);
    if(false !== strpos($_SERVER['REQUEST_URI'], $file)) {
    die("Sorry but you cannot access this file directly for security reasons.");
    

    strpos()

    or

    stripos()

    for case insensitive match, should be a better match for what you seem to be doing

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么