DIRECTORY_SEPARATOR

本文介绍了PHP中DIRECTORY_SEPARATOR常量的使用方法,该常量根据不同操作系统自动选择正确的路径分隔符。此外,还介绍了如何根据当前运行环境设置PHP的include_path,并简要提到了PHP_VERSION与PHP_OS两个内置常量。

 

 

DIRECTORY_SEPARATOR 是PHP内部常量,表示路径分隔符

在win里为\ ,在linux 里为/

 

 

 

if (DIRECTORY_SEPARATOR == '\\')
{
    @ini_set('include_path',      '.;' . ROOT_PATH);
}
else
{
    @ini_set('include_path',      '.:' . ROOT_PATH);
}
php配置文件里目录分隔符win下为 ;
unix为 :

 

 

还有两个内部常量:

PHP_VERSION
这个内建常量是 PHP 程序的版本,如 '3.0.8-dev'。

PHP_OS
这个内建常量指执行 PHP 解析器的操作系统名称,如 'Linux'。 

 

 

<?php /* '软件名称:漫城CMS(Mccms) '官方网站:http://www.mccms.cn/ '软件作者:桂林崇胜网络科技有限公司(By:烟雨江南) '-------------------------------------------------------- 'Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) '遵循Apache2开源协议发布,并提供免费使用。 '-------------------------------------------------------- */ //默认时区 date_default_timezone_set("Asia/Shanghai"); define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'production'); switch (ENVIRONMENT){ case 'development': error_reporting(-1); ini_set('display_errors', 1); break; case 'testing': case 'production': ini_set('display_errors', 0); if (version_compare(PHP_VERSION, '5.3', '>=')){ error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED); }else{ error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE); } break; default: header('HTTP/1.1 503 Service Unavailable.', TRUE, 503); echo 'The application environment is not set correctly.'; exit(1); } $application_folder = 'sys/apps'; $system_path = 'sys/system'; $view_folder = 'template'; if(defined('STDIN')) chdir(dirname(__FILE__)); if(($_temp = realpath($system_path)) !== FALSE){ $system_path = $_temp.'/'; }else{ $system_path = rtrim($system_path, '/').'/'; } if(!is_dir($system_path)){ header('HTTP/1.1 503 Service Unavailable.', TRUE, 503); echo 'Your system folder path does not appear to be set correctly. Please open the following file and correct this: '.pathinfo(__FILE__, PATHINFO_BASENAME); exit(3); } if(!defined('SELF')) { define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME)); } define('BASEPATH', str_replace('\\', '/', $system_path)); if(!defined('FCPATH')) define('FCPATH', str_replace('\\', '/', dirname(__FILE__).'/')); define('SYSDIR', trim(strrchr(trim(BASEPATH, '/'), '/'), '/')); define('MCCMSPATH', str_replace('\\', '/', dirname(BASEPATH).DIRECTORY_SEPARATOR)); if(is_dir($application_folder)){ if(($_temp = realpath($application_folder)) !== FALSE){ $application_folder = $_temp; } define('APPPATH', $application_folder.DIRECTORY_SEPARATOR); }else{ header('HTTP/1.1 503 Service Unavailable.', TRUE, 503); echo 'Your application folder path does not appear to be set correctly. Please open the following file and correct this: '.SELF; exit(3); } if(($_temp = realpath($view_folder)) !== FALSE){ $view_folder = $_temp.DIRECTORY_SEPARATOR; }else{ $view_folder = rtrim($view_folder, '/\\').DIRECTORY_SEPARATOR; } if(!is_dir($view_folder)){ header('HTTP/1.1 503 Service Unavailable.', TRUE, 503); echo 'Your view folder path does not appear to be set correctly. Please open the following file and correct this: '.pathinfo(__FILE__, PATHINFO_BASENAME); exit(3); } define('VIEWPATH', $view_folder); require_once MCCMSPATH.'libs/sys.php'; require_once BASEPATH.'core/CodeIgniter.php';
最新发布
08-01
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值