screen resolution with PHP - question.
Posted: Tue Sep 22, 2009 2:53 pm
Hello everyone,
I have a small script that takes the screen width with screen.width from java. it-s ok to post this value on the screen... but I need to make some operation with this variable. The problem is... I don't know what kind is it? is not integer, string...
<?php
$width = "<script>document.write(screen.width);</script>";
echo $width; // it shows ok my screen width everytime.... but i cannot do operation with $width...
if ($width >= 1280) echo 'OK!'; // it will not write the OK! message....
?>
I tried with (int)$width ... wich will be 0, also tried intval($width) wich also returns 0;
tried this small code... wich works ok with any other string but not in my case:
$new_string = ereg_replace("[^0-9]", "", $width);
echo $new_string;
I really don't know how to convert this variable so i can work with it....
Anyone, any ideea ?
Thanks.
DR
I have a small script that takes the screen width with screen.width from java. it-s ok to post this value on the screen... but I need to make some operation with this variable. The problem is... I don't know what kind is it? is not integer, string...
<?php
$width = "<script>document.write(screen.width);</script>";
echo $width; // it shows ok my screen width everytime.... but i cannot do operation with $width...
if ($width >= 1280) echo 'OK!'; // it will not write the OK! message....
?>
I tried with (int)$width ... wich will be 0, also tried intval($width) wich also returns 0;
tried this small code... wich works ok with any other string but not in my case:
$new_string = ereg_replace("[^0-9]", "", $width);
echo $new_string;
I really don't know how to convert this variable so i can work with it....
Anyone, any ideea ?
Thanks.
DR