I've seen this question asked dozens of times. The wording varies, but it's generally something like this:
"How can I hide my code from the browser's 'view source?' button?"
Of course, they are generally reminded that the browser cannot see PHP code (if the server is functioning properly) and that there is no way to hide HTML from the browser.
Some people resort to disabling the right mouse button via javascript which is, at best, an annoyance.
Concealing HTML is not only hardly worth the time, it is bad for those just learning the language who want to see examples.
However, due to the sheer number of times this question has been asked, I sat down and worked out a simple but effective method of helping to make HTML less readable when source is viewed.
Anyway, to the code:
/
Function: htmlconfusion
Usage: Send this function a string of content you wish to make hard to read. It converts all non-tag characters to their ordinal values and removes any line breaks.
/
function htmlconfusion($t){
for ($i=0; (strlen($t)-1)>$i;$i++){
if($t[$i] == "<"){
$e = strpos($t, ">",$i);
$r.= substr($t, $i,$e-$i+1);
$i=$e;
}
elseif($t[$i]!="\n" || $t[$i]!="\r") $r .= "&#".ord($t[$i]).";";
}
return($r);
}
I am well aware of the shortcomings of this code and technique.
-Ben