php - codeigniter 出了点问题,是真的吗?
问题描述
在 windows、php5.5 和 ci 3.1.8 中进行测试我创建了一个 test.php,如下所示:
<?php
session_start();
$_SESSION['admin']="1";
$str =array("_SESSION"=>array("isadmin"=>"admin","user"=>"user1"));
extract($str);
print_r($_SESSION);
运行它,返回结果:Array ( [isadmin] => admin [user] => user1 )
删除会话文件,并在 ci 中创建一个 Welcome.php,如下所示:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Welcome extends CI_Controller {
/**
* Index Page for this controller.
*
* Maps to the following URL
* http://example.com/index.php/welcome
* - or -
* http://example.com/index.php/welcome/index
* - or -
* Since this controller is set as the default controller in
* config/routes.php, it's displayed at http://example.com/
*
* So any other public methods not prefixed with an underscore will
* map to /index.php/welcome/<method_name>
* @see https://codeigniter.com/user_guide/general/urls.html
*/
public function index()
{
$this->load->view('welcome_message');
}
public function test()
{
session_start();
$_SESSION['admin']="1";
$str =array("_SESSION"=>array("isadmin"=>"admin","user"=>"user1"));
extract($str);
print_r($_SESSION);
}
}
并在http://localhost/index.php/welcome/test运行 返回结果:
数组( [管理员] => 1 )
操作的结果是不一样的。有事吗?
解决方案
推荐阅读
- vue.js - Nuxt js - 如何在静态目录中转换 .js 文件
- java - 从 .csv 文件扩展缩写
- c# - 如何避免 Unity Random.Range 函数生成相同的数字?
- sql - 如何返回数组
来自 hive 中的 json_tuple - nginx - 使用查询字符串时找不到 nginx 匹配项
- python - 用除值填充列表
- sql - 时间戳列的每小时平均值 - 未在预期位置找到 FROM 关键字
- postgresql - 在 PostgreSQL 中,如何在 R 中执行类似于 dcast 的功能?
- sql - 搜索多个表并返回 1 个组合列 MSQL
- javascript - 如何优化javascript