PHP Escaping HTML Tag


 

PHP Escaping HTML Tag

In this current tutorial we will study about how to escape from HTML tag, there are mainly four ways to do this, each of these tags are explained in this tutorial subsequently you can check the examples for better understanding

In this current tutorial we will study about how to escape from HTML tag, there are mainly four ways to do this, each of these tags are explained in this tutorial subsequently you can check the examples for better understanding

PHP Escaping Html Tag:

During the parsing of a file by PHP, it looks for opening and closing tags which indicates the starting and closing point of PHP. The parser ignores the coding outside of the tag. In general we use <?php ?> tag to mention the PHP portion. It is not mandatory to mention the closing tag all the time, unless you need to embed html or any other scripting tag.

In the example given below we are discussing three kind of special tags, first one is available in all php version, but rest of the two are not, to make it available you need to do some small changes in php.ini file. Find out short_open_tag and asp_tag, change the default value off to on and after that restart the server. 

Example of PHP Escape Html Tags:

<script language="php">

echo "hello";

</script>

<?echo "this is simple text <Br/>"; ?>

<%echo "This is asp style";%>

Output:

hello
this is simple text
This is asp style

Ads