PlatForm平台分发参数p

基本概念:

  platform 平台,在view/html中 填写参数p

  用来确定当前的平台,比如

  index.html?p=test&c=Mybank&a=show

  test平台下的Mybank控制器类中的show动作

  index.html?p=home&c=Myuser&a=delete    

  home平台下的Myuser控制器下的delete动作

 

步骤1:

  在test平台下的View中的Mybank.html中添加p参数,要保证p是最先获取的

  

        <td><?=$value['id']?></td>
        <td><?=$value['carNo']?></td>
        <td><?=$value['money']?></td>
        <!-- 填写a参数和c参数的值-->
        <td> <a href="index.php?p=test&c=Mybank&a=delete&id=<?=$value['id']?>">删除</a> </td>
    </tr>
    <?php endforeach?>
    </table>
    <p>
        <!-- 主动携带a和c参数的值 -->
        <a href="index.php?p=test&c=Myuser&a=show">获取my_user表</a>
    </p>
</body>
</html>

步骤2:在index.php入口文件中获取p参数

    //使用常量来保存参数p,平台的名字,
    $default_paltForm="test";
    define('PLATFORM',isset($_GET['p']) ? $_GET['p'] : $default_paltForm);
    //载入当前所需要的控制器
    include "./application/". PLATFORM."/Controller/{$controller_name}.class.php";

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章