note 46708 added to language.basic-syntax
| From: | stooges_cubed at racerx dot net | Date: | Wed, 20 Oct 2004 20:13:35 +0000 |
| Subject: | note 46708 added to language.basic-syntax | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-78852@lists.php.net to get a copy of this message | ||
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");
?>
----
Manual Page -- http://www.php.net/manual/en/language.basic-syntax.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+46708
Delete -- http://master.php.net/manage/user-notes.php?action=delete+46708&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+46708&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+46708&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+46708&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+46708&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+46708&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+46708&report=yes
Search -- http://master.php.net/manage/user-notes.php