CodeIgniter框架基本配置文件config.php介绍
CodeIgniter 基本配置信息在 application/config/config.php 文件,本文详细讲解每一个基本配置选项,从而快速掌握 CodeIgniter 进行开发。
$config['base_url'] = "http://www.bkjia.com/"。 您网站的网址,CodeIgniter 会根据这个网址来生成链接、表单地址等。
$config['index_page'] = "index.php" CodeIgniter 根目录下的 index.php 文件名,CodeIgniter 会使用它来生成链接地址。如果使用隐藏 index.php 的 URL,将其设置为空字符串:$config['index_page'] = ""。
$config['uri_protocol'] = "AUTO" CodeIgniter 生成 URL 使用的格式,设置为“AUTO”自动探测。如果链接不能正常工作,可以尝试以下值:PATH_INFO、QUERY_STRING、REQUEST_URI、ORIG_PATH_INFO。
$config['url_suffix'] = "" 。CodeIgniter 产生链接时使用的 URL 后缀,如果要实现伪静态,可以设置 $config['url_suffix'] = ".html"。
$config['language'] = "english" 。CodeIgniter 程序默认使用的语言
$config['charset'] = "UTF-8" 。CodeIgniter 程序默认使用的字符集
$config['enable_hooks'] = FALSE 。是否启用钩子,钩子功能使得您可以在不修改系统核心文件的基础上来改变或增加系统的核心运行功能。
$config['subclass_prefix'] = 'MY_' 。设置扩展 CodeIgniter 类库时使用的类名前缀
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-' 。设置 CodeIgniter URL 中允许使用的字符,这是一个正则表达式。当访问者试图访问的 CodeIgniter URL 包含其它字符时,会得到一个警告。应该尽量限制 CodeIgniter URL 使用的字符来提高安全性,可以有效的过滤注入攻击。如果设置为空,允许使用所有字符,强烈建议不要这么做。
$config['enable_query_strings'] = FALSE 。CodeIgniter URL 默认使用分段的 URL,此选项也允许 CodeIgniter 开启查询字符串形式 URL。您可以使用查询字符串来传递要访问的控制器和函数。例如: index.php?c=controller&m=method。CodeIgniter 默认使用分段的 URL,查询字符串的 URL 很多特性不被支持。
$config['controller_trigger'] = 'c' 。CodeIgniter 将查询字符串中此选项对应的值当做 CodeIgniter 控制器的名字。
$config['function_trigger'] = 'm' 。CodeIgniter 将查询字符串中此选项对应的值当做 CodeIgniter 控制器方法的名字
$config['log_threshold'] = 0 。启用错误日志,设置记录哪些类型的错误。
- 0 = 关闭错误日志记录
- 1 = 记录错误信息
- 2 = 记录调试信息
- 3 = 记录通知信息
- 4 = 记录所有信息
$config['log_path'] = ""。如果您不想使用默认的错误日志记录目录配置(system/logs/),可以设置完整的服务器目录。
$config['log_date_format'] = 'Y-m-d H:i:s' 。CodeIgniter 错误日志时间格式
$config['cache_path'] = ""。如果您不想使用默认的缓存目录(system/cache/)来存储缓存,可以设置完整的服务器目录
$config['encryption_key'] = "" 。CodeIgniter 使用的密钥
$config['global_xss_filtering'] = FALSE。 是否对输入数据(GET、POST)自动过滤跨脚本攻击
$config['compress_output'] = FALSE。 启用Gzip压缩达到最快的页面加载速度
$config['time_reference'] = 'local'。 设置时间格式:"local"、"GMT"
$config['rewrite_short_tags'] = FALSE。 如果您想要使用短标记,但 PHP 服务器不支持,CodeIgniter 可以通过重写短标记来支持这一功能。
$config['proxy_ips'] = ""。 如果访问者通过代理服务器来访问您的网站,您必须设置代理服务器 IP 列表,以识别出访问者真正的 IP。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to implement custom middleware in CodeIgniter Introduction: In modern web development, middleware plays a vital role in applications. They can be used to perform some shared processing logic before or after the request reaches the controller. CodeIgniter, as a popular PHP framework, also supports the use of middleware. This article will introduce how to implement custom middleware in CodeIgniter and provide a simple code example. Middleware overview: Middleware is a kind of request

CodeIgniter Middleware: Accelerating Application Responsiveness and Page Rendering Overview: As web applications continue to grow in complexity and interactivity, developers need to use more efficient and scalable solutions to improve application performance and responsiveness. . CodeIgniter (CI) is a lightweight PHP-based framework that provides many useful features, one of which is middleware. Middleware is a series of tasks that are performed before or after the request reaches the controller. This article will introduce how to use

Introduction to the method of using the database query builder (QueryBuilder) in the CodeIgniter framework: CodeIgniter is a lightweight PHP framework that provides many powerful tools and libraries to facilitate developers in web application development. One of the most impressive features is the database query builder (QueryBuilder), which provides a concise and powerful way to build and execute database query statements. This article will introduce how to use Co

With the development of mobile Internet, instant messaging has become more and more important and popular. For many companies, live chat is more like a communication service, providing a convenient communication method that can quickly and effectively solve business problems. Based on this, this article will introduce how to use the PHP framework CodeIgniter to develop a real-time chat application. Understand the CodeIgniter framework CodeIgniter is a lightweight PHP framework that provides a series of simple tools and libraries to help developers quickly

CodeIgniter middleware: Provides secure file upload and download functions Introduction: In the process of web application development, file upload and download are very common functions. However, for security reasons, handling file uploads and downloads often requires additional security measures. CodeIgniter is a popular PHP framework that provides a wealth of tools and libraries to support developers in building secure and reliable web applications. This article will introduce how to use CodeIgniter middleware to implement secure files

CodeIgniter is a lightweight PHP framework that uses MVC architecture to support rapid development and simplify common tasks. CodeIgniter5 is the latest version of the framework and offers many new features and improvements. This article will introduce how to use the CodeIgniter5 framework to build a simple web application. Step 1: Install CodeIgniter5 Downloading and installing CodeIgniter5 is very simple, just follow these steps: Download the latest version

As web applications continue to evolve, it is important to develop applications more quickly and efficiently. And, as RESTful API is widely used in web applications, it is necessary for developers to understand how to create and implement RESTful API. In this article, we will discuss how to implement MVC pattern and RESTful API using CodeIgniter framework. Introduction to MVC pattern MVC (Model-Vie

1. Introduction to CodeIgniter CodeIgniter is a lightweight and comprehensive PHP development framework designed to provide web developers with fast and powerful tools to build web applications. It is an open source framework that uses the MVC architecture pattern to achieve rapid development and basic functions, while supporting a variety of databases. 2. Introduction to the Config library The Config library is a component in the CodeIgniter framework and is used to configure and manage code. The Config library contains many
