PHP » PYTHON |
login |
register |
about
|
PYTHON htmlspecialchars
is this article helpful?
|
Python replacement for PHP's htmlspecialchars
[
edit
| history
]
import cgi print cgi.escape("<a href='test'>Test</a>", True) # <a href='test'>Test</a> #more info: http://docs.python.org/library/cgi.html#cgi.escape htmlspecialchars(PHP 4, PHP 5) htmlspecialchars — Convert special characters to HTML entities Description
string htmlspecialchars
( string $string
[, int $quote_style= ENT_COMPAT
[, string $charset
[, bool $double_encode= true
]]] )
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 some of these conversions made; the translations made are those most useful for everyday web programming. If you require all HTML character entities to be translated, use htmlentities() instead. This function is useful in preventing user-supplied text from containing HTML markup, such as in a message board or guest book application. The translations performed are:
Parameters
Return ValuesThe converted string. Changelog
Examples
Example #1 htmlspecialchars() example
<?php
Notes
See Also
|
more
Recently updated
more
Most requested
|