php跨平台小结 常用预定义常量

WBOY
Release: 2016-06-13 13:02:11
Original
960 people have browsed it

php跨平台总结 常用预定义常量

?

<?php /**
 * 获得用户操作系统的换行符 
 *
 * @access  public 
 * @return  string 
 */  
function get_crlf()
{
	/* LF (Line Feed, 0x0A, \N) 和 CR(Carriage Return, 0x0D, \R) */
	if (stristr($_SERVER['HTTP_USER_AGENT'], 'Win')){
		$the_crlf = '\r\n';
	}elseif (stristr($_SERVER['HTTP_USER_AGENT'], 'Mac')){
		$the_crlf = '\r'; // for old MAC OS
	}else{
		$the_crlf = '\n';
	}

	return $the_crlf;
}
// *nix
echo DIRECTORY_SEPARATOR; // /
echo PHP_SHLIB_SUFFIX;    // so
echo PATH_SEPARATOR;      // :

// Win*
echo DIRECTORY_SEPARATOR; // \
echo PHP_SHLIB_SUFFIX;    // dll
echo PATH_SEPARATOR;      // ;
?> 
?
Copy after login

if ?( strtoupper ( substr (PHP_OS,?0,?3))?===? 'WIN' )?{? ?? 得到操作系统类型

DEFAULT_INCLUDE_PATH? 得到php.ini中配置的include_path

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!