-1

Ok So I am making a 2.0 version of a my website and completely re-designing the layout I have brought in bootstrap because what I mainly want to do is make the website mobile friendly so basically what I'm trying to do is something along the lines of this and done in php

if(browser-width < 600px && browser-width > 100px) {
<div class="mobileHeader">stuff here</div>;
}elseif(browser-width > 700px) {
<div class="sidebar">stuff here</div>;
};

I hope this makes sense I have been trying to figure this out for awhile to no avail.

  • 1
    You dont need browser-width. Just you need knowledge how to use bootstrap. For examle: use `Responsive utility classes` [Bootstrap Document](http://getbootstrap.com/2.3.2/scaffolding.html#responsive). use these utility classes for showing and hiding content by device. – Bora Aug 13 '13 at 11:14
  • If I'm not mistaken, this is available in the Bootstrap css files. – Loetn Aug 13 '13 at 11:15

3 Answers3

3

You can't access browser width (or any other user properties) with PHP. The only thing possible would be to set the width in a cookie (with JS) and then read it with PHP. However, this works only on the second request, as PHP gets executed before JS.

I do suggest you read something about responsive webdesign and you might find out you don't actually need this.

Langdi
  • 229
  • 1
  • 10
1

You cannot know the browser-width in php. You have to do this with javascript. Also even if php had this result, it is static, so what if you resized the window? Php wouldn't detect that. In my opinion you are choosing the wrong tools for your task.

Source to prove my point

Community
  • 1
  • 1
Andrius Naruševičius
  • 8,348
  • 7
  • 49
  • 78
1

The browsers don't report chrome width on the request. So PHP will never know that. You will need to do that with CSS media queries or with JavaScript.

Adrian
  • 1,370
  • 11
  • 21