This is totally racking my brain... I'm hopeful that someone can help figure out what's wrong with this code.
I know that PHP cannot determine a user's screen resolution since it's a server side language, but Java can. And so I use Java to set two variables to the x and y resolution. But when I do that, the two variables are strings rather than integer values. I must have them as integer values so that I can use them later in my script.
Here is a snippet of code:
$xScreen = "
<SCRIPT LANGUAGE=JavaScript>
<!-- Begin
document.write(screen.width);
// End -->
</script>
";
$yScreen = "
<SCRIPT LANGUAGE=JavaScript>
<!-- Begin
document.write(screen.height);
// End -->
</script>
";
// echo them and you'll get the correct screen resolution
echo $xScreen.','.$yScreen;
// but try to get the integer value from the variable and I always get 0 instead
$xScreen = intval($xScreen);
$yScreen = intval($yScreen);
// also tried doing (int) $xScreen but that also was 0
The result of the code above will be $xScreen = 0; $yScreen = 0 which is not correct. If you echo the variables before intval() you'll get the correct number. I've also tried casting the strings as ints but that also gave me 0 for each variable.
I don't understand why I keep getting 0 as the values. Basically, all I want to do is extract or parse the integer from the string.
Any ideas?