Ian McCullough
Ian McCullough

Reputation: 1443

how to display "<?" AND "?>" tags in php

How can i echo a string that contains the php tags

whenever I write this in my IDE, it just assumes they are part of the PHP code.

Upvotes: 1

Views: 128

Answers (4)

Drew Chapin
Drew Chapin

Reputation: 7989

var oldString ="<" + "? xml version=\"1.0\" encoding=\"UTF-8\"?" + ">"+$('#hidden').html();

Upvotes: 0

mario
mario

Reputation: 145482

If your IDE has some quirk (from your question specificity I'd assume it's just a syntax highlighting glitch), then you can use partial / concatenated strings for comparison:

if ($compare == "<"."?") {
// or stristr()

This actually used to be a workaround for PHP3, which used a simpler tokenizer and didn't allow bare ?> in string context.

Upvotes: 0

Drew Chapin
Drew Chapin

Reputation: 7989

Like this

echo "&lt;? ... ?&gt;";

Please see this web-site for a list of other "HTML Entities." http://www.w3schools.com/html/html_entities.asp

Upvotes: 1

dresende
dresende

Reputation: 2230

You can use the PHP html_entities

echo html_entities($text);

I usually use UTF-8 so I force this encoding:

echo html_entities($text, ENT_COMPAT, "utf-8");

Upvotes: 1

Related Questions