// ============================================ // 城市检测:从子域名解析当前城市代码 // 例如: bj.zmn-zx.com → 'bj' // ============================================ function get_current_city_code() { \$host = \$_SERVER['HTTP_HOST'] ?? ''; \$main_domain = 'zmn-zx.com'; \$www_prefix = 'www.'; \$port = strpos(\$host, ':'); if (\$port !== false) \$host = substr(\$host, 0, \$port); if (strpos(\$host, \$main_domain) === false) return ''; \$sub = str_replace(['https://','http://',\$www_prefix,\$main_domain], '', \$host); \$sub = trim(\$sub, '.'); if (empty(\$sub) || \$sub === 'www') return ''; \$parts = explode('.', \$sub); return \$parts[0]; }