This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
uphp:functions:htmlspecialchars [2017/04/11 10:56] jeff created |
uphp:functions:htmlspecialchars [2021/09/13 05:57] (current) |
||
---|---|---|---|
Line 7: | Line 7: | ||
====Description==== | ====Description==== | ||
- | <well size=" | + | <well size=" |
- | < | + | |
<span style=" | <span style=" | ||
- | <span style=" | + | <span style=" |
- | </ | + | |
- | [[htmlspecialchars]] ( | + | |
- | < | + | |
<span style=" | <span style=" | ||
<span style=" | <span style=" | ||
<span style=" | <span style=" | ||
- | </ | + | </ |
- | </ | + | |
- | Certain characters have special significance in HTML, and should be represented by HTML entities if they are to preserve their meanings. This function returns a string with these conversions made. | + | Certain characters have special significance in HTML, and should be represented by HTML entities if they are to be displayed in a browser "as is." |
====Parameter==== | ====Parameter==== | ||
- | < | + | < |
- | ====Return | + | ====Return |
- | < | + | < |
^CHARACTER^NAME^TRANSLATED (HTML ENTITY)^ | ^CHARACTER^NAME^TRANSLATED (HTML ENTITY)^ | ||
- | |& | + | |& |
- | |" | + | |" |
- | |' | + | |' |
- | |<|less than|& | + | |<|less than|'' |
- | |> | + | |> |
- | ====Example==== | + | ====Examples==== |
<code php> | <code php> | ||
Line 43: | Line 38: | ||
$data="< | $data="< | ||
$send=htmlspecialchars($data); | $send=htmlspecialchars($data); | ||
+ | print($send); | ||
?> | ?> | ||
</ | </ | ||
- | The above example will set $send to the value ''& | + | The above example will set $send to the value ''& |
+ | |||
+ | < | ||
+ | <a href=' | ||
+ | </ | ||
+ | |||
+ | (Without conversion by [[htmlspecialchars]] the browser would instead display the hyperlink < | ||
+ | |||
+ | ===Read the file index.cgi line by line and format the output for display on the browser screen=== | ||
+ | |||
+ | <code php> | ||
+ | < | ||
+ | $f=fopen("/ | ||
+ | if ($f) { | ||
+ | while (!feof($f)) { | ||
+ | print(htmlspecialchars(fgets($f))." | ||
+ | } | ||
+ | fclose($f); // close the file referenced by file handle | ||
+ | } else { | ||
+ | print(" | ||
+ | } | ||
+ | ?></ | ||
+ | </ | ||