Page 1 of 1

Escape codes

Posted: Wed Jul 06, 2005 11:59 pm
by sheepz
:oops:
I'm sorry i'm very new, just learning about PHP. There are escaping codes for special characters like if i wanted to output this display on a browser:

<?

echo <p> Special \"characters\" like greater than sign <em> </p>;

?>

I cannot get the <em> to output onto my screen is there a delinating character? thanks

Posted: Thu Jul 07, 2005 12:11 am
by John Cartwright
to output the html entities use htmlentities()

Code: Select all

echo "<p> Special \"characters\" like greater than sign ".htmlentities("<em>")."</p>";
Sorry if this wasn't what you wanted, sort of unclear as to specifically what you were asking.ter than sign ".htmlentities("<em>")."</p>";

Sorry if this wasn't what you wanted, sort of unclear as to specifically what you were asking.ities]htmlentities()[/url]

Code: Select all

echo "<p> Special \"characters\" like greater than sign ".htmlentities("<em>")."</p>";
Sorry if this wasn't what you wanted, sort of unclear as to specifically what you were asking.cial \"characters\" like greater than sign &quote;.htmlentities(&quote;&lt;em&gt;&quote;).&quote;&amntities]htmlentities()[/url]

Code: Select all

echo "<p> Special \"characters\" like greater than sign ".htmlentities("<em>")."</p>";
Sorry if this wasn't what you wanted, sort of unclear as to specifically what you were asking.;lt;p> Special \"characters\" like greater than sign ".htmlentities("<em>").&quote;mp;gt; Special \"characters\" like greater than sign ".htmlentities("<em>")."&amp entities use htmlentities()

Code: Select all

echo "<p> Special \"characters\" like greater than sign ".htmlentities("<em>")."</p>";
Sorry if this wasn't what you wanted, sort of unclear as to specifically what you were asking.l=http://php.net/htmlentities]htmlentities()[/url]

Code: Select all

echo "<p> Special \"characters\" like greater than sign ".htmlentities("<em>")."</p>";
Sorry if this wasn't what you wanted, sort of unclear as to specifically what you were asking.;amp;lt;em>")."</p>";

Sorry if this wasn't what you wanted, sort of unclear as to specifically what you were asking.uote;.htmlentities("<em>")."</p>";

Sorry if this wasn't what you wanted, sort of unclear as to specifically what you were asking.ies()[/url]

Code: Select all

echo "<p> Special \"characters\" like greater than sign ".htmlentities("<em>")."</p>";
Sorry if this wasn't what you wanted, sort of unclear as to specifically what you were asking.>")."</p>";

Sorry if this wasn't what you wanted, sort of unclear as to specifically what you were asking.9c4]echo "<p> Special \"characters\" like greater than sign ".htmlentities( entities use htmlentities()

Code: Select all

echo "<p> Special \"characters\" like greater than sign ".htmlentities("<em>")."</p>";
Sorry if this wasn't what you wanted, sort of unclear as to specifically what you were asking.p://php.net/htmlentities]htmlentities()[/url]

Code: Select all

echo "<p> Special \"characters\" like greater than sign ".htmlentities("<em>")."</p>";
Sorry if this wasn't what you wanted, sort of unclear as to specifically what you were asking.".htmlentities("<em>").&quote;&lt;/p>";

Sorry if this wasn't what you wanted, sort of unclear as to specifically what you were asking.p.net/htmlentities]htmlentities()[/url]

Code: Select all

echo "<p> Special \"characters\" like greater than sign ".htmlentities("<em>")."</p>";
Sorry if this wasn't what you wanted, sort of unclear as to specifically what you were asking.;quote;;

Sorry if this wasn't what you wanted, sort of unclear as to specifically what you were asking.mlentities()[/url]

Code: Select all

echo "<p> Special \"characters\" like greater than sign ".htmlentities("<em>")."</p>";
Sorry if this wasn't what you wanted, sort of unclear as to specifically what you were asking. entities use htmlentities()

Code: Select all

echo "<p> Special \"characters\" like greater than sign ".htmlentities("<em>")."</p>";
Sorry if this wasn't what you wanted, sort of unclea256d9c4]echo "<p> Special \"characters\" like greater than sign ".htmlentities("<em>")."</p>";

Sorry if thiecho "<p> Special \"characters\" like greater than sign ".htmlentities("<em>")."</p>";

Sorry if this wasn't what you wanted, sort of unclear as to specifically what you were asking.

Posted: Thu Jul 07, 2005 12:32 am
by sheepz
Sorry I was unclear. The result is i would like to use PHP language to display exactly this

Demonstration of using <br> tag

This is what I have:

<?
echo "Demonstration of using <br> tag"
?>

This is saved as "test.php" and my output is exactly this:

Demonstration of using
tag

I would like my output to say:

Demonstration of using <br> tag

I'm not exactly sure how to do it =\

Posted: Thu Jul 07, 2005 12:41 am
by sheepz
I'm sorry I just figured it out. Your exactly right

".htmlentities("<em>")."

I thought the ("<em>").]" was just a period and was not part of the code. I kept getting errors because I left out that period. Thanks!

Posted: Thu Jul 07, 2005 12:46 am
by sheepz
I'm sorry just another question. How would I display this exactly

Demonstrating how to use "<br>" in PHP


The quotes are not being displayed

Posted: Thu Jul 07, 2005 12:52 am
by anjanesh

Code: Select all

echo htmlentities(&quote;Demonstration of using \&quote;&lt;br&gt;\" tag");
ion of using \"<br>\" tag");
a76608b]ation of using \"<br>\" tag");
quote;);
/php]
echo htmlentities("Demonstration of using \"<br>\" tag");
es("Demonstration of using \"<br>\&quote; tag&quote;);
amp;quote;<br>\" tag");
amp;gt;\" tag");

echo htmlentities("Demonstration of using \"<br>\" tag");
mp;quote;Demonstration of using \"<br>\" tag");
te;Demonstration of using \"<br>\" tag");
sing \"<br>\" tag");
");

echo htmlentities("Demonstration of using \"<br>\" tag");

Posted: Thu Jul 07, 2005 8:39 am
by s.dot
The only characters that need to be escaped to be echo'd to the browser are " and ' depending on your syntax.

example

Code: Select all

$string = "John said, \"PHP Rocks!\", in a whisper.";

// OR

$string = 'John said, \'PHP ROCKS!\', in a whisper.';
The only difference above is the single or double quotes you're enclosing your value in, and whether you want to print double or single quotes to the browser. If you must use the same quote that your value is enclosed in, escape it.

If you want to print out your HTML to the browser, you must use the entity for that character. For example, < is < and > is > and & is &. However the php function htmlentities() does this for you if you'd prefer to do it that way.mp;quote;, in a whisper.";

// OR

$string = 'John said, \'PHP ROCKS!\', in a whisper.';


The only difference above is the single or double quotes you're enclosing your value in, and whether you want to print double or single quotes to the browser. If you must use the same quote that your value is enclosed in, escape it.

If you want to print out your HTML to the browser, you must use the entity for that character. For example, < is < and > is > and & is &. However the php function htmlentities() does this for you if you'd prefer to do p function htmlentities() does this for you if you'd prefer to do it that way. the browser are " and ' depending on your syntax.

example

Code: Select all

$string = "John said, \"PHP Rocks!\", in a whisper.";

// OR

$string = 'John said, \'PHP ROCKS!\', in a whisper.';
The only difference above is the single or double quotes you're enclosing your value in, and whether you want to print double or single quotes to the browser. If you must use the same quote that your value is enclosed in, escape it.

If you want to print out your HTML to the browser, = "John said, \"PHP Rocks!\", in a whisper.&quote;;

// OR

$string = 'John said, \'PHP ROCKS!\', in a whisper.';


The only difference above is the single or double quotes you're enclosing your value in, and whether you want to print double or single quotes to the browser. If you must use the same quote that your value is enclosed in, escape it.

If you want to print out your HTML to the browser, you must use the entity for that character. For example, < is &lt; ato the browser are " and ' depending on your syntax.

example

Code: Select all

$string = "John said, \"PHP Rocks!\", in a whisper.";

// OR

$string = 'John said, \'PHP ROCKS!\', in a whisper.';
The only difference above is the single or double quotes you're enclosing your value in, and whether you want to print double or single quotes to the browser. If you must use the same quote that your value is enclosed in, escape it.

If you want to print out your HTML to the browser, you must use the entity for that character. For example, < is < and > is > and & is &. However the php function htmlentities() does this for you if you'd prefer to do it that way.s enclosed in, escape it.

If you want to print out your HTML to the browser, you must use the entity for that character. For example, < is < and > is > and & is &. However the php function htmlentities() does this for you if you'd prefer to do it that way. that your value is enclosed in, escape it.

If you want to print out your HTML to the browser, you must use the entity for that character. For example, < is < and > is > and & is &. However the php function htmlentities() does this for you if you'd prefer to do it that way.cf8c0f8669]
$string = "John said, \"PHP Rocks!\", in a whisper.";

// OR

$string = 'John said, \'PHP ROCKS!\', in a whisper.';


The only difference above is the single or double quotes you're enclosing your value in, and whether you want to print double or single quotes to the browser. If you must use the same quote that your value is enclosed in, escape it.

If you want to print out your HTML to the browser, you must use the entity for that character. For example, < is &lt
$string = "John said, \"PHP Rocks!\", in a whisper.";

// OR

$string = 'John said, \'PHP ROCKS!\', in a whisper.';


The only difference above is the single or double quotes you're enclosing your value in, and whether you want to print double or single quotes to the browser. If you must use the same quote that your value is enclosed in, escape it.

If you want to print out your HTML to the browser, you must use the entity for that character. For example, < is &lt; and > is &gt; and & is &amp;. However the php function htmlentities() does this for you if you'd prefer to do it that way.