panus 发表于 2013-10-29 20:14:33

CI的视图里面为什么可以使用$this

      我看见DiliCMS视图里面很多都有$this这个对象,我就不清楚这是哪个对象,于是我也在我的视图里面打印这个$this,发现好像是load这个超级对象。。
      有高手研究过吗???求解释啊。。。

panus 发表于 2013-10-29 20:17:11

补充打印结果:
object(CI_Loader)#12 (26) {
["_ci_ob_level":protected] => int(1)
["_ci_view_paths":protected] => array(1) {
    ["admin/views/"] => bool(true)
}
["_ci_library_paths":protected] => array(2) {
    => string(6) "admin/"
    => string(30) "D:/web/www/CodeIgniter/system/"
}
["_ci_model_paths":protected] => array(1) {
    => string(6) "admin/"
}
["_ci_helper_paths":protected] => array(2) {
    => string(6) "admin/"
    => string(30) "D:/web/www/CodeIgniter/system/"
}
["_base_classes":protected] => &array(12) {
    ["benchmark"] => string(9) "Benchmark"
    ["hooks"] => string(5) "Hooks"
    ["config"] => string(6) "Config"
    ["utf8"] => string(4) "Utf8"
    ["uri"] => string(3) "URI"
    ["router"] => string(6) "Router"
    ["output"] => string(6) "Output"
    ["security"] => string(8) "Security"
    ["input"] => string(5) "Input"
    ["lang"] => string(4) "Lang"
    ["loader"] => string(6) "Loader"
    ["model"] => string(5) "Model"
}
["_ci_cached_vars":protected] => array(0) {
}
["_ci_classes":protected] => array(1) {
    ["session"] => string(7) "session"
}
["_ci_loaded_files":protected] => array(1) {
    => string(51) "D:/web/www/CodeIgniter/system/libraries/Session.php"
}
["_ci_models":protected] => array(1) {
    => string(8) "Relation"
}
["_ci_helpers":protected] => array(4) {
    ["debug_helper"] => bool(true)
    ["url_helper"] => bool(true)
    ["cookie_helper"] => bool(true)
    ["string_helper"] => bool(true)
}
["_ci_varmap":protected] => array(2) {
    ["unit_test"] => string(4) "unit"
    ["user_agent"] => string(5) "agent"
}
["benchmark"] => &object(CI_Benchmark)#1 (1) {
    ["marker"] => array(4) {
      ["total_execution_time_start"] => string(21) "0.43442800 1383048898"
      ["loading_time:_base_classes_start"] => string(21) "0.43444400 1383048898"
      ["loading_time:_base_classes_end"] => string(21) "0.44666100 1383048898"
      ["controller_execution_time_( index / content )_start"] => string(21) "0.44670100 1383048898"
    }
}
["hooks"] => &object(CI_Hooks)#2 (3) {
    ["enabled"] => bool(false)
    ["hooks"] => array(0) {
    }
    ["in_progress"] => bool(false)
}
["config"] => &object(CI_Config)#3 (3) {
    ["config"] => &array(41) {
      ["base_url"] => string(19) "http://gxutcla.com/"
      ["index_page"] => string(9) "admin.php"
      ["uri_protocol"] => string(4) "AUTO"
      ["url_suffix"] => string(0) ""
      ["language"] => string(7) "english"
      ["charset"] => string(5) "UTF-8"
      ["enable_hooks"] => bool(true)
      ["subclass_prefix"] => string(3) "MY_"
      ["permitted_uri_chars"] => string(14) "a-z 0-9~%.:_\-"
      ["allow_get_array"] => bool(true)
      ["enable_query_strings"] => bool(false)
      ["controller_trigger"] => string(1) "c"
      ["function_trigger"] => string(1) "m"
      ["directory_trigger"] => string(1) "d"
      ["log_threshold"] => int(0)
      ["log_path"] => string(0) ""
      ["log_date_format"] => string(11) "Y-m-d H:i:s"
      ["cache_path"] => string(0) ""
      ["encryption_key"] => string(3) "abc"
      ["sess_cookie_name"] => string(10) "ci_session"
      ["sess_expiration"] => int(7200)
      ["sess_expire_on_close"] => bool(false)
      ["sess_encrypt_cookie"] => bool(false)
      ["sess_use_database"] => bool(false)
      ["sess_table_name"] => string(11) "ci_sessions"
      ["sess_match_ip"] => bool(false)
      ["sess_match_useragent"] => bool(true)
      ["sess_time_to_update"] => int(300)
      ["cookie_prefix"] => string(0) ""
      ["cookie_domain"] => string(0) ""
      ["cookie_path"] => string(1) "/"
      ["cookie_secure"] => bool(false)
      ["global_xss_filtering"] => bool(false)
      ["csrf_protection"] => bool(false)
      ["csrf_token_name"] => string(14) "csrf_test_name"
      ["csrf_cookie_name"] => string(16) "csrf_cookie_name"
      ["csrf_expire"] => int(7200)
      ["compress_output"] => bool(false)
      ["time_reference"] => string(5) "local"
      ["rewrite_short_tags"] => bool(false)
      ["proxy_ips"] => string(0) ""
    }
    ["is_loaded"] => array(0) {
    }
    ["_config_paths"] => array(1) {
       => string(6) "admin/"
    }
}
太多就不贴出来了。。。
页: [1]
查看完整版本: CI的视图里面为什么可以使用$this