CI框架constants.php系统常量配置详解
系统常量配置说明
首先,当文件系统处于工作状态时,需要检查并配置这些初始偏好设置。
在文件系统运行期间,这些默认值有助于提升系统的安全性。不过,如果在PHP或Apache底层为每个用户单独开启进程的环境中(例如某些特定服务器配置),使用八进制数值来设定权限始终是正确的做法。
FILE_READ_MODE:定义读取文件时所需的权限模式。
FILE_WRITE_MODE:定义写入文件时所需的权限模式。
DIR_READ_MODE:定义读取目录时所需的权限模式。
DIR_WRITE_MODE:定义写入目录时所需的权限模式。
接下来是文件流模式的配置。
这些模式主要用于在使用fopen()或popen()函数进行文件操作时指定打开方式。
define('FOPEN_READ', 'rb');
define('FOPEN_READ_WRITE', 'r+b');
define('FOPEN_WRITE_CREATE_DESTRUCTIVE', 'wb');
define('FOPEN_READ_WRITE_CREATE_DESTRUCTIVE', 'w+b');
define('FOPEN_WRITE_CREATE', 'ab');
define('FOPEN_READ_WRITE_CREATE', 'a+b');
define('FOPEN_WRITE_CREATE_STRICT', 'xb');
define('FOPEN_READ_WRITE_CREATE_STRICT', 'x+b');
以下是该配置文件的具体源码内容:
代码实现如下:
[php]
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
|--------------------------------------------------------------------------
| File and Directory Modes
|--------------------------------------------------------------------------
| These prefs 控制台、首选项 are used when checking and setting modes when working
| with the file system. The defaults are fine 罚款 on servers with proper
| security, but you may wish (or even need) to change the values in
| certain environments (Apache running a separate process for each
| user, PHP under CGI with Apache suEXEC, etc.). Octal values should
| always be used to set the mode correctly.
*/
define('FILE_READ_MODE', 0644);
define('FILE_WRITE_MODE', 0666);
define('DIR_READ_MODE', 0755);
define('DIR_WRITE_MODE', 0777);
/*
|--------------------------------------------------------------------------
| File Stream Modes 文件流模式
|--------------------------------------------------------------------------
| These modes are used when working with fopen()/popen()
*/
define('FOPEN_READ', 'rb');
define('FOPEN_READ_WRITE', 'r+b');
define('FOPEN_WRITE_CREATE_DESTRUCTIVE', 'wb'); // truncates existing file data, use with care
define('FOPEN_READ_WRITE_CREATE_DESTRUCTIVE', 'w+b'); // truncates existing file data, use with care
define('FOPEN_WRITE_CREATE', 'ab');
define('FOPEN_READ_WRITE_CREATE', 'a+b');
define('FOPEN_WRITE_CREATE_STRICT', 'xb');
define('FOPEN_READ_WRITE_CREATE_STRICT', 'x+b');
/* End of file constants.php */
/* Location: ./application/config/constants.php */