Why doesn't this create a link?

I am trying to communicate with PHP and I am not sure what is wrong with this code.

$product_list .= "\n\r " . 'Ticket Download: ' . ": " . <a href=$single_link["url"]>($single_link['name'])</a>  . "\n\r";

I know the problem is with the link (which means between the opening and closing html tags). What am I doing wrong?

Edit: I tried using the code that you all provided, and I still can't get it to work. I'm not sure why.

+5
source share
5 answers
$product_list .= PHP_EOL . 'Ticket Download: <a href="' . $single_link['url'] . '">' . $single_link['name'] . '</a>' . PHP_EOL;
+6
source

You must include anchor tags in the string

$product_list .= "\n\r " . 'Ticket Download: ' . ": <a href={$single_link['url']}>({$single_link['name']})</a> \n\r";
+3
source

. :

$product_list .= "\n\r Ticket Download: : <a href=\"" . $single_link["url"] . '">('. $single_link['name'] . ")</a>\n\r";

. , - . , .

+1

href .

$product_list .= "\n\r " . 'Ticket Download: ' . ": " . <a href='{$single_link["url"]}'>($single_link['name'])</a>  . "\n\r";
0

There it is much easier to read the syntax for this, which instead of <string specification> uses curly braces:

$product_list .= "\n\r Ticket Download: <a href={$single_link['url']}>({$single_link['name']})</a>\n\r";
0
source

All Articles