I was dealing with refactoring of my small web app. all night. Today when I started testing, first bug what I found was problem with system PHP function nl2br()
.
On my localhost I have PHP version 5.2.9 and as I see on PHP site from version 4.0.5 nl2br()
is XHTML compliant.
Then I absolutely don't understand why does my nl2br()
return <br>
without second argument set to false instead of <br />
.
Here is my method where I found this bug:
public function eliminateTags($msg) {
$setBrakes = nl2br($msg);
$decodeHTML = htmlspecialchars_decode($setBrakes);
# Check PHP version
if((int)version_compare(PHP_VERSION, '4.0.5') == 1) {
$withoutTags = strip_tags($decodeHTML, '<br />');
} else {
$withoutTags = strip_tags($decodeHTML, '<br>');
}
return $withoutTags;
}