|
对于apache的rewrite模块打开和设置则非本文主题,请见其他文章详解. 这个类只能php 5.30以上的版本才能使用,继承了上一个版本的快速重定向的特点(单独类,全部使用静态调用),增添了一个很重要的功能和属性 可以调用其他url中的模块了 也使得模块与模块间或页面与页面间的函数简化共享得以实现 .htaccess文件写法: <div class="codetitle"><a style="CURSOR: pointer" data="49555" class="copybut" id="copybut49555" onclick="doCopy('code49555')"> 代码如下:<div class="codebody" id="code49555"> #-------------- .htaccess start --------------- RewriteEngine on RewriteRule !.(js|ico|gif|jpg|png|css|swf|htm|txt)$ index.php php_flag magic_quotes_gpc off php_flag register_globals off #-------------- .htaccess end --------------- 重写功能引入:让站点根目录的index.php末尾写上下列代码,重写就开启了(正常条件:1.apache的重写配置成功,且开启了.htaccess支持的.2.站点根目录的.htaccess文件设置好了.3.class.rewrite.php类文件在index.php前面部分加载了.4.页面模块文件位置及写法无误): <div class="codetitle"><a style="CURSOR: pointer" data="41269" class="copybut" id="copybut41269" onclick="doCopy('code41269')"> 代码如下:<div class="codebody" id="code41269"> //............ Rewrite::config( $config['path'],/'http://xxxxx/mysite/'URL基础位置/ $config['md_path'],/'c:/phpsite/www/mysite/modules/'模块文件物理目录/ array( 'phpinfo' ) ); Rewrite::__parse(); //.......... 模块文件写法: testPk.php <div class="codetitle"><a style="CURSOR: pointer" data="19243" class="copybut" id="copybut19243" onclick="doCopy('code19243')"> 代码如下:<div class="codebody" id="code19243"> <?php class Rw_testPk extends Rewrite { //这个是前导函数,只要访问到testpk这个页面,这个必然会执行,可用来控制本页面内函数访问权限或本页面全局变量 public static function init(){ //if (!defined('SITE_PASS')){ echo self::$linktag.' ';//self::$linktag是页面解析位置路径值,会常使用. / (编辑:安卓应用网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|