简体   繁体   English

在这种情况下可以使用JS变量吗?如何使用?

[英]Can I use a JS variable in this case and how?

var myvar = <?php echo json_encode($a[i want to put the js var here]); ?>;

I'll appreciate any quick answer to this. 对此,我将不胜感激。 Thanks in regards. 谢谢。

No . 不行 You can render server side code into you client side code but not the other way around. 您可以将服务器端代码转换为客户端代码,但不能反过来。

The php runs on the server and has been executed before your client does anything. php在服务器上运行,并且已在客户端执行任何操作之前执行。

If you post your JavaScript variable back to the server you would be able to process it again. 如果将JavaScript变量重新发布回服务器,则可以再次对其进行处理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM