Chinaunix
标题:
学习整理心得12.05.09
[打印本页]
作者:
hkebao
时间:
2009-12-05 14:57
标题:
学习整理心得12.05.09
http://codeigniter.org.cn/
参考网站!
谈谈里面的URL机制吧。如果修改了application/config/config.php 配置文件将$config['enable_query_strings'] = true; 修改成true的话即就可以通过QueryString的形式进行查询操作。比如说
$config['enable_query_strings'] = true;
$config['controller_trigger'] = 'c';
$config['function_trigger'] = 'm';
$config['directory_trigger'] = 'd'; // experimental not currently in use
index.php?c=controller&m=method 这个思想与我的框架有点类似的。
不过我不知道CI里面的index.php里面的代码是如何实现这种处理的。也没有看到哪有写$_REQUEST的。比较疑惑
2、CI里面的控制器
http://localhost/phpci/index.php/welcome/shoes/test/34
我的类是这样写的
class Welcome extends Controller {
function Welcome()
{
parent::Controller();
}
function index()
{
$this->load->view('welcome_message');
}
function shoes($name,$price){
echo "name is:".$name." and price is:".$price;
}
}
其中这段URI:welcome/shoes/test/34 分别是表示哪个控制器 哪个方法 后面是表示这个方法的参数值!
遇到了一个小的问题
function shoes($name,$price){
echo "name is:".$name." and price is:".$price;
}
function _remap($method){
if ('shoes' == $method) {
$this->shoes();
} else {
$this->index();
}
}
我加了这个控制器层的一个路由转发器。现在我的URI地址值是
http://localhost/phpci/index.php/welcome/shoes/test/34
如何让_remap 方法接收到后面的这两个参数值呢?(祈求高手指点一二)
控制器里面的析构函数。即相当于是一个析构函数一样的功能。
function _output(){
echo "destory";
}
这个方法肯定会执行。
有好处。比如说要关闭数据库连接,关闭文件流什么的不错的选择!
私有方法即在方法名前加_即可。这样的方法是不能通过URI 的方式进行外部访问到的!
本文来自ChinaUnix博客,如果查看原文请点:
http://blog.chinaunix.net/u2/84280/showart_2111944.html
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2