A框架第一步,传递不同参数.主程序执行对应方法
访问: www.test.com/admin
1============后台目录:admin (确保单一入口) --有入口文件index.php
<?php
require '../A/a.php'; //导入主程序
function mylog2($word){
$file = './mylog2.txt';
file_put_contents($file ,$word."\n\n",FILE_APPEND);
}
$a = new a('admin');
$a->execute();
2===========主程序在A目录下a.php
<?php
define('DS','/');
define('A_PATH',str_replace('\\','/',dirname(__FILE__)).DS);
class a {
public $app,$controller,$action,$class,$client;
public function __construct($clien){
$this->client = $clien;
}
public function execute(){
$this->app = $_GET['app'];
$this->controller = $_GET['controller'];
$this->action = $_GET['action'];
$this->args = $_GET; //接收所有,作为参数
$this->app_dir = A_PATH .'apps'.DS.$this->app.DS;
$file = $this->app_dir.'controller'.DS.$this->controller.'.php';
require($file);
$this->class = 'controller_'.$this->controller;
call_user_func_array( array($this->class,$this->action),array($this->args));
//http://www.test.com/admin/?app=system&controller=admin&action=login //自动调用登录方法 ,使用call_user_func_array()
//http://www.test.com/admin/?app=system&controller=index&action=index //自动调用后台index方法
//执行,指定类名 controller_index 指定方法index
}
}
3,4具体controller文件放置在主程序A目录下面-->apps下面---模块system-->controller
3========== admin.php 登录php
<?php
class controller_admin {
public function __construct($app){
//parent::__construct($app);
}
public function login(){
echo 'please login';
}
}
4=============index.php 显示登录后页面
<?php
class controller_index{
public function index(){
echo 'the index';
}
}
5===========自由调用各种模块下的各种方法(member模块)member.php
<?php
class controller_member{
public function reg(){
echo 'member register';
}
}
//http://www.test.com/admin/?app=member&controller=member&action=reg //自动调用后台index方法
A框架第一步,传递不同参数.主程序执行对应方法的更多相关文章
- springboot框架在容器加载完成之后执行某个方法
问题描述: 想在websocket实现的Handler中执行一些初始化操作,但是初始化操作使用到了@Autowired自动注入的变量,而且是保护类型.第一个想法是放到Handler构造函数中执行,但是 ...
- springMVC,spring,mybatis全注解搭建框架--第一步,让框架跑起来
自己从事java开发工作也有一年多了,自己却没有亲手搭建一个完整的框架.于是今天自己动手搭建一个,过程中遇到一些问题,倒腾了大半天终于搞定了. 现在给大家分享一下过程,自己也记录下来,以后学习参考使用 ...
- 搭建数据驱动框架第一步-实现一个构造函数,将对Excel文件的基本操作API都封装进去
Python处理Excel常用操作就是读和写,我的需求是需要在原excel文件中进行读写操作.共用到了两个模块xlrd和openpyxl,这两个模块都是需要自己去安装的.openpyxl只能用来处理 ...
- Yii框架第一步-- 安装
0.首次安装请看 这里 下面的为非首次安装,不需要token的步骤 1.下载composer 官网下载: https://getcomposer.org/download/ 2.开启PHP的opens ...
- (大数据工程师学习路径)第一步 Linux 基础入门----命令执行顺序控制与管道
介绍 顺序执行.选择执行.管道.cut 命令.grep 命令.wc 命令.sort 命令等,高效率使用 Linux 的技巧. 一.命令执行顺序的控制 1.顺序执行多条命令 通常情况下,我们每次只能在终 ...
- HighChart 体验之旅 (后台传递JSON参数和数据的方法)
转自:http://www.cnblogs.com/daviddai/archive/2013/04/12/Highchart.html 官网:http://www.highcharts.com/ 中 ...
- java通过读取本地文件获取反射方法参数,执行对象方法
运用到的知识点 IO流, 集合properties 反射 在工程目录下新建file config.properties #one time only can run one method cl ...
- 写一个ORM框架的第一步
新一次的内部提升开始了,如果您想写一个框架从Apache Commons DbUtils开始学习是一种不错的选择,我们先学习应用这个小“框架”再把源代码理解,然后写一个属于自己的ORM框架不是梦. 一 ...
- 写一个ORM框架的第一步(Apache Commons DbUtils)
新一次的内部提升开始了,如果您想写一个框架从Apache Commons DbUtils开始学习是一种不错的选择,我们先学习应用这个小“框架”再把源代码理解,然后写一个属于自己的ORM框架不是梦. 一 ...
随机推荐
- mysql修改密码Your password does not satisfy the current policy requirements
出现这个问题的原因是:密码过于简单.刚安装的mysql的密码默认强度是最高的,如果想要设置简单的密码就要修改validate_password_policy的值, validate_password_ ...
- maven 阿里镜像
<mirror> <id>alimaven</id> <mirrorOf>central</mirrorOf> <name>al ...
- 二十五、oracle pl/sql进阶--控制结构(分支,循环,控制)
一.pl/sql的进阶--控制结构在任何计算机语言(c,java,pascal)都有各种控制语句(条件语句,循环结构,顺序控制结构...),在pl/sql中也存在这样的控制结构.在本部分学习完成后,希 ...
- Android中使用OKHttp上传图片,从相机和相册中获取图片并剪切
效果:注意:1:网络权限<;;;); intent.putExtra(); ); intent.putExtra(); intent.putExtra(, byteArrayOutputStre ...
- linux中fork()函数详解(转)
转自:http://blog.csdn.net/jason314/article/details/5640969 一.fork入门知识 一个进程,包括代码.数据和分配给进程的资源.fork()函数通过 ...
- android项目实战 --ListView 头部ViewPager广告轮询图效果
看开源框架:https://github.com/tianshaojie/AndroidFine,里面有如下效果,特记录学习下,以后项目中用也好能够立刻想起来. 如上面所示,是常见项目中的图片轮训 ...
- Sass入门:第四章
1.加法 加法运算是Sass中运算的一种,在变量或属性中都可以做加法运算.如: .box { width: 20px + 8in; } 编译出来的CSS: .box { width: 788px; } ...
- Spring Security(09)——Filter
目录 1.1 Filter顺序 1.2 添加Filter到FilterChain 1.3 DelegatingFilterProxy 1.4 FilterChainPr ...
- Nginx 搭建反向代理服务器过程详解
1.1 反向代理初印象 反向代理(Reverse Proxy)方式是指以代理服务器来接受internet上的连接请求,然后将请求转发给内部网络上的服务器,并将从服务器上得到的结果返回给internet ...
- HDU 1907 John(取火柴博弈2)
传送门 #include<iostream> #include<cstdio> #include<cstring> using namespace std; int ...