Home  >  Article  >  php教程  >  php各种操作系统都可用的符号

php各种操作系统都可用的符号

WBOY
WBOYOriginal
2016-06-06 19:56:302176browse

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入 不同的操作系统有不同的符号,如何写PHP代码使我们可以在不同操作系统中可移植? 1、DIRETORY_SEPORATOR 当前操作系统默认的文件路径分隔符 $unixpath = "/var/test/a.php": //在unix系统下必须使用"

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入

  不同的操作系统有不同的符号,如何写PHP代码使我们可以在不同操作系统中可移植?

  1、DIRETORY_SEPORATOR 当前操作系统默认的文件路径分隔符

  $unixpath = "/var/test/a.php":  //在unix系统下必须使用"/"作为文件路径分隔符

  $windwospath1 = "C:\\www\\test\\aa.php":  //windows系统下默认使用"\"作为文件路径分隔符,但是还是需要"\"将其转义

  $windowspath2="www/test/a.php"   //推荐使用这种

  为了程序的可移植性,建议文件路径都是用"/",也可以使用DIRETORY_SEPORATOR

  2、PHP_EOL 当前系统的换行符

  windows下 \r\n表示换行符

  unix系统下\r表示换行符

php各种操作系统都可用的符号

Statement:
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