helper.php 791 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * 添加自定义辅助函数
  4. */
  5. if ( ! function_exists('config_path'))
  6. {
  7. /**
  8. * Get the configuration path.
  9. *
  10. * @param string $path
  11. * @return string
  12. */
  13. function config_path($path = '')
  14. {
  15. return app()->basePath() . '/config' . ($path ? '/' . $path : $path);
  16. }
  17. }
  18. if (! function_exists('public_path')) {
  19. /**
  20. * Get the path to the public folder.
  21. *
  22. * @param string $path
  23. * @return string
  24. */
  25. function public_path($path = '')
  26. {
  27. return app()->basePath() . '/public' . ($path ? '/' . $path : $path);
  28. }
  29. }
  30. function subtext($text, $length)
  31. {
  32. if(mb_strlen($text, 'utf8') > $length) {
  33. return mb_substr($text, 0, $length, 'utf8').'...';
  34. } else {
  35. return $text;
  36. }
  37. }