note 38084 modified in language.basic-syntax by levim

From: Date: Wed, 04 Sep 2013 18:48:54 +0000
Subject: note 38084 modified in language.basic-syntax by levim
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-196162@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"); ?> --was-- 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"); ?> http://php.net/manual/en/language.basic-syntax.php

« previous php.notes (#196162) next »