I'm trying to pass a value of a javascript code into a php variable, I searched a lot but I couldn't solve the whole problem.
I founded something in this site https://x10hosting.com/community/threads/check-screen-resolution-with-php.60476/#post-347641 but when I try to do a var_dump
of the variable the result is a big string with a lot of spaces. I will show an example.
For example the width of the screen is 480px and I get this value in this way.
<?php $screenWidth = "<script>document.write(window.innerWidth);</script>"; ?>
But when I do a var_dump();
this is the result.
string(51) "490"
A string with 51 caracteres and the true result should be int(3) "490"
.
I tried to put the var in a trim();
bit it not worked to, how can I solve this?