Home >php教程 >PHP开发 >CI Framework Notes 4

CI Framework Notes 4

黄舟
黄舟Original
2016-12-29 09:40:361592browse

<?php
if(!isset($_SESSION)){
session_start();
}
$_SESSION[&#39;code&#39;] = $cap[&#39;word&#39;];
/**
*查询数据
*/
public function check(){
$this->db->where(array(&#39;username&#39;=>$username))->get(&#39;admin&#39;)->result_array();
$this->db->get_where(&#39;admin&#39;,array(&#39;username&#39;=>$username)->result_array();
}
?>
//在文件config.php文件中可以设置秘钥,这是CI框架提供的.
$config[&#39;encryption_key&#39;]=&#39;sdfsfsdfggsdfg&#39;;
// session存数组
$session=array(
&#39;username&#39;=>$username,
&#39;uid&#39; =>$uid,
);
存:
$this->session->set_userdata($session);
取:
$this->session->userdata($session);
/**
* 格式化时间
*/
<?php echo date(&#39;m-d&#39;,$this->session->userdata(&#39;logintime&#39;))?>
/**
* 客户端IP,服务器信息,服务器环境
*/
<?php echo $this->input->ip_address() ?>
<?php echo $this->input->server(&#39;SERVER_SOFTWARE&#39;)?>
<?php echo PHP_VERSION ?>
/**
* 隐藏单入口(-)
*/

1,保证Apache配置文件httpd.conf中的LoadModule rewrite_module modules/mod_rewrite.so开启(去掉#)

2,将相对应的目录AllowOverride改为ALL

3,在根目录下,在index.php同级目录下新建.htaccess

.htaccess内容:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

4,config.php中设置

$config[&#39;index_page&#39;]改为空值

5,开启缓存

$this->output->cache(1/60);

 以上就是CI框架随记4的内容,更多相关内容请关注PHP中文网(www.php.cn)!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:CI Framework Notes 3Next article:CI Framework Notes 3