I am going to set a php variable with javascript, the php variable.
I want to give size of browser to a php variable and then echo best css for that (a kind of responsive website by different css and not css3).
<script src="jquery-1.10.2.js"></script>
<script>
$(function(){
var size=($(document).width());
if(size>300){
<?php
$size="more";
?>
}else if(size<300){
<?php
$size="less";
?>
}
})
</script>
<?php
if($size=="more"){
echo '<link rel="stylesheet" href="index-1024.css"/>';
}else if($size=="less"){
echo '<link rel="stylesheet" href="index-less-1024.css"/>';
}
?>
With this code php variable $size is always 'less'