In PHP, you can use the "strip_tags()" function to prevent html from being displayed. The function of this function is to strip the HTML, XML and PHP tags in the string. The syntax is "strip_tags(string,allow )", the parameter string represents the string to be checked.
How to set the html tags not to be displayed in php
You can use the PHP strip_tags() function
Running example
Definition and usage
strip_tags() function strips HTML, XML and PHP tags in a string.
Comments: This function always strips HTML comments. This cannot be changed via the allow parameter.
Note: This function is binary safe.
Syntax
strip_tags(string,allow)
Parameters
string Required. Specifies the string to check.
allow Optional. Specifies allowed tags. These tags will not be deleted.
Return value: Returns the stripped string.
PHP Version: 4
Change Log:
Since PHP 5.0, this function is binary safe.
Since PHP 4.3, this function always strips HTML comments.
Example
Strip the HTML tags in the string, but allow the tag:
<?php echo strip_tags("Hello <b><i>world!</i></b>","<b>"); ?>
Input result:
For more related knowledge, please visit PHP Chinese website!
The above is the detailed content of How to set the html tag not to be displayed in php. For more information, please follow other related articles on the PHP Chinese website!