|
Posted by thib΄ on 01/13/08 02:18
Hi,
Taking a closer look to highlight_file() lastly, I found out that its line
break policy was a bit.. strange.
<?php # highlight_file() line breaks test
$f = fopen('highlight_file_test', 'w');
fwrite($f, highlight_file(__FILE__, true));
fclose($f);
?>
highlight_test (00 -> 0F):
3C 63 6F 64 65 3E 3C 73 70 61 6E 20 73 74 79 6C <code><span styl
65 3D 22 63 6F 6C 6F 72 3A 20 23 30 30 30 30 30 e="color: #00000
30 22 3E>0A<3C 73 70 61 6E 20 73 74 79 6C 65 3D 0"> <span style=
Here, the line break is obviously a LF (Line Feed, or \n).
highlight_test (A0 -> AF):
26 6E 62 73 70 3B 74 65 73 74>0D<3C 62 72 20 2F test <br /
Here, it's a CR (Carriage Return, or \r).
All other line breaks are just CRs, except the two last ones (before the
last </span> and the </code> tags), which are LFs like the first one.
As far as I know, only MacOS uses just CR for line breaks, as only Linux
does with LF (and Windows uses both of them, CR then LF). So.. what?
Firefox seems to render the source correctly (in its source window), and of
course, as it's XHTML formatted with <br /> tags for line breaks, the final
render is fine. I know it's intended to be displayed in a browser and thus
there's no real problem with it, but I was just wondering (like, for
'educational' purpose ^^').. is that really a mess of things or is there an
actual reason for this?
Well, anyway, I think it's good to know for those who like a nice looking
rendered script source and for that are wishing to indent their php sources
highlights ;).
Thanks for your interest !
-thibΒ΄
[Back to original message]
|