note 46708 deleted from language.basic-syntax by cmb
| From: | cmb@php.net | Date: | Mon, 30 May 2016 12:08:04 +0000 |
| Subject: | note 46708 deleted from language.basic-syntax by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-205616@lists.php.net to get a copy of this message | ||
Note Submitter: stooges_cubed at racerx dot net
----
In the note above about escaping XML/PHP style <?xml tags, the following code was used:
<?php // Html safe containers
echo <<<EOD
<?xml version="1.0"?>
...all sorts of XML goes here...
Nothing will affect the output of this code until:
EOD;
?>
EOD is just an example stop/start name.
This works too:
<?php // Html safe containers
$myOutput = <<<MYHTMLSAFEOUTPUT
<?xml version="1.0"?>
<html>
<title>PHP Example</title>
<body>
<p>...all sorts goes here...</p>
</body>
</html>
MYHTMLSAFEOUTPUT;
echo $myOutput;
?>
Only disadvantage of using this is that all the code highlighting programs I've seen never get
it right, making your code look eronous in the majority of viewers.
Another alternative is to keep the XML / HTML in a separate include file and read in when needed. I
don't know how efficient/inefficient this is for (idiots like yourselves) small amounts of
text.
xmlheader.txt:
<?xml version="1.0"?>
mypage.php:
<?php
include("xmlheader.txt");
?>