I have been stuck trying to write PHP code inside some HTML tags I set up.
I have a variable inside a .php file called $content, and I have a HTML page code inside this variable in the following way:
$content = <<<HTML some html code in here HTML;
Now, within that HTML tag I wanted to add some PHP code, tried using <?php ..... ?>, however I wasn't successful with it. Can anyone help?
That's a HEREDOC syntax , The closing HTML; should be in margin else it wont work.
<?php
$somevar="Hello World";
echo <<<HTML
<b> Hey this is some text and I am adding this variable $somevar</b>
HTML;
<?php
$somevar="Hello World";
echo <<<HTML
<b> Hey this is some text and I am adding this variable $somevar</b>
HTML; //<--- As you can see there is a leading space
You can always use <script type="text/php">...</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With