[Solved] Check a Website is Responsive or not using PHP [closed]


Thanks to @Alexander O’Mara for the suggestion. It’s little trick. Not 100% correct way. But working for all sites.

<?php
    ini_set('user_agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9');
    $html = file_get_contents("http://php.net/");

    ini_set('user_agent', 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7');
    $html2 = file_get_contents("http://php.net/");

    similar_text(substr($html,0,1000),substr($html2,0,1000), $similariy);
    echo $similariy."<br>";


if($similariy<50)
        echo "It's responsive";
else
        echo "not responsive";
?>

basically, what it do is compare the HTML code as computer and mobile. Then find the similarity. If the similarity is low, that means they are changing code based on user agents. Of course, that should be done for responsive sites

2

solved Check a Website is Responsive or not using PHP [closed]