Good day! I am just starting to learn PHP myself. Can you please tell me how to insert the php-code in the link?

<? Cmodule::IncludeModule('citrus.tszh'); $arResult["ACCOUNTS"] = Array(); $dbAccounts = CTszhAccount::GetList($arOrder = array(), $arFilter = array("USER_ID"=>CUser::GetID()), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array("*")); $arAccount = $dbAccounts->GetNext(); echo $arAccount["XML_ID"]; ?> 

To get a link like https://www.somesite.ru/pay/PERSONAL_ACCOUNT=### , where ### is the PHP code

I tried this:

 <? Cmodule::IncludeModule('citrus.tszh'); $arResult["ACCOUNTS"] = Array(); $dbAccounts = CTszhAccount::GetList($arOrder = array(), $arFilter = array("USER_ID"=>CUser::GetID()), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array("*")); $arAccount = $dbAccounts->GetNext(); echo '<a href="https://www.somesite.ru/pay/PERSONAL_ACCOUNT='$arAccount["XML_ID"];'">Ссылка</a>' ?> 

And, of course, nothing happens. What am I doing wrong?

  • What does it mean to insert a php code into a link ?, just the code you can not insert into the link, what do you want to get in the end? - Arsen
  • There is a suspicion that first you should learn the basics of the web as a whole. - u_mulder
  • I meant that I need to replace ### with the result of the PHP code above - Alina Monakova
  • To output several lines, use concatenation: echo '<a href="https://www.somesite.ru/pay/PERSONAL_ACCOUNT=' . $arAccount["XML_ID"] . '">Ссылка</a>' - u_mulder
  • @u_mulder, Ooh, thanks a lot! - Alina Monakova

1 answer 1

Or through concatenation

 echo '<a href="https://www.somesite.ru/pay/PERSONAL_ACCOUNT='.$arAccount["XML_ID"].'">Ссылка</a>' 

Either through interpretation.

 echo "<a href='https://www.somesite.ru/pay/PERSONAL_ACCOUNT={$arAccount["XML_ID"]}'>Ссылка</a>"