34 lines
624 B
PHP
34 lines
624 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Core\View;
|
|
|
|
function app_env(string $key, ?string $default = null): ?string
|
|
{
|
|
$value = $_ENV[$key] ?? getenv($key);
|
|
|
|
if ($value === false || $value === null) {
|
|
return $default;
|
|
}
|
|
|
|
return (string) $value;
|
|
}
|
|
|
|
function base_path(string $path = ''): string
|
|
{
|
|
$base = dirname(__DIR__);
|
|
|
|
return $path === '' ? $base : $base . '/' . ltrim($path, '/');
|
|
}
|
|
|
|
function view(string $template, array $data = []): void
|
|
{
|
|
View::render($template, $data);
|
|
}
|
|
|
|
function e(?string $value): string
|
|
{
|
|
return htmlspecialchars((string) $value, ENT_QUOTES, 'UTF-8');
|
|
}
|