- nl2br: documentation ( source)
- htmlentities: documentation ( source)
- html_entity_decode: documentation ( source)
<?php
$string = '<a href="http://test.com">test</a><br/>test';
$encode = nl2br(htmlentities($string, ENT_QUOTES, 'UTF-8'));
echo html_entity_decode($encode, ENT_QUOTES, 'UTF-8');