$baseUrl = request()->baseUrl();
if (!preg_match('/admin.php/',$baseUrl)) {
$this->redirect('/admin.php'.$baseUrl);
}

很实用的php自带方法。

<?php
//模式分隔符后的"i"标记这是一个大小写不敏感的搜索
if (preg_match("/php/i", "PHP is the web scripting language of choice.")) {
echo "A match was found.";
} else {
echo "A match was not found.";
}
?>

preg_match的更多相关文章

  1. preg_match()漏洞

    今天大哥丢了一道题过来. <?php $str = intval($_GET['id']); $reg = preg_match('/\d/is', $_GET['id']); //有0-9的数 ...

  2. php preg_match 过滤字符

    $f = preg_match("/g3watches/",$date[0]['desc']); if ($f='1') { $this->error(L('不好意思,输入有 ...

  3. php preg_match($p, $str, $match)方法简介

    方法作用:匹配指定的正则表达式并将结果放在$match数组中 代码示例: $p = '/name:([\\ws]+)/'; $str = "name:steven jobs"; p ...

  4. php 函数preg_match、preg_match_all ,以及正则表达式规则

    <?php $str = 'php is the best language phhhhp is'; $part = '/ph{1,}p/'; echo preg_match($part, $s ...

  5. ***PHP preg_match正则表达式的使用

    第一,让我们看看两个特别的字符:‘^’和‘$’他们是分别用来匹配字符串的开始和结束,以下分别举例说明 : "^The": 匹配以 "The"开头的字符串; &q ...

  6. php中preg_match用户名正则实例

    例子,字母.数字和汉字  代码如下 复制代码 if(preg_match("/[ '.,:;*?~`!@#$%^&+=)(<>{}]|]|[|/|\|"||/& ...

  7. preg_match_all, preg_match

    int preg_match(string $pattern, string $subject[, $arr][, int $flags]);$pattern 正则表达式$subject: 要搜索的字 ...

  8. PHP函数补完:preg_match()

    preg_match — 进行正则表达式匹配. 语法:int preg_match ( string $pattern , string $subject [, array $matches [, i ...

  9. PHP 正则表达式匹配 preg_match 与 preg_match_all 函数

    --http://www.5idev.com/p-php_preg_match.shtml 正则表达式在 PHP 中的应用 在 PHP 应用中,正则表达式主要用于: 正则匹配:根据正则表达式匹配相应的 ...

  10. PHP preg_match正则表达

    在php中preg_match()函数是用来执行正则表达式的一个常用的函数,下面我来给大家详细介绍preg_match使用方法. 函数用法 int preg_match_all ( string pa ...

随机推荐

  1. [LeetCode] 286. Walls and Gates_Medium tag: BFS

    You are given a m x n 2D grid initialized with these three possible values. -1 - A wall or an obstac ...

  2. [LeetCode] 674. Longest Continuous Increasing Subsequence_Easy Dynamic Programming

    Given an unsorted array of integers, find the length of longest continuous increasing subsequence (s ...

  3. 机器学习理论基础学习14.1---线性动态系统-卡曼滤波 Kalman filter

    一.背景 动态模型 = 图 + 时间 动态模型有三种:HMM.线性动态系统(kalman filter).particle filter 线性动态系统与HMM的区别是假设相邻隐变量之间满足线性高斯分布 ...

  4. python 皮尔森相关系数

    皮尔森理解 皮尔森相关系数(Pearson correlation coefficient)也称皮尔森积矩相关系数(Pearson product-moment correlation coeffic ...

  5. HTML鼠标悬停改变样式

    a.tt:hover {color: #FF0000;} <a class="tt" href="test.html">test</a> ...

  6. python 采坑总结 调用键盘事件后导致键盘失灵的可能原因

    在练习python封装键盘事件的时候,实现一个keyDown和keyUp的功能: @staticmethod    def keyDown(keyName):        #按下按键        ...

  7. Linux基础命令---gunzip

    gunzip 解压缩被gzip压缩过的文件.此命令的适用范围:RedHat.RHEL.Ubuntu.CentOS.SUSE.openSUSE.Fedora. 1.语法      gunzip [-ac ...

  8. C/C++中的位运算

    位运算     位运算的运算分量只能是整型或字符型数据,位运算把运算对象看作是由二进位组成的位串信息,按位完成指定的运算,得到位串信息的结果. 位运算符有:     &(按位与).|(按位或) ...

  9. android 接受系统锁屏广播,及高版本发送广播

    protected BroadcastReceiver messageReceiver = new BroadcastReceiver() { @Override public void onRece ...

  10. Fine报表权限流程分析记录

    Fine报表权限流程分析记录 URL访问三种类型的报表:第一个:BI报表 例如: http://192.25.103.250:37799/WebReport/ReportServer?op=fr_bi ...