*/ function h($str, $default = '') { return htmlspecialchars((string)($str ?? $default), ENT_QUOTES, 'UTF-8'); } /** * 获取当前请求的 CSP nonce * 由 index.php 在每次请求时生成并存入 $GLOBALS['csp_nonce']。 * 视图中为内联 */ function csp_nonce() { return $GLOBALS['csp_nonce'] ?? ''; }