note 38084 added to language.basic-syntax

From: Date: Sun, 07 Dec 2003 21:42:34 +0000
Subject: note 38084 added to language.basic-syntax
Groups: php.notes 
Request: Send a blank email to php-notes+get-61607@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 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+38084 Delete -- http://master.php.net/manage/user-notes.php?action=delete+38084&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+38084&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#61607) next »