views:

60

answers:

3

I need some opinions on using PHP to make completely "scalable" websites.. For instance, using viewport resolution and resizing images, applying dynamic css styles..... In my mind doing this just add's to the complexity and should not be done, it should be fixed or fluid using strictly css and no server-side languages to generate layouts based on the device size..

I need some input and maybe some philosophy on why using this approach is not used at all..

+5  A: 

Manipulating a web page in this way is the domain of CSS controlled by Javascript (or a library such as JQuery, see CSS docs). You shouldn't be wasting your server's processor cycles when client-side implementations will be far more responsive for the user and allow all the flexibility you require. Changing font size etc can be done almost instantly in the browser without the user having to request another page from your (remote) server, which would result in a slower user experience.

Andy
+1  A: 

Really, really DON'T

As Andy says it is the domain of CSS. Trying to adapt a design with PHP will make your code unmaintainable. You should really learn to use CSS efficiently to avoid this kind of hack.

The only reason for which you could use PHP to detect browser and adapt content is mobile browser.

Given the number of the existing User Agent tokens, it'll be almost impossible to make y scalable websites.

Boris Guéry
A: 
    $(function(){

        //get height
        var height = $(window).height();

        //get width
        var width = $(window).width();

     //create a simple ajax call
    $.ajax({
     // send to php
     });
    });

OR depending on the case use...

$(window).load(function() {

});

$(window).resize(function() {

});
aSeptik