What’s the best way to post this echo?

Asked

Viewed 43 times

4

What’s the best way to post this echo? I know there’s a quote missing, I just don’t know where to put it.

<?php

echo '<a href="page.php"><em>' <?php echo $locale->translate('ID'); ?> '</em></a>';

?>
  • <?php echo '<a href="page.php"><em>' $locale->Translate('ID') '</em>/a>'; ? > // Also did not work.

  • 1

    missed to place the point before $ and after ('ID').

2 answers

5


I would invert the code, let HTML call php and not the other way around:

<a href="page.php"><em><?php echo $locale->translate('ID'); ?></em></a>'

However, if you want to print from PHP itself:

<?php

echo '<a href="page.php"><em>' . $locale->translate('ID') . '</em></a>';

?>
  • It worked 100%. Solved. Thanks also to @Buback who also posted the correct solution.

5

You must concatenate and not repeat echo.

<?php
echo '<a href="page.php"><em>' . $locale->translate('ID') . '</em></a>';
?>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.