Hello, I have this code: $html = <<<HTML <p>Here is the PHP</p> <h2><?php echo="Hello" ?></h2> HTML; echo $html; ?> PHP: But the php line (<?php echo="Hello" ?>) is considerated html How i escape this "<?php echo="Hello" ?>" from HTML tags? Thanks Regards
One thing I noticed was that <?php echo="Hello" ?> Code (markup): is supposed to be <?php echo 'Hello'; ?> Code (markup): Try changing that and see if it works. BTW make sure you are running on a host or localhost, otherwise just loading the file in your browser will result in the PHP not being parsed, which in return shows up in the HTML.
Yes, i run it on the localhost, but the problem is that tha PHP line is considerated html <?php echo 'Hello'; ?> becouse is inside the HTML tags
What you are trying to does not exist in PHP If you wan't a variable to be parsed withing a HEREDOC syntax you can do the following: <?php $greeting = 'Hello'; $html = <<<HTML <p>Here is the PHP</p> <h2>$greeting</h2> HTML; echo $html; ?> PHP:
It sound like it's not being parsed as php within .html files. Edit /etc/httpd/httpd.conf. Amend this line to include .html: AddType application/x-httpd-php .php .php3 .phtml .html Then restart Apache. EDIT: Just re-read the post and miss read it the first time, ignore me, nabil_kadimi above has got it.
<?php ob_start(); ?> <p>Here is the PHP</p> <h2><?php echo "Hello"; ?></h2> <?php $html = ob_get_clean(); ?> PHP:
that is extremely unhelpful and actually pretty idiotic advice live.co.uk, even more so because you mispelled template. I honestly don't even understand the logic behind what you're trying to do, if you want the webpage generated entirely with PHP, just echo each HTML element and escape all the characters, like so: <?php echo "<<<HTML"; echo "<br />"; echo " <p>Here is the PHP</p>"; echo "<h2>$variableinPHP</h2>" echo "HTML\;"; ?> PHP:
i need to do a strong footer encryption, and i decided to try this site www[dot]byterun[dot]com/free-php-encoder.php. But if i insert my html code as it is, the PHP tags are unobserved. Here is the code: <p> <span><?php bloginfo('name'); ?> <?php echo date('Y'); ?></span></p><?php include (TEMPLATEPATH . '/searchform.php'); ?><p> PHP: so if i paste this code into encoder the PHP is not observed
Oh lol i think i know why PHP isn't installed on your computer is it? I had the same problem the other day then slapped myself for not realizing. Get WampServer or just use a free host to test your PHP code. ;P ~ Lam3r