kservice 0 Report post Posted July 25, 2005 (edited) Hello, i need tu put in $width (a php variable), the screen width of the client, and then do some arithmetics operations with it, I did this : $width = " <script>document.write(screen.width); </script>"; I tested if $width get the value, with this:echo $width;And, is ok, but when i multiply $width with any value, I got $width = 0;example;My Screen is at 1024 by 768 so:$width = "<script>document.write(screen.width); </script>"; echo $width; ---------------> 1024$width = $width * 2; echo $width; ------------------> 0 Please, Can someone tell me why? and is there a manner to do this!!Thank'skservice Notice from Johnny: Added code tags. Edited July 25, 2005 by Johnny (see edit history) Share this post Link to post Share on other sites
electriic ink 1 Report post Posted July 25, 2005 One possible solution seems simple $width = $width + $width; and for $width * 3 do$width = $width + $width + $width; Share this post Link to post Share on other sites
truefusion 3 Report post Posted July 25, 2005 Welp, i can tell you why it doesnt work the way you want it to. Reason being, it's impossible to multiply <script>document.write(screen.width); </script> by any number. $width has to equal an integer in order for it to be multiplied, or whatever. Share this post Link to post Share on other sites
rvalkass 5 Report post Posted July 25, 2005 truefusion is right. The variable $width is not holding a number but is holding a text string. PHP cannot multiply a text string by two, so it returns 0. After a short time searching on the web I have cobbled together a system that could work, although I have had no time to try it. Create an HTML page with the following code in it: <html><head></head><body><script>window.location="page.php?height="+screen.height+"&width="+screen.width;</script></body></html> Then on the page called page.php (feel free to change it in the script above): <?php$height = $_GET['height'];$width = $_GET['width'];//Now the rest of your page... In page.php the variables should now hold the screen resolution. If you want to check then just echo those variables and see what you get. Good luck Share this post Link to post Share on other sites