Javascript将内容写入PHP var以在IF语句中使用不起作用[关闭]

this is the code:

    <script language="Javascript" src="http://gd.geobytes.com/gd?after=-1&variables=GeobytesCountry,GeobytesCity">
    </script>

    <?php
      $City = '<script language="Javascript">
        document.write(sGeobytesCity);
      </script>';

      if($City=='Tijuana'){echo'This is Tijuana';}

    ?>

I want to use the result from the document.write() inside a php var to validate the city, I'm sure I'm doing it right cause if I echo the $City var it prints the string perfectly well but it s not working when using the var inside the if statement.

PHP executes on the server and Javascript executes on the client. So you can pass values from PHP to Javascript, but not vice versa without AJAX or a POST or GET method.