helpers.php 616 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. declare(strict_types=1);
  3. use Glacier\Core\Config;
  4. /** HTML 转义(输出安全)。 */
  5. if (!function_exists('e')) {
  6. function e(mixed $value): string
  7. {
  8. return htmlspecialchars((string) $value, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
  9. }
  10. }
  11. /** 读取配置(点号路径)。 */
  12. if (!function_exists('config')) {
  13. function config(string $key, mixed $default = null): mixed
  14. {
  15. return Config::get($key, $default);
  16. }
  17. }
  18. /** 应用根目录(绝对路径)。 */
  19. if (!function_exists('app_root')) {
  20. function app_root(): string
  21. {
  22. return APP_ROOT;
  23. }
  24. }