Q:

PHP Tidy & closing tags query

I'm just curious as to why this works:
$config = array('wrap' => 0,'show-body-only' => TRUE,);

$str = '<p>Hello World!';

$tidy = tidy_parse_string($str, $config);
tidy_clean_repair($tidy);
echo (htmlentities($tidy)); //outputs <p>Hello World!</p> 

while this doesn't:
$config = array('wrap' => 0,'show-body-only' => TRUE,);

$str = 'Hello World!</p>';

$tidy = tidy_parse_string($str, $config);
tidy_clean_repair($tidy);
echo (htmlentities($tidy)); //outputs Hello World! 

A:

I believe if you put <p> that most programs accept that as "until the end of the line" but if you put a </p> it is not able to match where it started and disregards it.
(But I am not 100% sure)

