$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. 【SVM】A Practical Guide to Support Vector Classi cation

    零.简介 一般认为,SVM比神经网络要简单. 优化目标:

  2. Pandas之Dropna滤除缺失数据

    import pandas as pd import numpy as np from numpy import nan as NaN 一.处理Series对象 通过dropna()滤除缺失数据 fr ...

  3. matlab 怎么建立结构体数组?

    https://zhidao.baidu.com/question/537198107.html 怎么定义一个结构体数组,使数组的每个元素是一个结构体变量.像这样:a=(1,2)a(1)=struct ...

  4. [转]Mac Appium环境安装

    原文:https://blog.csdn.net/dongqiushan/article/details/53326518 1.安装JDK; 2.安装Android SDK; 3.安装brew; 4. ...

  5. linux常用命令:grep 命令

    Linux系统中grep命令是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹 配的行打印出来.grep全称是Global Regular Expression Print,表示全局正则表达 ...

  6. python 文件操作 练习:取得文件的最后存取时间

    #coding=utf-8 import osimport time file_atime=int(os.path.getatime('d:\\a.txt'))print "file_ati ...

  7. java多线程----ReentrantReadWriteLock

    package com.test; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks ...

  8. IT行业——Linux

    现在是21世纪,是科学技术大力发展的一个时代,IT行业已经成为现在的一个非常热门的一个行业,许许多多的人都想要往IT方面发展,找IT方面相关的一个工作.因此,现在也出现了很多IT培训机构,比如培训Li ...

  9. ELK学习笔记之Logstash和Filebeat解析对java异常堆栈下多行日志配置支持

    0x00 概述 logstash官方最新文档.假设有几十台服务器,每台服务器要监控系统日志syslog.tomcat日志.nginx日志.mysql日志等等,监控OOM.内存低下进程被kill.ngi ...

  10. Kali连接不上ssh

    1.修改sshd_config文件 vim /etc/ssh/sshd_config 将#PasswordAuthentication yes的注释去掉 将#PermitRootLogin prohi ...