Save the integer of jscript as a php index

综合技术 2018-01-01

This question already has an answer here:

  • What is the difference between client-side and server-side programming? 5 answers

I'm trying to get the browser's width and then compare it as a php variable, but it is saving it as a string, I tried parsing it to another variable but it only returns 0.

$tam='var j= $(window).width(); document.write(j)';

I'm doing the parsing like this:

$ntam=(int) $tam;

You can't save a javascript value into a php variable directly. But you can....Put the php value into a javascript variable and use that for making your changes using javascript.

<?php  echo 'var jVar = "$phpVar";'; ?>

If you are importing your script from a js file you will want to add this before your import or course.

And I'm not sure what you're trying to accomplish but if you need a js value you can always send that value using an ajax Request...

var ajax = new XMLHttpRequest();
var form  = new FormData();

On the server side code, which in this example is processJSWindowSize.php, you can have something along the lines of

Hello, buddy!

责编内容by:Hello, buddy! (源链)。感谢您的支持!


Concurrent JavaScript: It can work With the recent addition of SharedArrayBuffer , concurrency is finding its way into the JavaScript language. This addition allows JavaScript progra...
编码在网络安全中的应用和原理 *本文原创作者:0d9y,本文属FreeBuf原创奖励计划,未经许可禁止转载 前言:现在的网站架构复杂,大多都有多个应用互相配合,不同应用之间往往需要数据交互,应用之间的编码不统一,编码自身的特性等都很有可能会被利用来绕过或配合一些策略,造成一些重大的漏洞。 什么是编码,为什么要有...
Save Javascript object I have tree of javascript objects. Let's call it "family. It can contain any number of certain objects ("parents") which can each contain any number o...
Release Radar · November 2017 We’re kicking off Cybersecurity month with a few projects to help up your security game with the tools and know-how to protect yourself from comm...
Creating an ODM with JavaScript I think the first time I heard about ORM was 10 years ago. I discovered this technique on a NetBeans tutorial that explained how to generate Ja...