欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

自己项目中PHP常用工具类大全分享,php工具类大全分享

程序员文章站 2022-06-02 10:56:30
...

自己项目中PHP常用工具类大全分享,php工具类大全分享

Php代码
  1. /**
  2. * 助手类
  3. * @author www.shouce.ren
  4. *
  5. */
  6. class Helper
  7. {
  8. /**
  9. * 判断当前服务器系统
  10. * @return string
  11. */
  12. public static function getOS(){
  13. if(PATH_SEPARATOR == ':'){
  14. return 'Linux';
  15. }else{
  16. return 'Windows';
  17. }
  18. }
  19. /**
  20. * 当前微妙数
  21. * @return number
  22. */
  23. public static function microtime_float() {
  24. list ( $usec, $sec ) = explode ( " ", microtime () );
  25. return (( float ) $usec + ( float ) $sec);
  26. }
  27. /**
  28. * 切割utf-8格式的字符串(一个汉字或者字符占一个字节)
  29. *
  30. * @author zhao jinhan
  31. * @version v1.0.0
  32. *
  33. */
  34. public static function truncate_utf8_string($string, $length, $etc = '...') {
  35. $result = '';
  36. $string = html_entity_decode ( trim ( strip_tags ( $string ) ), ENT_QUOTES, 'UTF-8' );
  37. $strlen = strlen ( $string );
  38. for($i = 0; (($i $strlen) && ($length > 0)); $i ++) {
相关标签: php