"php variable inside echo 'html code'" Answer’s

0

You concatenate the string by ending it and starting it again:

echo '
<div>
<a class="fragment" href="' . $url . '">
<div>';

Though I personally prefer to stop the PHP tags and start them again (if I have a lot of HTML) as my IDE won't syntax highlight the HTML as it's a string:

?>
    <div>
        <a class="fragment" href="<?php echo $url; ?>">link</a>
    </div>
<?php
Wednesday, March 31, 2021
 
Kemrop
answered 11 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :