note 47220 deleted from function.htmlspecialchars by betz

From: Date: Sun, 07 Nov 2004 23:25:39 +0000
Subject: note 47220 deleted from function.htmlspecialchars by betz
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-80254@lists.php.net to get a copy of this message
Note Submitter: programmabilities.com ---- I tried to use htmlspecialchars() to render/display my script code on a page but it would process the $variable's, so it wouldn't work. Actually, there is another way, which may be even simpler. For a long time, the HTML language has provided the <xmp> tag for showing, well, examples of mark-up and programs in the <html> and <script> tags which would otherwise be rendered. Thus, all you really need to do is wrap your mark-up in xmp tags <xmp>like this - <a href="whatever">this link will not be a link</a> ;)</xmp>, and the browsers will show it verbatim instead of rendering it. And yes, this works for scripts, too - no self-respecting browser should ever execute any <script> code when it is within an xmp block. So to display your PHP code, instead of the <?php ?> tag, put it in the <script type="php"> tag. --Of course, wrapping <?php ...?> in 'xmp' tags will not display it literally, since 'xmp' is processed by the client. The server will still happily execute the code and then pass its output within the 'xmp' tags... not exactly the purpose of the whole exercise. --SO, put your PHP code in the <script type="php"> tag! Otherwise, 'xmp' always works just fine for client-side mark-up and code like HTML and JavaScript. By Chief Programmabilities at http://programmabilities.com ---- Reason: useless note

« previous php.notes (#80254) next »