PARSE ERROR: syntax error, unexpected T_VARIABLE, expecting ‘,’ or ‘;’

As always, I run into these brackets in the output.
Please tell me where I went wrong?

<?echo "<a href=\"."$arElement["PROPERTIES"]["SITE_NAME"]["VALUE"]\"."$arElement["PROPERTIES"]["SITE_NAME"]["VALUE"]>."</a>";?>

Answer 1, authority 100%

Guys, you make life difficult for a guy. Damn, to display the link you need to write a function. It’s just a perversion.

$url = $arElement["PROPERTIES"]["SITE_NAME"]["VALUE"];
$title = $arElement["PROPERTIES"]["SITE_NAME"]["VALUE"];
echo "<a href='$url'>$title</a>";

Get in the habit of not putting long array names in your html code. Then you will be confused yourself.


Answer 2, authority 100%

Can’t you see it yourself? Break by line. Finally, write yourself a function.

<?php
   function takeA($href, $content) {
       return "<a href=\"$href\">$content</a>";
   }
   echo takeA($arElement["PROPERTIES"]["SITE_NAME"]["VALUE"], $arElement["PROPERTIES"]["SITE_NAME"]["VALUE"]);
?>

Answer 3

All options except @sensemen will work as expected.

It actually smells like Bitrix 🙂

It’s no wonder that Bitrix is ​​a complete crap, because those who don’t even know the syntax write for it 🙂


Answer 4

In double quotes, you can print like this:
<? echo “{$_SERVER[‘HTTP_HOST’]}”; ?>
For example.


Answer 5

Don’t tell me what’s behind the <? ... ?>you have plain html.

In this case, it would be worth doing:

<a href="<?=$arElement["PROPERTIES"]["SITE_NAME"]["VALUE"]?>">
  <?=$arElement["PROPERTIES"]["SITE_NAME"]["VALUE"]?>
</a>

Answer 6

<? echo "<a href=\"".$arElement["PROPERTIES"]["SITE_NAME"]["VALUE"]."\"".$arElement["PROPERTIES"]["SITE_NAME"]["VALUE"]."></a>";?>