php:字符串比较

The simple code is written below i m not getting 0 when i m running this code

<?php
 echo "<script>
     name=prompt('a code is sent to u','vivek')
      </script>";
 $code="<script>document.write(name);</script>";
 echo $code;
 $v='vivek';
 $n=strcmp($v,$code);
 echo $n;
 ?>

Seriously?! JS is client side, PHP is server side. When JS runs, PHP has long before closed. Only AJAX allows communication between them.

PHP is a printer, it generates HTML for a page. Then ships it to the browser. Only then JS kicks in. No communication back and forth unless you specifically devise a method.