# IF is not showing the correct answer

**URL:** <https://forum.kirupa.com/t/if-is-not-showing-the-correct-answer/301878>\
**Category:** programming\
**Created:** [December 17, 2009, 4:54am UTC](https://forum.kirupa.com/t/if-is-not-showing-the-correct-answer/301878 "2009-12-17T04:54:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ruiganga](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ruiganga/32/3679_2.png) [@ruiganga](https://forum.kirupa.com/u/ruiganga)\
**Post date:** [December 17, 2009, 4:54am UTC](https://forum.kirupa.com/t/if-is-not-showing-the-correct-answer/301878/1 "2009-12-17T04:54:35Z")

</div>

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
<?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
<?php
$isFlashVar = 1;

echo $isFlashVar;

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

```

Can anyone understand this?
