换行符

unix系列用 \n

windows系列用 \r\n

mac用 \r

PHP中可以用PHP_EOL来替代,以提高代码的源代码级可移植性

如:

<?php
    echo PHP_EOL;
    //windows平台相当于    echo "\r\n";
    //unix\linux平台相当于    echo "\n";
    //mac平台相当于    echo "\r";

 

替换换行符号

//需要注意的是遇到\r\n之类的符号,替换或者输出的时候一定要用双引号,不能用单引号
$str=str_replace("\n","",$str);
$str=str_replace("\r\n","",$str);
$str=str_replace("\r","",$str);

 

 

 

类似常用的还有

DIRECTORY_SEPARATOR

可以用函数get_defined_constants()来获取所有PHP常量

 

<?php
    print_r(get_defined_constants());//get_defined_constants()返回所有常量数组

 

 

相关文章:

  • 2022-01-11
  • 2022-02-01
  • 2021-09-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-07
相关资源
相似解决方案