The seoDomen function seoDomen nothing about the $listDomain variable - the wrong scope. It is necessary to transfer the initialization of the variable inside the function.
If you enable error output, you should immediately see it. Also, normal IDEs highlight such an error.
And the same with $APPLICATION . The function does not know about it. It is necessary to transfer as argument to function. Or even remove the use of the function:
if ($_SERVER['REQUEST_URI'] = "/test/"){ $url = $_SERVER['HTTP_HOST']; $listDomain = array( "k.example.com"=>"В k", "s.example.com"=>"В s", "v.example.com"=>"В v", "t.example.com"=>"В t", "b.example.com"=>"В b" ); foreach ($listDomain as $domain => $title) { if ($url == $domain) { $APPLICATION->SetPageProperty("title", $title); $APPLICATION->SetPageProperty("description", $title); $APPLICATION->SetPageProperty("keywords", $title); } } }
Option with function. $_SERVER is a superglobal array, there is no need to pass it to a function. But $APPLICATION needs to be passed or declared global global $APPLICATION inside the function for the function to see it (this works, taking into account that bitrix $ APPLICATION is already set as global).
if ($_SERVER['REQUEST_URI'] = "/test/") { function seoDomain() { global $APPLICATION; $currentHost = $_SERVER['HTTP_HOST']; $listDomain = array( "k.example.com"=>"В k", "s.example.com"=>"В s", "v.example.com"=>"В v", "t.example.com"=>"В t", "b.example.com"=>"В b" ); foreach ($listDomain as $domain => $title) { if ($currentHost == $domain) { $APPLICATION->SetPageProperty("title", $title); $APPLICATION->SetPageProperty("description", $title); $APPLICATION->SetPageProperty("keywords", $title); } } } seoDomain(); }
$n = explode('.', $_SERVER['HTTP_HOST']);- Mr. Black