+ 3

Hi Coders! ! *How do you insert HTML code within php tags (<?php //HTML DOCUMENTS ?>)?

21st Jul 2019, 3:18 PM
Aklil Asregid
Aklil Asregid - avatar
5 Answers
+ 3
What about this no need to rewrite php tag <?php echo >>>_END HTML CODES.. _END; ?>
21st Jul 2019, 8:35 PM
Aklil Asregid
Aklil Asregid - avatar
+ 2
You can close your <?php first with ?> //Add html again Than add <?php your next code ?>
21st Jul 2019, 3:25 PM
Dwi Novianto Nugroho
Dwi Novianto Nugroho - avatar
+ 2
Aklil Asregid, it's called a Heredoc, it's not "greater than sign" but "less than", like so: <?php <<<_OUTPUT <h2>This is a Heading </h2> <p>This portion of the document is an html code inserted into a PHP file/tag without exiting or employing the generosity of the "echo" and "print" PHP methods. _OUTPUT; ?> There you go...Hope it helps. Remember though, that you have to decide which works best for you and the situation at hand. My advice? Use echo/print for short html codes (keeping in mind that echo is a tad bit faster than print bcuz, print is a function and thus, it's always called just like any other function (and that "call time" amount to a tiny bit of lag - mostly unnoticeable though). Use Heredoc only when the block of code is pronounced or you've got lots of double quotes and single quotes in the output...and you don't wanna use the \escapism.
21st Jul 2019, 10:14 PM
Fredericks
Fredericks - avatar
+ 1
Instead of using an echo '//html code';
21st Jul 2019, 4:08 PM
Dwi Novianto Nugroho
Dwi Novianto Nugroho - avatar