This is an old revision of the document!
WMPRO, WMMINI FW >= 1.0 WMMEGA FW >= 2.0
Convert special characters for display in HTML
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.
$data: String to be formatted
String with certain characters replaced. The translations performed are:
CHARACTER | NAME | TRANSLATED (HTML ENTITY) |
---|---|---|
& | ampersand | & |
“ | double quote | " |
' | single quote | ' |
< | less than | < |
> | greater than | > |
<? $data="<a href='test'>Test</a>" $send=htmlspecialchars($data); ?>
The above example will set $send to the value <a href='test'>Test</a>
Read the file index.cgi line by line and format the output for display on the browser screen:
<pre><? $f=fopen("/index.cgi","r"); // open the file for reading and get the file handle if ($f) { while (!feof($f)) { print(htmlspecialchars(fgets($f))."\r\n"); // print the line to the screen } fclose($f); // close the file referenced by file handle } else { print("Unable to open file /index.cgi"); } ?></pre>