Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

JS variable how to get the php variable from the background

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces "JS variable how to get the php variable from the background". In the daily operation, I believe that many people have doubts about how to get the JS variable from the background. The editor consulted all kinds of data and sorted out a simple and easy-to-use method of operation. I hope it will be helpful for you to answer the question of "how to get the JS variable from the background". Next, please follow the editor to study!

As we all know, if the JS variable wants to get the php variable from the background, it can be written like this:

Var aaa =

So how do we pay the value of the js variable directly to the php variable?

The first and most common method:

No refresh: passing parameters using ajax

Refresh: submit directly with the form or directly after the jump link

The second method of passing values:

An example is date processing on the js variable:

C = "[xss_clean] (leaderTask_info ['end_time']);"; echo formatTime ($c); / / leaderTask_info [' end_time'] is the js variable / * converts cutoff seconds to date system * / function formatTime ($date) {$t = $date-time () F = array ('31536000 hours = >' year', '2592000 months = >' month', '604800 days', '86400 hours' = > 'days', '3600 hours = >' minutes', '1seconds = > seconds'); foreach ($f as $k = > $v) {$c = floor ($t / (int) $k) If ($c > 0) {if (0! = $c) {return "remaining". $c.availv;}} return "expired";}

This allows you to assign the value of the js variable to the php variable without using ajax and jump.

At this point, the study of "how to get JS variables from the background php variables" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report