IF is not showing the correct answer

HI

I am writing something that I thought simple, but is a problem. I can’t understand the result because I can’t see any error.

Here is my code:

<?php
$isFlashVar = '<script type="text/javascript">
function isFlash()
{
   var L = navigator.plugins.length;
   for(var i=0; i<L; i++) {
     if(navigator.plugins*.name == "Shockwave Flash"){
   	 	document.write("1");
    	break;
     } else {
     	if(i==L-1){
     	document.write("0");
     	}
     }
   }
 }
 isFlash();
</script>';

echo $isFlashVar;

if ($isFlashVar==1){
		echo "YES it have flash";
 }else{ 
 		echo "it has NOT flash";
}
?>

This way I can’t have my result, that should be “YES it have flash” because the first echo confirms that I have the same value inside the if.

Most weird is that when I do like this it works;

<?php
$isFlashVar = 1;

echo $isFlashVar;

if ($isFlashVar==1){
		echo "YES it have flash";
 }else{ 
 		echo "it has NOT flash";
}
?>

Can anyone understand this?