Home | New Examples | Popular | Top | Submit Examples | Request Examples

For example: Metaphors, hiatuses, adjectives, nouns,...
You are here: > Computer - Programming > PHP > Htmlentities PHP

Examples of Htmlentities PHP

Htmlentities PHP

Post by natttt
Posted on 2011-01-15 12:33:50
The htmlentities() function convert all applicable characters to HTML entities

string htmlentities ( string $string <, int $flags = ENT_COMPAT <, string $charset <, bool $double_encode = true >>> )

This function is identical to htmlspecialchars() in all ways, except with htmlentities(), all characters which have HTML character entity equivalents are translated into these entities.

Example of htmlentities() function:

$str = "Jane & "Tarzan"";
echo htmlentities($str, ENT_COMPAT);
echo "<br />";
echo htmlentities($str, ENT_QUOTES);
echo "<br />";
echo htmlentities($str, ENT_NOQUOTES);

The browser output of the code above will be:
Jane & "Tarzan"
Jane & "Tarzan"
Jane & "Tarzan"

If you select "View source" in the browser window, you will see the following HTML:
Jane &amp; "Tarzan"<br />
Jane &amp; &#039;Tarzan&#039;<br />
Jane &amp; "Tarzan"

Is this example useful?
 (0%) YES    NO (100%)

To share this example, copy and paste this code into your website, blog or forum:

To leave a comment, you must register for free or if you are already registered log in.

Has not written any comments yet.

Related examples
Htmlspecialchars PHP Posted on 2011-01-15 12:38:54
The htmlspecialchars() function converts special characters to HTML entities string htmlspecialchars ( string $string ) The translations ...
Htmlspecialchars_decode PHP Posted on 2011-01-15 12:35:47
The htmlspecialchars_decode() function convert special HTML entities back to characters string htmlspecialchars_decode ( string $string )...
Html_entity_decode PHP Posted on 2011-01-15 12:30:04
The html_entity_decode() function converts all HTML entities to their applicable characters. The html_entity_decode() function is the opposi...
Explode PHP Posted on 2011-01-15 12:26:14
The explode() function split a string by string into an array. array explode ( string $delimiter , string $string ) delimiter: The bounda...
Echo PHP Posted on 2011-01-15 12:22:55
The echo() function outputs one or more strings. void echo ( string $arg1 ) arg1: The parameter to output. Examples of echo function: ...
© 2010 · Compilation of examples, samples with definitions of all free   Legal Notice | Contact | Pending

eXTReMe Tracker