zoukankan      html  css  js  c++  java
  • 静态化

    效果:

    代码:

    <?php
    // + —— —— —— —— —— —— ——  —— —— —— —— —— —— —— —— ——  —— —— —— —— —— —— 
    // + 正则表达式,实现伪静态处理
    // + url:http://localhost/forgestatic/index.php/news-class12-id43.html
    // + —— —— —— —— —— —— ——  —— —— —— —— —— —— —— —— ——  —— —— —— —— —— —— 
    
    //设置输出编码
    header('Content-Type:text/html; charset=utf8');
    
    //获取参数信息
    //参数格式为:'/news-class12-id43.html'
    $_urlParam = $_SERVER['PATH_INFO'];
    
    // 匹配模式
    // 匹配后格式:
    // Array
    // (
    //     [0] => /news-class12-id43.html
    //     [1] => news
    //     [2] => class12
    //     [3] => class
    //     [4] => 12
    //     [5] => id43
    //     [6] => id
    //     [7] => 43
    // )
    $_pattern  = '#^/([a-z]+)-(([a-z]+)([0-9]+))-(([a-z]+)([0-9]+)).html$#';
    
    //接收数据参数
    $_paramArr = array();
    
    //匹配获取
    if ( preg_match($_pattern, $_urlParam, $_paramArr) ) {
    	//打印数据
    	echo '<pre>';
    	print_r($_paramArr);
    	echo '</pre>';
    } else {
    	exit('参数格式异常!');
    }
    
  • 相关阅读:
    Tinyhttpd 代码学习
    Windows noinstall zip 安装MySQL。
    Java 优先队列
    Java Comparable 和 Comparator
    Centos6.6下安装Python3.5
    对象的实现
    对象接口
    适配器模式
    java基础学习(一)
    【MongoDB】如何注册windows服务
  • 原文地址:https://www.cnblogs.com/KTblog/p/5166392.html
Copyright © 2011-2022 走看看