note 91931 deleted from language.basic-syntax.phpmode by googleguy
| From: | googleguy@php.net | Date: | Wed, 01 Jan 2014 03:58:14 +0000 |
| Subject: | note 91931 deleted from language.basic-syntax.phpmode by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-198061@lists.php.net to get a copy of this message | ||
Note Submitter: eksith at live dot com
----
Even if it's pretty simple to insert echo lines to your PHP, I would storngly advise against
it.
The safest way to output HTML content which may have special chraracters is to remove the HTML from
your core code.
Put them in heredocs instead.
See the heredoc documentation and comments for more examples.
If you can remove as much of the HTML as you can from the rest of the PHP code (in terms of printf
and echo lines), please do.
Try to keep your core logic and presentation separate.
<?php
$html =<<<HTML
<?xml version="1.0" encoding="UTF-8" ?>
... The rest of your HTML...
And a PHP {$variable} here and an array {$arr['value']} there.
HTML; // End of heredoc
// Print this HTML
echo $html
?>