This question already has an answer here:
I am trying to include some javascript for the google analytics ecommerce tracking.
In the example code I see something like this, in which I have replaced the variables with my own.
<?php
function getTransactionJs(&$order) {
return <<<HTML
ga('ecommerce:addTransaction', {
'id': '{$order->ord_order_numner}',
'affiliation': 'Marcella',
'revenue': '{$order->total_payment}',
'shipping': '0',
'tax': '0'
});
HTML;
}
echo getTransactionJs($order);
?>
However I met with a syntax error. May I ask what is the meaning of
return <<<HTML
Thanks in advance!
</div>
It’s PHP’s Heredoc syntax. I’m not a fan of it though.
It's a way to define a string on multiple lines. Your string begin juste after the <<<HTML
and ends at HTML;
The HTML
word can be replaced by whatever you want.
See Heredoc syntax.
As suggested read the manual, but consider not to use this kind of syntax.
To make your life easier - in most cases the problem is with text indenting.
HTML;
Must be at the start of the line not indented!