How to display HTML tags as plain text without conversion in php?


By default in php we don't convert html tags to plain text. Lets understand this more with below example:



In php we have special function htmlspecialchars() which can be used to display display HTML tags as plain text. Below is the syntax of this function:
string htmlspecialchars( $string, $flags, $encoding, $double_encode )
$string: This parameter is used to hold the input string.
$flags: This parameter is used to hold the flags. It is combination of one or two flags, which tells how to handle quotes.
$encoding: It is an optional argument which specifies the encoding which is used when characters are converted. If encoding is not given then it is converted according to PHP default version.
$double_encode: If double_encode is turned off then PHP will not encode existing HTML entities. The default is to convert everything.

Now by using this function below will be the output:




Related #tags:     #php     #html    

Related questions

Looking for change? Click below to prepare for technical interview.

Technical Interview Questions