0

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.

4

1 回答 1

3

PHP 在服务器上执行,Javascript 在客户端上执行。因此,您可以将值从 PHP 传递到 Javascript,但如果没有 AJAX 或 POST 或 GET 方法,则反之亦然。

于 2013-05-22T02:39:29.510 回答