I was reorganizing my small web application. all night long. Today, when I started testing, the first error I discovered was a problem with the PHP PHP function nl2br().
On my localhost, I have PHP version 5.2.9 , and, as I can see on the PHP site from version 4.0.5, it is nl2br() compatible with XHTML.
Then I absolutely do not understand why my nl2br()return <br>without the second argument is set to false instead <br />.
Here is my method where I found this error:
public function eliminateTags($msg) {
$setBrakes = nl2br($msg);
$decodeHTML = htmlspecialchars_decode($setBrakes);
if((int)version_compare(PHP_VERSION, '4.0.5') == 1) {
$withoutTags = strip_tags($decodeHTML, '<br />');
} else {
$withoutTags = strip_tags($decodeHTML, '<br>');
}
return $withoutTags;
}
source
share