$this->uri->segment(4); //获取url中pathinfo //的第四段的值
public function index($id=0,$name=''){
echo $id,$name;
}
class MY_Controller extends CI_Controller{
public function __construct(){
parent::__construct
}
}
$config['subclass_prefix']='MY_';//默认值
$this->load->model('User_model');
$this->User_model->get();
$this->load->model('User_model','user');
$this->user->get();
$this->load->helper('url');
site_url('控制器/方法');
$this->load->helper('url');
<img src="<?php echo base_url();?>upload/a.jpg" />
$router['show/([\d]+)\.html']='article/show/$1'; article/show/5.html => article/show/5;
#开启apache的rewrite模块
#在根目录中放入.htaccess文件进行重写
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
//模型中操作
//装载分页类文件
$this->load->library('pagination');
$this->load->helper(url);
//分页链接
$config['base_url'] = site_url('user/test');
//总记录条数
$config['total_rows'] = 100;
//每页显示10条数据
$config['per_page'] = 10;
//偏移量
$offset_limit = intval($this->uri->segment(3));
$this->pagination->initialize($config);
echo $this->pagination->create_links();
$config['first_link'] = '首页'; ... $config['uri_segment'] =3;//分页数据查询偏移量
//加载session库
$this->load->library('session');
//比如获取客户端的ip地址
$this->session->userdata('ip_address');
//添加
$this->session->set_userdata('some_name', 'some_value');
//获取
$this->session->userdata('some_name');
//删除
$this->session->unset_userdata('some_name');
//添加
$this->session->set_flashdata('item', 'value');
//获取
$this->session->flashdata('item');
$config['encryption_key']="fjkdsffjkhjd#kjh";
$config['sess_encrypt_cookie'] =TRUE;
<form action="<?php echo site_url('user/upload');?>" enctype="multipart/form-data">
<input type="file" name="pic"/>
<input type="submit" value="submit">
</form>
$config['upload_path']="./upload";
$config['allowed_types']='gif|jpeg|jpg';
$this->load->library('upload',$config);
$this->upload->do_upload('pic');
$filedata = $this->upload->data();
//生成验证码
$this->load->helper('captcha');
$this->load->helper('url');
$vals = array(
'word'=>rand(1000,9999),
'img_path'=>'./captcha/',
'img_url'=>base_url().'/captcha/'
'img_width'=>'150',
'img_height'=>'100',
'expiration'=>7200
);
$cap = create_captcha($vals);
echo $cap['image'];
//将验证码获取的数字放在session中
session_start();
$_SESSION['cap'] = $cap['word'];
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有